babylon.module.d.ts 5.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts current color in rgb space to HSV values
  466. * @returns a new color3 representing the HSV values
  467. */
  468. toHSV(): Color3;
  469. /**
  470. * Converts current color in rgb space to HSV values
  471. * @param result defines the Color3 where to store the HSV values
  472. */
  473. toHSVToRef(result: Color3): void;
  474. /**
  475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the linear space version
  477. * @returns the unmodified Color3
  478. */
  479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  480. /**
  481. * Computes a new Color3 converted from the current one to gamma space
  482. * @returns a new Color3 object
  483. */
  484. toGammaSpace(): Color3;
  485. /**
  486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  487. * @param convertedColor defines the Color3 object where to store the gamma space version
  488. * @returns the unmodified Color3
  489. */
  490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  491. private static _BlackReadOnly;
  492. /**
  493. * Convert Hue, saturation and value to a Color3 (RGB)
  494. * @param hue defines the hue
  495. * @param saturation defines the saturation
  496. * @param value defines the value
  497. * @param result defines the Color3 where to store the RGB values
  498. */
  499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  500. /**
  501. * Creates a new Color3 from the string containing valid hexadecimal values
  502. * @param hex defines a string containing valid hexadecimal values
  503. * @returns a new Color3 object
  504. */
  505. static FromHexString(hex: string): Color3;
  506. /**
  507. * Creates a new Color3 from the starting index of the given array
  508. * @param array defines the source array
  509. * @param offset defines an offset in the source array
  510. * @returns a new Color3 object
  511. */
  512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  513. /**
  514. * Creates a new Color3 from integer values (< 256)
  515. * @param r defines the red component to read from (value between 0 and 255)
  516. * @param g defines the green component to read from (value between 0 and 255)
  517. * @param b defines the blue component to read from (value between 0 and 255)
  518. * @returns a new Color3 object
  519. */
  520. static FromInts(r: number, g: number, b: number): Color3;
  521. /**
  522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  523. * @param start defines the start Color3 value
  524. * @param end defines the end Color3 value
  525. * @param amount defines the gradient value between start and end
  526. * @returns a new Color3 object
  527. */
  528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  529. /**
  530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  531. * @param left defines the start value
  532. * @param right defines the end value
  533. * @param amount defines the gradient factor
  534. * @param result defines the Color3 object where to store the result
  535. */
  536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  537. /**
  538. * Returns a Color3 value containing a red color
  539. * @returns a new Color3 object
  540. */
  541. static Red(): Color3;
  542. /**
  543. * Returns a Color3 value containing a green color
  544. * @returns a new Color3 object
  545. */
  546. static Green(): Color3;
  547. /**
  548. * Returns a Color3 value containing a blue color
  549. * @returns a new Color3 object
  550. */
  551. static Blue(): Color3;
  552. /**
  553. * Returns a Color3 value containing a black color
  554. * @returns a new Color3 object
  555. */
  556. static Black(): Color3;
  557. /**
  558. * Gets a Color3 value containing a black color that must not be updated
  559. */
  560. static readonly BlackReadOnly: DeepImmutable<Color3>;
  561. /**
  562. * Returns a Color3 value containing a white color
  563. * @returns a new Color3 object
  564. */
  565. static White(): Color3;
  566. /**
  567. * Returns a Color3 value containing a purple color
  568. * @returns a new Color3 object
  569. */
  570. static Purple(): Color3;
  571. /**
  572. * Returns a Color3 value containing a magenta color
  573. * @returns a new Color3 object
  574. */
  575. static Magenta(): Color3;
  576. /**
  577. * Returns a Color3 value containing a yellow color
  578. * @returns a new Color3 object
  579. */
  580. static Yellow(): Color3;
  581. /**
  582. * Returns a Color3 value containing a gray color
  583. * @returns a new Color3 object
  584. */
  585. static Gray(): Color3;
  586. /**
  587. * Returns a Color3 value containing a teal color
  588. * @returns a new Color3 object
  589. */
  590. static Teal(): Color3;
  591. /**
  592. * Returns a Color3 value containing a random color
  593. * @returns a new Color3 object
  594. */
  595. static Random(): Color3;
  596. }
  597. /**
  598. * Class used to hold a RBGA color
  599. */
  600. export class Color4 {
  601. /**
  602. * Defines the red component (between 0 and 1, default is 0)
  603. */
  604. r: number;
  605. /**
  606. * Defines the green component (between 0 and 1, default is 0)
  607. */
  608. g: number;
  609. /**
  610. * Defines the blue component (between 0 and 1, default is 0)
  611. */
  612. b: number;
  613. /**
  614. * Defines the alpha component (between 0 and 1, default is 1)
  615. */
  616. a: number;
  617. /**
  618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  619. * @param r defines the red component (between 0 and 1, default is 0)
  620. * @param g defines the green component (between 0 and 1, default is 0)
  621. * @param b defines the blue component (between 0 and 1, default is 0)
  622. * @param a defines the alpha component (between 0 and 1, default is 1)
  623. */
  624. constructor(
  625. /**
  626. * Defines the red component (between 0 and 1, default is 0)
  627. */
  628. r?: number,
  629. /**
  630. * Defines the green component (between 0 and 1, default is 0)
  631. */
  632. g?: number,
  633. /**
  634. * Defines the blue component (between 0 and 1, default is 0)
  635. */
  636. b?: number,
  637. /**
  638. * Defines the alpha component (between 0 and 1, default is 1)
  639. */
  640. a?: number);
  641. /**
  642. * Adds in place the given Color4 values to the current Color4 object
  643. * @param right defines the second operand
  644. * @returns the current updated Color4 object
  645. */
  646. addInPlace(right: DeepImmutable<Color4>): Color4;
  647. /**
  648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  649. * @returns the new array
  650. */
  651. asArray(): number[];
  652. /**
  653. * Stores from the starting index in the given array the Color4 successive values
  654. * @param array defines the array where to store the r,g,b components
  655. * @param index defines an optional index in the target array to define where to start storing values
  656. * @returns the current Color4 object
  657. */
  658. toArray(array: number[], index?: number): Color4;
  659. /**
  660. * Determines equality between Color4 objects
  661. * @param otherColor defines the second operand
  662. * @returns true if the rgba values are equal to the given ones
  663. */
  664. equals(otherColor: DeepImmutable<Color4>): boolean;
  665. /**
  666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  667. * @param right defines the second operand
  668. * @returns a new Color4 object
  669. */
  670. add(right: DeepImmutable<Color4>): Color4;
  671. /**
  672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  673. * @param right defines the second operand
  674. * @returns a new Color4 object
  675. */
  676. subtract(right: DeepImmutable<Color4>): Color4;
  677. /**
  678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  679. * @param right defines the second operand
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the current Color4 object
  682. */
  683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  684. /**
  685. * Creates a new Color4 with the current Color4 values multiplied by scale
  686. * @param scale defines the scaling factor to apply
  687. * @returns a new Color4 object
  688. */
  689. scale(scale: number): Color4;
  690. /**
  691. * Multiplies the current Color4 values by scale and stores the result in "result"
  692. * @param scale defines the scaling factor to apply
  693. * @param result defines the Color4 object where to store the result
  694. * @returns the current unmodified Color4
  695. */
  696. scaleToRef(scale: number, result: Color4): Color4;
  697. /**
  698. * Scale the current Color4 values by a factor and add the result to a given Color4
  699. * @param scale defines the scale factor
  700. * @param result defines the Color4 object where to store the result
  701. * @returns the unmodified current Color4
  702. */
  703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  704. /**
  705. * Clamps the rgb values by the min and max values and stores the result into "result"
  706. * @param min defines minimum clamping value (default is 0)
  707. * @param max defines maximum clamping value (default is 1)
  708. * @param result defines color to store the result into.
  709. * @returns the cuurent Color4
  710. */
  711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  712. /**
  713. * Multipy an Color4 value by another and return a new Color4 object
  714. * @param color defines the Color4 value to multiply by
  715. * @returns a new Color4 object
  716. */
  717. multiply(color: Color4): Color4;
  718. /**
  719. * Multipy a Color4 value by another and push the result in a reference value
  720. * @param color defines the Color4 value to multiply by
  721. * @param result defines the Color4 to fill the result in
  722. * @returns the result Color4
  723. */
  724. multiplyToRef(color: Color4, result: Color4): Color4;
  725. /**
  726. * Creates a string with the Color4 current values
  727. * @returns the string representation of the Color4 object
  728. */
  729. toString(): string;
  730. /**
  731. * Returns the string "Color4"
  732. * @returns "Color4"
  733. */
  734. getClassName(): string;
  735. /**
  736. * Compute the Color4 hash code
  737. * @returns an unique number that can be used to hash Color4 objects
  738. */
  739. getHashCode(): number;
  740. /**
  741. * Creates a new Color4 copied from the current one
  742. * @returns a new Color4 object
  743. */
  744. clone(): Color4;
  745. /**
  746. * Copies the given Color4 values into the current one
  747. * @param source defines the source Color4 object
  748. * @returns the current updated Color4 object
  749. */
  750. copyFrom(source: Color4): Color4;
  751. /**
  752. * Copies the given float values into the current one
  753. * @param r defines the red component to read from
  754. * @param g defines the green component to read from
  755. * @param b defines the blue component to read from
  756. * @param a defines the alpha component to read from
  757. * @returns the current updated Color4 object
  758. */
  759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  760. /**
  761. * Copies the given float values into the current one
  762. * @param r defines the red component to read from
  763. * @param g defines the green component to read from
  764. * @param b defines the blue component to read from
  765. * @param a defines the alpha component to read from
  766. * @returns the current updated Color4 object
  767. */
  768. set(r: number, g: number, b: number, a: number): Color4;
  769. /**
  770. * Compute the Color4 hexadecimal code as a string
  771. * @returns a string containing the hexadecimal representation of the Color4 object
  772. */
  773. toHexString(): string;
  774. /**
  775. * Computes a new Color4 converted from the current one to linear space
  776. * @returns a new Color4 object
  777. */
  778. toLinearSpace(): Color4;
  779. /**
  780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  781. * @param convertedColor defines the Color4 object where to store the linear space version
  782. * @returns the unmodified Color4
  783. */
  784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  785. /**
  786. * Computes a new Color4 converted from the current one to gamma space
  787. * @returns a new Color4 object
  788. */
  789. toGammaSpace(): Color4;
  790. /**
  791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  792. * @param convertedColor defines the Color4 object where to store the gamma space version
  793. * @returns the unmodified Color4
  794. */
  795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  796. /**
  797. * Creates a new Color4 from the string containing valid hexadecimal values
  798. * @param hex defines a string containing valid hexadecimal values
  799. * @returns a new Color4 object
  800. */
  801. static FromHexString(hex: string): Color4;
  802. /**
  803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  804. * @param left defines the start value
  805. * @param right defines the end value
  806. * @param amount defines the gradient factor
  807. * @returns a new Color4 object
  808. */
  809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  810. /**
  811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  812. * @param left defines the start value
  813. * @param right defines the end value
  814. * @param amount defines the gradient factor
  815. * @param result defines the Color4 object where to store data
  816. */
  817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  818. /**
  819. * Creates a new Color4 from a Color3 and an alpha value
  820. * @param color3 defines the source Color3 to read from
  821. * @param alpha defines the alpha component (1.0 by default)
  822. * @returns a new Color4 object
  823. */
  824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  825. /**
  826. * Creates a new Color4 from the starting index element of the given array
  827. * @param array defines the source array to read from
  828. * @param offset defines the offset in the source array
  829. * @returns a new Color4 object
  830. */
  831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  832. /**
  833. * Creates a new Color3 from integer values (< 256)
  834. * @param r defines the red component to read from (value between 0 and 255)
  835. * @param g defines the green component to read from (value between 0 and 255)
  836. * @param b defines the blue component to read from (value between 0 and 255)
  837. * @param a defines the alpha component to read from (value between 0 and 255)
  838. * @returns a new Color3 object
  839. */
  840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  841. /**
  842. * Check the content of a given array and convert it to an array containing RGBA data
  843. * If the original array was already containing count * 4 values then it is returned directly
  844. * @param colors defines the array to check
  845. * @param count defines the number of RGBA data to expect
  846. * @returns an array containing count * 4 values (RGBA)
  847. */
  848. static CheckColors4(colors: number[], count: number): number[];
  849. }
  850. /**
  851. * Class representing a vector containing 2 coordinates
  852. */
  853. export class Vector2 {
  854. /** defines the first coordinate */
  855. x: number;
  856. /** defines the second coordinate */
  857. y: number;
  858. /**
  859. * Creates a new Vector2 from the given x and y coordinates
  860. * @param x defines the first coordinate
  861. * @param y defines the second coordinate
  862. */
  863. constructor(
  864. /** defines the first coordinate */
  865. x?: number,
  866. /** defines the second coordinate */
  867. y?: number);
  868. /**
  869. * Gets a string with the Vector2 coordinates
  870. * @returns a string with the Vector2 coordinates
  871. */
  872. toString(): string;
  873. /**
  874. * Gets class name
  875. * @returns the string "Vector2"
  876. */
  877. getClassName(): string;
  878. /**
  879. * Gets current vector hash code
  880. * @returns the Vector2 hash code as a number
  881. */
  882. getHashCode(): number;
  883. /**
  884. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  885. * @param array defines the source array
  886. * @param index defines the offset in source array
  887. * @returns the current Vector2
  888. */
  889. toArray(array: FloatArray, index?: number): Vector2;
  890. /**
  891. * Copy the current vector to an array
  892. * @returns a new array with 2 elements: the Vector2 coordinates.
  893. */
  894. asArray(): number[];
  895. /**
  896. * Sets the Vector2 coordinates with the given Vector2 coordinates
  897. * @param source defines the source Vector2
  898. * @returns the current updated Vector2
  899. */
  900. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. copyFromFloats(x: number, y: number): Vector2;
  908. /**
  909. * Sets the Vector2 coordinates with the given floats
  910. * @param x defines the first coordinate
  911. * @param y defines the second coordinate
  912. * @returns the current updated Vector2
  913. */
  914. set(x: number, y: number): Vector2;
  915. /**
  916. * Add another vector with the current one
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  919. */
  920. add(otherVector: DeepImmutable<Vector2>): Vector2;
  921. /**
  922. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  923. * @param otherVector defines the other vector
  924. * @param result defines the target vector
  925. * @returns the unmodified current Vector2
  926. */
  927. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  928. /**
  929. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  930. * @param otherVector defines the other vector
  931. * @returns the current updated Vector2
  932. */
  933. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  934. /**
  935. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  936. * @param otherVector defines the other vector
  937. * @returns a new Vector2
  938. */
  939. addVector3(otherVector: Vector3): Vector2;
  940. /**
  941. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  942. * @param otherVector defines the other vector
  943. * @returns a new Vector2
  944. */
  945. subtract(otherVector: Vector2): Vector2;
  946. /**
  947. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  948. * @param otherVector defines the other vector
  949. * @param result defines the target vector
  950. * @returns the unmodified current Vector2
  951. */
  952. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  953. /**
  954. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @returns the current updated Vector2
  957. */
  958. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  959. /**
  960. * Multiplies in place the current Vector2 coordinates by the given ones
  961. * @param otherVector defines the other vector
  962. * @returns the current updated Vector2
  963. */
  964. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  971. /**
  972. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  980. * @param x defines the first coordinate
  981. * @param y defines the second coordinate
  982. * @returns a new Vector2
  983. */
  984. multiplyByFloats(x: number, y: number): Vector2;
  985. /**
  986. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  987. * @param otherVector defines the other vector
  988. * @returns a new Vector2
  989. */
  990. divide(otherVector: Vector2): Vector2;
  991. /**
  992. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  993. * @param otherVector defines the other vector
  994. * @param result defines the target vector
  995. * @returns the unmodified current Vector2
  996. */
  997. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  998. /**
  999. * Divides the current Vector2 coordinates by the given ones
  1000. * @param otherVector defines the other vector
  1001. * @returns the current updated Vector2
  1002. */
  1003. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1004. /**
  1005. * Gets a new Vector2 with current Vector2 negated coordinates
  1006. * @returns a new Vector2
  1007. */
  1008. negate(): Vector2;
  1009. /**
  1010. * Multiply the Vector2 coordinates by scale
  1011. * @param scale defines the scaling factor
  1012. * @returns the current updated Vector2
  1013. */
  1014. scaleInPlace(scale: number): Vector2;
  1015. /**
  1016. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1017. * @param scale defines the scaling factor
  1018. * @returns a new Vector2
  1019. */
  1020. scale(scale: number): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1030. * @param scale defines the scale factor
  1031. * @param result defines the Vector2 object where to store the result
  1032. * @returns the unmodified current Vector2
  1033. */
  1034. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1035. /**
  1036. * Gets a boolean if two vectors are equals
  1037. * @param otherVector defines the other vector
  1038. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1039. */
  1040. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1041. /**
  1042. * Gets a boolean if two vectors are equals (using an epsilon value)
  1043. * @param otherVector defines the other vector
  1044. * @param epsilon defines the minimal distance to consider equality
  1045. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1046. */
  1047. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1048. /**
  1049. * Gets a new Vector2 from current Vector2 floored values
  1050. * @returns a new Vector2
  1051. */
  1052. floor(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 from current Vector2 floored values
  1055. * @returns a new Vector2
  1056. */
  1057. fract(): Vector2;
  1058. /**
  1059. * Gets the length of the vector
  1060. * @returns the vector length (float)
  1061. */
  1062. length(): number;
  1063. /**
  1064. * Gets the vector squared length
  1065. * @returns the vector squared length (float)
  1066. */
  1067. lengthSquared(): number;
  1068. /**
  1069. * Normalize the vector
  1070. * @returns the current updated Vector2
  1071. */
  1072. normalize(): Vector2;
  1073. /**
  1074. * Gets a new Vector2 copied from the Vector2
  1075. * @returns a new Vector2
  1076. */
  1077. clone(): Vector2;
  1078. /**
  1079. * Gets a new Vector2(0, 0)
  1080. * @returns a new Vector2
  1081. */
  1082. static Zero(): Vector2;
  1083. /**
  1084. * Gets a new Vector2(1, 1)
  1085. * @returns a new Vector2
  1086. */
  1087. static One(): Vector2;
  1088. /**
  1089. * Gets a new Vector2 set from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @returns a new Vector2
  1093. */
  1094. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1095. /**
  1096. * Sets "result" from the given index element of the given array
  1097. * @param array defines the data source
  1098. * @param offset defines the offset in the data source
  1099. * @param result defines the target vector
  1100. */
  1101. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1102. /**
  1103. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1104. * @param value1 defines 1st point of control
  1105. * @param value2 defines 2nd point of control
  1106. * @param value3 defines 3rd point of control
  1107. * @param value4 defines 4th point of control
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * 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".
  1114. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1115. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1116. * @param value defines the value to clamp
  1117. * @param min defines the lower limit
  1118. * @param max defines the upper limit
  1119. * @returns a new Vector2
  1120. */
  1121. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1122. /**
  1123. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1124. * @param value1 defines the 1st control point
  1125. * @param tangent1 defines the outgoing tangent
  1126. * @param value2 defines the 2nd control point
  1127. * @param tangent2 defines the incoming tangent
  1128. * @param amount defines the interpolation factor
  1129. * @returns a new Vector2
  1130. */
  1131. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1132. /**
  1133. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1134. * @param start defines the start vector
  1135. * @param end defines the end vector
  1136. * @param amount defines the interpolation factor
  1137. * @returns a new Vector2
  1138. */
  1139. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1140. /**
  1141. * Gets the dot product of the vector "left" and the vector "right"
  1142. * @param left defines first vector
  1143. * @param right defines second vector
  1144. * @returns the dot product (float)
  1145. */
  1146. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1147. /**
  1148. * Returns a new Vector2 equal to the normalized given vector
  1149. * @param vector defines the vector to normalize
  1150. * @returns a new Vector2
  1151. */
  1152. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1162. * @param left defines 1st vector
  1163. * @param right defines 2nd vector
  1164. * @returns a new Vector2
  1165. */
  1166. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1167. /**
  1168. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @returns a new Vector2
  1172. */
  1173. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1174. /**
  1175. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1176. * @param vector defines the vector to transform
  1177. * @param transformation defines the matrix to apply
  1178. * @param result defines the target vector
  1179. */
  1180. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1181. /**
  1182. * Determines if a given vector is included in a triangle
  1183. * @param p defines the vector to test
  1184. * @param p0 defines 1st triangle point
  1185. * @param p1 defines 2nd triangle point
  1186. * @param p2 defines 3rd triangle point
  1187. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1188. */
  1189. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1190. /**
  1191. * Gets the distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the distance between vectors
  1195. */
  1196. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Returns the squared distance between the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns the squared distance between vectors
  1202. */
  1203. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1204. /**
  1205. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1206. * @param value1 defines first vector
  1207. * @param value2 defines second vector
  1208. * @returns a new Vector2
  1209. */
  1210. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1211. /**
  1212. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1213. * @param p defines the middle point
  1214. * @param segA defines one point of the segment
  1215. * @param segB defines the other point of the segment
  1216. * @returns the shortest distance
  1217. */
  1218. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1219. }
  1220. /**
  1221. * Classed used to store (x,y,z) vector representation
  1222. * A Vector3 is the main object used in 3D geometry
  1223. * It can represent etiher the coordinates of a point the space, either a direction
  1224. * Reminder: js uses a left handed forward facing system
  1225. */
  1226. export class Vector3 {
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x: number;
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y: number;
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z: number;
  1239. private static _UpReadOnly;
  1240. private static _ZeroReadOnly;
  1241. /**
  1242. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1243. * @param x defines the first coordinates (on X axis)
  1244. * @param y defines the second coordinates (on Y axis)
  1245. * @param z defines the third coordinates (on Z axis)
  1246. */
  1247. constructor(
  1248. /**
  1249. * Defines the first coordinates (on X axis)
  1250. */
  1251. x?: number,
  1252. /**
  1253. * Defines the second coordinates (on Y axis)
  1254. */
  1255. y?: number,
  1256. /**
  1257. * Defines the third coordinates (on Z axis)
  1258. */
  1259. z?: number);
  1260. /**
  1261. * Creates a string representation of the Vector3
  1262. * @returns a string with the Vector3 coordinates.
  1263. */
  1264. toString(): string;
  1265. /**
  1266. * Gets the class name
  1267. * @returns the string "Vector3"
  1268. */
  1269. getClassName(): string;
  1270. /**
  1271. * Creates the Vector3 hash code
  1272. * @returns a number which tends to be unique between Vector3 instances
  1273. */
  1274. getHashCode(): number;
  1275. /**
  1276. * Creates an array containing three elements : the coordinates of the Vector3
  1277. * @returns a new array of numbers
  1278. */
  1279. asArray(): number[];
  1280. /**
  1281. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1282. * @param array defines the destination array
  1283. * @param index defines the offset in the destination array
  1284. * @returns the current Vector3
  1285. */
  1286. toArray(array: FloatArray, index?: number): Vector3;
  1287. /**
  1288. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1289. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1290. */
  1291. toQuaternion(): Quaternion;
  1292. /**
  1293. * Adds the given vector to the current Vector3
  1294. * @param otherVector defines the second operand
  1295. * @returns the current updated Vector3
  1296. */
  1297. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the given coordinates to the current Vector3
  1300. * @param x defines the x coordinate of the operand
  1301. * @param y defines the y coordinate of the operand
  1302. * @param z defines the z coordinate of the operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1306. /**
  1307. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Subtract the given vector from the current Vector3
  1321. * @param otherVector defines the second operand
  1322. * @returns the current updated Vector3
  1323. */
  1324. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1325. /**
  1326. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1327. * @param otherVector defines the second operand
  1328. * @returns the resulting Vector3
  1329. */
  1330. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1331. /**
  1332. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1333. * @param otherVector defines the second operand
  1334. * @param result defines the Vector3 object where to store the result
  1335. * @returns the current Vector3
  1336. */
  1337. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1338. /**
  1339. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1340. * @param x defines the x coordinate of the operand
  1341. * @param y defines the y coordinate of the operand
  1342. * @param z defines the z coordinate of the operand
  1343. * @returns the resulting Vector3
  1344. */
  1345. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1346. /**
  1347. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1348. * @param x defines the x coordinate of the operand
  1349. * @param y defines the y coordinate of the operand
  1350. * @param z defines the z coordinate of the operand
  1351. * @param result defines the Vector3 object where to store the result
  1352. * @returns the current Vector3
  1353. */
  1354. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1355. /**
  1356. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1357. * @returns a new Vector3
  1358. */
  1359. negate(): Vector3;
  1360. /**
  1361. * Multiplies the Vector3 coordinates by the float "scale"
  1362. * @param scale defines the multiplier factor
  1363. * @returns the current updated Vector3
  1364. */
  1365. scaleInPlace(scale: number): Vector3;
  1366. /**
  1367. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1368. * @param scale defines the multiplier factor
  1369. * @returns a new Vector3
  1370. */
  1371. scale(scale: number): Vector3;
  1372. /**
  1373. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1374. * @param scale defines the multiplier factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the current Vector3
  1377. */
  1378. scaleToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1381. * @param scale defines the scale factor
  1382. * @param result defines the Vector3 object where to store the result
  1383. * @returns the unmodified current Vector3
  1384. */
  1385. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1386. /**
  1387. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1388. * @param otherVector defines the second operand
  1389. * @returns true if both vectors are equals
  1390. */
  1391. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1394. * @param otherVector defines the second operand
  1395. * @param epsilon defines the minimal distance to define values as equals
  1396. * @returns true if both vectors are distant less than epsilon
  1397. */
  1398. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1399. /**
  1400. * Returns true if the current Vector3 coordinates equals the given floats
  1401. * @param x defines the x coordinate of the operand
  1402. * @param y defines the y coordinate of the operand
  1403. * @param z defines the z coordinate of the operand
  1404. * @returns true if both vectors are equals
  1405. */
  1406. equalsToFloats(x: number, y: number, z: number): boolean;
  1407. /**
  1408. * Multiplies the current Vector3 coordinates by the given ones
  1409. * @param otherVector defines the second operand
  1410. * @returns the current updated Vector3
  1411. */
  1412. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1413. /**
  1414. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1428. * @param x defines the x coordinate of the operand
  1429. * @param y defines the y coordinate of the operand
  1430. * @param z defines the z coordinate of the operand
  1431. * @returns the new Vector3
  1432. */
  1433. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1434. /**
  1435. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1436. * @param otherVector defines the second operand
  1437. * @returns the new Vector3
  1438. */
  1439. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1442. * @param otherVector defines the second operand
  1443. * @param result defines the Vector3 object where to store the result
  1444. * @returns the current Vector3
  1445. */
  1446. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1447. /**
  1448. * Divides the current Vector3 coordinates by the given ones.
  1449. * @param otherVector defines the second operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. divideInPlace(otherVector: Vector3): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1455. * @param other defines the second operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1461. * @param other defines the second operand
  1462. * @returns the current updated Vector3
  1463. */
  1464. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1465. /**
  1466. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1467. * @param x defines the x coordinate of the operand
  1468. * @param y defines the y coordinate of the operand
  1469. * @param z defines the z coordinate of the operand
  1470. * @returns the current updated Vector3
  1471. */
  1472. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1473. /**
  1474. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1475. * @param x defines the x coordinate of the operand
  1476. * @param y defines the y coordinate of the operand
  1477. * @param z defines the z coordinate of the operand
  1478. * @returns the current updated Vector3
  1479. */
  1480. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1481. /**
  1482. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1483. * Check if is non uniform within a certain amount of decimal places to account for this
  1484. * @param epsilon the amount the values can differ
  1485. * @returns if the the vector is non uniform to a certain number of decimal places
  1486. */
  1487. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1488. /**
  1489. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1490. */
  1491. readonly isNonUniform: boolean;
  1492. /**
  1493. * Gets a new Vector3 from current Vector3 floored values
  1494. * @returns a new Vector3
  1495. */
  1496. floor(): Vector3;
  1497. /**
  1498. * Gets a new Vector3 from current Vector3 floored values
  1499. * @returns a new Vector3
  1500. */
  1501. fract(): Vector3;
  1502. /**
  1503. * Gets the length of the Vector3
  1504. * @returns the length of the Vector3
  1505. */
  1506. length(): number;
  1507. /**
  1508. * Gets the squared length of the Vector3
  1509. * @returns squared length of the Vector3
  1510. */
  1511. lengthSquared(): number;
  1512. /**
  1513. * Normalize the current Vector3.
  1514. * Please note that this is an in place operation.
  1515. * @returns the current updated Vector3
  1516. */
  1517. normalize(): Vector3;
  1518. /**
  1519. * Reorders the x y z properties of the vector in place
  1520. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1521. * @returns the current updated vector
  1522. */
  1523. reorderInPlace(order: string): this;
  1524. /**
  1525. * Rotates the vector around 0,0,0 by a quaternion
  1526. * @param quaternion the rotation quaternion
  1527. * @param result vector to store the result
  1528. * @returns the resulting vector
  1529. */
  1530. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1531. /**
  1532. * Rotates a vector around a given point
  1533. * @param quaternion the rotation quaternion
  1534. * @param point the point to rotate around
  1535. * @param result vector to store the result
  1536. * @returns the resulting vector
  1537. */
  1538. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * 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"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * 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"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Interface for the size containing width and height
  2363. */
  2364. export interface ISize {
  2365. /**
  2366. * Width
  2367. */
  2368. width: number;
  2369. /**
  2370. * Heighht
  2371. */
  2372. height: number;
  2373. }
  2374. /**
  2375. * Size containing widht and height
  2376. */
  2377. export class Size implements ISize {
  2378. /**
  2379. * Width
  2380. */
  2381. width: number;
  2382. /**
  2383. * Height
  2384. */
  2385. height: number;
  2386. /**
  2387. * Creates a Size object from the given width and height (floats).
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. */
  2391. constructor(width: number, height: number);
  2392. /**
  2393. * Returns a string with the Size width and height
  2394. * @returns a string with the Size width and height
  2395. */
  2396. toString(): string;
  2397. /**
  2398. * "Size"
  2399. * @returns the string "Size"
  2400. */
  2401. getClassName(): string;
  2402. /**
  2403. * Returns the Size hash code.
  2404. * @returns a hash code for a unique width and height
  2405. */
  2406. getHashCode(): number;
  2407. /**
  2408. * Updates the current size from the given one.
  2409. * @param src the given size
  2410. */
  2411. copyFrom(src: Size): void;
  2412. /**
  2413. * Updates in place the current Size from the given floats.
  2414. * @param width width of the new size
  2415. * @param height height of the new size
  2416. * @returns the updated Size.
  2417. */
  2418. copyFromFloats(width: number, height: number): Size;
  2419. /**
  2420. * Updates in place the current Size from the given floats.
  2421. * @param width width to set
  2422. * @param height height to set
  2423. * @returns the updated Size.
  2424. */
  2425. set(width: number, height: number): Size;
  2426. /**
  2427. * Multiplies the width and height by numbers
  2428. * @param w factor to multiple the width by
  2429. * @param h factor to multiple the height by
  2430. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2431. */
  2432. multiplyByFloats(w: number, h: number): Size;
  2433. /**
  2434. * Clones the size
  2435. * @returns a new Size copied from the given one.
  2436. */
  2437. clone(): Size;
  2438. /**
  2439. * True if the current Size and the given one width and height are strictly equal.
  2440. * @param other the other size to compare against
  2441. * @returns True if the current Size and the given one width and height are strictly equal.
  2442. */
  2443. equals(other: Size): boolean;
  2444. /**
  2445. * The surface of the Size : width * height (float).
  2446. */
  2447. readonly surface: number;
  2448. /**
  2449. * Create a new size of zero
  2450. * @returns a new Size set to (0.0, 0.0)
  2451. */
  2452. static Zero(): Size;
  2453. /**
  2454. * Sums the width and height of two sizes
  2455. * @param otherSize size to add to this size
  2456. * @returns a new Size set as the addition result of the current Size and the given one.
  2457. */
  2458. add(otherSize: Size): Size;
  2459. /**
  2460. * Subtracts the width and height of two
  2461. * @param otherSize size to subtract to this size
  2462. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2463. */
  2464. subtract(otherSize: Size): Size;
  2465. /**
  2466. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2467. * @param start starting size to lerp between
  2468. * @param end end size to lerp between
  2469. * @param amount amount to lerp between the start and end values
  2470. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2471. */
  2472. static Lerp(start: Size, end: Size, amount: number): Size;
  2473. }
  2474. /**
  2475. * Class used to store quaternion data
  2476. * @see https://en.wikipedia.org/wiki/Quaternion
  2477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2478. */
  2479. export class Quaternion {
  2480. /** defines the first component (0 by default) */
  2481. x: number;
  2482. /** defines the second component (0 by default) */
  2483. y: number;
  2484. /** defines the third component (0 by default) */
  2485. z: number;
  2486. /** defines the fourth component (1.0 by default) */
  2487. w: number;
  2488. /**
  2489. * Creates a new Quaternion from the given floats
  2490. * @param x defines the first component (0 by default)
  2491. * @param y defines the second component (0 by default)
  2492. * @param z defines the third component (0 by default)
  2493. * @param w defines the fourth component (1.0 by default)
  2494. */
  2495. constructor(
  2496. /** defines the first component (0 by default) */
  2497. x?: number,
  2498. /** defines the second component (0 by default) */
  2499. y?: number,
  2500. /** defines the third component (0 by default) */
  2501. z?: number,
  2502. /** defines the fourth component (1.0 by default) */
  2503. w?: number);
  2504. /**
  2505. * Gets a string representation for the current quaternion
  2506. * @returns a string with the Quaternion coordinates
  2507. */
  2508. toString(): string;
  2509. /**
  2510. * Gets the class name of the quaternion
  2511. * @returns the string "Quaternion"
  2512. */
  2513. getClassName(): string;
  2514. /**
  2515. * Gets a hash code for this quaternion
  2516. * @returns the quaternion hash code
  2517. */
  2518. getHashCode(): number;
  2519. /**
  2520. * Copy the quaternion to an array
  2521. * @returns a new array populated with 4 elements from the quaternion coordinates
  2522. */
  2523. asArray(): number[];
  2524. /**
  2525. * Check if two quaternions are equals
  2526. * @param otherQuaternion defines the second operand
  2527. * @return true if the current quaternion and the given one coordinates are strictly equals
  2528. */
  2529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2530. /**
  2531. * Clone the current quaternion
  2532. * @returns a new quaternion copied from the current one
  2533. */
  2534. clone(): Quaternion;
  2535. /**
  2536. * Copy a quaternion to the current one
  2537. * @param other defines the other quaternion
  2538. * @returns the updated current quaternion
  2539. */
  2540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Updates the current quaternion with the given float coordinates
  2543. * @param x defines the x coordinate
  2544. * @param y defines the y coordinate
  2545. * @param z defines the z coordinate
  2546. * @param w defines the w coordinate
  2547. * @returns the updated current quaternion
  2548. */
  2549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2550. /**
  2551. * Updates the current quaternion from the given float coordinates
  2552. * @param x defines the x coordinate
  2553. * @param y defines the y coordinate
  2554. * @param z defines the z coordinate
  2555. * @param w defines the w coordinate
  2556. * @returns the updated current quaternion
  2557. */
  2558. set(x: number, y: number, z: number, w: number): Quaternion;
  2559. /**
  2560. * Adds two quaternions
  2561. * @param other defines the second operand
  2562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2563. */
  2564. add(other: DeepImmutable<Quaternion>): Quaternion;
  2565. /**
  2566. * Add a quaternion to the current one
  2567. * @param other defines the quaternion to add
  2568. * @returns the current quaternion
  2569. */
  2570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2571. /**
  2572. * Subtract two quaternions
  2573. * @param other defines the second operand
  2574. * @returns a new quaternion as the subtraction result of the given one from the current one
  2575. */
  2576. subtract(other: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies the current quaternion by a scale factor
  2579. * @param value defines the scale factor
  2580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2581. */
  2582. scale(value: number): Quaternion;
  2583. /**
  2584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2585. * @param scale defines the scale factor
  2586. * @param result defines the Quaternion object where to store the result
  2587. * @returns the unmodified current quaternion
  2588. */
  2589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2590. /**
  2591. * Multiplies in place the current quaternion by a scale factor
  2592. * @param value defines the scale factor
  2593. * @returns the current modified quaternion
  2594. */
  2595. scaleInPlace(value: number): Quaternion;
  2596. /**
  2597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2598. * @param scale defines the scale factor
  2599. * @param result defines the Quaternion object where to store the result
  2600. * @returns the unmodified current quaternion
  2601. */
  2602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2603. /**
  2604. * Multiplies two quaternions
  2605. * @param q1 defines the second operand
  2606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2607. */
  2608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2609. /**
  2610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2611. * @param q1 defines the second operand
  2612. * @param result defines the target quaternion
  2613. * @returns the current quaternion
  2614. */
  2615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2616. /**
  2617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2618. * @param q1 defines the second operand
  2619. * @returns the currentupdated quaternion
  2620. */
  2621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2622. /**
  2623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2624. * @param ref defines the target quaternion
  2625. * @returns the current quaternion
  2626. */
  2627. conjugateToRef(ref: Quaternion): Quaternion;
  2628. /**
  2629. * Conjugates in place (1-q) the current quaternion
  2630. * @returns the current updated quaternion
  2631. */
  2632. conjugateInPlace(): Quaternion;
  2633. /**
  2634. * Conjugates in place (1-q) the current quaternion
  2635. * @returns a new quaternion
  2636. */
  2637. conjugate(): Quaternion;
  2638. /**
  2639. * Gets length of current quaternion
  2640. * @returns the quaternion length (float)
  2641. */
  2642. length(): number;
  2643. /**
  2644. * Normalize in place the current quaternion
  2645. * @returns the current updated quaternion
  2646. */
  2647. normalize(): Quaternion;
  2648. /**
  2649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2650. * @param order is a reserved parameter and is ignore for now
  2651. * @returns a new Vector3 containing the Euler angles
  2652. */
  2653. toEulerAngles(order?: string): Vector3;
  2654. /**
  2655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2656. * @param result defines the vector which will be filled with the Euler angles
  2657. * @param order is a reserved parameter and is ignore for now
  2658. * @returns the current unchanged quaternion
  2659. */
  2660. toEulerAnglesToRef(result: Vector3): Quaternion;
  2661. /**
  2662. * Updates the given rotation matrix with the current quaternion values
  2663. * @param result defines the target matrix
  2664. * @returns the current unchanged quaternion
  2665. */
  2666. toRotationMatrix(result: Matrix): Quaternion;
  2667. /**
  2668. * Updates the current quaternion from the given rotation matrix values
  2669. * @param matrix defines the source matrix
  2670. * @returns the current updated quaternion
  2671. */
  2672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2673. /**
  2674. * Creates a new quaternion from a rotation matrix
  2675. * @param matrix defines the source matrix
  2676. * @returns a new quaternion created from the given rotation matrix values
  2677. */
  2678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2679. /**
  2680. * Updates the given quaternion with the given rotation matrix values
  2681. * @param matrix defines the source matrix
  2682. * @param result defines the target quaternion
  2683. */
  2684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2685. /**
  2686. * Returns the dot product (float) between the quaternions "left" and "right"
  2687. * @param left defines the left operand
  2688. * @param right defines the right operand
  2689. * @returns the dot product
  2690. */
  2691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2692. /**
  2693. * Checks if the two quaternions are close to each other
  2694. * @param quat0 defines the first quaternion to check
  2695. * @param quat1 defines the second quaternion to check
  2696. * @returns true if the two quaternions are close to each other
  2697. */
  2698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2699. /**
  2700. * Creates an empty quaternion
  2701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2702. */
  2703. static Zero(): Quaternion;
  2704. /**
  2705. * Inverse a given quaternion
  2706. * @param q defines the source quaternion
  2707. * @returns a new quaternion as the inverted current quaternion
  2708. */
  2709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2710. /**
  2711. * Inverse a given quaternion
  2712. * @param q defines the source quaternion
  2713. * @param result the quaternion the result will be stored in
  2714. * @returns the result quaternion
  2715. */
  2716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates an identity quaternion
  2719. * @returns the identity quaternion
  2720. */
  2721. static Identity(): Quaternion;
  2722. /**
  2723. * Gets a boolean indicating if the given quaternion is identity
  2724. * @param quaternion defines the quaternion to check
  2725. * @returns true if the quaternion is identity
  2726. */
  2727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2728. /**
  2729. * Creates a quaternion from a rotation around an axis
  2730. * @param axis defines the axis to use
  2731. * @param angle defines the angle to use
  2732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2733. */
  2734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2735. /**
  2736. * Creates a rotation around an axis and stores it into the given quaternion
  2737. * @param axis defines the axis to use
  2738. * @param angle defines the angle to use
  2739. * @param result defines the target quaternion
  2740. * @returns the target quaternion
  2741. */
  2742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Creates a new quaternion from data stored into an array
  2745. * @param array defines the data source
  2746. * @param offset defines the offset in the source array where the data starts
  2747. * @returns a new quaternion
  2748. */
  2749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2750. /**
  2751. * Create a quaternion from Euler rotation angles
  2752. * @param x Pitch
  2753. * @param y Yaw
  2754. * @param z Roll
  2755. * @returns the new Quaternion
  2756. */
  2757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2758. /**
  2759. * Updates a quaternion from Euler rotation angles
  2760. * @param x Pitch
  2761. * @param y Yaw
  2762. * @param z Roll
  2763. * @param result the quaternion to store the result
  2764. * @returns the updated quaternion
  2765. */
  2766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2767. /**
  2768. * Create a quaternion from Euler rotation vector
  2769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2770. * @returns the new Quaternion
  2771. */
  2772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2773. /**
  2774. * Updates a quaternion from Euler rotation vector
  2775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2776. * @param result the quaternion to store the result
  2777. * @returns the updated quaternion
  2778. */
  2779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2782. * @param yaw defines the rotation around Y axis
  2783. * @param pitch defines the rotation around X axis
  2784. * @param roll defines the rotation around Z axis
  2785. * @returns the new quaternion
  2786. */
  2787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2788. /**
  2789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2790. * @param yaw defines the rotation around Y axis
  2791. * @param pitch defines the rotation around X axis
  2792. * @param roll defines the rotation around Z axis
  2793. * @param result defines the target quaternion
  2794. */
  2795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2796. /**
  2797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2798. * @param alpha defines the rotation around first axis
  2799. * @param beta defines the rotation around second axis
  2800. * @param gamma defines the rotation around third axis
  2801. * @returns the new quaternion
  2802. */
  2803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2804. /**
  2805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2806. * @param alpha defines the rotation around first axis
  2807. * @param beta defines the rotation around second axis
  2808. * @param gamma defines the rotation around third axis
  2809. * @param result defines the target quaternion
  2810. */
  2811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2812. /**
  2813. * 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)
  2814. * @param axis1 defines the first axis
  2815. * @param axis2 defines the second axis
  2816. * @param axis3 defines the third axis
  2817. * @returns the new quaternion
  2818. */
  2819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2820. /**
  2821. * 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
  2822. * @param axis1 defines the first axis
  2823. * @param axis2 defines the second axis
  2824. * @param axis3 defines the third axis
  2825. * @param ref defines the target quaternion
  2826. */
  2827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2828. /**
  2829. * Interpolates between two quaternions
  2830. * @param left defines first quaternion
  2831. * @param right defines second quaternion
  2832. * @param amount defines the gradient to use
  2833. * @returns the new interpolated quaternion
  2834. */
  2835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2836. /**
  2837. * Interpolates between two quaternions and stores it into a target quaternion
  2838. * @param left defines first quaternion
  2839. * @param right defines second quaternion
  2840. * @param amount defines the gradient to use
  2841. * @param result defines the target quaternion
  2842. */
  2843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2844. /**
  2845. * Interpolate between two quaternions using Hermite interpolation
  2846. * @param value1 defines first quaternion
  2847. * @param tangent1 defines the incoming tangent
  2848. * @param value2 defines second quaternion
  2849. * @param tangent2 defines the outgoing tangent
  2850. * @param amount defines the target quaternion
  2851. * @returns the new interpolated quaternion
  2852. */
  2853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2854. }
  2855. /**
  2856. * Class used to store matrix data (4x4)
  2857. */
  2858. export class Matrix {
  2859. private static _updateFlagSeed;
  2860. private static _identityReadOnly;
  2861. private _isIdentity;
  2862. private _isIdentityDirty;
  2863. private _isIdentity3x2;
  2864. private _isIdentity3x2Dirty;
  2865. /**
  2866. * Gets the update flag of the matrix which is an unique number for the matrix.
  2867. * It will be incremented every time the matrix data change.
  2868. * You can use it to speed the comparison between two versions of the same matrix.
  2869. */
  2870. updateFlag: number;
  2871. private readonly _m;
  2872. /**
  2873. * Gets the internal data of the matrix
  2874. */
  2875. readonly m: DeepImmutable<Float32Array>;
  2876. /** @hidden */
  2877. _markAsUpdated(): void;
  2878. /** @hidden */
  2879. private _updateIdentityStatus;
  2880. /**
  2881. * Creates an empty matrix (filled with zeros)
  2882. */
  2883. constructor();
  2884. /**
  2885. * Check if the current matrix is identity
  2886. * @returns true is the matrix is the identity matrix
  2887. */
  2888. isIdentity(): boolean;
  2889. /**
  2890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2891. * @returns true is the matrix is the identity matrix
  2892. */
  2893. isIdentityAs3x2(): boolean;
  2894. /**
  2895. * Gets the determinant of the matrix
  2896. * @returns the matrix determinant
  2897. */
  2898. determinant(): number;
  2899. /**
  2900. * Returns the matrix as a Float32Array
  2901. * @returns the matrix underlying array
  2902. */
  2903. toArray(): DeepImmutable<Float32Array>;
  2904. /**
  2905. * Returns the matrix as a Float32Array
  2906. * @returns the matrix underlying array.
  2907. */
  2908. asArray(): DeepImmutable<Float32Array>;
  2909. /**
  2910. * Inverts the current matrix in place
  2911. * @returns the current inverted matrix
  2912. */
  2913. invert(): Matrix;
  2914. /**
  2915. * Sets all the matrix elements to zero
  2916. * @returns the current matrix
  2917. */
  2918. reset(): Matrix;
  2919. /**
  2920. * Adds the current matrix with a second one
  2921. * @param other defines the matrix to add
  2922. * @returns a new matrix as the addition of the current matrix and the given one
  2923. */
  2924. add(other: DeepImmutable<Matrix>): Matrix;
  2925. /**
  2926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2927. * @param other defines the matrix to add
  2928. * @param result defines the target matrix
  2929. * @returns the current matrix
  2930. */
  2931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2932. /**
  2933. * Adds in place the given matrix to the current matrix
  2934. * @param other defines the second operand
  2935. * @returns the current updated matrix
  2936. */
  2937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2938. /**
  2939. * Sets the given matrix to the current inverted Matrix
  2940. * @param other defines the target matrix
  2941. * @returns the unmodified current matrix
  2942. */
  2943. invertToRef(other: Matrix): Matrix;
  2944. /**
  2945. * add a value at the specified position in the current Matrix
  2946. * @param index the index of the value within the matrix. between 0 and 15.
  2947. * @param value the value to be added
  2948. * @returns the current updated matrix
  2949. */
  2950. addAtIndex(index: number, value: number): Matrix;
  2951. /**
  2952. * mutiply the specified position in the current Matrix by a value
  2953. * @param index the index of the value within the matrix. between 0 and 15.
  2954. * @param value the value to be added
  2955. * @returns the current updated matrix
  2956. */
  2957. multiplyAtIndex(index: number, value: number): Matrix;
  2958. /**
  2959. * Inserts the translation vector (using 3 floats) in the current matrix
  2960. * @param x defines the 1st component of the translation
  2961. * @param y defines the 2nd component of the translation
  2962. * @param z defines the 3rd component of the translation
  2963. * @returns the current updated matrix
  2964. */
  2965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2966. /**
  2967. * Adds the translation vector (using 3 floats) in the current matrix
  2968. * @param x defines the 1st component of the translation
  2969. * @param y defines the 2nd component of the translation
  2970. * @param z defines the 3rd component of the translation
  2971. * @returns the current updated matrix
  2972. */
  2973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2974. /**
  2975. * Inserts the translation vector in the current matrix
  2976. * @param vector3 defines the translation to insert
  2977. * @returns the current updated matrix
  2978. */
  2979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2980. /**
  2981. * Gets the translation value of the current matrix
  2982. * @returns a new Vector3 as the extracted translation from the matrix
  2983. */
  2984. getTranslation(): Vector3;
  2985. /**
  2986. * Fill a Vector3 with the extracted translation from the matrix
  2987. * @param result defines the Vector3 where to store the translation
  2988. * @returns the current matrix
  2989. */
  2990. getTranslationToRef(result: Vector3): Matrix;
  2991. /**
  2992. * Remove rotation and scaling part from the matrix
  2993. * @returns the updated matrix
  2994. */
  2995. removeRotationAndScaling(): Matrix;
  2996. /**
  2997. * Multiply two matrices
  2998. * @param other defines the second operand
  2999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3000. */
  3001. multiply(other: DeepImmutable<Matrix>): Matrix;
  3002. /**
  3003. * Copy the current matrix from the given one
  3004. * @param other defines the source matrix
  3005. * @returns the current updated matrix
  3006. */
  3007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3008. /**
  3009. * Populates the given array from the starting index with the current matrix values
  3010. * @param array defines the target array
  3011. * @param offset defines the offset in the target array where to start storing values
  3012. * @returns the current matrix
  3013. */
  3014. copyToArray(array: Float32Array, offset?: number): Matrix;
  3015. /**
  3016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3017. * @param other defines the second operand
  3018. * @param result defines the matrix where to store the multiplication
  3019. * @returns the current matrix
  3020. */
  3021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3022. /**
  3023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3024. * @param other defines the second operand
  3025. * @param result defines the array where to store the multiplication
  3026. * @param offset defines the offset in the target array where to start storing values
  3027. * @returns the current matrix
  3028. */
  3029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3030. /**
  3031. * Check equality between this matrix and a second one
  3032. * @param value defines the second matrix to compare
  3033. * @returns true is the current matrix and the given one values are strictly equal
  3034. */
  3035. equals(value: DeepImmutable<Matrix>): boolean;
  3036. /**
  3037. * Clone the current matrix
  3038. * @returns a new matrix from the current matrix
  3039. */
  3040. clone(): Matrix;
  3041. /**
  3042. * Returns the name of the current matrix class
  3043. * @returns the string "Matrix"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Gets the hash code of the current matrix
  3048. * @returns the hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Decomposes the current Matrix into a translation, rotation and scaling components
  3053. * @param scale defines the scale vector3 given as a reference to update
  3054. * @param rotation defines the rotation quaternion given as a reference to update
  3055. * @param translation defines the translation vector3 given as a reference to update
  3056. * @returns true if operation was successful
  3057. */
  3058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3059. /**
  3060. * Gets specific row of the matrix
  3061. * @param index defines the number of the row to get
  3062. * @returns the index-th row of the current matrix as a new Vector4
  3063. */
  3064. getRow(index: number): Nullable<Vector4>;
  3065. /**
  3066. * Sets the index-th row of the current matrix to the vector4 values
  3067. * @param index defines the number of the row to set
  3068. * @param row defines the target vector4
  3069. * @returns the updated current matrix
  3070. */
  3071. setRow(index: number, row: Vector4): Matrix;
  3072. /**
  3073. * Compute the transpose of the matrix
  3074. * @returns the new transposed matrix
  3075. */
  3076. transpose(): Matrix;
  3077. /**
  3078. * Compute the transpose of the matrix and store it in a given matrix
  3079. * @param result defines the target matrix
  3080. * @returns the current matrix
  3081. */
  3082. transposeToRef(result: Matrix): Matrix;
  3083. /**
  3084. * Sets the index-th row of the current matrix with the given 4 x float values
  3085. * @param index defines the row index
  3086. * @param x defines the x component to set
  3087. * @param y defines the y component to set
  3088. * @param z defines the z component to set
  3089. * @param w defines the w component to set
  3090. * @returns the updated current matrix
  3091. */
  3092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3093. /**
  3094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3095. * @param scale defines the scale factor
  3096. * @returns a new matrix
  3097. */
  3098. scale(scale: number): Matrix;
  3099. /**
  3100. * Scale the current matrix values by a factor to a given result matrix
  3101. * @param scale defines the scale factor
  3102. * @param result defines the matrix to store the result
  3103. * @returns the current matrix
  3104. */
  3105. scaleToRef(scale: number, result: Matrix): Matrix;
  3106. /**
  3107. * Scale the current matrix values by a factor and add the result to a given matrix
  3108. * @param scale defines the scale factor
  3109. * @param result defines the Matrix to store the result
  3110. * @returns the current matrix
  3111. */
  3112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3113. /**
  3114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3115. * @param ref matrix to store the result
  3116. */
  3117. toNormalMatrix(ref: Matrix): void;
  3118. /**
  3119. * Gets only rotation part of the current matrix
  3120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3121. */
  3122. getRotationMatrix(): Matrix;
  3123. /**
  3124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3125. * @param result defines the target matrix to store data to
  3126. * @returns the current matrix
  3127. */
  3128. getRotationMatrixToRef(result: Matrix): Matrix;
  3129. /**
  3130. * Toggles model matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleModelMatrixHandInPlace(): void;
  3133. /**
  3134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3135. */
  3136. toggleProjectionMatrixHandInPlace(): void;
  3137. /**
  3138. * Creates a matrix from an array
  3139. * @param array defines the source array
  3140. * @param offset defines an offset in the source array
  3141. * @returns a new Matrix set from the starting index of the given array
  3142. */
  3143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3144. /**
  3145. * Copy the content of an array into a given matrix
  3146. * @param array defines the source array
  3147. * @param offset defines an offset in the source array
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3151. /**
  3152. * Stores an array into a matrix after having multiplied each component by a given factor
  3153. * @param array defines the source array
  3154. * @param offset defines the offset in the source array
  3155. * @param scale defines the scaling factor
  3156. * @param result defines the target matrix
  3157. */
  3158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3159. /**
  3160. * Gets an identity matrix that must not be updated
  3161. */
  3162. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3163. /**
  3164. * Stores a list of values (16) inside a given matrix
  3165. * @param initialM11 defines 1st value of 1st row
  3166. * @param initialM12 defines 2nd value of 1st row
  3167. * @param initialM13 defines 3rd value of 1st row
  3168. * @param initialM14 defines 4th value of 1st row
  3169. * @param initialM21 defines 1st value of 2nd row
  3170. * @param initialM22 defines 2nd value of 2nd row
  3171. * @param initialM23 defines 3rd value of 2nd row
  3172. * @param initialM24 defines 4th value of 2nd row
  3173. * @param initialM31 defines 1st value of 3rd row
  3174. * @param initialM32 defines 2nd value of 3rd row
  3175. * @param initialM33 defines 3rd value of 3rd row
  3176. * @param initialM34 defines 4th value of 3rd row
  3177. * @param initialM41 defines 1st value of 4th row
  3178. * @param initialM42 defines 2nd value of 4th row
  3179. * @param initialM43 defines 3rd value of 4th row
  3180. * @param initialM44 defines 4th value of 4th row
  3181. * @param result defines the target matrix
  3182. */
  3183. 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;
  3184. /**
  3185. * Creates new matrix from a list of values (16)
  3186. * @param initialM11 defines 1st value of 1st row
  3187. * @param initialM12 defines 2nd value of 1st row
  3188. * @param initialM13 defines 3rd value of 1st row
  3189. * @param initialM14 defines 4th value of 1st row
  3190. * @param initialM21 defines 1st value of 2nd row
  3191. * @param initialM22 defines 2nd value of 2nd row
  3192. * @param initialM23 defines 3rd value of 2nd row
  3193. * @param initialM24 defines 4th value of 2nd row
  3194. * @param initialM31 defines 1st value of 3rd row
  3195. * @param initialM32 defines 2nd value of 3rd row
  3196. * @param initialM33 defines 3rd value of 3rd row
  3197. * @param initialM34 defines 4th value of 3rd row
  3198. * @param initialM41 defines 1st value of 4th row
  3199. * @param initialM42 defines 2nd value of 4th row
  3200. * @param initialM43 defines 3rd value of 4th row
  3201. * @param initialM44 defines 4th value of 4th row
  3202. * @returns the new matrix
  3203. */
  3204. 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;
  3205. /**
  3206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3207. * @param scale defines the scale vector3
  3208. * @param rotation defines the rotation quaternion
  3209. * @param translation defines the translation vector3
  3210. * @returns a new matrix
  3211. */
  3212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3213. /**
  3214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3215. * @param scale defines the scale vector3
  3216. * @param rotation defines the rotation quaternion
  3217. * @param translation defines the translation vector3
  3218. * @param result defines the target matrix
  3219. */
  3220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3221. /**
  3222. * Creates a new identity matrix
  3223. * @returns a new identity matrix
  3224. */
  3225. static Identity(): Matrix;
  3226. /**
  3227. * Creates a new identity matrix and stores the result in a given matrix
  3228. * @param result defines the target matrix
  3229. */
  3230. static IdentityToRef(result: Matrix): void;
  3231. /**
  3232. * Creates a new zero matrix
  3233. * @returns a new zero matrix
  3234. */
  3235. static Zero(): Matrix;
  3236. /**
  3237. * Creates a new rotation matrix for "angle" radians around the X axis
  3238. * @param angle defines the angle (in radians) to use
  3239. * @return the new matrix
  3240. */
  3241. static RotationX(angle: number): Matrix;
  3242. /**
  3243. * Creates a new matrix as the invert of a given matrix
  3244. * @param source defines the source matrix
  3245. * @returns the new matrix
  3246. */
  3247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3248. /**
  3249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3250. * @param angle defines the angle (in radians) to use
  3251. * @param result defines the target matrix
  3252. */
  3253. static RotationXToRef(angle: number, result: Matrix): void;
  3254. /**
  3255. * Creates a new rotation matrix for "angle" radians around the Y axis
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationY(angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3262. * @param angle defines the angle (in radians) to use
  3263. * @param result defines the target matrix
  3264. */
  3265. static RotationYToRef(angle: number, result: Matrix): void;
  3266. /**
  3267. * Creates a new rotation matrix for "angle" radians around the Z axis
  3268. * @param angle defines the angle (in radians) to use
  3269. * @return the new matrix
  3270. */
  3271. static RotationZ(angle: number): Matrix;
  3272. /**
  3273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3274. * @param angle defines the angle (in radians) to use
  3275. * @param result defines the target matrix
  3276. */
  3277. static RotationZToRef(angle: number, result: Matrix): void;
  3278. /**
  3279. * Creates a new rotation matrix for "angle" radians around the given axis
  3280. * @param axis defines the axis to use
  3281. * @param angle defines the angle (in radians) to use
  3282. * @return the new matrix
  3283. */
  3284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3285. /**
  3286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3287. * @param axis defines the axis to use
  3288. * @param angle defines the angle (in radians) to use
  3289. * @param result defines the target matrix
  3290. */
  3291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3292. /**
  3293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3295. * @param from defines the vector to align
  3296. * @param to defines the vector to align to
  3297. * @param result defines the target matrix
  3298. */
  3299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3300. /**
  3301. * Creates a rotation matrix
  3302. * @param yaw defines the yaw angle in radians (Y axis)
  3303. * @param pitch defines the pitch angle in radians (X axis)
  3304. * @param roll defines the roll angle in radians (X axis)
  3305. * @returns the new rotation matrix
  3306. */
  3307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3308. /**
  3309. * Creates a rotation matrix and stores it in a given matrix
  3310. * @param yaw defines the yaw angle in radians (Y axis)
  3311. * @param pitch defines the pitch angle in radians (X axis)
  3312. * @param roll defines the roll angle in radians (X axis)
  3313. * @param result defines the target matrix
  3314. */
  3315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3316. /**
  3317. * Creates a scaling matrix
  3318. * @param x defines the scale factor on X axis
  3319. * @param y defines the scale factor on Y axis
  3320. * @param z defines the scale factor on Z axis
  3321. * @returns the new matrix
  3322. */
  3323. static Scaling(x: number, y: number, z: number): Matrix;
  3324. /**
  3325. * Creates a scaling matrix and stores it in a given matrix
  3326. * @param x defines the scale factor on X axis
  3327. * @param y defines the scale factor on Y axis
  3328. * @param z defines the scale factor on Z axis
  3329. * @param result defines the target matrix
  3330. */
  3331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3332. /**
  3333. * Creates a translation matrix
  3334. * @param x defines the translation on X axis
  3335. * @param y defines the translation on Y axis
  3336. * @param z defines the translationon Z axis
  3337. * @returns the new matrix
  3338. */
  3339. static Translation(x: number, y: number, z: number): Matrix;
  3340. /**
  3341. * Creates a translation matrix and stores it in a given matrix
  3342. * @param x defines the translation on X axis
  3343. * @param y defines the translation on Y axis
  3344. * @param z defines the translationon Z axis
  3345. * @param result defines the target matrix
  3346. */
  3347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3348. /**
  3349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3350. * @param startValue defines the start value
  3351. * @param endValue defines the end value
  3352. * @param gradient defines the gradient factor
  3353. * @returns the new matrix
  3354. */
  3355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3356. /**
  3357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3358. * @param startValue defines the start value
  3359. * @param endValue defines the end value
  3360. * @param gradient defines the gradient factor
  3361. * @param result defines the Matrix object where to store data
  3362. */
  3363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3364. /**
  3365. * Builds a new matrix whose values are computed by:
  3366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3369. * @param startValue defines the first matrix
  3370. * @param endValue defines the second matrix
  3371. * @param gradient defines the gradient between the two matrices
  3372. * @returns the new matrix
  3373. */
  3374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3375. /**
  3376. * Update a matrix to values which are computed by:
  3377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3380. * @param startValue defines the first matrix
  3381. * @param endValue defines the second matrix
  3382. * @param gradient defines the gradient between the two matrices
  3383. * @param result defines the target matrix
  3384. */
  3385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3386. /**
  3387. * 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"
  3388. * This function works in left handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @returns the new matrix
  3393. */
  3394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3395. /**
  3396. * 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".
  3397. * This function works in left handed mode
  3398. * @param eye defines the final position of the entity
  3399. * @param target defines where the entity should look at
  3400. * @param up defines the up vector for the entity
  3401. * @param result defines the target matrix
  3402. */
  3403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3404. /**
  3405. * 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"
  3406. * This function works in right handed mode
  3407. * @param eye defines the final position of the entity
  3408. * @param target defines where the entity should look at
  3409. * @param up defines the up vector for the entity
  3410. * @returns the new matrix
  3411. */
  3412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3413. /**
  3414. * 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".
  3415. * This function works in right handed mode
  3416. * @param eye defines the final position of the entity
  3417. * @param target defines where the entity should look at
  3418. * @param up defines the up vector for the entity
  3419. * @param result defines the target matrix
  3420. */
  3421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3422. /**
  3423. * Create a left-handed orthographic projection matrix
  3424. * @param width defines the viewport width
  3425. * @param height defines the viewport height
  3426. * @param znear defines the near clip plane
  3427. * @param zfar defines the far clip plane
  3428. * @returns a new matrix as a left-handed orthographic projection matrix
  3429. */
  3430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3431. /**
  3432. * Store a left-handed orthographic projection to a given matrix
  3433. * @param width defines the viewport width
  3434. * @param height defines the viewport height
  3435. * @param znear defines the near clip plane
  3436. * @param zfar defines the far clip plane
  3437. * @param result defines the target matrix
  3438. */
  3439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3440. /**
  3441. * Create a left-handed orthographic projection matrix
  3442. * @param left defines the viewport left coordinate
  3443. * @param right defines the viewport right coordinate
  3444. * @param bottom defines the viewport bottom coordinate
  3445. * @param top defines the viewport top coordinate
  3446. * @param znear defines the near clip plane
  3447. * @param zfar defines the far clip plane
  3448. * @returns a new matrix as a left-handed orthographic projection matrix
  3449. */
  3450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3451. /**
  3452. * Stores a left-handed orthographic projection into a given matrix
  3453. * @param left defines the viewport left coordinate
  3454. * @param right defines the viewport right coordinate
  3455. * @param bottom defines the viewport bottom coordinate
  3456. * @param top defines the viewport top coordinate
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @param result defines the target matrix
  3460. */
  3461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3462. /**
  3463. * Creates a right-handed orthographic projection matrix
  3464. * @param left defines the viewport left coordinate
  3465. * @param right defines the viewport right coordinate
  3466. * @param bottom defines the viewport bottom coordinate
  3467. * @param top defines the viewport top coordinate
  3468. * @param znear defines the near clip plane
  3469. * @param zfar defines the far clip plane
  3470. * @returns a new matrix as a right-handed orthographic projection matrix
  3471. */
  3472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3473. /**
  3474. * Stores a right-handed orthographic projection into a given matrix
  3475. * @param left defines the viewport left coordinate
  3476. * @param right defines the viewport right coordinate
  3477. * @param bottom defines the viewport bottom coordinate
  3478. * @param top defines the viewport top coordinate
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. */
  3483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3484. /**
  3485. * Creates a left-handed perspective projection matrix
  3486. * @param width defines the viewport width
  3487. * @param height defines the viewport height
  3488. * @param znear defines the near clip plane
  3489. * @param zfar defines the far clip plane
  3490. * @returns a new matrix as a left-handed perspective projection matrix
  3491. */
  3492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3493. /**
  3494. * Creates a left-handed perspective projection matrix
  3495. * @param fov defines the horizontal field of view
  3496. * @param aspect defines the aspect ratio
  3497. * @param znear defines the near clip plane
  3498. * @param zfar defines the far clip plane
  3499. * @returns a new matrix as a left-handed perspective projection matrix
  3500. */
  3501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3502. /**
  3503. * Stores a left-handed perspective projection into a given matrix
  3504. * @param fov defines the horizontal field of view
  3505. * @param aspect defines the aspect ratio
  3506. * @param znear defines the near clip plane
  3507. * @param zfar defines the far clip plane
  3508. * @param result defines the target matrix
  3509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3510. */
  3511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3512. /**
  3513. * Creates a right-handed perspective projection matrix
  3514. * @param fov defines the horizontal field of view
  3515. * @param aspect defines the aspect ratio
  3516. * @param znear defines the near clip plane
  3517. * @param zfar defines the far clip plane
  3518. * @returns a new matrix as a right-handed perspective projection matrix
  3519. */
  3520. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3521. /**
  3522. * Stores a right-handed perspective projection into a given matrix
  3523. * @param fov defines the horizontal field of view
  3524. * @param aspect defines the aspect ratio
  3525. * @param znear defines the near clip plane
  3526. * @param zfar defines the far clip plane
  3527. * @param result defines the target matrix
  3528. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3529. */
  3530. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3531. /**
  3532. * Stores a perspective projection for WebVR info a given matrix
  3533. * @param fov defines the field of view
  3534. * @param znear defines the near clip plane
  3535. * @param zfar defines the far clip plane
  3536. * @param result defines the target matrix
  3537. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3538. */
  3539. static PerspectiveFovWebVRToRef(fov: {
  3540. upDegrees: number;
  3541. downDegrees: number;
  3542. leftDegrees: number;
  3543. rightDegrees: number;
  3544. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3545. /**
  3546. * Computes a complete transformation matrix
  3547. * @param viewport defines the viewport to use
  3548. * @param world defines the world matrix
  3549. * @param view defines the view matrix
  3550. * @param projection defines the projection matrix
  3551. * @param zmin defines the near clip plane
  3552. * @param zmax defines the far clip plane
  3553. * @returns the transformation matrix
  3554. */
  3555. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3556. /**
  3557. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3558. * @param matrix defines the matrix to use
  3559. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3560. */
  3561. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3562. /**
  3563. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3564. * @param matrix defines the matrix to use
  3565. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3566. */
  3567. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3568. /**
  3569. * Compute the transpose of a given matrix
  3570. * @param matrix defines the matrix to transpose
  3571. * @returns the new matrix
  3572. */
  3573. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3574. /**
  3575. * Compute the transpose of a matrix and store it in a target matrix
  3576. * @param matrix defines the matrix to transpose
  3577. * @param result defines the target matrix
  3578. */
  3579. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3580. /**
  3581. * Computes a reflection matrix from a plane
  3582. * @param plane defines the reflection plane
  3583. * @returns a new matrix
  3584. */
  3585. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3586. /**
  3587. * Computes a reflection matrix from a plane
  3588. * @param plane defines the reflection plane
  3589. * @param result defines the target matrix
  3590. */
  3591. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3592. /**
  3593. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3594. * @param xaxis defines the value of the 1st axis
  3595. * @param yaxis defines the value of the 2nd axis
  3596. * @param zaxis defines the value of the 3rd axis
  3597. * @param result defines the target matrix
  3598. */
  3599. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3600. /**
  3601. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3602. * @param quat defines the quaternion to use
  3603. * @param result defines the target matrix
  3604. */
  3605. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3606. }
  3607. /**
  3608. * Represens a plane by the equation ax + by + cz + d = 0
  3609. */
  3610. export class Plane {
  3611. /**
  3612. * Normal of the plane (a,b,c)
  3613. */
  3614. normal: Vector3;
  3615. /**
  3616. * d component of the plane
  3617. */
  3618. d: number;
  3619. /**
  3620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3621. * @param a a component of the plane
  3622. * @param b b component of the plane
  3623. * @param c c component of the plane
  3624. * @param d d component of the plane
  3625. */
  3626. constructor(a: number, b: number, c: number, d: number);
  3627. /**
  3628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3629. */
  3630. asArray(): number[];
  3631. /**
  3632. * @returns a new plane copied from the current Plane.
  3633. */
  3634. clone(): Plane;
  3635. /**
  3636. * @returns the string "Plane".
  3637. */
  3638. getClassName(): string;
  3639. /**
  3640. * @returns the Plane hash code.
  3641. */
  3642. getHashCode(): number;
  3643. /**
  3644. * Normalize the current Plane in place.
  3645. * @returns the updated Plane.
  3646. */
  3647. normalize(): Plane;
  3648. /**
  3649. * Applies a transformation the plane and returns the result
  3650. * @param transformation the transformation matrix to be applied to the plane
  3651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3652. */
  3653. transform(transformation: DeepImmutable<Matrix>): Plane;
  3654. /**
  3655. * Calcualtte the dot product between the point and the plane normal
  3656. * @param point point to calculate the dot product with
  3657. * @returns the dot product (float) of the point coordinates and the plane normal.
  3658. */
  3659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3660. /**
  3661. * Updates the current Plane from the plane defined by the three given points.
  3662. * @param point1 one of the points used to contruct the plane
  3663. * @param point2 one of the points used to contruct the plane
  3664. * @param point3 one of the points used to contruct the plane
  3665. * @returns the updated Plane.
  3666. */
  3667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Checks if the plane is facing a given direction
  3670. * @param direction the direction to check if the plane is facing
  3671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3672. * @returns True is the vector "direction" is the same side than the plane normal.
  3673. */
  3674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3675. /**
  3676. * Calculates the distance to a point
  3677. * @param point point to calculate distance to
  3678. * @returns the signed distance (float) from the given point to the Plane.
  3679. */
  3680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3681. /**
  3682. * Creates a plane from an array
  3683. * @param array the array to create a plane from
  3684. * @returns a new Plane from the given array.
  3685. */
  3686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3687. /**
  3688. * Creates a plane from three points
  3689. * @param point1 point used to create the plane
  3690. * @param point2 point used to create the plane
  3691. * @param point3 point used to create the plane
  3692. * @returns a new Plane defined by the three given points.
  3693. */
  3694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3695. /**
  3696. * Creates a plane from an origin point and a normal
  3697. * @param origin origin of the plane to be constructed
  3698. * @param normal normal of the plane to be constructed
  3699. * @returns a new Plane the normal vector to this plane at the given origin point.
  3700. * Note : the vector "normal" is updated because normalized.
  3701. */
  3702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3703. /**
  3704. * Calculates the distance from a plane and a point
  3705. * @param origin origin of the plane to be constructed
  3706. * @param normal normal of the plane to be constructed
  3707. * @param point point to calculate distance to
  3708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3709. */
  3710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3711. }
  3712. /**
  3713. * Class used to represent a viewport on screen
  3714. */
  3715. export class Viewport {
  3716. /** viewport left coordinate */
  3717. x: number;
  3718. /** viewport top coordinate */
  3719. y: number;
  3720. /**viewport width */
  3721. width: number;
  3722. /** viewport height */
  3723. height: number;
  3724. /**
  3725. * Creates a Viewport object located at (x, y) and sized (width, height)
  3726. * @param x defines viewport left coordinate
  3727. * @param y defines viewport top coordinate
  3728. * @param width defines the viewport width
  3729. * @param height defines the viewport height
  3730. */
  3731. constructor(
  3732. /** viewport left coordinate */
  3733. x: number,
  3734. /** viewport top coordinate */
  3735. y: number,
  3736. /**viewport width */
  3737. width: number,
  3738. /** viewport height */
  3739. height: number);
  3740. /**
  3741. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3742. * @param renderWidth defines the rendering width
  3743. * @param renderHeight defines the rendering height
  3744. * @returns a new Viewport
  3745. */
  3746. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3747. /**
  3748. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3749. * @param renderWidth defines the rendering width
  3750. * @param renderHeight defines the rendering height
  3751. * @param ref defines the target viewport
  3752. * @returns the current viewport
  3753. */
  3754. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3755. /**
  3756. * Returns a new Viewport copied from the current one
  3757. * @returns a new Viewport
  3758. */
  3759. clone(): Viewport;
  3760. }
  3761. /**
  3762. * Reprasents a camera frustum
  3763. */
  3764. export class Frustum {
  3765. /**
  3766. * Gets the planes representing the frustum
  3767. * @param transform matrix to be applied to the returned planes
  3768. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3769. */
  3770. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3771. /**
  3772. * Gets the near frustum plane transformed by the transform matrix
  3773. * @param transform transformation matrix to be applied to the resulting frustum plane
  3774. * @param frustumPlane the resuling frustum plane
  3775. */
  3776. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3777. /**
  3778. * Gets the far frustum plane transformed by the transform matrix
  3779. * @param transform transformation matrix to be applied to the resulting frustum plane
  3780. * @param frustumPlane the resuling frustum plane
  3781. */
  3782. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3783. /**
  3784. * Gets the left frustum plane transformed by the transform matrix
  3785. * @param transform transformation matrix to be applied to the resulting frustum plane
  3786. * @param frustumPlane the resuling frustum plane
  3787. */
  3788. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3789. /**
  3790. * Gets the right frustum plane transformed by the transform matrix
  3791. * @param transform transformation matrix to be applied to the resulting frustum plane
  3792. * @param frustumPlane the resuling frustum plane
  3793. */
  3794. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3795. /**
  3796. * Gets the top frustum plane transformed by the transform matrix
  3797. * @param transform transformation matrix to be applied to the resulting frustum plane
  3798. * @param frustumPlane the resuling frustum plane
  3799. */
  3800. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3801. /**
  3802. * Gets the bottom frustum plane transformed by the transform matrix
  3803. * @param transform transformation matrix to be applied to the resulting frustum plane
  3804. * @param frustumPlane the resuling frustum plane
  3805. */
  3806. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3807. /**
  3808. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3809. * @param transform transformation matrix to be applied to the resulting frustum planes
  3810. * @param frustumPlanes the resuling frustum planes
  3811. */
  3812. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3813. }
  3814. /** Defines supported spaces */
  3815. export enum Space {
  3816. /** Local (object) space */
  3817. LOCAL = 0,
  3818. /** World space */
  3819. WORLD = 1,
  3820. /** Bone space */
  3821. BONE = 2
  3822. }
  3823. /** Defines the 3 main axes */
  3824. export class Axis {
  3825. /** X axis */
  3826. static X: Vector3;
  3827. /** Y axis */
  3828. static Y: Vector3;
  3829. /** Z axis */
  3830. static Z: Vector3;
  3831. }
  3832. /** Class used to represent a Bezier curve */
  3833. export class BezierCurve {
  3834. /**
  3835. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3836. * @param t defines the time
  3837. * @param x1 defines the left coordinate on X axis
  3838. * @param y1 defines the left coordinate on Y axis
  3839. * @param x2 defines the right coordinate on X axis
  3840. * @param y2 defines the right coordinate on Y axis
  3841. * @returns the interpolated value
  3842. */
  3843. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3844. }
  3845. /**
  3846. * Defines potential orientation for back face culling
  3847. */
  3848. export enum Orientation {
  3849. /**
  3850. * Clockwise
  3851. */
  3852. CW = 0,
  3853. /** Counter clockwise */
  3854. CCW = 1
  3855. }
  3856. /**
  3857. * Defines angle representation
  3858. */
  3859. export class Angle {
  3860. private _radians;
  3861. /**
  3862. * Creates an Angle object of "radians" radians (float).
  3863. * @param radians the angle in radians
  3864. */
  3865. constructor(radians: number);
  3866. /**
  3867. * Get value in degrees
  3868. * @returns the Angle value in degrees (float)
  3869. */
  3870. degrees(): number;
  3871. /**
  3872. * Get value in radians
  3873. * @returns the Angle value in radians (float)
  3874. */
  3875. radians(): number;
  3876. /**
  3877. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3878. * @param a defines first vector
  3879. * @param b defines second vector
  3880. * @returns a new Angle
  3881. */
  3882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3883. /**
  3884. * Gets a new Angle object from the given float in radians
  3885. * @param radians defines the angle value in radians
  3886. * @returns a new Angle
  3887. */
  3888. static FromRadians(radians: number): Angle;
  3889. /**
  3890. * Gets a new Angle object from the given float in degrees
  3891. * @param degrees defines the angle value in degrees
  3892. * @returns a new Angle
  3893. */
  3894. static FromDegrees(degrees: number): Angle;
  3895. }
  3896. /**
  3897. * This represents an arc in a 2d space.
  3898. */
  3899. export class Arc2 {
  3900. /** Defines the start point of the arc */
  3901. startPoint: Vector2;
  3902. /** Defines the mid point of the arc */
  3903. midPoint: Vector2;
  3904. /** Defines the end point of the arc */
  3905. endPoint: Vector2;
  3906. /**
  3907. * Defines the center point of the arc.
  3908. */
  3909. centerPoint: Vector2;
  3910. /**
  3911. * Defines the radius of the arc.
  3912. */
  3913. radius: number;
  3914. /**
  3915. * Defines the angle of the arc (from mid point to end point).
  3916. */
  3917. angle: Angle;
  3918. /**
  3919. * Defines the start angle of the arc (from start point to middle point).
  3920. */
  3921. startAngle: Angle;
  3922. /**
  3923. * Defines the orientation of the arc (clock wise/counter clock wise).
  3924. */
  3925. orientation: Orientation;
  3926. /**
  3927. * Creates an Arc object from the three given points : start, middle and end.
  3928. * @param startPoint Defines the start point of the arc
  3929. * @param midPoint Defines the midlle point of the arc
  3930. * @param endPoint Defines the end point of the arc
  3931. */
  3932. constructor(
  3933. /** Defines the start point of the arc */
  3934. startPoint: Vector2,
  3935. /** Defines the mid point of the arc */
  3936. midPoint: Vector2,
  3937. /** Defines the end point of the arc */
  3938. endPoint: Vector2);
  3939. }
  3940. /**
  3941. * Represents a 2D path made up of multiple 2D points
  3942. */
  3943. export class Path2 {
  3944. private _points;
  3945. private _length;
  3946. /**
  3947. * If the path start and end point are the same
  3948. */
  3949. closed: boolean;
  3950. /**
  3951. * Creates a Path2 object from the starting 2D coordinates x and y.
  3952. * @param x the starting points x value
  3953. * @param y the starting points y value
  3954. */
  3955. constructor(x: number, y: number);
  3956. /**
  3957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3958. * @param x the added points x value
  3959. * @param y the added points y value
  3960. * @returns the updated Path2.
  3961. */
  3962. addLineTo(x: number, y: number): Path2;
  3963. /**
  3964. * 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.
  3965. * @param midX middle point x value
  3966. * @param midY middle point y value
  3967. * @param endX end point x value
  3968. * @param endY end point y value
  3969. * @param numberOfSegments (default: 36)
  3970. * @returns the updated Path2.
  3971. */
  3972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3973. /**
  3974. * Closes the Path2.
  3975. * @returns the Path2.
  3976. */
  3977. close(): Path2;
  3978. /**
  3979. * Gets the sum of the distance between each sequential point in the path
  3980. * @returns the Path2 total length (float).
  3981. */
  3982. length(): number;
  3983. /**
  3984. * Gets the points which construct the path
  3985. * @returns the Path2 internal array of points.
  3986. */
  3987. getPoints(): Vector2[];
  3988. /**
  3989. * Retreives the point at the distance aways from the starting point
  3990. * @param normalizedLengthPosition the length along the path to retreive the point from
  3991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3992. */
  3993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3994. /**
  3995. * Creates a new path starting from an x and y position
  3996. * @param x starting x value
  3997. * @param y starting y value
  3998. * @returns a new Path2 starting at the coordinates (x, y).
  3999. */
  4000. static StartingAt(x: number, y: number): Path2;
  4001. }
  4002. /**
  4003. * Represents a 3D path made up of multiple 3D points
  4004. */
  4005. export class Path3D {
  4006. /**
  4007. * an array of Vector3, the curve axis of the Path3D
  4008. */
  4009. path: Vector3[];
  4010. private _curve;
  4011. private _distances;
  4012. private _tangents;
  4013. private _normals;
  4014. private _binormals;
  4015. private _raw;
  4016. /**
  4017. * new Path3D(path, normal, raw)
  4018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4020. * @param path an array of Vector3, the curve axis of the Path3D
  4021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4023. */
  4024. constructor(
  4025. /**
  4026. * an array of Vector3, the curve axis of the Path3D
  4027. */
  4028. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4029. /**
  4030. * Returns the Path3D array of successive Vector3 designing its curve.
  4031. * @returns the Path3D array of successive Vector3 designing its curve.
  4032. */
  4033. getCurve(): Vector3[];
  4034. /**
  4035. * Returns an array populated with tangent vectors on each Path3D curve point.
  4036. * @returns an array populated with tangent vectors on each Path3D curve point.
  4037. */
  4038. getTangents(): Vector3[];
  4039. /**
  4040. * Returns an array populated with normal vectors on each Path3D curve point.
  4041. * @returns an array populated with normal vectors on each Path3D curve point.
  4042. */
  4043. getNormals(): Vector3[];
  4044. /**
  4045. * Returns an array populated with binormal vectors on each Path3D curve point.
  4046. * @returns an array populated with binormal vectors on each Path3D curve point.
  4047. */
  4048. getBinormals(): Vector3[];
  4049. /**
  4050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4051. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4052. */
  4053. getDistances(): number[];
  4054. /**
  4055. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4056. * @param path path which all values are copied into the curves points
  4057. * @param firstNormal which should be projected onto the curve
  4058. * @returns the same object updated.
  4059. */
  4060. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4061. private _compute;
  4062. private _getFirstNonNullVector;
  4063. private _getLastNonNullVector;
  4064. private _normalVector;
  4065. }
  4066. /**
  4067. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4068. * A Curve3 is designed from a series of successive Vector3.
  4069. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4070. */
  4071. export class Curve3 {
  4072. private _points;
  4073. private _length;
  4074. /**
  4075. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4076. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4077. * @param v1 (Vector3) the control point
  4078. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4079. * @param nbPoints (integer) the wanted number of points in the curve
  4080. * @returns the created Curve3
  4081. */
  4082. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4083. /**
  4084. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4085. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4086. * @param v1 (Vector3) the first control point
  4087. * @param v2 (Vector3) the second control point
  4088. * @param v3 (Vector3) the end point of the Cubic Bezier
  4089. * @param nbPoints (integer) the wanted number of points in the curve
  4090. * @returns the created Curve3
  4091. */
  4092. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4093. /**
  4094. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4095. * @param p1 (Vector3) the origin point of the Hermite Spline
  4096. * @param t1 (Vector3) the tangent vector at the origin point
  4097. * @param p2 (Vector3) the end point of the Hermite Spline
  4098. * @param t2 (Vector3) the tangent vector at the end point
  4099. * @param nbPoints (integer) the wanted number of points in the curve
  4100. * @returns the created Curve3
  4101. */
  4102. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4103. /**
  4104. * Returns a Curve3 object along a CatmullRom Spline curve :
  4105. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4106. * @param nbPoints (integer) the wanted number of points between each curve control points
  4107. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4108. * @returns the created Curve3
  4109. */
  4110. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4111. /**
  4112. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4113. * A Curve3 is designed from a series of successive Vector3.
  4114. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4115. * @param points points which make up the curve
  4116. */
  4117. constructor(points: Vector3[]);
  4118. /**
  4119. * @returns the Curve3 stored array of successive Vector3
  4120. */
  4121. getPoints(): Vector3[];
  4122. /**
  4123. * @returns the computed length (float) of the curve.
  4124. */
  4125. length(): number;
  4126. /**
  4127. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4128. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4129. * curveA and curveB keep unchanged.
  4130. * @param curve the curve to continue from this curve
  4131. * @returns the newly constructed curve
  4132. */
  4133. continue(curve: DeepImmutable<Curve3>): Curve3;
  4134. private _computeLength;
  4135. }
  4136. /**
  4137. * Contains position and normal vectors for a vertex
  4138. */
  4139. export class PositionNormalVertex {
  4140. /** the position of the vertex (defaut: 0,0,0) */
  4141. position: Vector3;
  4142. /** the normal of the vertex (defaut: 0,1,0) */
  4143. normal: Vector3;
  4144. /**
  4145. * Creates a PositionNormalVertex
  4146. * @param position the position of the vertex (defaut: 0,0,0)
  4147. * @param normal the normal of the vertex (defaut: 0,1,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3);
  4154. /**
  4155. * Clones the PositionNormalVertex
  4156. * @returns the cloned PositionNormalVertex
  4157. */
  4158. clone(): PositionNormalVertex;
  4159. }
  4160. /**
  4161. * Contains position, normal and uv vectors for a vertex
  4162. */
  4163. export class PositionNormalTextureVertex {
  4164. /** the position of the vertex (defaut: 0,0,0) */
  4165. position: Vector3;
  4166. /** the normal of the vertex (defaut: 0,1,0) */
  4167. normal: Vector3;
  4168. /** the uv of the vertex (default: 0,0) */
  4169. uv: Vector2;
  4170. /**
  4171. * Creates a PositionNormalTextureVertex
  4172. * @param position the position of the vertex (defaut: 0,0,0)
  4173. * @param normal the normal of the vertex (defaut: 0,1,0)
  4174. * @param uv the uv of the vertex (default: 0,0)
  4175. */
  4176. constructor(
  4177. /** the position of the vertex (defaut: 0,0,0) */
  4178. position?: Vector3,
  4179. /** the normal of the vertex (defaut: 0,1,0) */
  4180. normal?: Vector3,
  4181. /** the uv of the vertex (default: 0,0) */
  4182. uv?: Vector2);
  4183. /**
  4184. * Clones the PositionNormalTextureVertex
  4185. * @returns the cloned PositionNormalTextureVertex
  4186. */
  4187. clone(): PositionNormalTextureVertex;
  4188. }
  4189. /**
  4190. * @hidden
  4191. */
  4192. export class Tmp {
  4193. static Color3: Color3[];
  4194. static Color4: Color4[];
  4195. static Vector2: Vector2[];
  4196. static Vector3: Vector3[];
  4197. static Vector4: Vector4[];
  4198. static Quaternion: Quaternion[];
  4199. static Matrix: Matrix[];
  4200. }
  4201. }
  4202. declare module "babylonjs/Offline/IOfflineProvider" {
  4203. /**
  4204. * Class used to enable access to offline support
  4205. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4206. */
  4207. export interface IOfflineProvider {
  4208. /**
  4209. * Gets a boolean indicating if scene must be saved in the database
  4210. */
  4211. enableSceneOffline: boolean;
  4212. /**
  4213. * Gets a boolean indicating if textures must be saved in the database
  4214. */
  4215. enableTexturesOffline: boolean;
  4216. /**
  4217. * Open the offline support and make it available
  4218. * @param successCallback defines the callback to call on success
  4219. * @param errorCallback defines the callback to call on error
  4220. */
  4221. open(successCallback: () => void, errorCallback: () => void): void;
  4222. /**
  4223. * Loads an image from the offline support
  4224. * @param url defines the url to load from
  4225. * @param image defines the target DOM image
  4226. */
  4227. loadImage(url: string, image: HTMLImageElement): void;
  4228. /**
  4229. * Loads a file from offline support
  4230. * @param url defines the URL to load from
  4231. * @param sceneLoaded defines a callback to call on success
  4232. * @param progressCallBack defines a callback to call when progress changed
  4233. * @param errorCallback defines a callback to call on error
  4234. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4235. */
  4236. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4237. }
  4238. }
  4239. declare module "babylonjs/Misc/observable" {
  4240. import { Nullable } from "babylonjs/types";
  4241. /**
  4242. * A class serves as a medium between the observable and its observers
  4243. */
  4244. export class EventState {
  4245. /**
  4246. * Create a new EventState
  4247. * @param mask defines the mask associated with this state
  4248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4249. * @param target defines the original target of the state
  4250. * @param currentTarget defines the current target of the state
  4251. */
  4252. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4253. /**
  4254. * Initialize the current event state
  4255. * @param mask defines the mask associated with this state
  4256. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4257. * @param target defines the original target of the state
  4258. * @param currentTarget defines the current target of the state
  4259. * @returns the current event state
  4260. */
  4261. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4262. /**
  4263. * An Observer can set this property to true to prevent subsequent observers of being notified
  4264. */
  4265. skipNextObservers: boolean;
  4266. /**
  4267. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4268. */
  4269. mask: number;
  4270. /**
  4271. * The object that originally notified the event
  4272. */
  4273. target?: any;
  4274. /**
  4275. * The current object in the bubbling phase
  4276. */
  4277. currentTarget?: any;
  4278. /**
  4279. * This will be populated with the return value of the last function that was executed.
  4280. * If it is the first function in the callback chain it will be the event data.
  4281. */
  4282. lastReturnValue?: any;
  4283. }
  4284. /**
  4285. * Represent an Observer registered to a given Observable object.
  4286. */
  4287. export class Observer<T> {
  4288. /**
  4289. * Defines the callback to call when the observer is notified
  4290. */
  4291. callback: (eventData: T, eventState: EventState) => void;
  4292. /**
  4293. * Defines the mask of the observer (used to filter notifications)
  4294. */
  4295. mask: number;
  4296. /**
  4297. * Defines the current scope used to restore the JS context
  4298. */
  4299. scope: any;
  4300. /** @hidden */
  4301. _willBeUnregistered: boolean;
  4302. /**
  4303. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4304. */
  4305. unregisterOnNextCall: boolean;
  4306. /**
  4307. * Creates a new observer
  4308. * @param callback defines the callback to call when the observer is notified
  4309. * @param mask defines the mask of the observer (used to filter notifications)
  4310. * @param scope defines the current scope used to restore the JS context
  4311. */
  4312. constructor(
  4313. /**
  4314. * Defines the callback to call when the observer is notified
  4315. */
  4316. callback: (eventData: T, eventState: EventState) => void,
  4317. /**
  4318. * Defines the mask of the observer (used to filter notifications)
  4319. */
  4320. mask: number,
  4321. /**
  4322. * Defines the current scope used to restore the JS context
  4323. */
  4324. scope?: any);
  4325. }
  4326. /**
  4327. * Represent a list of observers registered to multiple Observables object.
  4328. */
  4329. export class MultiObserver<T> {
  4330. private _observers;
  4331. private _observables;
  4332. /**
  4333. * Release associated resources
  4334. */
  4335. dispose(): void;
  4336. /**
  4337. * Raise a callback when one of the observable will notify
  4338. * @param observables defines a list of observables to watch
  4339. * @param callback defines the callback to call on notification
  4340. * @param mask defines the mask used to filter notifications
  4341. * @param scope defines the current scope used to restore the JS context
  4342. * @returns the new MultiObserver
  4343. */
  4344. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4345. }
  4346. /**
  4347. * The Observable class is a simple implementation of the Observable pattern.
  4348. *
  4349. * 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.
  4350. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4351. * 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).
  4352. * 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.
  4353. */
  4354. export class Observable<T> {
  4355. private _observers;
  4356. private _eventState;
  4357. private _onObserverAdded;
  4358. /**
  4359. * Gets the list of observers
  4360. */
  4361. readonly observers: Array<Observer<T>>;
  4362. /**
  4363. * Creates a new observable
  4364. * @param onObserverAdded defines a callback to call when a new observer is added
  4365. */
  4366. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4367. /**
  4368. * Create a new Observer with the specified callback
  4369. * @param callback the callback that will be executed for that Observer
  4370. * @param mask the mask used to filter observers
  4371. * @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.
  4372. * @param scope optional scope for the callback to be called from
  4373. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4374. * @returns the new observer created for the callback
  4375. */
  4376. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4377. /**
  4378. * Create a new Observer with the specified callback and unregisters after the next notification
  4379. * @param callback the callback that will be executed for that Observer
  4380. * @returns the new observer created for the callback
  4381. */
  4382. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4383. /**
  4384. * Remove an Observer from the Observable object
  4385. * @param observer the instance of the Observer to remove
  4386. * @returns false if it doesn't belong to this Observable
  4387. */
  4388. remove(observer: Nullable<Observer<T>>): boolean;
  4389. /**
  4390. * Remove a callback from the Observable object
  4391. * @param callback the callback to remove
  4392. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4393. * @returns false if it doesn't belong to this Observable
  4394. */
  4395. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4396. private _deferUnregister;
  4397. private _remove;
  4398. /**
  4399. * Moves the observable to the top of the observer list making it get called first when notified
  4400. * @param observer the observer to move
  4401. */
  4402. makeObserverTopPriority(observer: Observer<T>): void;
  4403. /**
  4404. * Moves the observable to the bottom of the observer list making it get called last when notified
  4405. * @param observer the observer to move
  4406. */
  4407. makeObserverBottomPriority(observer: Observer<T>): void;
  4408. /**
  4409. * Notify all Observers by calling their respective callback with the given data
  4410. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4411. * @param eventData defines the data to send to all observers
  4412. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4413. * @param target defines the original target of the state
  4414. * @param currentTarget defines the current target of the state
  4415. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4416. */
  4417. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4418. /**
  4419. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4420. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4421. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4422. * and it is crucial that all callbacks will be executed.
  4423. * The order of the callbacks is kept, callbacks are not executed parallel.
  4424. *
  4425. * @param eventData The data to be sent to each callback
  4426. * @param mask is used to filter observers defaults to -1
  4427. * @param target defines the callback target (see EventState)
  4428. * @param currentTarget defines he current object in the bubbling phase
  4429. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4430. */
  4431. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4432. /**
  4433. * Notify a specific observer
  4434. * @param observer defines the observer to notify
  4435. * @param eventData defines the data to be sent to each callback
  4436. * @param mask is used to filter observers defaults to -1
  4437. */
  4438. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4439. /**
  4440. * Gets a boolean indicating if the observable has at least one observer
  4441. * @returns true is the Observable has at least one Observer registered
  4442. */
  4443. hasObservers(): boolean;
  4444. /**
  4445. * Clear the list of observers
  4446. */
  4447. clear(): void;
  4448. /**
  4449. * Clone the current observable
  4450. * @returns a new observable
  4451. */
  4452. clone(): Observable<T>;
  4453. /**
  4454. * Does this observable handles observer registered with a given mask
  4455. * @param mask defines the mask to be tested
  4456. * @return whether or not one observer registered with the given mask is handeled
  4457. **/
  4458. hasSpecificMask(mask?: number): boolean;
  4459. }
  4460. }
  4461. declare module "babylonjs/Misc/filesInputStore" {
  4462. /**
  4463. * Class used to help managing file picking and drag'n'drop
  4464. * File Storage
  4465. */
  4466. export class FilesInputStore {
  4467. /**
  4468. * List of files ready to be loaded
  4469. */
  4470. static FilesToLoad: {
  4471. [key: string]: File;
  4472. };
  4473. }
  4474. }
  4475. declare module "babylonjs/Engines/constants" {
  4476. /** Defines the cross module used constants to avoid circular dependncies */
  4477. export class Constants {
  4478. /** Defines that alpha blending is disabled */
  4479. static readonly ALPHA_DISABLE: number;
  4480. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4481. static readonly ALPHA_ADD: number;
  4482. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4483. static readonly ALPHA_COMBINE: number;
  4484. /** Defines that alpha blending to DEST - SRC * DEST */
  4485. static readonly ALPHA_SUBTRACT: number;
  4486. /** Defines that alpha blending to SRC * DEST */
  4487. static readonly ALPHA_MULTIPLY: number;
  4488. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4489. static readonly ALPHA_MAXIMIZED: number;
  4490. /** Defines that alpha blending to SRC + DEST */
  4491. static readonly ALPHA_ONEONE: number;
  4492. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4493. static readonly ALPHA_PREMULTIPLIED: number;
  4494. /**
  4495. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4496. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4497. */
  4498. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4499. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4500. static readonly ALPHA_INTERPOLATE: number;
  4501. /**
  4502. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4503. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4504. */
  4505. static readonly ALPHA_SCREENMODE: number;
  4506. /** Defines that the ressource is not delayed*/
  4507. static readonly DELAYLOADSTATE_NONE: number;
  4508. /** Defines that the ressource was successfully delay loaded */
  4509. static readonly DELAYLOADSTATE_LOADED: number;
  4510. /** Defines that the ressource is currently delay loading */
  4511. static readonly DELAYLOADSTATE_LOADING: number;
  4512. /** Defines that the ressource is delayed and has not started loading */
  4513. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4515. static readonly NEVER: number;
  4516. /** 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 */
  4517. static readonly ALWAYS: number;
  4518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4519. static readonly LESS: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4521. static readonly EQUAL: number;
  4522. /** 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 */
  4523. static readonly LEQUAL: number;
  4524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4525. static readonly GREATER: number;
  4526. /** 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 */
  4527. static readonly GEQUAL: number;
  4528. /** 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 */
  4529. static readonly NOTEQUAL: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be kept */
  4531. static readonly KEEP: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4533. static readonly REPLACE: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4535. static readonly INCR: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4537. static readonly DECR: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4539. static readonly INVERT: number;
  4540. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4541. static readonly INCR_WRAP: number;
  4542. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4543. static readonly DECR_WRAP: number;
  4544. /** Texture is not repeating outside of 0..1 UVs */
  4545. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4546. /** Texture is repeating outside of 0..1 UVs */
  4547. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4548. /** Texture is repeating and mirrored */
  4549. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4550. /** ALPHA */
  4551. static readonly TEXTUREFORMAT_ALPHA: number;
  4552. /** LUMINANCE */
  4553. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4554. /** LUMINANCE_ALPHA */
  4555. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4556. /** RGB */
  4557. static readonly TEXTUREFORMAT_RGB: number;
  4558. /** RGBA */
  4559. static readonly TEXTUREFORMAT_RGBA: number;
  4560. /** RED */
  4561. static readonly TEXTUREFORMAT_RED: number;
  4562. /** RED (2nd reference) */
  4563. static readonly TEXTUREFORMAT_R: number;
  4564. /** RG */
  4565. static readonly TEXTUREFORMAT_RG: number;
  4566. /** RED_INTEGER */
  4567. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4568. /** RED_INTEGER (2nd reference) */
  4569. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4570. /** RG_INTEGER */
  4571. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4572. /** RGB_INTEGER */
  4573. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4574. /** RGBA_INTEGER */
  4575. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4576. /** UNSIGNED_BYTE */
  4577. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4578. /** UNSIGNED_BYTE (2nd reference) */
  4579. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4580. /** FLOAT */
  4581. static readonly TEXTURETYPE_FLOAT: number;
  4582. /** HALF_FLOAT */
  4583. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4584. /** BYTE */
  4585. static readonly TEXTURETYPE_BYTE: number;
  4586. /** SHORT */
  4587. static readonly TEXTURETYPE_SHORT: number;
  4588. /** UNSIGNED_SHORT */
  4589. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4590. /** INT */
  4591. static readonly TEXTURETYPE_INT: number;
  4592. /** UNSIGNED_INT */
  4593. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4594. /** UNSIGNED_SHORT_4_4_4_4 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4596. /** UNSIGNED_SHORT_5_5_5_1 */
  4597. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4598. /** UNSIGNED_SHORT_5_6_5 */
  4599. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4600. /** UNSIGNED_INT_2_10_10_10_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4602. /** UNSIGNED_INT_24_8 */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4604. /** UNSIGNED_INT_10F_11F_11F_REV */
  4605. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4606. /** UNSIGNED_INT_5_9_9_9_REV */
  4607. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4608. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4609. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4610. /** nearest is mag = nearest and min = nearest and mip = linear */
  4611. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4612. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4613. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4614. /** Trilinear is mag = linear and min = linear and mip = linear */
  4615. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4616. /** nearest is mag = nearest and min = nearest and mip = linear */
  4617. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4618. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4619. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4620. /** Trilinear is mag = linear and min = linear and mip = linear */
  4621. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4622. /** mag = nearest and min = nearest and mip = nearest */
  4623. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4624. /** mag = nearest and min = linear and mip = nearest */
  4625. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4626. /** mag = nearest and min = linear and mip = linear */
  4627. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4628. /** mag = nearest and min = linear and mip = none */
  4629. static readonly TEXTURE_NEAREST_LINEAR: number;
  4630. /** mag = nearest and min = nearest and mip = none */
  4631. static readonly TEXTURE_NEAREST_NEAREST: number;
  4632. /** mag = linear and min = nearest and mip = nearest */
  4633. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4634. /** mag = linear and min = nearest and mip = linear */
  4635. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4636. /** mag = linear and min = linear and mip = none */
  4637. static readonly TEXTURE_LINEAR_LINEAR: number;
  4638. /** mag = linear and min = nearest and mip = none */
  4639. static readonly TEXTURE_LINEAR_NEAREST: number;
  4640. /** Explicit coordinates mode */
  4641. static readonly TEXTURE_EXPLICIT_MODE: number;
  4642. /** Spherical coordinates mode */
  4643. static readonly TEXTURE_SPHERICAL_MODE: number;
  4644. /** Planar coordinates mode */
  4645. static readonly TEXTURE_PLANAR_MODE: number;
  4646. /** Cubic coordinates mode */
  4647. static readonly TEXTURE_CUBIC_MODE: number;
  4648. /** Projection coordinates mode */
  4649. static readonly TEXTURE_PROJECTION_MODE: number;
  4650. /** Skybox coordinates mode */
  4651. static readonly TEXTURE_SKYBOX_MODE: number;
  4652. /** Inverse Cubic coordinates mode */
  4653. static readonly TEXTURE_INVCUBIC_MODE: number;
  4654. /** Equirectangular coordinates mode */
  4655. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4656. /** Equirectangular Fixed coordinates mode */
  4657. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4658. /** Equirectangular Fixed Mirrored coordinates mode */
  4659. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4660. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4661. static readonly SCALEMODE_FLOOR: number;
  4662. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4663. static readonly SCALEMODE_NEAREST: number;
  4664. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4665. static readonly SCALEMODE_CEILING: number;
  4666. /**
  4667. * The dirty texture flag value
  4668. */
  4669. static readonly MATERIAL_TextureDirtyFlag: number;
  4670. /**
  4671. * The dirty light flag value
  4672. */
  4673. static readonly MATERIAL_LightDirtyFlag: number;
  4674. /**
  4675. * The dirty fresnel flag value
  4676. */
  4677. static readonly MATERIAL_FresnelDirtyFlag: number;
  4678. /**
  4679. * The dirty attribute flag value
  4680. */
  4681. static readonly MATERIAL_AttributesDirtyFlag: number;
  4682. /**
  4683. * The dirty misc flag value
  4684. */
  4685. static readonly MATERIAL_MiscDirtyFlag: number;
  4686. /**
  4687. * The all dirty flag value
  4688. */
  4689. static readonly MATERIAL_AllDirtyFlag: number;
  4690. /**
  4691. * Returns the triangle fill mode
  4692. */
  4693. static readonly MATERIAL_TriangleFillMode: number;
  4694. /**
  4695. * Returns the wireframe mode
  4696. */
  4697. static readonly MATERIAL_WireFrameFillMode: number;
  4698. /**
  4699. * Returns the point fill mode
  4700. */
  4701. static readonly MATERIAL_PointFillMode: number;
  4702. /**
  4703. * Returns the point list draw mode
  4704. */
  4705. static readonly MATERIAL_PointListDrawMode: number;
  4706. /**
  4707. * Returns the line list draw mode
  4708. */
  4709. static readonly MATERIAL_LineListDrawMode: number;
  4710. /**
  4711. * Returns the line loop draw mode
  4712. */
  4713. static readonly MATERIAL_LineLoopDrawMode: number;
  4714. /**
  4715. * Returns the line strip draw mode
  4716. */
  4717. static readonly MATERIAL_LineStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle strip draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleStripDrawMode: number;
  4722. /**
  4723. * Returns the triangle fan draw mode
  4724. */
  4725. static readonly MATERIAL_TriangleFanDrawMode: number;
  4726. /**
  4727. * Stores the clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4730. /**
  4731. * Stores the counter clock-wise side orientation
  4732. */
  4733. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4734. /**
  4735. * Nothing
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_NothingTrigger: number;
  4739. /**
  4740. * On pick
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPickTrigger: number;
  4744. /**
  4745. * On left pick
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnLeftPickTrigger: number;
  4749. /**
  4750. * On right pick
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnRightPickTrigger: number;
  4754. /**
  4755. * On center pick
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnCenterPickTrigger: number;
  4759. /**
  4760. * On pick down
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnPickDownTrigger: number;
  4764. /**
  4765. * On double pick
  4766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4767. */
  4768. static readonly ACTION_OnDoublePickTrigger: number;
  4769. /**
  4770. * On pick up
  4771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4772. */
  4773. static readonly ACTION_OnPickUpTrigger: number;
  4774. /**
  4775. * On pick out.
  4776. * This trigger will only be raised if you also declared a OnPickDown
  4777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4778. */
  4779. static readonly ACTION_OnPickOutTrigger: number;
  4780. /**
  4781. * On long press
  4782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4783. */
  4784. static readonly ACTION_OnLongPressTrigger: number;
  4785. /**
  4786. * On pointer over
  4787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4788. */
  4789. static readonly ACTION_OnPointerOverTrigger: number;
  4790. /**
  4791. * On pointer out
  4792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4793. */
  4794. static readonly ACTION_OnPointerOutTrigger: number;
  4795. /**
  4796. * On every frame
  4797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4798. */
  4799. static readonly ACTION_OnEveryFrameTrigger: number;
  4800. /**
  4801. * On intersection enter
  4802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4803. */
  4804. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4805. /**
  4806. * On intersection exit
  4807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4808. */
  4809. static readonly ACTION_OnIntersectionExitTrigger: number;
  4810. /**
  4811. * On key down
  4812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4813. */
  4814. static readonly ACTION_OnKeyDownTrigger: number;
  4815. /**
  4816. * On key up
  4817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4818. */
  4819. static readonly ACTION_OnKeyUpTrigger: number;
  4820. /**
  4821. * Billboard mode will only apply to Y axis
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4824. /**
  4825. * Billboard mode will apply to all axes
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4828. /**
  4829. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4830. */
  4831. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4832. /**
  4833. * Gets or sets base Assets URL
  4834. */
  4835. static PARTICLES_BaseAssetsUrl: string;
  4836. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4837. * Test order :
  4838. * Is the bounding sphere outside the frustum ?
  4839. * If not, are the bounding box vertices outside the frustum ?
  4840. * It not, then the cullable object is in the frustum.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4843. /** Culling strategy : Bounding Sphere Only.
  4844. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4845. * It's also less accurate than the standard because some not visible objects can still be selected.
  4846. * Test : is the bounding sphere outside the frustum ?
  4847. * If not, then the cullable object is in the frustum.
  4848. */
  4849. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4850. /** Culling strategy : Optimistic Inclusion.
  4851. * This in an inclusion test first, then the standard exclusion test.
  4852. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4853. * 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.
  4854. * Anyway, it's as accurate as the standard strategy.
  4855. * Test :
  4856. * Is the cullable object bounding sphere center in the frustum ?
  4857. * If not, apply the default culling strategy.
  4858. */
  4859. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4860. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4861. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4862. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4863. * 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.
  4864. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4865. * Test :
  4866. * Is the cullable object bounding sphere center in the frustum ?
  4867. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4868. */
  4869. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4870. /**
  4871. * No logging while loading
  4872. */
  4873. static readonly SCENELOADER_NO_LOGGING: number;
  4874. /**
  4875. * Minimal logging while loading
  4876. */
  4877. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4878. /**
  4879. * Summary logging while loading
  4880. */
  4881. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4882. /**
  4883. * Detailled logging while loading
  4884. */
  4885. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4886. }
  4887. }
  4888. declare module "babylonjs/Misc/domManagement" {
  4889. /**
  4890. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4891. * Babylon.js
  4892. */
  4893. export class DomManagement {
  4894. /**
  4895. * Checks if the window object exists
  4896. * @returns true if the window object exists
  4897. */
  4898. static IsWindowObjectExist(): boolean;
  4899. /**
  4900. * Extracts text content from a DOM element hierarchy
  4901. * @param element defines the root element
  4902. * @returns a string
  4903. */
  4904. static GetDOMTextContent(element: HTMLElement): string;
  4905. }
  4906. }
  4907. declare module "babylonjs/Misc/logger" {
  4908. /**
  4909. * Logger used througouht the application to allow configuration of
  4910. * the log level required for the messages.
  4911. */
  4912. export class Logger {
  4913. /**
  4914. * No log
  4915. */
  4916. static readonly NoneLogLevel: number;
  4917. /**
  4918. * Only message logs
  4919. */
  4920. static readonly MessageLogLevel: number;
  4921. /**
  4922. * Only warning logs
  4923. */
  4924. static readonly WarningLogLevel: number;
  4925. /**
  4926. * Only error logs
  4927. */
  4928. static readonly ErrorLogLevel: number;
  4929. /**
  4930. * All logs
  4931. */
  4932. static readonly AllLogLevel: number;
  4933. private static _LogCache;
  4934. /**
  4935. * Gets a value indicating the number of loading errors
  4936. * @ignorenaming
  4937. */
  4938. static errorsCount: number;
  4939. /**
  4940. * Callback called when a new log is added
  4941. */
  4942. static OnNewCacheEntry: (entry: string) => void;
  4943. private static _AddLogEntry;
  4944. private static _FormatMessage;
  4945. private static _LogDisabled;
  4946. private static _LogEnabled;
  4947. private static _WarnDisabled;
  4948. private static _WarnEnabled;
  4949. private static _ErrorDisabled;
  4950. private static _ErrorEnabled;
  4951. /**
  4952. * Log a message to the console
  4953. */
  4954. static Log: (message: string) => void;
  4955. /**
  4956. * Write a warning message to the console
  4957. */
  4958. static Warn: (message: string) => void;
  4959. /**
  4960. * Write an error message to the console
  4961. */
  4962. static Error: (message: string) => void;
  4963. /**
  4964. * Gets current log cache (list of logs)
  4965. */
  4966. static readonly LogCache: string;
  4967. /**
  4968. * Clears the log cache
  4969. */
  4970. static ClearLogCache(): void;
  4971. /**
  4972. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4973. */
  4974. static LogLevels: number;
  4975. }
  4976. }
  4977. declare module "babylonjs/Misc/typeStore" {
  4978. /** @hidden */
  4979. export class _TypeStore {
  4980. /** @hidden */
  4981. static RegisteredTypes: {
  4982. [key: string]: Object;
  4983. };
  4984. /** @hidden */
  4985. static GetClass(fqdn: string): any;
  4986. }
  4987. }
  4988. declare module "babylonjs/Misc/deepCopier" {
  4989. /**
  4990. * Class containing a set of static utilities functions for deep copy.
  4991. */
  4992. export class DeepCopier {
  4993. /**
  4994. * Tries to copy an object by duplicating every property
  4995. * @param source defines the source object
  4996. * @param destination defines the target object
  4997. * @param doNotCopyList defines a list of properties to avoid
  4998. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4999. */
  5000. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  5001. }
  5002. }
  5003. declare module "babylonjs/Misc/precisionDate" {
  5004. /**
  5005. * Class containing a set of static utilities functions for precision date
  5006. */
  5007. export class PrecisionDate {
  5008. /**
  5009. * Gets either window.performance.now() if supported or Date.now() else
  5010. */
  5011. static readonly Now: number;
  5012. }
  5013. }
  5014. declare module "babylonjs/Misc/devTools" {
  5015. /** @hidden */
  5016. export class _DevTools {
  5017. static WarnImport(name: string): string;
  5018. }
  5019. }
  5020. declare module "babylonjs/Misc/webRequest" {
  5021. /**
  5022. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5023. */
  5024. export class WebRequest {
  5025. private _xhr;
  5026. /**
  5027. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5028. * i.e. when loading files, where the server/service expects an Authorization header
  5029. */
  5030. static CustomRequestHeaders: {
  5031. [key: string]: string;
  5032. };
  5033. /**
  5034. * Add callback functions in this array to update all the requests before they get sent to the network
  5035. */
  5036. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  5037. private _injectCustomRequestHeaders;
  5038. /**
  5039. * Gets or sets a function to be called when loading progress changes
  5040. */
  5041. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5042. /**
  5043. * Returns client's state
  5044. */
  5045. readonly readyState: number;
  5046. /**
  5047. * Returns client's status
  5048. */
  5049. readonly status: number;
  5050. /**
  5051. * Returns client's status as a text
  5052. */
  5053. readonly statusText: string;
  5054. /**
  5055. * Returns client's response
  5056. */
  5057. readonly response: any;
  5058. /**
  5059. * Returns client's response url
  5060. */
  5061. readonly responseURL: string;
  5062. /**
  5063. * Returns client's response as text
  5064. */
  5065. readonly responseText: string;
  5066. /**
  5067. * Gets or sets the expected response type
  5068. */
  5069. responseType: XMLHttpRequestResponseType;
  5070. /** @hidden */
  5071. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5072. /** @hidden */
  5073. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5074. /**
  5075. * Cancels any network activity
  5076. */
  5077. abort(): void;
  5078. /**
  5079. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5080. * @param body defines an optional request body
  5081. */
  5082. send(body?: Document | BodyInit | null): void;
  5083. /**
  5084. * Sets the request method, request URL
  5085. * @param method defines the method to use (GET, POST, etc..)
  5086. * @param url defines the url to connect with
  5087. */
  5088. open(method: string, url: string): void;
  5089. }
  5090. }
  5091. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5092. /**
  5093. * Class used to evalaute queries containing `and` and `or` operators
  5094. */
  5095. export class AndOrNotEvaluator {
  5096. /**
  5097. * Evaluate a query
  5098. * @param query defines the query to evaluate
  5099. * @param evaluateCallback defines the callback used to filter result
  5100. * @returns true if the query matches
  5101. */
  5102. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5103. private static _HandleParenthesisContent;
  5104. private static _SimplifyNegation;
  5105. }
  5106. }
  5107. declare module "babylonjs/Misc/tags" {
  5108. /**
  5109. * Class used to store custom tags
  5110. */
  5111. export class Tags {
  5112. /**
  5113. * Adds support for tags on the given object
  5114. * @param obj defines the object to use
  5115. */
  5116. static EnableFor(obj: any): void;
  5117. /**
  5118. * Removes tags support
  5119. * @param obj defines the object to use
  5120. */
  5121. static DisableFor(obj: any): void;
  5122. /**
  5123. * Gets a boolean indicating if the given object has tags
  5124. * @param obj defines the object to use
  5125. * @returns a boolean
  5126. */
  5127. static HasTags(obj: any): boolean;
  5128. /**
  5129. * Gets the tags available on a given object
  5130. * @param obj defines the object to use
  5131. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5132. * @returns the tags
  5133. */
  5134. static GetTags(obj: any, asString?: boolean): any;
  5135. /**
  5136. * Adds tags to an object
  5137. * @param obj defines the object to use
  5138. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5139. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5140. */
  5141. static AddTagsTo(obj: any, tagsString: string): void;
  5142. /**
  5143. * @hidden
  5144. */
  5145. static _AddTagTo(obj: any, tag: string): void;
  5146. /**
  5147. * Removes specific tags from a specific object
  5148. * @param obj defines the object to use
  5149. * @param tagsString defines the tags to remove
  5150. */
  5151. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5152. /**
  5153. * @hidden
  5154. */
  5155. static _RemoveTagFrom(obj: any, tag: string): void;
  5156. /**
  5157. * Defines if tags hosted on an object match a given query
  5158. * @param obj defines the object to use
  5159. * @param tagsQuery defines the tag query
  5160. * @returns a boolean
  5161. */
  5162. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5163. }
  5164. }
  5165. declare module "babylonjs/Materials/materialDefines" {
  5166. /**
  5167. * Manages the defines for the Material
  5168. */
  5169. export class MaterialDefines {
  5170. /** @hidden */
  5171. protected _keys: string[];
  5172. private _isDirty;
  5173. /** @hidden */
  5174. _renderId: number;
  5175. /** @hidden */
  5176. _areLightsDirty: boolean;
  5177. /** @hidden */
  5178. _areAttributesDirty: boolean;
  5179. /** @hidden */
  5180. _areTexturesDirty: boolean;
  5181. /** @hidden */
  5182. _areFresnelDirty: boolean;
  5183. /** @hidden */
  5184. _areMiscDirty: boolean;
  5185. /** @hidden */
  5186. _areImageProcessingDirty: boolean;
  5187. /** @hidden */
  5188. _normals: boolean;
  5189. /** @hidden */
  5190. _uvs: boolean;
  5191. /** @hidden */
  5192. _needNormals: boolean;
  5193. /** @hidden */
  5194. _needUVs: boolean;
  5195. [id: string]: any;
  5196. /**
  5197. * Specifies if the material needs to be re-calculated
  5198. */
  5199. readonly isDirty: boolean;
  5200. /**
  5201. * Marks the material to indicate that it has been re-calculated
  5202. */
  5203. markAsProcessed(): void;
  5204. /**
  5205. * Marks the material to indicate that it needs to be re-calculated
  5206. */
  5207. markAsUnprocessed(): void;
  5208. /**
  5209. * Marks the material to indicate all of its defines need to be re-calculated
  5210. */
  5211. markAllAsDirty(): void;
  5212. /**
  5213. * Marks the material to indicate that image processing needs to be re-calculated
  5214. */
  5215. markAsImageProcessingDirty(): void;
  5216. /**
  5217. * Marks the material to indicate the lights need to be re-calculated
  5218. */
  5219. markAsLightDirty(): void;
  5220. /**
  5221. * Marks the attribute state as changed
  5222. */
  5223. markAsAttributesDirty(): void;
  5224. /**
  5225. * Marks the texture state as changed
  5226. */
  5227. markAsTexturesDirty(): void;
  5228. /**
  5229. * Marks the fresnel state as changed
  5230. */
  5231. markAsFresnelDirty(): void;
  5232. /**
  5233. * Marks the misc state as changed
  5234. */
  5235. markAsMiscDirty(): void;
  5236. /**
  5237. * Rebuilds the material defines
  5238. */
  5239. rebuild(): void;
  5240. /**
  5241. * Specifies if two material defines are equal
  5242. * @param other - A material define instance to compare to
  5243. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5244. */
  5245. isEqual(other: MaterialDefines): boolean;
  5246. /**
  5247. * Clones this instance's defines to another instance
  5248. * @param other - material defines to clone values to
  5249. */
  5250. cloneTo(other: MaterialDefines): void;
  5251. /**
  5252. * Resets the material define values
  5253. */
  5254. reset(): void;
  5255. /**
  5256. * Converts the material define values to a string
  5257. * @returns - String of material define information
  5258. */
  5259. toString(): string;
  5260. }
  5261. }
  5262. declare module "babylonjs/Engines/IPipelineContext" {
  5263. /**
  5264. * Class used to store and describe the pipeline context associated with an effect
  5265. */
  5266. export interface IPipelineContext {
  5267. /**
  5268. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5269. */
  5270. isAsync: boolean;
  5271. /**
  5272. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5273. */
  5274. isReady: boolean;
  5275. /** @hidden */
  5276. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5277. }
  5278. }
  5279. declare module "babylonjs/Meshes/dataBuffer" {
  5280. /**
  5281. * Class used to store gfx data (like WebGLBuffer)
  5282. */
  5283. export class DataBuffer {
  5284. /**
  5285. * Gets or sets the number of objects referencing this buffer
  5286. */
  5287. references: number;
  5288. /** Gets or sets the size of the underlying buffer */
  5289. capacity: number;
  5290. /**
  5291. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5292. */
  5293. is32Bits: boolean;
  5294. /**
  5295. * Gets the underlying buffer
  5296. */
  5297. readonly underlyingResource: any;
  5298. }
  5299. }
  5300. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  5301. /** @hidden */
  5302. export interface IShaderProcessor {
  5303. attributeProcessor?: (attribute: string) => string;
  5304. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5305. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5306. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5307. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5308. lineProcessor?: (line: string, isFragment: boolean) => string;
  5309. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5310. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5311. }
  5312. }
  5313. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  5314. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  5315. /** @hidden */
  5316. export interface ProcessingOptions {
  5317. defines: string[];
  5318. indexParameters: any;
  5319. isFragment: boolean;
  5320. shouldUseHighPrecisionShader: boolean;
  5321. supportsUniformBuffers: boolean;
  5322. shadersRepository: string;
  5323. includesShadersStore: {
  5324. [key: string]: string;
  5325. };
  5326. processor?: IShaderProcessor;
  5327. version: string;
  5328. platformName: string;
  5329. lookForClosingBracketForUniformBuffer?: boolean;
  5330. }
  5331. }
  5332. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5333. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5334. /** @hidden */
  5335. export class ShaderCodeNode {
  5336. line: string;
  5337. children: ShaderCodeNode[];
  5338. additionalDefineKey?: string;
  5339. additionalDefineValue?: string;
  5340. isValid(preprocessors: {
  5341. [key: string]: string;
  5342. }): boolean;
  5343. process(preprocessors: {
  5344. [key: string]: string;
  5345. }, options: ProcessingOptions): string;
  5346. }
  5347. }
  5348. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5349. /** @hidden */
  5350. export class ShaderCodeCursor {
  5351. private _lines;
  5352. lineIndex: number;
  5353. readonly currentLine: string;
  5354. readonly canRead: boolean;
  5355. lines: string[];
  5356. }
  5357. }
  5358. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5359. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5360. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5361. /** @hidden */
  5362. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5363. process(preprocessors: {
  5364. [key: string]: string;
  5365. }, options: ProcessingOptions): string;
  5366. }
  5367. }
  5368. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5369. /** @hidden */
  5370. export class ShaderDefineExpression {
  5371. isTrue(preprocessors: {
  5372. [key: string]: string;
  5373. }): boolean;
  5374. }
  5375. }
  5376. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5377. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5378. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5379. /** @hidden */
  5380. export class ShaderCodeTestNode extends ShaderCodeNode {
  5381. testExpression: ShaderDefineExpression;
  5382. isValid(preprocessors: {
  5383. [key: string]: string;
  5384. }): boolean;
  5385. }
  5386. }
  5387. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5388. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5389. /** @hidden */
  5390. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5391. define: string;
  5392. not: boolean;
  5393. constructor(define: string, not?: boolean);
  5394. isTrue(preprocessors: {
  5395. [key: string]: string;
  5396. }): boolean;
  5397. }
  5398. }
  5399. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5400. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5401. /** @hidden */
  5402. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5403. leftOperand: ShaderDefineExpression;
  5404. rightOperand: ShaderDefineExpression;
  5405. isTrue(preprocessors: {
  5406. [key: string]: string;
  5407. }): boolean;
  5408. }
  5409. }
  5410. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5411. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5412. /** @hidden */
  5413. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5414. leftOperand: ShaderDefineExpression;
  5415. rightOperand: ShaderDefineExpression;
  5416. isTrue(preprocessors: {
  5417. [key: string]: string;
  5418. }): boolean;
  5419. }
  5420. }
  5421. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5422. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5423. /** @hidden */
  5424. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5425. define: string;
  5426. operand: string;
  5427. testValue: string;
  5428. constructor(define: string, operand: string, testValue: string);
  5429. isTrue(preprocessors: {
  5430. [key: string]: string;
  5431. }): boolean;
  5432. }
  5433. }
  5434. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5435. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5436. /** @hidden */
  5437. export class ShaderProcessor {
  5438. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5439. private static _ProcessPrecision;
  5440. private static _ExtractOperation;
  5441. private static _BuildSubExpression;
  5442. private static _BuildExpression;
  5443. private static _MoveCursorWithinIf;
  5444. private static _MoveCursor;
  5445. private static _EvaluatePreProcessors;
  5446. private static _PreparePreProcessors;
  5447. private static _ProcessShaderConversion;
  5448. private static _ProcessIncludes;
  5449. }
  5450. }
  5451. declare module "babylonjs/Misc/performanceMonitor" {
  5452. /**
  5453. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5454. */
  5455. export class PerformanceMonitor {
  5456. private _enabled;
  5457. private _rollingFrameTime;
  5458. private _lastFrameTimeMs;
  5459. /**
  5460. * constructor
  5461. * @param frameSampleSize The number of samples required to saturate the sliding window
  5462. */
  5463. constructor(frameSampleSize?: number);
  5464. /**
  5465. * Samples current frame
  5466. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5467. */
  5468. sampleFrame(timeMs?: number): void;
  5469. /**
  5470. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5471. */
  5472. readonly averageFrameTime: number;
  5473. /**
  5474. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5475. */
  5476. readonly averageFrameTimeVariance: number;
  5477. /**
  5478. * Returns the frame time of the most recent frame
  5479. */
  5480. readonly instantaneousFrameTime: number;
  5481. /**
  5482. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5483. */
  5484. readonly averageFPS: number;
  5485. /**
  5486. * Returns the average framerate in frames per second using the most recent frame time
  5487. */
  5488. readonly instantaneousFPS: number;
  5489. /**
  5490. * Returns true if enough samples have been taken to completely fill the sliding window
  5491. */
  5492. readonly isSaturated: boolean;
  5493. /**
  5494. * Enables contributions to the sliding window sample set
  5495. */
  5496. enable(): void;
  5497. /**
  5498. * Disables contributions to the sliding window sample set
  5499. * Samples will not be interpolated over the disabled period
  5500. */
  5501. disable(): void;
  5502. /**
  5503. * Returns true if sampling is enabled
  5504. */
  5505. readonly isEnabled: boolean;
  5506. /**
  5507. * Resets performance monitor
  5508. */
  5509. reset(): void;
  5510. }
  5511. /**
  5512. * RollingAverage
  5513. *
  5514. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5515. */
  5516. export class RollingAverage {
  5517. /**
  5518. * Current average
  5519. */
  5520. average: number;
  5521. /**
  5522. * Current variance
  5523. */
  5524. variance: number;
  5525. protected _samples: Array<number>;
  5526. protected _sampleCount: number;
  5527. protected _pos: number;
  5528. protected _m2: number;
  5529. /**
  5530. * constructor
  5531. * @param length The number of samples required to saturate the sliding window
  5532. */
  5533. constructor(length: number);
  5534. /**
  5535. * Adds a sample to the sample set
  5536. * @param v The sample value
  5537. */
  5538. add(v: number): void;
  5539. /**
  5540. * Returns previously added values or null if outside of history or outside the sliding window domain
  5541. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5542. * @return Value previously recorded with add() or null if outside of range
  5543. */
  5544. history(i: number): number;
  5545. /**
  5546. * Returns true if enough samples have been taken to completely fill the sliding window
  5547. * @return true if sample-set saturated
  5548. */
  5549. isSaturated(): boolean;
  5550. /**
  5551. * Resets the rolling average (equivalent to 0 samples taken so far)
  5552. */
  5553. reset(): void;
  5554. /**
  5555. * Wraps a value around the sample range boundaries
  5556. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5557. * @return Wrapped position in sample range
  5558. */
  5559. protected _wrapPosition(i: number): number;
  5560. }
  5561. }
  5562. declare module "babylonjs/Misc/stringDictionary" {
  5563. import { Nullable } from "babylonjs/types";
  5564. /**
  5565. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5566. * The underlying implementation relies on an associative array to ensure the best performances.
  5567. * The value can be anything including 'null' but except 'undefined'
  5568. */
  5569. export class StringDictionary<T> {
  5570. /**
  5571. * This will clear this dictionary and copy the content from the 'source' one.
  5572. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5573. * @param source the dictionary to take the content from and copy to this dictionary
  5574. */
  5575. copyFrom(source: StringDictionary<T>): void;
  5576. /**
  5577. * Get a value based from its key
  5578. * @param key the given key to get the matching value from
  5579. * @return the value if found, otherwise undefined is returned
  5580. */
  5581. get(key: string): T | undefined;
  5582. /**
  5583. * Get a value from its key or add it if it doesn't exist.
  5584. * This method will ensure you that a given key/data will be present in the dictionary.
  5585. * @param key the given key to get the matching value from
  5586. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5587. * The factory will only be invoked if there's no data for the given key.
  5588. * @return the value corresponding to the key.
  5589. */
  5590. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5591. /**
  5592. * Get a value from its key if present in the dictionary otherwise add it
  5593. * @param key the key to get the value from
  5594. * @param val if there's no such key/value pair in the dictionary add it with this value
  5595. * @return the value corresponding to the key
  5596. */
  5597. getOrAdd(key: string, val: T): T;
  5598. /**
  5599. * Check if there's a given key in the dictionary
  5600. * @param key the key to check for
  5601. * @return true if the key is present, false otherwise
  5602. */
  5603. contains(key: string): boolean;
  5604. /**
  5605. * Add a new key and its corresponding value
  5606. * @param key the key to add
  5607. * @param value the value corresponding to the key
  5608. * @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
  5609. */
  5610. add(key: string, value: T): boolean;
  5611. /**
  5612. * Update a specific value associated to a key
  5613. * @param key defines the key to use
  5614. * @param value defines the value to store
  5615. * @returns true if the value was updated (or false if the key was not found)
  5616. */
  5617. set(key: string, value: T): boolean;
  5618. /**
  5619. * Get the element of the given key and remove it from the dictionary
  5620. * @param key defines the key to search
  5621. * @returns the value associated with the key or null if not found
  5622. */
  5623. getAndRemove(key: string): Nullable<T>;
  5624. /**
  5625. * Remove a key/value from the dictionary.
  5626. * @param key the key to remove
  5627. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5628. */
  5629. remove(key: string): boolean;
  5630. /**
  5631. * Clear the whole content of the dictionary
  5632. */
  5633. clear(): void;
  5634. /**
  5635. * Gets the current count
  5636. */
  5637. readonly count: number;
  5638. /**
  5639. * Execute a callback on each key/val of the dictionary.
  5640. * Note that you can remove any element in this dictionary in the callback implementation
  5641. * @param callback the callback to execute on a given key/value pair
  5642. */
  5643. forEach(callback: (key: string, val: T) => void): void;
  5644. /**
  5645. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5646. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5647. * Note that you can remove any element in this dictionary in the callback implementation
  5648. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5649. * @returns the first item
  5650. */
  5651. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5652. private _count;
  5653. private _data;
  5654. }
  5655. }
  5656. declare module "babylonjs/Misc/promise" {
  5657. /**
  5658. * Helper class that provides a small promise polyfill
  5659. */
  5660. export class PromisePolyfill {
  5661. /**
  5662. * Static function used to check if the polyfill is required
  5663. * If this is the case then the function will inject the polyfill to window.Promise
  5664. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5665. */
  5666. static Apply(force?: boolean): void;
  5667. }
  5668. }
  5669. declare module "babylonjs/Meshes/buffer" {
  5670. import { Nullable, DataArray } from "babylonjs/types";
  5671. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5672. /**
  5673. * Class used to store data that will be store in GPU memory
  5674. */
  5675. export class Buffer {
  5676. private _engine;
  5677. private _buffer;
  5678. /** @hidden */
  5679. _data: Nullable<DataArray>;
  5680. private _updatable;
  5681. private _instanced;
  5682. /**
  5683. * Gets the byte stride.
  5684. */
  5685. readonly byteStride: number;
  5686. /**
  5687. * Constructor
  5688. * @param engine the engine
  5689. * @param data the data to use for this buffer
  5690. * @param updatable whether the data is updatable
  5691. * @param stride the stride (optional)
  5692. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5693. * @param instanced whether the buffer is instanced (optional)
  5694. * @param useBytes set to true if the stride in in bytes (optional)
  5695. */
  5696. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5697. /**
  5698. * Create a new VertexBuffer based on the current buffer
  5699. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5700. * @param offset defines offset in the buffer (0 by default)
  5701. * @param size defines the size in floats of attributes (position is 3 for instance)
  5702. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5703. * @param instanced defines if the vertex buffer contains indexed data
  5704. * @param useBytes defines if the offset and stride are in bytes
  5705. * @returns the new vertex buffer
  5706. */
  5707. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5708. /**
  5709. * Gets a boolean indicating if the Buffer is updatable?
  5710. * @returns true if the buffer is updatable
  5711. */
  5712. isUpdatable(): boolean;
  5713. /**
  5714. * Gets current buffer's data
  5715. * @returns a DataArray or null
  5716. */
  5717. getData(): Nullable<DataArray>;
  5718. /**
  5719. * Gets underlying native buffer
  5720. * @returns underlying native buffer
  5721. */
  5722. getBuffer(): Nullable<DataBuffer>;
  5723. /**
  5724. * Gets the stride in float32 units (i.e. byte stride / 4).
  5725. * May not be an integer if the byte stride is not divisible by 4.
  5726. * DEPRECATED. Use byteStride instead.
  5727. * @returns the stride in float32 units
  5728. */
  5729. getStrideSize(): number;
  5730. /**
  5731. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5732. * @param data defines the data to store
  5733. */
  5734. create(data?: Nullable<DataArray>): void;
  5735. /** @hidden */
  5736. _rebuild(): void;
  5737. /**
  5738. * Update current buffer data
  5739. * @param data defines the data to store
  5740. */
  5741. update(data: DataArray): void;
  5742. /**
  5743. * Updates the data directly.
  5744. * @param data the new data
  5745. * @param offset the new offset
  5746. * @param vertexCount the vertex count (optional)
  5747. * @param useBytes set to true if the offset is in bytes
  5748. */
  5749. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5750. /**
  5751. * Release all resources
  5752. */
  5753. dispose(): void;
  5754. }
  5755. /**
  5756. * Specialized buffer used to store vertex data
  5757. */
  5758. export class VertexBuffer {
  5759. /** @hidden */
  5760. _buffer: Buffer;
  5761. private _kind;
  5762. private _size;
  5763. private _ownsBuffer;
  5764. private _instanced;
  5765. private _instanceDivisor;
  5766. /**
  5767. * The byte type.
  5768. */
  5769. static readonly BYTE: number;
  5770. /**
  5771. * The unsigned byte type.
  5772. */
  5773. static readonly UNSIGNED_BYTE: number;
  5774. /**
  5775. * The short type.
  5776. */
  5777. static readonly SHORT: number;
  5778. /**
  5779. * The unsigned short type.
  5780. */
  5781. static readonly UNSIGNED_SHORT: number;
  5782. /**
  5783. * The integer type.
  5784. */
  5785. static readonly INT: number;
  5786. /**
  5787. * The unsigned integer type.
  5788. */
  5789. static readonly UNSIGNED_INT: number;
  5790. /**
  5791. * The float type.
  5792. */
  5793. static readonly FLOAT: number;
  5794. /**
  5795. * Gets or sets the instance divisor when in instanced mode
  5796. */
  5797. instanceDivisor: number;
  5798. /**
  5799. * Gets the byte stride.
  5800. */
  5801. readonly byteStride: number;
  5802. /**
  5803. * Gets the byte offset.
  5804. */
  5805. readonly byteOffset: number;
  5806. /**
  5807. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5808. */
  5809. readonly normalized: boolean;
  5810. /**
  5811. * Gets the data type of each component in the array.
  5812. */
  5813. readonly type: number;
  5814. /**
  5815. * Constructor
  5816. * @param engine the engine
  5817. * @param data the data to use for this vertex buffer
  5818. * @param kind the vertex buffer kind
  5819. * @param updatable whether the data is updatable
  5820. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5821. * @param stride the stride (optional)
  5822. * @param instanced whether the buffer is instanced (optional)
  5823. * @param offset the offset of the data (optional)
  5824. * @param size the number of components (optional)
  5825. * @param type the type of the component (optional)
  5826. * @param normalized whether the data contains normalized data (optional)
  5827. * @param useBytes set to true if stride and offset are in bytes (optional)
  5828. */
  5829. 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);
  5830. /** @hidden */
  5831. _rebuild(): void;
  5832. /**
  5833. * Returns the kind of the VertexBuffer (string)
  5834. * @returns a string
  5835. */
  5836. getKind(): string;
  5837. /**
  5838. * Gets a boolean indicating if the VertexBuffer is updatable?
  5839. * @returns true if the buffer is updatable
  5840. */
  5841. isUpdatable(): boolean;
  5842. /**
  5843. * Gets current buffer's data
  5844. * @returns a DataArray or null
  5845. */
  5846. getData(): Nullable<DataArray>;
  5847. /**
  5848. * Gets underlying native buffer
  5849. * @returns underlying native buffer
  5850. */
  5851. getBuffer(): Nullable<DataBuffer>;
  5852. /**
  5853. * Gets the stride in float32 units (i.e. byte stride / 4).
  5854. * May not be an integer if the byte stride is not divisible by 4.
  5855. * DEPRECATED. Use byteStride instead.
  5856. * @returns the stride in float32 units
  5857. */
  5858. getStrideSize(): number;
  5859. /**
  5860. * Returns the offset as a multiple of the type byte length.
  5861. * DEPRECATED. Use byteOffset instead.
  5862. * @returns the offset in bytes
  5863. */
  5864. getOffset(): number;
  5865. /**
  5866. * Returns the number of components per vertex attribute (integer)
  5867. * @returns the size in float
  5868. */
  5869. getSize(): number;
  5870. /**
  5871. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5872. * @returns true if this buffer is instanced
  5873. */
  5874. getIsInstanced(): boolean;
  5875. /**
  5876. * Returns the instancing divisor, zero for non-instanced (integer).
  5877. * @returns a number
  5878. */
  5879. getInstanceDivisor(): number;
  5880. /**
  5881. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5882. * @param data defines the data to store
  5883. */
  5884. create(data?: DataArray): void;
  5885. /**
  5886. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5887. * This function will create a new buffer if the current one is not updatable
  5888. * @param data defines the data to store
  5889. */
  5890. update(data: DataArray): void;
  5891. /**
  5892. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5893. * Returns the directly updated WebGLBuffer.
  5894. * @param data the new data
  5895. * @param offset the new offset
  5896. * @param useBytes set to true if the offset is in bytes
  5897. */
  5898. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5899. /**
  5900. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5901. */
  5902. dispose(): void;
  5903. /**
  5904. * Enumerates each value of this vertex buffer as numbers.
  5905. * @param count the number of values to enumerate
  5906. * @param callback the callback function called for each value
  5907. */
  5908. forEach(count: number, callback: (value: number, index: number) => void): void;
  5909. /**
  5910. * Positions
  5911. */
  5912. static readonly PositionKind: string;
  5913. /**
  5914. * Normals
  5915. */
  5916. static readonly NormalKind: string;
  5917. /**
  5918. * Tangents
  5919. */
  5920. static readonly TangentKind: string;
  5921. /**
  5922. * Texture coordinates
  5923. */
  5924. static readonly UVKind: string;
  5925. /**
  5926. * Texture coordinates 2
  5927. */
  5928. static readonly UV2Kind: string;
  5929. /**
  5930. * Texture coordinates 3
  5931. */
  5932. static readonly UV3Kind: string;
  5933. /**
  5934. * Texture coordinates 4
  5935. */
  5936. static readonly UV4Kind: string;
  5937. /**
  5938. * Texture coordinates 5
  5939. */
  5940. static readonly UV5Kind: string;
  5941. /**
  5942. * Texture coordinates 6
  5943. */
  5944. static readonly UV6Kind: string;
  5945. /**
  5946. * Colors
  5947. */
  5948. static readonly ColorKind: string;
  5949. /**
  5950. * Matrix indices (for bones)
  5951. */
  5952. static readonly MatricesIndicesKind: string;
  5953. /**
  5954. * Matrix weights (for bones)
  5955. */
  5956. static readonly MatricesWeightsKind: string;
  5957. /**
  5958. * Additional matrix indices (for bones)
  5959. */
  5960. static readonly MatricesIndicesExtraKind: string;
  5961. /**
  5962. * Additional matrix weights (for bones)
  5963. */
  5964. static readonly MatricesWeightsExtraKind: string;
  5965. /**
  5966. * Deduces the stride given a kind.
  5967. * @param kind The kind string to deduce
  5968. * @returns The deduced stride
  5969. */
  5970. static DeduceStride(kind: string): number;
  5971. /**
  5972. * Gets the byte length of the given type.
  5973. * @param type the type
  5974. * @returns the number of bytes
  5975. */
  5976. static GetTypeByteLength(type: number): number;
  5977. /**
  5978. * Enumerates each value of the given parameters as numbers.
  5979. * @param data the data to enumerate
  5980. * @param byteOffset the byte offset of the data
  5981. * @param byteStride the byte stride of the data
  5982. * @param componentCount the number of components per element
  5983. * @param componentType the type of the component
  5984. * @param count the number of values to enumerate
  5985. * @param normalized whether the data is normalized
  5986. * @param callback the callback function called for each value
  5987. */
  5988. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5989. private static _GetFloatValue;
  5990. }
  5991. }
  5992. declare module "babylonjs/Maths/sphericalPolynomial" {
  5993. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5994. /**
  5995. * Class representing spherical harmonics coefficients to the 3rd degree
  5996. */
  5997. export class SphericalHarmonics {
  5998. /**
  5999. * Defines whether or not the harmonics have been prescaled for rendering.
  6000. */
  6001. preScaled: boolean;
  6002. /**
  6003. * The l0,0 coefficients of the spherical harmonics
  6004. */
  6005. l00: Vector3;
  6006. /**
  6007. * The l1,-1 coefficients of the spherical harmonics
  6008. */
  6009. l1_1: Vector3;
  6010. /**
  6011. * The l1,0 coefficients of the spherical harmonics
  6012. */
  6013. l10: Vector3;
  6014. /**
  6015. * The l1,1 coefficients of the spherical harmonics
  6016. */
  6017. l11: Vector3;
  6018. /**
  6019. * The l2,-2 coefficients of the spherical harmonics
  6020. */
  6021. l2_2: Vector3;
  6022. /**
  6023. * The l2,-1 coefficients of the spherical harmonics
  6024. */
  6025. l2_1: Vector3;
  6026. /**
  6027. * The l2,0 coefficients of the spherical harmonics
  6028. */
  6029. l20: Vector3;
  6030. /**
  6031. * The l2,1 coefficients of the spherical harmonics
  6032. */
  6033. l21: Vector3;
  6034. /**
  6035. * The l2,2 coefficients of the spherical harmonics
  6036. */
  6037. l22: Vector3;
  6038. /**
  6039. * Adds a light to the spherical harmonics
  6040. * @param direction the direction of the light
  6041. * @param color the color of the light
  6042. * @param deltaSolidAngle the delta solid angle of the light
  6043. */
  6044. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6045. /**
  6046. * Scales the spherical harmonics by the given amount
  6047. * @param scale the amount to scale
  6048. */
  6049. scaleInPlace(scale: number): void;
  6050. /**
  6051. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6052. *
  6053. * ```
  6054. * E_lm = A_l * L_lm
  6055. * ```
  6056. *
  6057. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6058. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6059. * the scaling factors are given in equation 9.
  6060. */
  6061. convertIncidentRadianceToIrradiance(): void;
  6062. /**
  6063. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6064. *
  6065. * ```
  6066. * L = (1/pi) * E * rho
  6067. * ```
  6068. *
  6069. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6070. */
  6071. convertIrradianceToLambertianRadiance(): void;
  6072. /**
  6073. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6074. * required operations at run time.
  6075. *
  6076. * This is simply done by scaling back the SH with Ylm constants parameter.
  6077. * The trigonometric part being applied by the shader at run time.
  6078. */
  6079. preScaleForRendering(): void;
  6080. /**
  6081. * Constructs a spherical harmonics from an array.
  6082. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6083. * @returns the spherical harmonics
  6084. */
  6085. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6086. /**
  6087. * Gets the spherical harmonics from polynomial
  6088. * @param polynomial the spherical polynomial
  6089. * @returns the spherical harmonics
  6090. */
  6091. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6092. }
  6093. /**
  6094. * Class representing spherical polynomial coefficients to the 3rd degree
  6095. */
  6096. export class SphericalPolynomial {
  6097. private _harmonics;
  6098. /**
  6099. * The spherical harmonics used to create the polynomials.
  6100. */
  6101. readonly preScaledHarmonics: SphericalHarmonics;
  6102. /**
  6103. * The x coefficients of the spherical polynomial
  6104. */
  6105. x: Vector3;
  6106. /**
  6107. * The y coefficients of the spherical polynomial
  6108. */
  6109. y: Vector3;
  6110. /**
  6111. * The z coefficients of the spherical polynomial
  6112. */
  6113. z: Vector3;
  6114. /**
  6115. * The xx coefficients of the spherical polynomial
  6116. */
  6117. xx: Vector3;
  6118. /**
  6119. * The yy coefficients of the spherical polynomial
  6120. */
  6121. yy: Vector3;
  6122. /**
  6123. * The zz coefficients of the spherical polynomial
  6124. */
  6125. zz: Vector3;
  6126. /**
  6127. * The xy coefficients of the spherical polynomial
  6128. */
  6129. xy: Vector3;
  6130. /**
  6131. * The yz coefficients of the spherical polynomial
  6132. */
  6133. yz: Vector3;
  6134. /**
  6135. * The zx coefficients of the spherical polynomial
  6136. */
  6137. zx: Vector3;
  6138. /**
  6139. * Adds an ambient color to the spherical polynomial
  6140. * @param color the color to add
  6141. */
  6142. addAmbient(color: Color3): void;
  6143. /**
  6144. * Scales the spherical polynomial by the given amount
  6145. * @param scale the amount to scale
  6146. */
  6147. scaleInPlace(scale: number): void;
  6148. /**
  6149. * Gets the spherical polynomial from harmonics
  6150. * @param harmonics the spherical harmonics
  6151. * @returns the spherical polynomial
  6152. */
  6153. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6154. /**
  6155. * Constructs a spherical polynomial from an array.
  6156. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6157. * @returns the spherical polynomial
  6158. */
  6159. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6160. }
  6161. }
  6162. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6163. import { Nullable } from "babylonjs/types";
  6164. /**
  6165. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6166. */
  6167. export interface CubeMapInfo {
  6168. /**
  6169. * The pixel array for the front face.
  6170. * This is stored in format, left to right, up to down format.
  6171. */
  6172. front: Nullable<ArrayBufferView>;
  6173. /**
  6174. * The pixel array for the back face.
  6175. * This is stored in format, left to right, up to down format.
  6176. */
  6177. back: Nullable<ArrayBufferView>;
  6178. /**
  6179. * The pixel array for the left face.
  6180. * This is stored in format, left to right, up to down format.
  6181. */
  6182. left: Nullable<ArrayBufferView>;
  6183. /**
  6184. * The pixel array for the right face.
  6185. * This is stored in format, left to right, up to down format.
  6186. */
  6187. right: Nullable<ArrayBufferView>;
  6188. /**
  6189. * The pixel array for the up face.
  6190. * This is stored in format, left to right, up to down format.
  6191. */
  6192. up: Nullable<ArrayBufferView>;
  6193. /**
  6194. * The pixel array for the down face.
  6195. * This is stored in format, left to right, up to down format.
  6196. */
  6197. down: Nullable<ArrayBufferView>;
  6198. /**
  6199. * The size of the cubemap stored.
  6200. *
  6201. * Each faces will be size * size pixels.
  6202. */
  6203. size: number;
  6204. /**
  6205. * The format of the texture.
  6206. *
  6207. * RGBA, RGB.
  6208. */
  6209. format: number;
  6210. /**
  6211. * The type of the texture data.
  6212. *
  6213. * UNSIGNED_INT, FLOAT.
  6214. */
  6215. type: number;
  6216. /**
  6217. * Specifies whether the texture is in gamma space.
  6218. */
  6219. gammaSpace: boolean;
  6220. }
  6221. /**
  6222. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6223. */
  6224. export class PanoramaToCubeMapTools {
  6225. private static FACE_FRONT;
  6226. private static FACE_BACK;
  6227. private static FACE_RIGHT;
  6228. private static FACE_LEFT;
  6229. private static FACE_DOWN;
  6230. private static FACE_UP;
  6231. /**
  6232. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6233. *
  6234. * @param float32Array The source data.
  6235. * @param inputWidth The width of the input panorama.
  6236. * @param inputHeight The height of the input panorama.
  6237. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6238. * @return The cubemap data
  6239. */
  6240. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6241. private static CreateCubemapTexture;
  6242. private static CalcProjectionSpherical;
  6243. }
  6244. }
  6245. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6246. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6248. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6249. /**
  6250. * Helper class dealing with the extraction of spherical polynomial dataArray
  6251. * from a cube map.
  6252. */
  6253. export class CubeMapToSphericalPolynomialTools {
  6254. private static FileFaces;
  6255. /**
  6256. * Converts a texture to the according Spherical Polynomial data.
  6257. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6258. *
  6259. * @param texture The texture to extract the information from.
  6260. * @return The Spherical Polynomial data.
  6261. */
  6262. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6263. /**
  6264. * Converts a cubemap to the according Spherical Polynomial data.
  6265. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6266. *
  6267. * @param cubeInfo The Cube map to extract the information from.
  6268. * @return The Spherical Polynomial data.
  6269. */
  6270. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6271. }
  6272. }
  6273. declare module "babylonjs/Engines/engineStore" {
  6274. import { Nullable } from "babylonjs/types";
  6275. import { Engine } from "babylonjs/Engines/engine";
  6276. import { Scene } from "babylonjs/scene";
  6277. /**
  6278. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6279. * during the life time of the application.
  6280. */
  6281. export class EngineStore {
  6282. /** Gets the list of created engines */
  6283. static Instances: import("babylonjs/Engines/engine").Engine[];
  6284. /** @hidden */
  6285. static _LastCreatedScene: Nullable<Scene>;
  6286. /**
  6287. * Gets the latest created engine
  6288. */
  6289. static readonly LastCreatedEngine: Nullable<Engine>;
  6290. /**
  6291. * Gets the latest created scene
  6292. */
  6293. static readonly LastCreatedScene: Nullable<Scene>;
  6294. }
  6295. }
  6296. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6297. /**
  6298. * Define options used to create a render target texture
  6299. */
  6300. export class RenderTargetCreationOptions {
  6301. /**
  6302. * Specifies is mipmaps must be generated
  6303. */
  6304. generateMipMaps?: boolean;
  6305. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6306. generateDepthBuffer?: boolean;
  6307. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6308. generateStencilBuffer?: boolean;
  6309. /** Defines texture type (int by default) */
  6310. type?: number;
  6311. /** Defines sampling mode (trilinear by default) */
  6312. samplingMode?: number;
  6313. /** Defines format (RGBA by default) */
  6314. format?: number;
  6315. }
  6316. }
  6317. declare module "babylonjs/States/alphaCullingState" {
  6318. /**
  6319. * @hidden
  6320. **/
  6321. export class _AlphaState {
  6322. private _isAlphaBlendDirty;
  6323. private _isBlendFunctionParametersDirty;
  6324. private _isBlendEquationParametersDirty;
  6325. private _isBlendConstantsDirty;
  6326. private _alphaBlend;
  6327. private _blendFunctionParameters;
  6328. private _blendEquationParameters;
  6329. private _blendConstants;
  6330. /**
  6331. * Initializes the state.
  6332. */
  6333. constructor();
  6334. readonly isDirty: boolean;
  6335. alphaBlend: boolean;
  6336. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6337. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6338. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6339. reset(): void;
  6340. apply(gl: WebGLRenderingContext): void;
  6341. }
  6342. }
  6343. declare module "babylonjs/States/depthCullingState" {
  6344. import { Nullable } from "babylonjs/types";
  6345. /**
  6346. * @hidden
  6347. **/
  6348. export class _DepthCullingState {
  6349. private _isDepthTestDirty;
  6350. private _isDepthMaskDirty;
  6351. private _isDepthFuncDirty;
  6352. private _isCullFaceDirty;
  6353. private _isCullDirty;
  6354. private _isZOffsetDirty;
  6355. private _isFrontFaceDirty;
  6356. private _depthTest;
  6357. private _depthMask;
  6358. private _depthFunc;
  6359. private _cull;
  6360. private _cullFace;
  6361. private _zOffset;
  6362. private _frontFace;
  6363. /**
  6364. * Initializes the state.
  6365. */
  6366. constructor();
  6367. readonly isDirty: boolean;
  6368. zOffset: number;
  6369. cullFace: Nullable<number>;
  6370. cull: Nullable<boolean>;
  6371. depthFunc: Nullable<number>;
  6372. depthMask: boolean;
  6373. depthTest: boolean;
  6374. frontFace: Nullable<number>;
  6375. reset(): void;
  6376. apply(gl: WebGLRenderingContext): void;
  6377. }
  6378. }
  6379. declare module "babylonjs/States/stencilState" {
  6380. /**
  6381. * @hidden
  6382. **/
  6383. export class _StencilState {
  6384. /** 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 */
  6385. static readonly ALWAYS: number;
  6386. /** Passed to stencilOperation to specify that stencil value must be kept */
  6387. static readonly KEEP: number;
  6388. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6389. static readonly REPLACE: number;
  6390. private _isStencilTestDirty;
  6391. private _isStencilMaskDirty;
  6392. private _isStencilFuncDirty;
  6393. private _isStencilOpDirty;
  6394. private _stencilTest;
  6395. private _stencilMask;
  6396. private _stencilFunc;
  6397. private _stencilFuncRef;
  6398. private _stencilFuncMask;
  6399. private _stencilOpStencilFail;
  6400. private _stencilOpDepthFail;
  6401. private _stencilOpStencilDepthPass;
  6402. readonly isDirty: boolean;
  6403. stencilFunc: number;
  6404. stencilFuncRef: number;
  6405. stencilFuncMask: number;
  6406. stencilOpStencilFail: number;
  6407. stencilOpDepthFail: number;
  6408. stencilOpStencilDepthPass: number;
  6409. stencilMask: number;
  6410. stencilTest: boolean;
  6411. constructor();
  6412. reset(): void;
  6413. apply(gl: WebGLRenderingContext): void;
  6414. }
  6415. }
  6416. declare module "babylonjs/States/index" {
  6417. export * from "babylonjs/States/alphaCullingState";
  6418. export * from "babylonjs/States/depthCullingState";
  6419. export * from "babylonjs/States/stencilState";
  6420. }
  6421. declare module "babylonjs/Instrumentation/timeToken" {
  6422. import { Nullable } from "babylonjs/types";
  6423. /**
  6424. * @hidden
  6425. **/
  6426. export class _TimeToken {
  6427. _startTimeQuery: Nullable<WebGLQuery>;
  6428. _endTimeQuery: Nullable<WebGLQuery>;
  6429. _timeElapsedQuery: Nullable<WebGLQuery>;
  6430. _timeElapsedQueryEnded: boolean;
  6431. }
  6432. }
  6433. declare module "babylonjs/Materials/Textures/internalTexture" {
  6434. import { Observable } from "babylonjs/Misc/observable";
  6435. import { Nullable, int } from "babylonjs/types";
  6436. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6437. import { Engine } from "babylonjs/Engines/engine";
  6438. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6439. /**
  6440. * Class used to store data associated with WebGL texture data for the engine
  6441. * This class should not be used directly
  6442. */
  6443. export class InternalTexture {
  6444. /** @hidden */
  6445. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6446. /**
  6447. * The source of the texture data is unknown
  6448. */
  6449. static DATASOURCE_UNKNOWN: number;
  6450. /**
  6451. * Texture data comes from an URL
  6452. */
  6453. static DATASOURCE_URL: number;
  6454. /**
  6455. * Texture data is only used for temporary storage
  6456. */
  6457. static DATASOURCE_TEMP: number;
  6458. /**
  6459. * Texture data comes from raw data (ArrayBuffer)
  6460. */
  6461. static DATASOURCE_RAW: number;
  6462. /**
  6463. * Texture content is dynamic (video or dynamic texture)
  6464. */
  6465. static DATASOURCE_DYNAMIC: number;
  6466. /**
  6467. * Texture content is generated by rendering to it
  6468. */
  6469. static DATASOURCE_RENDERTARGET: number;
  6470. /**
  6471. * Texture content is part of a multi render target process
  6472. */
  6473. static DATASOURCE_MULTIRENDERTARGET: number;
  6474. /**
  6475. * Texture data comes from a cube data file
  6476. */
  6477. static DATASOURCE_CUBE: number;
  6478. /**
  6479. * Texture data comes from a raw cube data
  6480. */
  6481. static DATASOURCE_CUBERAW: number;
  6482. /**
  6483. * Texture data come from a prefiltered cube data file
  6484. */
  6485. static DATASOURCE_CUBEPREFILTERED: number;
  6486. /**
  6487. * Texture content is raw 3D data
  6488. */
  6489. static DATASOURCE_RAW3D: number;
  6490. /**
  6491. * Texture content is a depth texture
  6492. */
  6493. static DATASOURCE_DEPTHTEXTURE: number;
  6494. /**
  6495. * Texture data comes from a raw cube data encoded with RGBD
  6496. */
  6497. static DATASOURCE_CUBERAW_RGBD: number;
  6498. /**
  6499. * Defines if the texture is ready
  6500. */
  6501. isReady: boolean;
  6502. /**
  6503. * Defines if the texture is a cube texture
  6504. */
  6505. isCube: boolean;
  6506. /**
  6507. * Defines if the texture contains 3D data
  6508. */
  6509. is3D: boolean;
  6510. /**
  6511. * Defines if the texture contains multiview data
  6512. */
  6513. isMultiview: boolean;
  6514. /**
  6515. * Gets the URL used to load this texture
  6516. */
  6517. url: string;
  6518. /**
  6519. * Gets the sampling mode of the texture
  6520. */
  6521. samplingMode: number;
  6522. /**
  6523. * Gets a boolean indicating if the texture needs mipmaps generation
  6524. */
  6525. generateMipMaps: boolean;
  6526. /**
  6527. * Gets the number of samples used by the texture (WebGL2+ only)
  6528. */
  6529. samples: number;
  6530. /**
  6531. * Gets the type of the texture (int, float...)
  6532. */
  6533. type: number;
  6534. /**
  6535. * Gets the format of the texture (RGB, RGBA...)
  6536. */
  6537. format: number;
  6538. /**
  6539. * Observable called when the texture is loaded
  6540. */
  6541. onLoadedObservable: Observable<InternalTexture>;
  6542. /**
  6543. * Gets the width of the texture
  6544. */
  6545. width: number;
  6546. /**
  6547. * Gets the height of the texture
  6548. */
  6549. height: number;
  6550. /**
  6551. * Gets the depth of the texture
  6552. */
  6553. depth: number;
  6554. /**
  6555. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6556. */
  6557. baseWidth: number;
  6558. /**
  6559. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6560. */
  6561. baseHeight: number;
  6562. /**
  6563. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6564. */
  6565. baseDepth: number;
  6566. /**
  6567. * Gets a boolean indicating if the texture is inverted on Y axis
  6568. */
  6569. invertY: boolean;
  6570. /** @hidden */
  6571. _invertVScale: boolean;
  6572. /** @hidden */
  6573. _associatedChannel: number;
  6574. /** @hidden */
  6575. _dataSource: number;
  6576. /** @hidden */
  6577. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6578. /** @hidden */
  6579. _bufferView: Nullable<ArrayBufferView>;
  6580. /** @hidden */
  6581. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6582. /** @hidden */
  6583. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6584. /** @hidden */
  6585. _size: number;
  6586. /** @hidden */
  6587. _extension: string;
  6588. /** @hidden */
  6589. _files: Nullable<string[]>;
  6590. /** @hidden */
  6591. _workingCanvas: Nullable<HTMLCanvasElement>;
  6592. /** @hidden */
  6593. _workingContext: Nullable<CanvasRenderingContext2D>;
  6594. /** @hidden */
  6595. _framebuffer: Nullable<WebGLFramebuffer>;
  6596. /** @hidden */
  6597. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6598. /** @hidden */
  6599. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6600. /** @hidden */
  6601. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6602. /** @hidden */
  6603. _attachments: Nullable<number[]>;
  6604. /** @hidden */
  6605. _cachedCoordinatesMode: Nullable<number>;
  6606. /** @hidden */
  6607. _cachedWrapU: Nullable<number>;
  6608. /** @hidden */
  6609. _cachedWrapV: Nullable<number>;
  6610. /** @hidden */
  6611. _cachedWrapR: Nullable<number>;
  6612. /** @hidden */
  6613. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6614. /** @hidden */
  6615. _isDisabled: boolean;
  6616. /** @hidden */
  6617. _compression: Nullable<string>;
  6618. /** @hidden */
  6619. _generateStencilBuffer: boolean;
  6620. /** @hidden */
  6621. _generateDepthBuffer: boolean;
  6622. /** @hidden */
  6623. _comparisonFunction: number;
  6624. /** @hidden */
  6625. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6626. /** @hidden */
  6627. _lodGenerationScale: number;
  6628. /** @hidden */
  6629. _lodGenerationOffset: number;
  6630. /** @hidden */
  6631. _colorTextureArray: Nullable<WebGLTexture>;
  6632. /** @hidden */
  6633. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6634. /** @hidden */
  6635. _lodTextureHigh: Nullable<BaseTexture>;
  6636. /** @hidden */
  6637. _lodTextureMid: Nullable<BaseTexture>;
  6638. /** @hidden */
  6639. _lodTextureLow: Nullable<BaseTexture>;
  6640. /** @hidden */
  6641. _isRGBD: boolean;
  6642. /** @hidden */
  6643. _linearSpecularLOD: boolean;
  6644. /** @hidden */
  6645. _irradianceTexture: Nullable<BaseTexture>;
  6646. /** @hidden */
  6647. _webGLTexture: Nullable<WebGLTexture>;
  6648. /** @hidden */
  6649. _references: number;
  6650. private _engine;
  6651. /**
  6652. * Gets the Engine the texture belongs to.
  6653. * @returns The babylon engine
  6654. */
  6655. getEngine(): Engine;
  6656. /**
  6657. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6658. */
  6659. readonly dataSource: number;
  6660. /**
  6661. * Creates a new InternalTexture
  6662. * @param engine defines the engine to use
  6663. * @param dataSource defines the type of data that will be used
  6664. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6665. */
  6666. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6667. /**
  6668. * Increments the number of references (ie. the number of Texture that point to it)
  6669. */
  6670. incrementReferences(): void;
  6671. /**
  6672. * Change the size of the texture (not the size of the content)
  6673. * @param width defines the new width
  6674. * @param height defines the new height
  6675. * @param depth defines the new depth (1 by default)
  6676. */
  6677. updateSize(width: int, height: int, depth?: int): void;
  6678. /** @hidden */
  6679. _rebuild(): void;
  6680. /** @hidden */
  6681. _swapAndDie(target: InternalTexture): void;
  6682. /**
  6683. * Dispose the current allocated resources
  6684. */
  6685. dispose(): void;
  6686. }
  6687. }
  6688. declare module "babylonjs/Animations/easing" {
  6689. /**
  6690. * This represents the main contract an easing function should follow.
  6691. * Easing functions are used throughout the animation system.
  6692. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6693. */
  6694. export interface IEasingFunction {
  6695. /**
  6696. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6697. * of the easing function.
  6698. * The link below provides some of the most common examples of easing functions.
  6699. * @see https://easings.net/
  6700. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6701. * @returns the corresponding value on the curve defined by the easing function
  6702. */
  6703. ease(gradient: number): number;
  6704. }
  6705. /**
  6706. * Base class used for every default easing function.
  6707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6708. */
  6709. export class EasingFunction implements IEasingFunction {
  6710. /**
  6711. * Interpolation follows the mathematical formula associated with the easing function.
  6712. */
  6713. static readonly EASINGMODE_EASEIN: number;
  6714. /**
  6715. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6716. */
  6717. static readonly EASINGMODE_EASEOUT: number;
  6718. /**
  6719. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6720. */
  6721. static readonly EASINGMODE_EASEINOUT: number;
  6722. private _easingMode;
  6723. /**
  6724. * Sets the easing mode of the current function.
  6725. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6726. */
  6727. setEasingMode(easingMode: number): void;
  6728. /**
  6729. * Gets the current easing mode.
  6730. * @returns the easing mode
  6731. */
  6732. getEasingMode(): number;
  6733. /**
  6734. * @hidden
  6735. */
  6736. easeInCore(gradient: number): number;
  6737. /**
  6738. * Given an input gradient between 0 and 1, this returns the corresponding value
  6739. * of the easing function.
  6740. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6741. * @returns the corresponding value on the curve defined by the easing function
  6742. */
  6743. ease(gradient: number): number;
  6744. }
  6745. /**
  6746. * Easing function with a circle shape (see link below).
  6747. * @see https://easings.net/#easeInCirc
  6748. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6749. */
  6750. export class CircleEase extends EasingFunction implements IEasingFunction {
  6751. /** @hidden */
  6752. easeInCore(gradient: number): number;
  6753. }
  6754. /**
  6755. * Easing function with a ease back shape (see link below).
  6756. * @see https://easings.net/#easeInBack
  6757. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6758. */
  6759. export class BackEase extends EasingFunction implements IEasingFunction {
  6760. /** Defines the amplitude of the function */
  6761. amplitude: number;
  6762. /**
  6763. * Instantiates a back ease easing
  6764. * @see https://easings.net/#easeInBack
  6765. * @param amplitude Defines the amplitude of the function
  6766. */
  6767. constructor(
  6768. /** Defines the amplitude of the function */
  6769. amplitude?: number);
  6770. /** @hidden */
  6771. easeInCore(gradient: number): number;
  6772. }
  6773. /**
  6774. * Easing function with a bouncing shape (see link below).
  6775. * @see https://easings.net/#easeInBounce
  6776. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6777. */
  6778. export class BounceEase extends EasingFunction implements IEasingFunction {
  6779. /** Defines the number of bounces */
  6780. bounces: number;
  6781. /** Defines the amplitude of the bounce */
  6782. bounciness: number;
  6783. /**
  6784. * Instantiates a bounce easing
  6785. * @see https://easings.net/#easeInBounce
  6786. * @param bounces Defines the number of bounces
  6787. * @param bounciness Defines the amplitude of the bounce
  6788. */
  6789. constructor(
  6790. /** Defines the number of bounces */
  6791. bounces?: number,
  6792. /** Defines the amplitude of the bounce */
  6793. bounciness?: number);
  6794. /** @hidden */
  6795. easeInCore(gradient: number): number;
  6796. }
  6797. /**
  6798. * Easing function with a power of 3 shape (see link below).
  6799. * @see https://easings.net/#easeInCubic
  6800. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6801. */
  6802. export class CubicEase extends EasingFunction implements IEasingFunction {
  6803. /** @hidden */
  6804. easeInCore(gradient: number): number;
  6805. }
  6806. /**
  6807. * Easing function with an elastic shape (see link below).
  6808. * @see https://easings.net/#easeInElastic
  6809. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6810. */
  6811. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6812. /** Defines the number of oscillations*/
  6813. oscillations: number;
  6814. /** Defines the amplitude of the oscillations*/
  6815. springiness: number;
  6816. /**
  6817. * Instantiates an elastic easing function
  6818. * @see https://easings.net/#easeInElastic
  6819. * @param oscillations Defines the number of oscillations
  6820. * @param springiness Defines the amplitude of the oscillations
  6821. */
  6822. constructor(
  6823. /** Defines the number of oscillations*/
  6824. oscillations?: number,
  6825. /** Defines the amplitude of the oscillations*/
  6826. springiness?: number);
  6827. /** @hidden */
  6828. easeInCore(gradient: number): number;
  6829. }
  6830. /**
  6831. * Easing function with an exponential shape (see link below).
  6832. * @see https://easings.net/#easeInExpo
  6833. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6834. */
  6835. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6836. /** Defines the exponent of the function */
  6837. exponent: number;
  6838. /**
  6839. * Instantiates an exponential easing function
  6840. * @see https://easings.net/#easeInExpo
  6841. * @param exponent Defines the exponent of the function
  6842. */
  6843. constructor(
  6844. /** Defines the exponent of the function */
  6845. exponent?: number);
  6846. /** @hidden */
  6847. easeInCore(gradient: number): number;
  6848. }
  6849. /**
  6850. * Easing function with a power shape (see link below).
  6851. * @see https://easings.net/#easeInQuad
  6852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6853. */
  6854. export class PowerEase extends EasingFunction implements IEasingFunction {
  6855. /** Defines the power of the function */
  6856. power: number;
  6857. /**
  6858. * Instantiates an power base easing function
  6859. * @see https://easings.net/#easeInQuad
  6860. * @param power Defines the power of the function
  6861. */
  6862. constructor(
  6863. /** Defines the power of the function */
  6864. power?: number);
  6865. /** @hidden */
  6866. easeInCore(gradient: number): number;
  6867. }
  6868. /**
  6869. * Easing function with a power of 2 shape (see link below).
  6870. * @see https://easings.net/#easeInQuad
  6871. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6872. */
  6873. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6874. /** @hidden */
  6875. easeInCore(gradient: number): number;
  6876. }
  6877. /**
  6878. * Easing function with a power of 4 shape (see link below).
  6879. * @see https://easings.net/#easeInQuart
  6880. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6881. */
  6882. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6883. /** @hidden */
  6884. easeInCore(gradient: number): number;
  6885. }
  6886. /**
  6887. * Easing function with a power of 5 shape (see link below).
  6888. * @see https://easings.net/#easeInQuint
  6889. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6890. */
  6891. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6892. /** @hidden */
  6893. easeInCore(gradient: number): number;
  6894. }
  6895. /**
  6896. * Easing function with a sin shape (see link below).
  6897. * @see https://easings.net/#easeInSine
  6898. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6899. */
  6900. export class SineEase extends EasingFunction implements IEasingFunction {
  6901. /** @hidden */
  6902. easeInCore(gradient: number): number;
  6903. }
  6904. /**
  6905. * Easing function with a bezier shape (see link below).
  6906. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6907. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6908. */
  6909. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6910. /** Defines the x component of the start tangent in the bezier curve */
  6911. x1: number;
  6912. /** Defines the y component of the start tangent in the bezier curve */
  6913. y1: number;
  6914. /** Defines the x component of the end tangent in the bezier curve */
  6915. x2: number;
  6916. /** Defines the y component of the end tangent in the bezier curve */
  6917. y2: number;
  6918. /**
  6919. * Instantiates a bezier function
  6920. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6921. * @param x1 Defines the x component of the start tangent in the bezier curve
  6922. * @param y1 Defines the y component of the start tangent in the bezier curve
  6923. * @param x2 Defines the x component of the end tangent in the bezier curve
  6924. * @param y2 Defines the y component of the end tangent in the bezier curve
  6925. */
  6926. constructor(
  6927. /** Defines the x component of the start tangent in the bezier curve */
  6928. x1?: number,
  6929. /** Defines the y component of the start tangent in the bezier curve */
  6930. y1?: number,
  6931. /** Defines the x component of the end tangent in the bezier curve */
  6932. x2?: number,
  6933. /** Defines the y component of the end tangent in the bezier curve */
  6934. y2?: number);
  6935. /** @hidden */
  6936. easeInCore(gradient: number): number;
  6937. }
  6938. }
  6939. declare module "babylonjs/Animations/animationKey" {
  6940. /**
  6941. * Defines an interface which represents an animation key frame
  6942. */
  6943. export interface IAnimationKey {
  6944. /**
  6945. * Frame of the key frame
  6946. */
  6947. frame: number;
  6948. /**
  6949. * Value at the specifies key frame
  6950. */
  6951. value: any;
  6952. /**
  6953. * The input tangent for the cubic hermite spline
  6954. */
  6955. inTangent?: any;
  6956. /**
  6957. * The output tangent for the cubic hermite spline
  6958. */
  6959. outTangent?: any;
  6960. /**
  6961. * The animation interpolation type
  6962. */
  6963. interpolation?: AnimationKeyInterpolation;
  6964. }
  6965. /**
  6966. * Enum for the animation key frame interpolation type
  6967. */
  6968. export enum AnimationKeyInterpolation {
  6969. /**
  6970. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6971. */
  6972. STEP = 1
  6973. }
  6974. }
  6975. declare module "babylonjs/Animations/animationRange" {
  6976. /**
  6977. * Represents the range of an animation
  6978. */
  6979. export class AnimationRange {
  6980. /**The name of the animation range**/
  6981. name: string;
  6982. /**The starting frame of the animation */
  6983. from: number;
  6984. /**The ending frame of the animation*/
  6985. to: number;
  6986. /**
  6987. * Initializes the range of an animation
  6988. * @param name The name of the animation range
  6989. * @param from The starting frame of the animation
  6990. * @param to The ending frame of the animation
  6991. */
  6992. constructor(
  6993. /**The name of the animation range**/
  6994. name: string,
  6995. /**The starting frame of the animation */
  6996. from: number,
  6997. /**The ending frame of the animation*/
  6998. to: number);
  6999. /**
  7000. * Makes a copy of the animation range
  7001. * @returns A copy of the animation range
  7002. */
  7003. clone(): AnimationRange;
  7004. }
  7005. }
  7006. declare module "babylonjs/Animations/animationEvent" {
  7007. /**
  7008. * Composed of a frame, and an action function
  7009. */
  7010. export class AnimationEvent {
  7011. /** The frame for which the event is triggered **/
  7012. frame: number;
  7013. /** The event to perform when triggered **/
  7014. action: (currentFrame: number) => void;
  7015. /** Specifies if the event should be triggered only once**/
  7016. onlyOnce?: boolean | undefined;
  7017. /**
  7018. * Specifies if the animation event is done
  7019. */
  7020. isDone: boolean;
  7021. /**
  7022. * Initializes the animation event
  7023. * @param frame The frame for which the event is triggered
  7024. * @param action The event to perform when triggered
  7025. * @param onlyOnce Specifies if the event should be triggered only once
  7026. */
  7027. constructor(
  7028. /** The frame for which the event is triggered **/
  7029. frame: number,
  7030. /** The event to perform when triggered **/
  7031. action: (currentFrame: number) => void,
  7032. /** Specifies if the event should be triggered only once**/
  7033. onlyOnce?: boolean | undefined);
  7034. /** @hidden */
  7035. _clone(): AnimationEvent;
  7036. }
  7037. }
  7038. declare module "babylonjs/Behaviors/behavior" {
  7039. import { Nullable } from "babylonjs/types";
  7040. /**
  7041. * Interface used to define a behavior
  7042. */
  7043. export interface Behavior<T> {
  7044. /** gets or sets behavior's name */
  7045. name: string;
  7046. /**
  7047. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7048. */
  7049. init(): void;
  7050. /**
  7051. * Called when the behavior is attached to a target
  7052. * @param target defines the target where the behavior is attached to
  7053. */
  7054. attach(target: T): void;
  7055. /**
  7056. * Called when the behavior is detached from its target
  7057. */
  7058. detach(): void;
  7059. }
  7060. /**
  7061. * Interface implemented by classes supporting behaviors
  7062. */
  7063. export interface IBehaviorAware<T> {
  7064. /**
  7065. * Attach a behavior
  7066. * @param behavior defines the behavior to attach
  7067. * @returns the current host
  7068. */
  7069. addBehavior(behavior: Behavior<T>): T;
  7070. /**
  7071. * Remove a behavior from the current object
  7072. * @param behavior defines the behavior to detach
  7073. * @returns the current host
  7074. */
  7075. removeBehavior(behavior: Behavior<T>): T;
  7076. /**
  7077. * Gets a behavior using its name to search
  7078. * @param name defines the name to search
  7079. * @returns the behavior or null if not found
  7080. */
  7081. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7082. }
  7083. }
  7084. declare module "babylonjs/Collisions/intersectionInfo" {
  7085. import { Nullable } from "babylonjs/types";
  7086. /**
  7087. * @hidden
  7088. */
  7089. export class IntersectionInfo {
  7090. bu: Nullable<number>;
  7091. bv: Nullable<number>;
  7092. distance: number;
  7093. faceId: number;
  7094. subMeshId: number;
  7095. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7096. }
  7097. }
  7098. declare module "babylonjs/Culling/boundingSphere" {
  7099. import { DeepImmutable } from "babylonjs/types";
  7100. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7101. /**
  7102. * Class used to store bounding sphere information
  7103. */
  7104. export class BoundingSphere {
  7105. /**
  7106. * Gets the center of the bounding sphere in local space
  7107. */
  7108. readonly center: Vector3;
  7109. /**
  7110. * Radius of the bounding sphere in local space
  7111. */
  7112. radius: number;
  7113. /**
  7114. * Gets the center of the bounding sphere in world space
  7115. */
  7116. readonly centerWorld: Vector3;
  7117. /**
  7118. * Radius of the bounding sphere in world space
  7119. */
  7120. radiusWorld: number;
  7121. /**
  7122. * Gets the minimum vector in local space
  7123. */
  7124. readonly minimum: Vector3;
  7125. /**
  7126. * Gets the maximum vector in local space
  7127. */
  7128. readonly maximum: Vector3;
  7129. private _worldMatrix;
  7130. private static readonly TmpVector3;
  7131. /**
  7132. * Creates a new bounding sphere
  7133. * @param min defines the minimum vector (in local space)
  7134. * @param max defines the maximum vector (in local space)
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7138. /**
  7139. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7140. * @param min defines the new minimum vector (in local space)
  7141. * @param max defines the new maximum vector (in local space)
  7142. * @param worldMatrix defines the new world matrix
  7143. */
  7144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * Scale the current bounding sphere by applying a scale factor
  7147. * @param factor defines the scale factor to apply
  7148. * @returns the current bounding box
  7149. */
  7150. scale(factor: number): BoundingSphere;
  7151. /**
  7152. * Gets the world matrix of the bounding box
  7153. * @returns a matrix
  7154. */
  7155. getWorldMatrix(): DeepImmutable<Matrix>;
  7156. /** @hidden */
  7157. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7158. /**
  7159. * Tests if the bounding sphere is intersecting the frustum planes
  7160. * @param frustumPlanes defines the frustum planes to test
  7161. * @returns true if there is an intersection
  7162. */
  7163. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7164. /**
  7165. * Tests if the bounding sphere center is in between the frustum planes.
  7166. * Used for optimistic fast inclusion.
  7167. * @param frustumPlanes defines the frustum planes to test
  7168. * @returns true if the sphere center is in between the frustum planes
  7169. */
  7170. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7171. /**
  7172. * Tests if a point is inside the bounding sphere
  7173. * @param point defines the point to test
  7174. * @returns true if the point is inside the bounding sphere
  7175. */
  7176. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7177. /**
  7178. * Checks if two sphere intersct
  7179. * @param sphere0 sphere 0
  7180. * @param sphere1 sphere 1
  7181. * @returns true if the speres intersect
  7182. */
  7183. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7184. }
  7185. }
  7186. declare module "babylonjs/Culling/boundingBox" {
  7187. import { DeepImmutable } from "babylonjs/types";
  7188. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7189. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7190. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7191. /**
  7192. * Class used to store bounding box information
  7193. */
  7194. export class BoundingBox implements ICullable {
  7195. /**
  7196. * Gets the 8 vectors representing the bounding box in local space
  7197. */
  7198. readonly vectors: Vector3[];
  7199. /**
  7200. * Gets the center of the bounding box in local space
  7201. */
  7202. readonly center: Vector3;
  7203. /**
  7204. * Gets the center of the bounding box in world space
  7205. */
  7206. readonly centerWorld: Vector3;
  7207. /**
  7208. * Gets the extend size in local space
  7209. */
  7210. readonly extendSize: Vector3;
  7211. /**
  7212. * Gets the extend size in world space
  7213. */
  7214. readonly extendSizeWorld: Vector3;
  7215. /**
  7216. * Gets the OBB (object bounding box) directions
  7217. */
  7218. readonly directions: Vector3[];
  7219. /**
  7220. * Gets the 8 vectors representing the bounding box in world space
  7221. */
  7222. readonly vectorsWorld: Vector3[];
  7223. /**
  7224. * Gets the minimum vector in world space
  7225. */
  7226. readonly minimumWorld: Vector3;
  7227. /**
  7228. * Gets the maximum vector in world space
  7229. */
  7230. readonly maximumWorld: Vector3;
  7231. /**
  7232. * Gets the minimum vector in local space
  7233. */
  7234. readonly minimum: Vector3;
  7235. /**
  7236. * Gets the maximum vector in local space
  7237. */
  7238. readonly maximum: Vector3;
  7239. private _worldMatrix;
  7240. private static readonly TmpVector3;
  7241. /**
  7242. * @hidden
  7243. */
  7244. _tag: number;
  7245. /**
  7246. * Creates a new bounding box
  7247. * @param min defines the minimum vector (in local space)
  7248. * @param max defines the maximum vector (in local space)
  7249. * @param worldMatrix defines the new world matrix
  7250. */
  7251. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7252. /**
  7253. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7254. * @param min defines the new minimum vector (in local space)
  7255. * @param max defines the new maximum vector (in local space)
  7256. * @param worldMatrix defines the new world matrix
  7257. */
  7258. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7259. /**
  7260. * Scale the current bounding box by applying a scale factor
  7261. * @param factor defines the scale factor to apply
  7262. * @returns the current bounding box
  7263. */
  7264. scale(factor: number): BoundingBox;
  7265. /**
  7266. * Gets the world matrix of the bounding box
  7267. * @returns a matrix
  7268. */
  7269. getWorldMatrix(): DeepImmutable<Matrix>;
  7270. /** @hidden */
  7271. _update(world: DeepImmutable<Matrix>): void;
  7272. /**
  7273. * Tests if the bounding box is intersecting the frustum planes
  7274. * @param frustumPlanes defines the frustum planes to test
  7275. * @returns true if there is an intersection
  7276. */
  7277. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7278. /**
  7279. * Tests if the bounding box is entirely inside the frustum planes
  7280. * @param frustumPlanes defines the frustum planes to test
  7281. * @returns true if there is an inclusion
  7282. */
  7283. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. /**
  7285. * Tests if a point is inside the bounding box
  7286. * @param point defines the point to test
  7287. * @returns true if the point is inside the bounding box
  7288. */
  7289. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7290. /**
  7291. * Tests if the bounding box intersects with a bounding sphere
  7292. * @param sphere defines the sphere to test
  7293. * @returns true if there is an intersection
  7294. */
  7295. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7296. /**
  7297. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7298. * @param min defines the min vector to use
  7299. * @param max defines the max vector to use
  7300. * @returns true if there is an intersection
  7301. */
  7302. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7303. /**
  7304. * Tests if two bounding boxes are intersections
  7305. * @param box0 defines the first box to test
  7306. * @param box1 defines the second box to test
  7307. * @returns true if there is an intersection
  7308. */
  7309. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7310. /**
  7311. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7312. * @param minPoint defines the minimum vector of the bounding box
  7313. * @param maxPoint defines the maximum vector of the bounding box
  7314. * @param sphereCenter defines the sphere center
  7315. * @param sphereRadius defines the sphere radius
  7316. * @returns true if there is an intersection
  7317. */
  7318. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7319. /**
  7320. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7321. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7322. * @param frustumPlanes defines the frustum planes to test
  7323. * @return true if there is an inclusion
  7324. */
  7325. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7326. /**
  7327. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7328. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7329. * @param frustumPlanes defines the frustum planes to test
  7330. * @return true if there is an intersection
  7331. */
  7332. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7333. }
  7334. }
  7335. declare module "babylonjs/Collisions/collider" {
  7336. import { Nullable, IndicesArray } from "babylonjs/types";
  7337. import { Vector3, Plane } from "babylonjs/Maths/math";
  7338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7339. /** @hidden */
  7340. export class Collider {
  7341. /** Define if a collision was found */
  7342. collisionFound: boolean;
  7343. /**
  7344. * Define last intersection point in local space
  7345. */
  7346. intersectionPoint: Vector3;
  7347. /**
  7348. * Define last collided mesh
  7349. */
  7350. collidedMesh: Nullable<AbstractMesh>;
  7351. private _collisionPoint;
  7352. private _planeIntersectionPoint;
  7353. private _tempVector;
  7354. private _tempVector2;
  7355. private _tempVector3;
  7356. private _tempVector4;
  7357. private _edge;
  7358. private _baseToVertex;
  7359. private _destinationPoint;
  7360. private _slidePlaneNormal;
  7361. private _displacementVector;
  7362. /** @hidden */
  7363. _radius: Vector3;
  7364. /** @hidden */
  7365. _retry: number;
  7366. private _velocity;
  7367. private _basePoint;
  7368. private _epsilon;
  7369. /** @hidden */
  7370. _velocityWorldLength: number;
  7371. /** @hidden */
  7372. _basePointWorld: Vector3;
  7373. private _velocityWorld;
  7374. private _normalizedVelocity;
  7375. /** @hidden */
  7376. _initialVelocity: Vector3;
  7377. /** @hidden */
  7378. _initialPosition: Vector3;
  7379. private _nearestDistance;
  7380. private _collisionMask;
  7381. collisionMask: number;
  7382. /**
  7383. * Gets the plane normal used to compute the sliding response (in local space)
  7384. */
  7385. readonly slidePlaneNormal: Vector3;
  7386. /** @hidden */
  7387. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7388. /** @hidden */
  7389. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7390. /** @hidden */
  7391. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7392. /** @hidden */
  7393. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7394. /** @hidden */
  7395. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7396. /** @hidden */
  7397. _getResponse(pos: Vector3, vel: Vector3): void;
  7398. }
  7399. }
  7400. declare module "babylonjs/Culling/boundingInfo" {
  7401. import { DeepImmutable } from "babylonjs/types";
  7402. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7403. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7404. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7405. import { Collider } from "babylonjs/Collisions/collider";
  7406. /**
  7407. * Interface for cullable objects
  7408. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7409. */
  7410. export interface ICullable {
  7411. /**
  7412. * Checks if the object or part of the object is in the frustum
  7413. * @param frustumPlanes Camera near/planes
  7414. * @returns true if the object is in frustum otherwise false
  7415. */
  7416. isInFrustum(frustumPlanes: Plane[]): boolean;
  7417. /**
  7418. * Checks if a cullable object (mesh...) is in the camera frustum
  7419. * Unlike isInFrustum this cheks the full bounding box
  7420. * @param frustumPlanes Camera near/planes
  7421. * @returns true if the object is in frustum otherwise false
  7422. */
  7423. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7424. }
  7425. /**
  7426. * Info for a bounding data of a mesh
  7427. */
  7428. export class BoundingInfo implements ICullable {
  7429. /**
  7430. * Bounding box for the mesh
  7431. */
  7432. readonly boundingBox: BoundingBox;
  7433. /**
  7434. * Bounding sphere for the mesh
  7435. */
  7436. readonly boundingSphere: BoundingSphere;
  7437. private _isLocked;
  7438. private static readonly TmpVector3;
  7439. /**
  7440. * Constructs bounding info
  7441. * @param minimum min vector of the bounding box/sphere
  7442. * @param maximum max vector of the bounding box/sphere
  7443. * @param worldMatrix defines the new world matrix
  7444. */
  7445. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7446. /**
  7447. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7448. * @param min defines the new minimum vector (in local space)
  7449. * @param max defines the new maximum vector (in local space)
  7450. * @param worldMatrix defines the new world matrix
  7451. */
  7452. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7453. /**
  7454. * min vector of the bounding box/sphere
  7455. */
  7456. readonly minimum: Vector3;
  7457. /**
  7458. * max vector of the bounding box/sphere
  7459. */
  7460. readonly maximum: Vector3;
  7461. /**
  7462. * If the info is locked and won't be updated to avoid perf overhead
  7463. */
  7464. isLocked: boolean;
  7465. /**
  7466. * Updates the bounding sphere and box
  7467. * @param world world matrix to be used to update
  7468. */
  7469. update(world: DeepImmutable<Matrix>): void;
  7470. /**
  7471. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7472. * @param center New center of the bounding info
  7473. * @param extend New extend of the bounding info
  7474. * @returns the current bounding info
  7475. */
  7476. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7477. /**
  7478. * Scale the current bounding info by applying a scale factor
  7479. * @param factor defines the scale factor to apply
  7480. * @returns the current bounding info
  7481. */
  7482. scale(factor: number): BoundingInfo;
  7483. /**
  7484. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7485. * @param frustumPlanes defines the frustum to test
  7486. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7487. * @returns true if the bounding info is in the frustum planes
  7488. */
  7489. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7490. /**
  7491. * Gets the world distance between the min and max points of the bounding box
  7492. */
  7493. readonly diagonalLength: number;
  7494. /**
  7495. * Checks if a cullable object (mesh...) is in the camera frustum
  7496. * Unlike isInFrustum this cheks the full bounding box
  7497. * @param frustumPlanes Camera near/planes
  7498. * @returns true if the object is in frustum otherwise false
  7499. */
  7500. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7501. /** @hidden */
  7502. _checkCollision(collider: Collider): boolean;
  7503. /**
  7504. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7505. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7506. * @param point the point to check intersection with
  7507. * @returns if the point intersects
  7508. */
  7509. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7510. /**
  7511. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7512. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7513. * @param boundingInfo the bounding info to check intersection with
  7514. * @param precise if the intersection should be done using OBB
  7515. * @returns if the bounding info intersects
  7516. */
  7517. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7518. }
  7519. }
  7520. declare module "babylonjs/Misc/smartArray" {
  7521. /**
  7522. * Defines an array and its length.
  7523. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7524. */
  7525. export interface ISmartArrayLike<T> {
  7526. /**
  7527. * The data of the array.
  7528. */
  7529. data: Array<T>;
  7530. /**
  7531. * The active length of the array.
  7532. */
  7533. length: number;
  7534. }
  7535. /**
  7536. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7537. */
  7538. export class SmartArray<T> implements ISmartArrayLike<T> {
  7539. /**
  7540. * The full set of data from the array.
  7541. */
  7542. data: Array<T>;
  7543. /**
  7544. * The active length of the array.
  7545. */
  7546. length: number;
  7547. protected _id: number;
  7548. /**
  7549. * Instantiates a Smart Array.
  7550. * @param capacity defines the default capacity of the array.
  7551. */
  7552. constructor(capacity: number);
  7553. /**
  7554. * Pushes a value at the end of the active data.
  7555. * @param value defines the object to push in the array.
  7556. */
  7557. push(value: T): void;
  7558. /**
  7559. * Iterates over the active data and apply the lambda to them.
  7560. * @param func defines the action to apply on each value.
  7561. */
  7562. forEach(func: (content: T) => void): void;
  7563. /**
  7564. * Sorts the full sets of data.
  7565. * @param compareFn defines the comparison function to apply.
  7566. */
  7567. sort(compareFn: (a: T, b: T) => number): void;
  7568. /**
  7569. * Resets the active data to an empty array.
  7570. */
  7571. reset(): void;
  7572. /**
  7573. * Releases all the data from the array as well as the array.
  7574. */
  7575. dispose(): void;
  7576. /**
  7577. * Concats the active data with a given array.
  7578. * @param array defines the data to concatenate with.
  7579. */
  7580. concat(array: any): void;
  7581. /**
  7582. * Returns the position of a value in the active data.
  7583. * @param value defines the value to find the index for
  7584. * @returns the index if found in the active data otherwise -1
  7585. */
  7586. indexOf(value: T): number;
  7587. /**
  7588. * Returns whether an element is part of the active data.
  7589. * @param value defines the value to look for
  7590. * @returns true if found in the active data otherwise false
  7591. */
  7592. contains(value: T): boolean;
  7593. private static _GlobalId;
  7594. }
  7595. /**
  7596. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7597. * The data in this array can only be present once
  7598. */
  7599. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7600. private _duplicateId;
  7601. /**
  7602. * Pushes a value at the end of the active data.
  7603. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7604. * @param value defines the object to push in the array.
  7605. */
  7606. push(value: T): void;
  7607. /**
  7608. * Pushes a value at the end of the active data.
  7609. * If the data is already present, it won t be added again
  7610. * @param value defines the object to push in the array.
  7611. * @returns true if added false if it was already present
  7612. */
  7613. pushNoDuplicate(value: T): boolean;
  7614. /**
  7615. * Resets the active data to an empty array.
  7616. */
  7617. reset(): void;
  7618. /**
  7619. * Concats the active data with a given array.
  7620. * This ensures no dupplicate will be present in the result.
  7621. * @param array defines the data to concatenate with.
  7622. */
  7623. concatWithNoDuplicate(array: any): void;
  7624. }
  7625. }
  7626. declare module "babylonjs/Misc/iInspectable" {
  7627. /**
  7628. * Enum that determines the text-wrapping mode to use.
  7629. */
  7630. export enum InspectableType {
  7631. /**
  7632. * Checkbox for booleans
  7633. */
  7634. Checkbox = 0,
  7635. /**
  7636. * Sliders for numbers
  7637. */
  7638. Slider = 1,
  7639. /**
  7640. * Vector3
  7641. */
  7642. Vector3 = 2,
  7643. /**
  7644. * Quaternions
  7645. */
  7646. Quaternion = 3,
  7647. /**
  7648. * Color3
  7649. */
  7650. Color3 = 4
  7651. }
  7652. /**
  7653. * Interface used to define custom inspectable properties.
  7654. * This interface is used by the inspector to display custom property grids
  7655. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7656. */
  7657. export interface IInspectable {
  7658. /**
  7659. * Gets the label to display
  7660. */
  7661. label: string;
  7662. /**
  7663. * Gets the name of the property to edit
  7664. */
  7665. propertyName: string;
  7666. /**
  7667. * Gets the type of the editor to use
  7668. */
  7669. type: InspectableType;
  7670. /**
  7671. * Gets the minimum value of the property when using in "slider" mode
  7672. */
  7673. min?: number;
  7674. /**
  7675. * Gets the maximum value of the property when using in "slider" mode
  7676. */
  7677. max?: number;
  7678. /**
  7679. * Gets the setp to use when using in "slider" mode
  7680. */
  7681. step?: number;
  7682. }
  7683. }
  7684. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7685. import { Nullable } from "babylonjs/types";
  7686. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7687. /**
  7688. * This represents the required contract to create a new type of texture loader.
  7689. */
  7690. export interface IInternalTextureLoader {
  7691. /**
  7692. * Defines wether the loader supports cascade loading the different faces.
  7693. */
  7694. supportCascades: boolean;
  7695. /**
  7696. * This returns if the loader support the current file information.
  7697. * @param extension defines the file extension of the file being loaded
  7698. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7699. * @param fallback defines the fallback internal texture if any
  7700. * @param isBase64 defines whether the texture is encoded as a base64
  7701. * @param isBuffer defines whether the texture data are stored as a buffer
  7702. * @returns true if the loader can load the specified file
  7703. */
  7704. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7705. /**
  7706. * Transform the url before loading if required.
  7707. * @param rootUrl the url of the texture
  7708. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7709. * @returns the transformed texture
  7710. */
  7711. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7712. /**
  7713. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7714. * @param rootUrl the url of the texture
  7715. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7716. * @returns the fallback texture
  7717. */
  7718. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7719. /**
  7720. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7721. * @param data contains the texture data
  7722. * @param texture defines the BabylonJS internal texture
  7723. * @param createPolynomials will be true if polynomials have been requested
  7724. * @param onLoad defines the callback to trigger once the texture is ready
  7725. * @param onError defines the callback to trigger in case of error
  7726. */
  7727. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7728. /**
  7729. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7730. * @param data contains the texture data
  7731. * @param texture defines the BabylonJS internal texture
  7732. * @param callback defines the method to call once ready to upload
  7733. */
  7734. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7735. }
  7736. }
  7737. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7738. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7739. import { Nullable } from "babylonjs/types";
  7740. import { Scene } from "babylonjs/scene";
  7741. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7742. module "babylonjs/Engines/engine" {
  7743. interface Engine {
  7744. /**
  7745. * Creates a depth stencil cube texture.
  7746. * This is only available in WebGL 2.
  7747. * @param size The size of face edge in the cube texture.
  7748. * @param options The options defining the cube texture.
  7749. * @returns The cube texture
  7750. */
  7751. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7752. /**
  7753. * Creates a cube texture
  7754. * @param rootUrl defines the url where the files to load is located
  7755. * @param scene defines the current scene
  7756. * @param files defines the list of files to load (1 per face)
  7757. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7758. * @param onLoad defines an optional callback raised when the texture is loaded
  7759. * @param onError defines an optional callback raised if there is an issue to load the texture
  7760. * @param format defines the format of the data
  7761. * @param forcedExtension defines the extension to use to pick the right loader
  7762. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7765. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7766. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7767. * @returns the cube texture as an InternalTexture
  7768. */
  7769. 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;
  7770. /**
  7771. * Creates a cube texture
  7772. * @param rootUrl defines the url where the files to load is located
  7773. * @param scene defines the current scene
  7774. * @param files defines the list of files to load (1 per face)
  7775. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7776. * @param onLoad defines an optional callback raised when the texture is loaded
  7777. * @param onError defines an optional callback raised if there is an issue to load the texture
  7778. * @param format defines the format of the data
  7779. * @param forcedExtension defines the extension to use to pick the right loader
  7780. * @returns the cube texture as an InternalTexture
  7781. */
  7782. 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;
  7783. /**
  7784. * Creates a cube texture
  7785. * @param rootUrl defines the url where the files to load is located
  7786. * @param scene defines the current scene
  7787. * @param files defines the list of files to load (1 per face)
  7788. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7789. * @param onLoad defines an optional callback raised when the texture is loaded
  7790. * @param onError defines an optional callback raised if there is an issue to load the texture
  7791. * @param format defines the format of the data
  7792. * @param forcedExtension defines the extension to use to pick the right loader
  7793. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7794. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7795. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7796. * @returns the cube texture as an InternalTexture
  7797. */
  7798. 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;
  7799. /** @hidden */
  7800. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7801. /** @hidden */
  7802. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7803. /** @hidden */
  7804. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7805. /** @hidden */
  7806. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7807. }
  7808. }
  7809. }
  7810. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7811. import { Nullable } from "babylonjs/types";
  7812. import { Scene } from "babylonjs/scene";
  7813. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7814. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7815. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7816. /**
  7817. * Class for creating a cube texture
  7818. */
  7819. export class CubeTexture extends BaseTexture {
  7820. private _delayedOnLoad;
  7821. /**
  7822. * The url of the texture
  7823. */
  7824. url: string;
  7825. /**
  7826. * Gets or sets the center of the bounding box associated with the cube texture.
  7827. * It must define where the camera used to render the texture was set
  7828. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7829. */
  7830. boundingBoxPosition: Vector3;
  7831. private _boundingBoxSize;
  7832. /**
  7833. * Gets or sets the size of the bounding box associated with the cube texture
  7834. * When defined, the cubemap will switch to local mode
  7835. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7836. * @example https://www.babylonjs-playground.com/#RNASML
  7837. */
  7838. /**
  7839. * Returns the bounding box size
  7840. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7841. */
  7842. boundingBoxSize: Vector3;
  7843. protected _rotationY: number;
  7844. /**
  7845. * Sets texture matrix rotation angle around Y axis in radians.
  7846. */
  7847. /**
  7848. * Gets texture matrix rotation angle around Y axis radians.
  7849. */
  7850. rotationY: number;
  7851. /**
  7852. * Are mip maps generated for this texture or not.
  7853. */
  7854. readonly noMipmap: boolean;
  7855. private _noMipmap;
  7856. private _files;
  7857. private _extensions;
  7858. private _textureMatrix;
  7859. private _format;
  7860. private _createPolynomials;
  7861. /** @hidden */
  7862. _prefiltered: boolean;
  7863. /**
  7864. * Creates a cube texture from an array of image urls
  7865. * @param files defines an array of image urls
  7866. * @param scene defines the hosting scene
  7867. * @param noMipmap specifies if mip maps are not used
  7868. * @returns a cube texture
  7869. */
  7870. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7871. /**
  7872. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7873. * @param url defines the url of the prefiltered texture
  7874. * @param scene defines the scene the texture is attached to
  7875. * @param forcedExtension defines the extension of the file if different from the url
  7876. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7877. * @return the prefiltered texture
  7878. */
  7879. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7880. /**
  7881. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7882. * as prefiltered data.
  7883. * @param rootUrl defines the url of the texture or the root name of the six images
  7884. * @param scene defines the scene the texture is attached to
  7885. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7886. * @param noMipmap defines if mipmaps should be created or not
  7887. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7888. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7889. * @param onError defines a callback triggered in case of error during load
  7890. * @param format defines the internal format to use for the texture once loaded
  7891. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7892. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7893. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7894. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7895. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7896. * @return the cube texture
  7897. */
  7898. 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);
  7899. /**
  7900. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7901. */
  7902. readonly isPrefiltered: boolean;
  7903. /**
  7904. * Get the current class name of the texture useful for serialization or dynamic coding.
  7905. * @returns "CubeTexture"
  7906. */
  7907. getClassName(): string;
  7908. /**
  7909. * Update the url (and optional buffer) of this texture if url was null during construction.
  7910. * @param url the url of the texture
  7911. * @param forcedExtension defines the extension to use
  7912. * @param onLoad callback called when the texture is loaded (defaults to null)
  7913. */
  7914. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7915. /**
  7916. * Delays loading of the cube texture
  7917. * @param forcedExtension defines the extension to use
  7918. */
  7919. delayLoad(forcedExtension?: string): void;
  7920. /**
  7921. * Returns the reflection texture matrix
  7922. * @returns the reflection texture matrix
  7923. */
  7924. getReflectionTextureMatrix(): Matrix;
  7925. /**
  7926. * Sets the reflection texture matrix
  7927. * @param value Reflection texture matrix
  7928. */
  7929. setReflectionTextureMatrix(value: Matrix): void;
  7930. /**
  7931. * Parses text to create a cube texture
  7932. * @param parsedTexture define the serialized text to read from
  7933. * @param scene defines the hosting scene
  7934. * @param rootUrl defines the root url of the cube texture
  7935. * @returns a cube texture
  7936. */
  7937. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7938. /**
  7939. * Makes a clone, or deep copy, of the cube texture
  7940. * @returns a new cube texture
  7941. */
  7942. clone(): CubeTexture;
  7943. }
  7944. }
  7945. declare module "babylonjs/Shaders/postprocess.vertex" {
  7946. /** @hidden */
  7947. export var postprocessVertexShader: {
  7948. name: string;
  7949. shader: string;
  7950. };
  7951. }
  7952. declare module "babylonjs/Cameras/targetCamera" {
  7953. import { Nullable } from "babylonjs/types";
  7954. import { Camera } from "babylonjs/Cameras/camera";
  7955. import { Scene } from "babylonjs/scene";
  7956. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7957. /**
  7958. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7959. * This is the base of the follow, arc rotate cameras and Free camera
  7960. * @see http://doc.babylonjs.com/features/cameras
  7961. */
  7962. export class TargetCamera extends Camera {
  7963. private static _RigCamTransformMatrix;
  7964. private static _TargetTransformMatrix;
  7965. private static _TargetFocalPoint;
  7966. /**
  7967. * Define the current direction the camera is moving to
  7968. */
  7969. cameraDirection: Vector3;
  7970. /**
  7971. * Define the current rotation the camera is rotating to
  7972. */
  7973. cameraRotation: Vector2;
  7974. /**
  7975. * When set, the up vector of the camera will be updated by the rotation of the camera
  7976. */
  7977. updateUpVectorFromRotation: boolean;
  7978. private _tmpQuaternion;
  7979. /**
  7980. * Define the current rotation of the camera
  7981. */
  7982. rotation: Vector3;
  7983. /**
  7984. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7985. */
  7986. rotationQuaternion: Quaternion;
  7987. /**
  7988. * Define the current speed of the camera
  7989. */
  7990. speed: number;
  7991. /**
  7992. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7993. * around all axis.
  7994. */
  7995. noRotationConstraint: boolean;
  7996. /**
  7997. * Define the current target of the camera as an object or a position.
  7998. */
  7999. lockedTarget: any;
  8000. /** @hidden */
  8001. _currentTarget: Vector3;
  8002. /** @hidden */
  8003. _initialFocalDistance: number;
  8004. /** @hidden */
  8005. _viewMatrix: Matrix;
  8006. /** @hidden */
  8007. _camMatrix: Matrix;
  8008. /** @hidden */
  8009. _cameraTransformMatrix: Matrix;
  8010. /** @hidden */
  8011. _cameraRotationMatrix: Matrix;
  8012. /** @hidden */
  8013. _referencePoint: Vector3;
  8014. /** @hidden */
  8015. _transformedReferencePoint: Vector3;
  8016. protected _globalCurrentTarget: Vector3;
  8017. protected _globalCurrentUpVector: Vector3;
  8018. /** @hidden */
  8019. _reset: () => void;
  8020. private _defaultUp;
  8021. /**
  8022. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8023. * This is the base of the follow, arc rotate cameras and Free camera
  8024. * @see http://doc.babylonjs.com/features/cameras
  8025. * @param name Defines the name of the camera in the scene
  8026. * @param position Defines the start position of the camera in the scene
  8027. * @param scene Defines the scene the camera belongs to
  8028. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8029. */
  8030. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8031. /**
  8032. * Gets the position in front of the camera at a given distance.
  8033. * @param distance The distance from the camera we want the position to be
  8034. * @returns the position
  8035. */
  8036. getFrontPosition(distance: number): Vector3;
  8037. /** @hidden */
  8038. _getLockedTargetPosition(): Nullable<Vector3>;
  8039. private _storedPosition;
  8040. private _storedRotation;
  8041. private _storedRotationQuaternion;
  8042. /**
  8043. * Store current camera state of the camera (fov, position, rotation, etc..)
  8044. * @returns the camera
  8045. */
  8046. storeState(): Camera;
  8047. /**
  8048. * Restored camera state. You must call storeState() first
  8049. * @returns whether it was successful or not
  8050. * @hidden
  8051. */
  8052. _restoreStateValues(): boolean;
  8053. /** @hidden */
  8054. _initCache(): void;
  8055. /** @hidden */
  8056. _updateCache(ignoreParentClass?: boolean): void;
  8057. /** @hidden */
  8058. _isSynchronizedViewMatrix(): boolean;
  8059. /** @hidden */
  8060. _computeLocalCameraSpeed(): number;
  8061. /**
  8062. * Defines the target the camera should look at.
  8063. * @param target Defines the new target as a Vector or a mesh
  8064. */
  8065. setTarget(target: Vector3): void;
  8066. /**
  8067. * Return the current target position of the camera. This value is expressed in local space.
  8068. * @returns the target position
  8069. */
  8070. getTarget(): Vector3;
  8071. /** @hidden */
  8072. _decideIfNeedsToMove(): boolean;
  8073. /** @hidden */
  8074. _updatePosition(): void;
  8075. /** @hidden */
  8076. _checkInputs(): void;
  8077. protected _updateCameraRotationMatrix(): void;
  8078. /**
  8079. * 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)
  8080. * @returns the current camera
  8081. */
  8082. private _rotateUpVectorWithCameraRotationMatrix;
  8083. private _cachedRotationZ;
  8084. private _cachedQuaternionRotationZ;
  8085. /** @hidden */
  8086. _getViewMatrix(): Matrix;
  8087. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8088. /**
  8089. * @hidden
  8090. */
  8091. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8092. /**
  8093. * @hidden
  8094. */
  8095. _updateRigCameras(): void;
  8096. private _getRigCamPositionAndTarget;
  8097. /**
  8098. * Gets the current object class name.
  8099. * @return the class name
  8100. */
  8101. getClassName(): string;
  8102. }
  8103. }
  8104. declare module "babylonjs/Cameras/cameraInputsManager" {
  8105. import { Nullable } from "babylonjs/types";
  8106. import { Camera } from "babylonjs/Cameras/camera";
  8107. /**
  8108. * @ignore
  8109. * This is a list of all the different input types that are available in the application.
  8110. * Fo instance: ArcRotateCameraGamepadInput...
  8111. */
  8112. export var CameraInputTypes: {};
  8113. /**
  8114. * This is the contract to implement in order to create a new input class.
  8115. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8116. */
  8117. export interface ICameraInput<TCamera extends Camera> {
  8118. /**
  8119. * Defines the camera the input is attached to.
  8120. */
  8121. camera: Nullable<TCamera>;
  8122. /**
  8123. * Gets the class name of the current intput.
  8124. * @returns the class name
  8125. */
  8126. getClassName(): string;
  8127. /**
  8128. * Get the friendly name associated with the input class.
  8129. * @returns the input friendly name
  8130. */
  8131. getSimpleName(): string;
  8132. /**
  8133. * Attach the input controls to a specific dom element to get the input from.
  8134. * @param element Defines the element the controls should be listened from
  8135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8136. */
  8137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8138. /**
  8139. * Detach the current controls from the specified dom element.
  8140. * @param element Defines the element to stop listening the inputs from
  8141. */
  8142. detachControl(element: Nullable<HTMLElement>): void;
  8143. /**
  8144. * Update the current camera state depending on the inputs that have been used this frame.
  8145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8146. */
  8147. checkInputs?: () => void;
  8148. }
  8149. /**
  8150. * Represents a map of input types to input instance or input index to input instance.
  8151. */
  8152. export interface CameraInputsMap<TCamera extends Camera> {
  8153. /**
  8154. * Accessor to the input by input type.
  8155. */
  8156. [name: string]: ICameraInput<TCamera>;
  8157. /**
  8158. * Accessor to the input by input index.
  8159. */
  8160. [idx: number]: ICameraInput<TCamera>;
  8161. }
  8162. /**
  8163. * This represents the input manager used within a camera.
  8164. * It helps dealing with all the different kind of input attached to a camera.
  8165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8166. */
  8167. export class CameraInputsManager<TCamera extends Camera> {
  8168. /**
  8169. * Defines the list of inputs attahed to the camera.
  8170. */
  8171. attached: CameraInputsMap<TCamera>;
  8172. /**
  8173. * Defines the dom element the camera is collecting inputs from.
  8174. * This is null if the controls have not been attached.
  8175. */
  8176. attachedElement: Nullable<HTMLElement>;
  8177. /**
  8178. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8179. */
  8180. noPreventDefault: boolean;
  8181. /**
  8182. * Defined the camera the input manager belongs to.
  8183. */
  8184. camera: TCamera;
  8185. /**
  8186. * Update the current camera state depending on the inputs that have been used this frame.
  8187. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8188. */
  8189. checkInputs: () => void;
  8190. /**
  8191. * Instantiate a new Camera Input Manager.
  8192. * @param camera Defines the camera the input manager blongs to
  8193. */
  8194. constructor(camera: TCamera);
  8195. /**
  8196. * Add an input method to a camera
  8197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8198. * @param input camera input method
  8199. */
  8200. add(input: ICameraInput<TCamera>): void;
  8201. /**
  8202. * Remove a specific input method from a camera
  8203. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8204. * @param inputToRemove camera input method
  8205. */
  8206. remove(inputToRemove: ICameraInput<TCamera>): void;
  8207. /**
  8208. * Remove a specific input type from a camera
  8209. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8210. * @param inputType the type of the input to remove
  8211. */
  8212. removeByType(inputType: string): void;
  8213. private _addCheckInputs;
  8214. /**
  8215. * Attach the input controls to the currently attached dom element to listen the events from.
  8216. * @param input Defines the input to attach
  8217. */
  8218. attachInput(input: ICameraInput<TCamera>): void;
  8219. /**
  8220. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8221. * @param element Defines the dom element to collect the events from
  8222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8223. */
  8224. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8225. /**
  8226. * Detach the current manager inputs controls from a specific dom element.
  8227. * @param element Defines the dom element to collect the events from
  8228. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8229. */
  8230. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8231. /**
  8232. * Rebuild the dynamic inputCheck function from the current list of
  8233. * defined inputs in the manager.
  8234. */
  8235. rebuildInputCheck(): void;
  8236. /**
  8237. * Remove all attached input methods from a camera
  8238. */
  8239. clear(): void;
  8240. /**
  8241. * Serialize the current input manager attached to a camera.
  8242. * This ensures than once parsed,
  8243. * the input associated to the camera will be identical to the current ones
  8244. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8245. */
  8246. serialize(serializedCamera: any): void;
  8247. /**
  8248. * Parses an input manager serialized JSON to restore the previous list of inputs
  8249. * and states associated to a camera.
  8250. * @param parsedCamera Defines the JSON to parse
  8251. */
  8252. parse(parsedCamera: any): void;
  8253. }
  8254. }
  8255. declare module "babylonjs/Events/keyboardEvents" {
  8256. /**
  8257. * Gather the list of keyboard event types as constants.
  8258. */
  8259. export class KeyboardEventTypes {
  8260. /**
  8261. * The keydown event is fired when a key becomes active (pressed).
  8262. */
  8263. static readonly KEYDOWN: number;
  8264. /**
  8265. * The keyup event is fired when a key has been released.
  8266. */
  8267. static readonly KEYUP: number;
  8268. }
  8269. /**
  8270. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8271. */
  8272. export class KeyboardInfo {
  8273. /**
  8274. * Defines the type of event (KeyboardEventTypes)
  8275. */
  8276. type: number;
  8277. /**
  8278. * Defines the related dom event
  8279. */
  8280. event: KeyboardEvent;
  8281. /**
  8282. * Instantiates a new keyboard info.
  8283. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8284. * @param type Defines the type of event (KeyboardEventTypes)
  8285. * @param event Defines the related dom event
  8286. */
  8287. constructor(
  8288. /**
  8289. * Defines the type of event (KeyboardEventTypes)
  8290. */
  8291. type: number,
  8292. /**
  8293. * Defines the related dom event
  8294. */
  8295. event: KeyboardEvent);
  8296. }
  8297. /**
  8298. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8299. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8300. */
  8301. export class KeyboardInfoPre extends KeyboardInfo {
  8302. /**
  8303. * Defines the type of event (KeyboardEventTypes)
  8304. */
  8305. type: number;
  8306. /**
  8307. * Defines the related dom event
  8308. */
  8309. event: KeyboardEvent;
  8310. /**
  8311. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8312. */
  8313. skipOnPointerObservable: boolean;
  8314. /**
  8315. * Instantiates a new keyboard pre info.
  8316. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8317. * @param type Defines the type of event (KeyboardEventTypes)
  8318. * @param event Defines the related dom event
  8319. */
  8320. constructor(
  8321. /**
  8322. * Defines the type of event (KeyboardEventTypes)
  8323. */
  8324. type: number,
  8325. /**
  8326. * Defines the related dom event
  8327. */
  8328. event: KeyboardEvent);
  8329. }
  8330. }
  8331. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8332. import { Nullable } from "babylonjs/types";
  8333. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8334. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8335. /**
  8336. * Manage the keyboard inputs to control the movement of a free camera.
  8337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8338. */
  8339. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8340. /**
  8341. * Defines the camera the input is attached to.
  8342. */
  8343. camera: FreeCamera;
  8344. /**
  8345. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8346. */
  8347. keysUp: number[];
  8348. /**
  8349. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8350. */
  8351. keysDown: number[];
  8352. /**
  8353. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8354. */
  8355. keysLeft: number[];
  8356. /**
  8357. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8358. */
  8359. keysRight: number[];
  8360. private _keys;
  8361. private _onCanvasBlurObserver;
  8362. private _onKeyboardObserver;
  8363. private _engine;
  8364. private _scene;
  8365. /**
  8366. * Attach the input controls to a specific dom element to get the input from.
  8367. * @param element Defines the element the controls should be listened from
  8368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8369. */
  8370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8371. /**
  8372. * Detach the current controls from the specified dom element.
  8373. * @param element Defines the element to stop listening the inputs from
  8374. */
  8375. detachControl(element: Nullable<HTMLElement>): void;
  8376. /**
  8377. * Update the current camera state depending on the inputs that have been used this frame.
  8378. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8379. */
  8380. checkInputs(): void;
  8381. /**
  8382. * Gets the class name of the current intput.
  8383. * @returns the class name
  8384. */
  8385. getClassName(): string;
  8386. /** @hidden */
  8387. _onLostFocus(): void;
  8388. /**
  8389. * Get the friendly name associated with the input class.
  8390. * @returns the input friendly name
  8391. */
  8392. getSimpleName(): string;
  8393. }
  8394. }
  8395. declare module "babylonjs/Materials/multiMaterial" {
  8396. import { Nullable } from "babylonjs/types";
  8397. import { Scene } from "babylonjs/scene";
  8398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8399. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  8400. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8401. import { Material } from "babylonjs/Materials/material";
  8402. /**
  8403. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8404. * separate meshes. This can be use to improve performances.
  8405. * @see http://doc.babylonjs.com/how_to/multi_materials
  8406. */
  8407. export class MultiMaterial extends Material {
  8408. private _subMaterials;
  8409. /**
  8410. * Gets or Sets the list of Materials used within the multi material.
  8411. * They need to be ordered according to the submeshes order in the associated mesh
  8412. */
  8413. subMaterials: Nullable<Material>[];
  8414. /**
  8415. * Function used to align with Node.getChildren()
  8416. * @returns the list of Materials used within the multi material
  8417. */
  8418. getChildren(): Nullable<Material>[];
  8419. /**
  8420. * Instantiates a new Multi Material
  8421. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8422. * separate meshes. This can be use to improve performances.
  8423. * @see http://doc.babylonjs.com/how_to/multi_materials
  8424. * @param name Define the name in the scene
  8425. * @param scene Define the scene the material belongs to
  8426. */
  8427. constructor(name: string, scene: Scene);
  8428. private _hookArray;
  8429. /**
  8430. * Get one of the submaterial by its index in the submaterials array
  8431. * @param index The index to look the sub material at
  8432. * @returns The Material if the index has been defined
  8433. */
  8434. getSubMaterial(index: number): Nullable<Material>;
  8435. /**
  8436. * Get the list of active textures for the whole sub materials list.
  8437. * @returns All the textures that will be used during the rendering
  8438. */
  8439. getActiveTextures(): BaseTexture[];
  8440. /**
  8441. * Gets the current class name of the material e.g. "MultiMaterial"
  8442. * Mainly use in serialization.
  8443. * @returns the class name
  8444. */
  8445. getClassName(): string;
  8446. /**
  8447. * Checks if the material is ready to render the requested sub mesh
  8448. * @param mesh Define the mesh the submesh belongs to
  8449. * @param subMesh Define the sub mesh to look readyness for
  8450. * @param useInstances Define whether or not the material is used with instances
  8451. * @returns true if ready, otherwise false
  8452. */
  8453. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8454. /**
  8455. * Clones the current material and its related sub materials
  8456. * @param name Define the name of the newly cloned material
  8457. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8458. * @returns the cloned material
  8459. */
  8460. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8461. /**
  8462. * Serializes the materials into a JSON representation.
  8463. * @returns the JSON representation
  8464. */
  8465. serialize(): any;
  8466. /**
  8467. * Dispose the material and release its associated resources
  8468. * @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)
  8469. * @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)
  8470. * @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)
  8471. */
  8472. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8473. /**
  8474. * Creates a MultiMaterial from parsed MultiMaterial data.
  8475. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8476. * @param scene defines the hosting scene
  8477. * @returns a new MultiMaterial
  8478. */
  8479. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8480. }
  8481. }
  8482. declare module "babylonjs/Loading/sceneLoaderFlags" {
  8483. /**
  8484. * Class used to represent data loading progression
  8485. */
  8486. export class SceneLoaderFlags {
  8487. private static _ForceFullSceneLoadingForIncremental;
  8488. private static _ShowLoadingScreen;
  8489. private static _CleanBoneMatrixWeights;
  8490. private static _loggingLevel;
  8491. /**
  8492. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8493. */
  8494. static ForceFullSceneLoadingForIncremental: boolean;
  8495. /**
  8496. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8497. */
  8498. static ShowLoadingScreen: boolean;
  8499. /**
  8500. * Defines the current logging level (while loading the scene)
  8501. * @ignorenaming
  8502. */
  8503. static loggingLevel: number;
  8504. /**
  8505. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8506. */
  8507. static CleanBoneMatrixWeights: boolean;
  8508. }
  8509. }
  8510. declare module "babylonjs/Meshes/transformNode" {
  8511. import { DeepImmutable } from "babylonjs/types";
  8512. import { Observable } from "babylonjs/Misc/observable";
  8513. import { Nullable } from "babylonjs/types";
  8514. import { Camera } from "babylonjs/Cameras/camera";
  8515. import { Scene } from "babylonjs/scene";
  8516. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  8517. import { Node } from "babylonjs/node";
  8518. import { Bone } from "babylonjs/Bones/bone";
  8519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8520. /**
  8521. * 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.
  8522. * @see https://doc.babylonjs.com/how_to/transformnode
  8523. */
  8524. export class TransformNode extends Node {
  8525. /**
  8526. * Object will not rotate to face the camera
  8527. */
  8528. static BILLBOARDMODE_NONE: number;
  8529. /**
  8530. * Object will rotate to face the camera but only on the x axis
  8531. */
  8532. static BILLBOARDMODE_X: number;
  8533. /**
  8534. * Object will rotate to face the camera but only on the y axis
  8535. */
  8536. static BILLBOARDMODE_Y: number;
  8537. /**
  8538. * Object will rotate to face the camera but only on the z axis
  8539. */
  8540. static BILLBOARDMODE_Z: number;
  8541. /**
  8542. * Object will rotate to face the camera
  8543. */
  8544. static BILLBOARDMODE_ALL: number;
  8545. private _forward;
  8546. private _forwardInverted;
  8547. private _up;
  8548. private _right;
  8549. private _rightInverted;
  8550. private _position;
  8551. private _rotation;
  8552. private _rotationQuaternion;
  8553. protected _scaling: Vector3;
  8554. protected _isDirty: boolean;
  8555. private _transformToBoneReferal;
  8556. private _billboardMode;
  8557. /**
  8558. * Gets or sets the billboard mode. Default is 0.
  8559. *
  8560. * | Value | Type | Description |
  8561. * | --- | --- | --- |
  8562. * | 0 | BILLBOARDMODE_NONE | |
  8563. * | 1 | BILLBOARDMODE_X | |
  8564. * | 2 | BILLBOARDMODE_Y | |
  8565. * | 4 | BILLBOARDMODE_Z | |
  8566. * | 7 | BILLBOARDMODE_ALL | |
  8567. *
  8568. */
  8569. billboardMode: number;
  8570. private _preserveParentRotationForBillboard;
  8571. /**
  8572. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8573. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8574. */
  8575. preserveParentRotationForBillboard: boolean;
  8576. /**
  8577. * 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
  8578. */
  8579. scalingDeterminant: number;
  8580. private _infiniteDistance;
  8581. /**
  8582. * Gets or sets the distance of the object to max, often used by skybox
  8583. */
  8584. infiniteDistance: boolean;
  8585. /**
  8586. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8587. * By default the system will update normals to compensate
  8588. */
  8589. ignoreNonUniformScaling: boolean;
  8590. /**
  8591. * 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
  8592. */
  8593. reIntegrateRotationIntoRotationQuaternion: boolean;
  8594. /** @hidden */
  8595. _poseMatrix: Nullable<Matrix>;
  8596. /** @hidden */
  8597. _localMatrix: Matrix;
  8598. private _usePivotMatrix;
  8599. private _absolutePosition;
  8600. private _pivotMatrix;
  8601. private _pivotMatrixInverse;
  8602. protected _postMultiplyPivotMatrix: boolean;
  8603. protected _isWorldMatrixFrozen: boolean;
  8604. /** @hidden */
  8605. _indexInSceneTransformNodesArray: number;
  8606. /**
  8607. * An event triggered after the world matrix is updated
  8608. */
  8609. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8610. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8611. /**
  8612. * Gets a string identifying the name of the class
  8613. * @returns "TransformNode" string
  8614. */
  8615. getClassName(): string;
  8616. /**
  8617. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8618. */
  8619. position: Vector3;
  8620. /**
  8621. * 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)).
  8622. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8623. */
  8624. rotation: Vector3;
  8625. /**
  8626. * 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)).
  8627. */
  8628. scaling: Vector3;
  8629. /**
  8630. * 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).
  8631. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8632. */
  8633. rotationQuaternion: Nullable<Quaternion>;
  8634. /**
  8635. * The forward direction of that transform in world space.
  8636. */
  8637. readonly forward: Vector3;
  8638. /**
  8639. * The up direction of that transform in world space.
  8640. */
  8641. readonly up: Vector3;
  8642. /**
  8643. * The right direction of that transform in world space.
  8644. */
  8645. readonly right: Vector3;
  8646. /**
  8647. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8648. * @param matrix the matrix to copy the pose from
  8649. * @returns this TransformNode.
  8650. */
  8651. updatePoseMatrix(matrix: Matrix): TransformNode;
  8652. /**
  8653. * Returns the mesh Pose matrix.
  8654. * @returns the pose matrix
  8655. */
  8656. getPoseMatrix(): Matrix;
  8657. /** @hidden */
  8658. _isSynchronized(): boolean;
  8659. /** @hidden */
  8660. _initCache(): void;
  8661. /**
  8662. * Flag the transform node as dirty (Forcing it to update everything)
  8663. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8664. * @returns this transform node
  8665. */
  8666. markAsDirty(property: string): TransformNode;
  8667. /**
  8668. * Returns the current mesh absolute position.
  8669. * Returns a Vector3.
  8670. */
  8671. readonly absolutePosition: Vector3;
  8672. /**
  8673. * Sets a new matrix to apply before all other transformation
  8674. * @param matrix defines the transform matrix
  8675. * @returns the current TransformNode
  8676. */
  8677. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8678. /**
  8679. * Sets a new pivot matrix to the current node
  8680. * @param matrix defines the new pivot matrix to use
  8681. * @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
  8682. * @returns the current TransformNode
  8683. */
  8684. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8685. /**
  8686. * Returns the mesh pivot matrix.
  8687. * Default : Identity.
  8688. * @returns the matrix
  8689. */
  8690. getPivotMatrix(): Matrix;
  8691. /**
  8692. * Prevents the World matrix to be computed any longer.
  8693. * @returns the TransformNode.
  8694. */
  8695. freezeWorldMatrix(): TransformNode;
  8696. /**
  8697. * Allows back the World matrix computation.
  8698. * @returns the TransformNode.
  8699. */
  8700. unfreezeWorldMatrix(): this;
  8701. /**
  8702. * True if the World matrix has been frozen.
  8703. */
  8704. readonly isWorldMatrixFrozen: boolean;
  8705. /**
  8706. * Retuns the mesh absolute position in the World.
  8707. * @returns a Vector3.
  8708. */
  8709. getAbsolutePosition(): Vector3;
  8710. /**
  8711. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8712. * @param absolutePosition the absolute position to set
  8713. * @returns the TransformNode.
  8714. */
  8715. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8716. /**
  8717. * Sets the mesh position in its local space.
  8718. * @param vector3 the position to set in localspace
  8719. * @returns the TransformNode.
  8720. */
  8721. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8722. /**
  8723. * Returns the mesh position in the local space from the current World matrix values.
  8724. * @returns a new Vector3.
  8725. */
  8726. getPositionExpressedInLocalSpace(): Vector3;
  8727. /**
  8728. * Translates the mesh along the passed Vector3 in its local space.
  8729. * @param vector3 the distance to translate in localspace
  8730. * @returns the TransformNode.
  8731. */
  8732. locallyTranslate(vector3: Vector3): TransformNode;
  8733. private static _lookAtVectorCache;
  8734. /**
  8735. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8736. * @param targetPoint the position (must be in same space as current mesh) to look at
  8737. * @param yawCor optional yaw (y-axis) correction in radians
  8738. * @param pitchCor optional pitch (x-axis) correction in radians
  8739. * @param rollCor optional roll (z-axis) correction in radians
  8740. * @param space the choosen space of the target
  8741. * @returns the TransformNode.
  8742. */
  8743. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8744. /**
  8745. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8746. * This Vector3 is expressed in the World space.
  8747. * @param localAxis axis to rotate
  8748. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8749. */
  8750. getDirection(localAxis: Vector3): Vector3;
  8751. /**
  8752. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8753. * localAxis is expressed in the mesh local space.
  8754. * result is computed in the Wordl space from the mesh World matrix.
  8755. * @param localAxis axis to rotate
  8756. * @param result the resulting transformnode
  8757. * @returns this TransformNode.
  8758. */
  8759. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8760. /**
  8761. * Sets this transform node rotation to the given local axis.
  8762. * @param localAxis the axis in local space
  8763. * @param yawCor optional yaw (y-axis) correction in radians
  8764. * @param pitchCor optional pitch (x-axis) correction in radians
  8765. * @param rollCor optional roll (z-axis) correction in radians
  8766. * @returns this TransformNode
  8767. */
  8768. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8769. /**
  8770. * Sets a new pivot point to the current node
  8771. * @param point defines the new pivot point to use
  8772. * @param space defines if the point is in world or local space (local by default)
  8773. * @returns the current TransformNode
  8774. */
  8775. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8776. /**
  8777. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8778. * @returns the pivot point
  8779. */
  8780. getPivotPoint(): Vector3;
  8781. /**
  8782. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8783. * @param result the vector3 to store the result
  8784. * @returns this TransformNode.
  8785. */
  8786. getPivotPointToRef(result: Vector3): TransformNode;
  8787. /**
  8788. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8789. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8790. */
  8791. getAbsolutePivotPoint(): Vector3;
  8792. /**
  8793. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8794. * @param result vector3 to store the result
  8795. * @returns this TransformNode.
  8796. */
  8797. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8798. /**
  8799. * Defines the passed node as the parent of the current node.
  8800. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8801. * @see https://doc.babylonjs.com/how_to/parenting
  8802. * @param node the node ot set as the parent
  8803. * @returns this TransformNode.
  8804. */
  8805. setParent(node: Nullable<Node>): TransformNode;
  8806. private _nonUniformScaling;
  8807. /**
  8808. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8809. */
  8810. readonly nonUniformScaling: boolean;
  8811. /** @hidden */
  8812. _updateNonUniformScalingState(value: boolean): boolean;
  8813. /**
  8814. * Attach the current TransformNode to another TransformNode associated with a bone
  8815. * @param bone Bone affecting the TransformNode
  8816. * @param affectedTransformNode TransformNode associated with the bone
  8817. * @returns this object
  8818. */
  8819. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8820. /**
  8821. * Detach the transform node if its associated with a bone
  8822. * @returns this object
  8823. */
  8824. detachFromBone(): TransformNode;
  8825. private static _rotationAxisCache;
  8826. /**
  8827. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8828. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8829. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8830. * The passed axis is also normalized.
  8831. * @param axis the axis to rotate around
  8832. * @param amount the amount to rotate in radians
  8833. * @param space Space to rotate in (Default: local)
  8834. * @returns the TransformNode.
  8835. */
  8836. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8837. /**
  8838. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8839. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8840. * The passed axis is also normalized. .
  8841. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8842. * @param point the point to rotate around
  8843. * @param axis the axis to rotate around
  8844. * @param amount the amount to rotate in radians
  8845. * @returns the TransformNode
  8846. */
  8847. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8848. /**
  8849. * Translates the mesh along the axis vector for the passed distance in the given space.
  8850. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8851. * @param axis the axis to translate in
  8852. * @param distance the distance to translate
  8853. * @param space Space to rotate in (Default: local)
  8854. * @returns the TransformNode.
  8855. */
  8856. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8857. /**
  8858. * Adds a rotation step to the mesh current rotation.
  8859. * x, y, z are Euler angles expressed in radians.
  8860. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8861. * This means this rotation is made in the mesh local space only.
  8862. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8863. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8864. * ```javascript
  8865. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8866. * ```
  8867. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8868. * 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.
  8869. * @param x Rotation to add
  8870. * @param y Rotation to add
  8871. * @param z Rotation to add
  8872. * @returns the TransformNode.
  8873. */
  8874. addRotation(x: number, y: number, z: number): TransformNode;
  8875. /**
  8876. * @hidden
  8877. */
  8878. protected _getEffectiveParent(): Nullable<Node>;
  8879. /**
  8880. * Computes the world matrix of the node
  8881. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8882. * @returns the world matrix
  8883. */
  8884. computeWorldMatrix(force?: boolean): Matrix;
  8885. protected _afterComputeWorldMatrix(): void;
  8886. /**
  8887. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8888. * @param func callback function to add
  8889. *
  8890. * @returns the TransformNode.
  8891. */
  8892. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8893. /**
  8894. * Removes a registered callback function.
  8895. * @param func callback function to remove
  8896. * @returns the TransformNode.
  8897. */
  8898. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8899. /**
  8900. * Gets the position of the current mesh in camera space
  8901. * @param camera defines the camera to use
  8902. * @returns a position
  8903. */
  8904. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8905. /**
  8906. * Returns the distance from the mesh to the active camera
  8907. * @param camera defines the camera to use
  8908. * @returns the distance
  8909. */
  8910. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8911. /**
  8912. * Clone the current transform node
  8913. * @param name Name of the new clone
  8914. * @param newParent New parent for the clone
  8915. * @param doNotCloneChildren Do not clone children hierarchy
  8916. * @returns the new transform node
  8917. */
  8918. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8919. /**
  8920. * Serializes the objects information.
  8921. * @param currentSerializationObject defines the object to serialize in
  8922. * @returns the serialized object
  8923. */
  8924. serialize(currentSerializationObject?: any): any;
  8925. /**
  8926. * Returns a new TransformNode object parsed from the source provided.
  8927. * @param parsedTransformNode is the source.
  8928. * @param scene the scne the object belongs to
  8929. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8930. * @returns a new TransformNode object parsed from the source provided.
  8931. */
  8932. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8933. /**
  8934. * Get all child-transformNodes of this node
  8935. * @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
  8936. * @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
  8937. * @returns an array of TransformNode
  8938. */
  8939. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8940. /**
  8941. * Releases resources associated with this transform node.
  8942. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8943. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8944. */
  8945. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8946. /**
  8947. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8948. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8949. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8950. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8951. * @returns the current mesh
  8952. */
  8953. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8954. }
  8955. }
  8956. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8957. /**
  8958. * Class used to override all child animations of a given target
  8959. */
  8960. export class AnimationPropertiesOverride {
  8961. /**
  8962. * Gets or sets a value indicating if animation blending must be used
  8963. */
  8964. enableBlending: boolean;
  8965. /**
  8966. * Gets or sets the blending speed to use when enableBlending is true
  8967. */
  8968. blendingSpeed: number;
  8969. /**
  8970. * Gets or sets the default loop mode to use
  8971. */
  8972. loopMode: number;
  8973. }
  8974. }
  8975. declare module "babylonjs/Bones/bone" {
  8976. import { Skeleton } from "babylonjs/Bones/skeleton";
  8977. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8978. import { Nullable } from "babylonjs/types";
  8979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8980. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8981. import { Node } from "babylonjs/node";
  8982. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8983. /**
  8984. * Class used to store bone information
  8985. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8986. */
  8987. export class Bone extends Node {
  8988. /**
  8989. * defines the bone name
  8990. */
  8991. name: string;
  8992. private static _tmpVecs;
  8993. private static _tmpQuat;
  8994. private static _tmpMats;
  8995. /**
  8996. * Gets the list of child bones
  8997. */
  8998. children: Bone[];
  8999. /** Gets the animations associated with this bone */
  9000. animations: import("babylonjs/Animations/animation").Animation[];
  9001. /**
  9002. * Gets or sets bone length
  9003. */
  9004. length: number;
  9005. /**
  9006. * @hidden Internal only
  9007. * Set this value to map this bone to a different index in the transform matrices
  9008. * Set this value to -1 to exclude the bone from the transform matrices
  9009. */
  9010. _index: Nullable<number>;
  9011. private _skeleton;
  9012. private _localMatrix;
  9013. private _restPose;
  9014. private _baseMatrix;
  9015. private _absoluteTransform;
  9016. private _invertedAbsoluteTransform;
  9017. private _parent;
  9018. private _scalingDeterminant;
  9019. private _worldTransform;
  9020. private _localScaling;
  9021. private _localRotation;
  9022. private _localPosition;
  9023. private _needToDecompose;
  9024. private _needToCompose;
  9025. /** @hidden */
  9026. _linkedTransformNode: Nullable<TransformNode>;
  9027. /** @hidden */
  9028. _waitingTransformNodeId: Nullable<string>;
  9029. /** @hidden */
  9030. /** @hidden */
  9031. _matrix: Matrix;
  9032. /**
  9033. * Create a new bone
  9034. * @param name defines the bone name
  9035. * @param skeleton defines the parent skeleton
  9036. * @param parentBone defines the parent (can be null if the bone is the root)
  9037. * @param localMatrix defines the local matrix
  9038. * @param restPose defines the rest pose matrix
  9039. * @param baseMatrix defines the base matrix
  9040. * @param index defines index of the bone in the hiearchy
  9041. */
  9042. constructor(
  9043. /**
  9044. * defines the bone name
  9045. */
  9046. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9047. /**
  9048. * Gets the current object class name.
  9049. * @return the class name
  9050. */
  9051. getClassName(): string;
  9052. /**
  9053. * Gets the parent skeleton
  9054. * @returns a skeleton
  9055. */
  9056. getSkeleton(): Skeleton;
  9057. /**
  9058. * Gets parent bone
  9059. * @returns a bone or null if the bone is the root of the bone hierarchy
  9060. */
  9061. getParent(): Nullable<Bone>;
  9062. /**
  9063. * Returns an array containing the root bones
  9064. * @returns an array containing the root bones
  9065. */
  9066. getChildren(): Array<Bone>;
  9067. /**
  9068. * Sets the parent bone
  9069. * @param parent defines the parent (can be null if the bone is the root)
  9070. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9071. */
  9072. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9073. /**
  9074. * Gets the local matrix
  9075. * @returns a matrix
  9076. */
  9077. getLocalMatrix(): Matrix;
  9078. /**
  9079. * Gets the base matrix (initial matrix which remains unchanged)
  9080. * @returns a matrix
  9081. */
  9082. getBaseMatrix(): Matrix;
  9083. /**
  9084. * Gets the rest pose matrix
  9085. * @returns a matrix
  9086. */
  9087. getRestPose(): Matrix;
  9088. /**
  9089. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9090. */
  9091. getWorldMatrix(): Matrix;
  9092. /**
  9093. * Sets the local matrix to rest pose matrix
  9094. */
  9095. returnToRest(): void;
  9096. /**
  9097. * Gets the inverse of the absolute transform matrix.
  9098. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9099. * @returns a matrix
  9100. */
  9101. getInvertedAbsoluteTransform(): Matrix;
  9102. /**
  9103. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9104. * @returns a matrix
  9105. */
  9106. getAbsoluteTransform(): Matrix;
  9107. /**
  9108. * Links with the given transform node.
  9109. * The local matrix of this bone is copied from the transform node every frame.
  9110. * @param transformNode defines the transform node to link to
  9111. */
  9112. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9113. /** Gets or sets current position (in local space) */
  9114. position: Vector3;
  9115. /** Gets or sets current rotation (in local space) */
  9116. rotation: Vector3;
  9117. /** Gets or sets current rotation quaternion (in local space) */
  9118. rotationQuaternion: Quaternion;
  9119. /** Gets or sets current scaling (in local space) */
  9120. scaling: Vector3;
  9121. /**
  9122. * Gets the animation properties override
  9123. */
  9124. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9125. private _decompose;
  9126. private _compose;
  9127. /**
  9128. * Update the base and local matrices
  9129. * @param matrix defines the new base or local matrix
  9130. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9131. * @param updateLocalMatrix defines if the local matrix should be updated
  9132. */
  9133. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9134. /** @hidden */
  9135. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9136. /**
  9137. * Flag the bone as dirty (Forcing it to update everything)
  9138. */
  9139. markAsDirty(): void;
  9140. /** @hidden */
  9141. _markAsDirtyAndCompose(): void;
  9142. private _markAsDirtyAndDecompose;
  9143. /**
  9144. * Translate the bone in local or world space
  9145. * @param vec The amount to translate the bone
  9146. * @param space The space that the translation is in
  9147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9148. */
  9149. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9150. /**
  9151. * Set the postion of the bone in local or world space
  9152. * @param position The position to set the bone
  9153. * @param space The space that the position is in
  9154. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9155. */
  9156. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9157. /**
  9158. * Set the absolute position of the bone (world space)
  9159. * @param position The position to set the bone
  9160. * @param mesh The mesh that this bone is attached to
  9161. */
  9162. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9163. /**
  9164. * Scale the bone on the x, y and z axes (in local space)
  9165. * @param x The amount to scale the bone on the x axis
  9166. * @param y The amount to scale the bone on the y axis
  9167. * @param z The amount to scale the bone on the z axis
  9168. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9169. */
  9170. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9171. /**
  9172. * Set the bone scaling in local space
  9173. * @param scale defines the scaling vector
  9174. */
  9175. setScale(scale: Vector3): void;
  9176. /**
  9177. * Gets the current scaling in local space
  9178. * @returns the current scaling vector
  9179. */
  9180. getScale(): Vector3;
  9181. /**
  9182. * Gets the current scaling in local space and stores it in a target vector
  9183. * @param result defines the target vector
  9184. */
  9185. getScaleToRef(result: Vector3): void;
  9186. /**
  9187. * Set the yaw, pitch, and roll of the bone in local or world space
  9188. * @param yaw The rotation of the bone on the y axis
  9189. * @param pitch The rotation of the bone on the x axis
  9190. * @param roll The rotation of the bone on the z axis
  9191. * @param space The space that the axes of rotation are in
  9192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9193. */
  9194. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9195. /**
  9196. * Add a rotation to the bone on an axis in local or world space
  9197. * @param axis The axis to rotate the bone on
  9198. * @param amount The amount to rotate the bone
  9199. * @param space The space that the axis is in
  9200. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9201. */
  9202. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9203. /**
  9204. * Set the rotation of the bone to a particular axis angle in local or world space
  9205. * @param axis The axis to rotate the bone on
  9206. * @param angle The angle that the bone should be rotated to
  9207. * @param space The space that the axis is in
  9208. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9209. */
  9210. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9211. /**
  9212. * Set the euler rotation of the bone in local of world space
  9213. * @param rotation The euler rotation that the bone should be set to
  9214. * @param space The space that the rotation is in
  9215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9216. */
  9217. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9218. /**
  9219. * Set the quaternion rotation of the bone in local of world space
  9220. * @param quat The quaternion rotation that the bone should be set to
  9221. * @param space The space that the rotation is in
  9222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9223. */
  9224. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9225. /**
  9226. * Set the rotation matrix of the bone in local of world space
  9227. * @param rotMat The rotation matrix that the bone should be set to
  9228. * @param space The space that the rotation is in
  9229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9230. */
  9231. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9232. private _rotateWithMatrix;
  9233. private _getNegativeRotationToRef;
  9234. /**
  9235. * Get the position of the bone in local or world space
  9236. * @param space The space that the returned position is in
  9237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9238. * @returns The position of the bone
  9239. */
  9240. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9241. /**
  9242. * Copy the position of the bone to a vector3 in local or world space
  9243. * @param space The space that the returned position is in
  9244. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9245. * @param result The vector3 to copy the position to
  9246. */
  9247. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9248. /**
  9249. * Get the absolute position of the bone (world space)
  9250. * @param mesh The mesh that this bone is attached to
  9251. * @returns The absolute position of the bone
  9252. */
  9253. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9254. /**
  9255. * Copy the absolute position of the bone (world space) to the result param
  9256. * @param mesh The mesh that this bone is attached to
  9257. * @param result The vector3 to copy the absolute position to
  9258. */
  9259. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9260. /**
  9261. * Compute the absolute transforms of this bone and its children
  9262. */
  9263. computeAbsoluteTransforms(): void;
  9264. /**
  9265. * Get the world direction from an axis that is in the local space of the bone
  9266. * @param localAxis The local direction that is used to compute the world direction
  9267. * @param mesh The mesh that this bone is attached to
  9268. * @returns The world direction
  9269. */
  9270. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9271. /**
  9272. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9273. * @param localAxis The local direction that is used to compute the world direction
  9274. * @param mesh The mesh that this bone is attached to
  9275. * @param result The vector3 that the world direction will be copied to
  9276. */
  9277. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9278. /**
  9279. * Get the euler rotation of the bone in local or world space
  9280. * @param space The space that the rotation should be in
  9281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9282. * @returns The euler rotation
  9283. */
  9284. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9285. /**
  9286. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9287. * @param space The space that the rotation should be in
  9288. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9289. * @param result The vector3 that the rotation should be copied to
  9290. */
  9291. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9292. /**
  9293. * Get the quaternion rotation of the bone in either local or world space
  9294. * @param space The space that the rotation should be in
  9295. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9296. * @returns The quaternion rotation
  9297. */
  9298. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9299. /**
  9300. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9301. * @param space The space that the rotation should be in
  9302. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9303. * @param result The quaternion that the rotation should be copied to
  9304. */
  9305. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9306. /**
  9307. * Get the rotation matrix of the bone in local or world space
  9308. * @param space The space that the rotation should be in
  9309. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9310. * @returns The rotation matrix
  9311. */
  9312. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9313. /**
  9314. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9315. * @param space The space that the rotation should be in
  9316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9317. * @param result The quaternion that the rotation should be copied to
  9318. */
  9319. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9320. /**
  9321. * Get the world position of a point that is in the local space of the bone
  9322. * @param position The local position
  9323. * @param mesh The mesh that this bone is attached to
  9324. * @returns The world position
  9325. */
  9326. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9327. /**
  9328. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9329. * @param position The local position
  9330. * @param mesh The mesh that this bone is attached to
  9331. * @param result The vector3 that the world position should be copied to
  9332. */
  9333. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9334. /**
  9335. * Get the local position of a point that is in world space
  9336. * @param position The world position
  9337. * @param mesh The mesh that this bone is attached to
  9338. * @returns The local position
  9339. */
  9340. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9341. /**
  9342. * Get the local position of a point that is in world space and copy it to the result param
  9343. * @param position The world position
  9344. * @param mesh The mesh that this bone is attached to
  9345. * @param result The vector3 that the local position should be copied to
  9346. */
  9347. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9348. }
  9349. }
  9350. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  9351. import { Nullable } from "babylonjs/types";
  9352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  9353. import { Scene } from "babylonjs/scene";
  9354. module "babylonjs/Engines/engine" {
  9355. interface Engine {
  9356. /**
  9357. * Creates a raw texture
  9358. * @param data defines the data to store in the texture
  9359. * @param width defines the width of the texture
  9360. * @param height defines the height of the texture
  9361. * @param format defines the format of the data
  9362. * @param generateMipMaps defines if the engine should generate the mip levels
  9363. * @param invertY defines if data must be stored with Y axis inverted
  9364. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9365. * @param compression defines the compression used (null by default)
  9366. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9367. * @returns the raw texture inside an InternalTexture
  9368. */
  9369. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9370. /**
  9371. * Update a raw texture
  9372. * @param texture defines the texture to update
  9373. * @param data defines the data to store in the texture
  9374. * @param format defines the format of the data
  9375. * @param invertY defines if data must be stored with Y axis inverted
  9376. */
  9377. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9378. /**
  9379. * Update a raw texture
  9380. * @param texture defines the texture to update
  9381. * @param data defines the data to store in the texture
  9382. * @param format defines the format of the data
  9383. * @param invertY defines if data must be stored with Y axis inverted
  9384. * @param compression defines the compression used (null by default)
  9385. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9386. */
  9387. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9388. /**
  9389. * Creates a new raw cube texture
  9390. * @param data defines the array of data to use to create each face
  9391. * @param size defines the size of the textures
  9392. * @param format defines the format of the data
  9393. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9394. * @param generateMipMaps defines if the engine should generate the mip levels
  9395. * @param invertY defines if data must be stored with Y axis inverted
  9396. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9397. * @param compression defines the compression used (null by default)
  9398. * @returns the cube texture as an InternalTexture
  9399. */
  9400. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9401. /**
  9402. * Update a raw cube texture
  9403. * @param texture defines the texture to udpdate
  9404. * @param data defines the data to store
  9405. * @param format defines the data format
  9406. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9407. * @param invertY defines if data must be stored with Y axis inverted
  9408. */
  9409. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9410. /**
  9411. * Update a raw cube texture
  9412. * @param texture defines the texture to udpdate
  9413. * @param data defines the data to store
  9414. * @param format defines the data format
  9415. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9416. * @param invertY defines if data must be stored with Y axis inverted
  9417. * @param compression defines the compression used (null by default)
  9418. */
  9419. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9420. /**
  9421. * Update a raw cube texture
  9422. * @param texture defines the texture to udpdate
  9423. * @param data defines the data to store
  9424. * @param format defines the data format
  9425. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9426. * @param invertY defines if data must be stored with Y axis inverted
  9427. * @param compression defines the compression used (null by default)
  9428. * @param level defines which level of the texture to update
  9429. */
  9430. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9431. /**
  9432. * Creates a new raw cube texture from a specified url
  9433. * @param url defines the url where the data is located
  9434. * @param scene defines the current scene
  9435. * @param size defines the size of the textures
  9436. * @param format defines the format of the data
  9437. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9438. * @param noMipmap defines if the engine should avoid generating the mip levels
  9439. * @param callback defines a callback used to extract texture data from loaded data
  9440. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9441. * @param onLoad defines a callback called when texture is loaded
  9442. * @param onError defines a callback called if there is an error
  9443. * @returns the cube texture as an InternalTexture
  9444. */
  9445. 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;
  9446. /**
  9447. * Creates a new raw cube texture from a specified url
  9448. * @param url defines the url where the data is located
  9449. * @param scene defines the current scene
  9450. * @param size defines the size of the textures
  9451. * @param format defines the format of the data
  9452. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9453. * @param noMipmap defines if the engine should avoid generating the mip levels
  9454. * @param callback defines a callback used to extract texture data from loaded data
  9455. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9456. * @param onLoad defines a callback called when texture is loaded
  9457. * @param onError defines a callback called if there is an error
  9458. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9459. * @param invertY defines if data must be stored with Y axis inverted
  9460. * @returns the cube texture as an InternalTexture
  9461. */
  9462. 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;
  9463. /**
  9464. * Creates a new raw 3D texture
  9465. * @param data defines the data used to create the texture
  9466. * @param width defines the width of the texture
  9467. * @param height defines the height of the texture
  9468. * @param depth defines the depth of the texture
  9469. * @param format defines the format of the texture
  9470. * @param generateMipMaps defines if the engine must generate mip levels
  9471. * @param invertY defines if data must be stored with Y axis inverted
  9472. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9473. * @param compression defines the compressed used (can be null)
  9474. * @param textureType defines the compressed used (can be null)
  9475. * @returns a new raw 3D texture (stored in an InternalTexture)
  9476. */
  9477. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9478. /**
  9479. * Update a raw 3D texture
  9480. * @param texture defines the texture to update
  9481. * @param data defines the data to store
  9482. * @param format defines the data format
  9483. * @param invertY defines if data must be stored with Y axis inverted
  9484. */
  9485. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9486. /**
  9487. * Update a raw 3D texture
  9488. * @param texture defines the texture to update
  9489. * @param data defines the data to store
  9490. * @param format defines the data format
  9491. * @param invertY defines if data must be stored with Y axis inverted
  9492. * @param compression defines the used compression (can be null)
  9493. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9494. */
  9495. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9496. }
  9497. }
  9498. }
  9499. declare module "babylonjs/Materials/Textures/rawTexture" {
  9500. import { Scene } from "babylonjs/scene";
  9501. import { Texture } from "babylonjs/Materials/Textures/texture";
  9502. import "babylonjs/Engines/Extensions/engine.rawTexture";
  9503. /**
  9504. * Raw texture can help creating a texture directly from an array of data.
  9505. * This can be super useful if you either get the data from an uncompressed source or
  9506. * if you wish to create your texture pixel by pixel.
  9507. */
  9508. export class RawTexture extends Texture {
  9509. /**
  9510. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9511. */
  9512. format: number;
  9513. private _engine;
  9514. /**
  9515. * Instantiates a new RawTexture.
  9516. * Raw texture can help creating a texture directly from an array of data.
  9517. * This can be super useful if you either get the data from an uncompressed source or
  9518. * if you wish to create your texture pixel by pixel.
  9519. * @param data define the array of data to use to create the texture
  9520. * @param width define the width of the texture
  9521. * @param height define the height of the texture
  9522. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9523. * @param scene define the scene the texture belongs to
  9524. * @param generateMipMaps define whether mip maps should be generated or not
  9525. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9526. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9527. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9528. */
  9529. constructor(data: ArrayBufferView, width: number, height: number,
  9530. /**
  9531. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9532. */
  9533. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9534. /**
  9535. * Updates the texture underlying data.
  9536. * @param data Define the new data of the texture
  9537. */
  9538. update(data: ArrayBufferView): void;
  9539. /**
  9540. * Creates a luminance texture from some data.
  9541. * @param data Define the texture data
  9542. * @param width Define the width of the texture
  9543. * @param height Define the height of the texture
  9544. * @param scene Define the scene the texture belongs to
  9545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9548. * @returns the luminance texture
  9549. */
  9550. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9551. /**
  9552. * Creates a luminance alpha texture from some data.
  9553. * @param data Define the texture data
  9554. * @param width Define the width of the texture
  9555. * @param height Define the height of the texture
  9556. * @param scene Define the scene the texture belongs to
  9557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9560. * @returns the luminance alpha texture
  9561. */
  9562. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9563. /**
  9564. * Creates an alpha texture from some data.
  9565. * @param data Define the texture data
  9566. * @param width Define the width of the texture
  9567. * @param height Define the height of the texture
  9568. * @param scene Define the scene the texture belongs to
  9569. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9572. * @returns the alpha texture
  9573. */
  9574. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9575. /**
  9576. * Creates a RGB texture from some data.
  9577. * @param data Define the texture data
  9578. * @param width Define the width of the texture
  9579. * @param height Define the height of the texture
  9580. * @param scene Define the scene the texture belongs to
  9581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9585. * @returns the RGB alpha texture
  9586. */
  9587. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9588. /**
  9589. * Creates a RGBA texture from some data.
  9590. * @param data Define the texture data
  9591. * @param width Define the width of the texture
  9592. * @param height Define the height of the texture
  9593. * @param scene Define the scene the texture belongs to
  9594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9597. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9598. * @returns the RGBA texture
  9599. */
  9600. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9601. /**
  9602. * Creates a R texture from some data.
  9603. * @param data Define the texture data
  9604. * @param width Define the width of the texture
  9605. * @param height Define the height of the texture
  9606. * @param scene Define the scene the texture belongs to
  9607. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9608. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9609. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9610. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9611. * @returns the R texture
  9612. */
  9613. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9614. }
  9615. }
  9616. declare module "babylonjs/Animations/runtimeAnimation" {
  9617. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  9618. import { Animatable } from "babylonjs/Animations/animatable";
  9619. import { Scene } from "babylonjs/scene";
  9620. /**
  9621. * Defines a runtime animation
  9622. */
  9623. export class RuntimeAnimation {
  9624. private _events;
  9625. /**
  9626. * The current frame of the runtime animation
  9627. */
  9628. private _currentFrame;
  9629. /**
  9630. * The animation used by the runtime animation
  9631. */
  9632. private _animation;
  9633. /**
  9634. * The target of the runtime animation
  9635. */
  9636. private _target;
  9637. /**
  9638. * The initiating animatable
  9639. */
  9640. private _host;
  9641. /**
  9642. * The original value of the runtime animation
  9643. */
  9644. private _originalValue;
  9645. /**
  9646. * The original blend value of the runtime animation
  9647. */
  9648. private _originalBlendValue;
  9649. /**
  9650. * The offsets cache of the runtime animation
  9651. */
  9652. private _offsetsCache;
  9653. /**
  9654. * The high limits cache of the runtime animation
  9655. */
  9656. private _highLimitsCache;
  9657. /**
  9658. * Specifies if the runtime animation has been stopped
  9659. */
  9660. private _stopped;
  9661. /**
  9662. * The blending factor of the runtime animation
  9663. */
  9664. private _blendingFactor;
  9665. /**
  9666. * The BabylonJS scene
  9667. */
  9668. private _scene;
  9669. /**
  9670. * The current value of the runtime animation
  9671. */
  9672. private _currentValue;
  9673. /** @hidden */
  9674. _animationState: _IAnimationState;
  9675. /**
  9676. * The active target of the runtime animation
  9677. */
  9678. private _activeTargets;
  9679. private _currentActiveTarget;
  9680. private _directTarget;
  9681. /**
  9682. * The target path of the runtime animation
  9683. */
  9684. private _targetPath;
  9685. /**
  9686. * The weight of the runtime animation
  9687. */
  9688. private _weight;
  9689. /**
  9690. * The ratio offset of the runtime animation
  9691. */
  9692. private _ratioOffset;
  9693. /**
  9694. * The previous delay of the runtime animation
  9695. */
  9696. private _previousDelay;
  9697. /**
  9698. * The previous ratio of the runtime animation
  9699. */
  9700. private _previousRatio;
  9701. private _enableBlending;
  9702. private _keys;
  9703. private _minFrame;
  9704. private _maxFrame;
  9705. private _minValue;
  9706. private _maxValue;
  9707. private _targetIsArray;
  9708. /**
  9709. * Gets the current frame of the runtime animation
  9710. */
  9711. readonly currentFrame: number;
  9712. /**
  9713. * Gets the weight of the runtime animation
  9714. */
  9715. readonly weight: number;
  9716. /**
  9717. * Gets the current value of the runtime animation
  9718. */
  9719. readonly currentValue: any;
  9720. /**
  9721. * Gets the target path of the runtime animation
  9722. */
  9723. readonly targetPath: string;
  9724. /**
  9725. * Gets the actual target of the runtime animation
  9726. */
  9727. readonly target: any;
  9728. /** @hidden */
  9729. _onLoop: () => void;
  9730. /**
  9731. * Create a new RuntimeAnimation object
  9732. * @param target defines the target of the animation
  9733. * @param animation defines the source animation object
  9734. * @param scene defines the hosting scene
  9735. * @param host defines the initiating Animatable
  9736. */
  9737. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9738. private _preparePath;
  9739. /**
  9740. * Gets the animation from the runtime animation
  9741. */
  9742. readonly animation: Animation;
  9743. /**
  9744. * Resets the runtime animation to the beginning
  9745. * @param restoreOriginal defines whether to restore the target property to the original value
  9746. */
  9747. reset(restoreOriginal?: boolean): void;
  9748. /**
  9749. * Specifies if the runtime animation is stopped
  9750. * @returns Boolean specifying if the runtime animation is stopped
  9751. */
  9752. isStopped(): boolean;
  9753. /**
  9754. * Disposes of the runtime animation
  9755. */
  9756. dispose(): void;
  9757. /**
  9758. * Apply the interpolated value to the target
  9759. * @param currentValue defines the value computed by the animation
  9760. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9761. */
  9762. setValue(currentValue: any, weight: number): void;
  9763. private _getOriginalValues;
  9764. private _setValue;
  9765. /**
  9766. * Gets the loop pmode of the runtime animation
  9767. * @returns Loop Mode
  9768. */
  9769. private _getCorrectLoopMode;
  9770. /**
  9771. * Move the current animation to a given frame
  9772. * @param frame defines the frame to move to
  9773. */
  9774. goToFrame(frame: number): void;
  9775. /**
  9776. * @hidden Internal use only
  9777. */
  9778. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9779. /**
  9780. * Execute the current animation
  9781. * @param delay defines the delay to add to the current frame
  9782. * @param from defines the lower bound of the animation range
  9783. * @param to defines the upper bound of the animation range
  9784. * @param loop defines if the current animation must loop
  9785. * @param speedRatio defines the current speed ratio
  9786. * @param weight defines the weight of the animation (default is -1 so no weight)
  9787. * @param onLoop optional callback called when animation loops
  9788. * @returns a boolean indicating if the animation is running
  9789. */
  9790. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9791. }
  9792. }
  9793. declare module "babylonjs/Animations/animatable" {
  9794. import { Animation } from "babylonjs/Animations/animation";
  9795. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  9796. import { Nullable } from "babylonjs/types";
  9797. import { Observable } from "babylonjs/Misc/observable";
  9798. import { Scene } from "babylonjs/scene";
  9799. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  9800. import { Node } from "babylonjs/node";
  9801. /**
  9802. * Class used to store an actual running animation
  9803. */
  9804. export class Animatable {
  9805. /** defines the target object */
  9806. target: any;
  9807. /** defines the starting frame number (default is 0) */
  9808. fromFrame: number;
  9809. /** defines the ending frame number (default is 100) */
  9810. toFrame: number;
  9811. /** defines if the animation must loop (default is false) */
  9812. loopAnimation: boolean;
  9813. /** defines a callback to call when animation ends if it is not looping */
  9814. onAnimationEnd?: (() => void) | null | undefined;
  9815. /** defines a callback to call when animation loops */
  9816. onAnimationLoop?: (() => void) | null | undefined;
  9817. private _localDelayOffset;
  9818. private _pausedDelay;
  9819. private _runtimeAnimations;
  9820. private _paused;
  9821. private _scene;
  9822. private _speedRatio;
  9823. private _weight;
  9824. private _syncRoot;
  9825. /**
  9826. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9827. * This will only apply for non looping animation (default is true)
  9828. */
  9829. disposeOnEnd: boolean;
  9830. /**
  9831. * Gets a boolean indicating if the animation has started
  9832. */
  9833. animationStarted: boolean;
  9834. /**
  9835. * Observer raised when the animation ends
  9836. */
  9837. onAnimationEndObservable: Observable<Animatable>;
  9838. /**
  9839. * Observer raised when the animation loops
  9840. */
  9841. onAnimationLoopObservable: Observable<Animatable>;
  9842. /**
  9843. * Gets the root Animatable used to synchronize and normalize animations
  9844. */
  9845. readonly syncRoot: Nullable<Animatable>;
  9846. /**
  9847. * Gets the current frame of the first RuntimeAnimation
  9848. * Used to synchronize Animatables
  9849. */
  9850. readonly masterFrame: number;
  9851. /**
  9852. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9853. */
  9854. weight: number;
  9855. /**
  9856. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9857. */
  9858. speedRatio: number;
  9859. /**
  9860. * Creates a new Animatable
  9861. * @param scene defines the hosting scene
  9862. * @param target defines the target object
  9863. * @param fromFrame defines the starting frame number (default is 0)
  9864. * @param toFrame defines the ending frame number (default is 100)
  9865. * @param loopAnimation defines if the animation must loop (default is false)
  9866. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9867. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9868. * @param animations defines a group of animation to add to the new Animatable
  9869. * @param onAnimationLoop defines a callback to call when animation loops
  9870. */
  9871. constructor(scene: Scene,
  9872. /** defines the target object */
  9873. target: any,
  9874. /** defines the starting frame number (default is 0) */
  9875. fromFrame?: number,
  9876. /** defines the ending frame number (default is 100) */
  9877. toFrame?: number,
  9878. /** defines if the animation must loop (default is false) */
  9879. loopAnimation?: boolean, speedRatio?: number,
  9880. /** defines a callback to call when animation ends if it is not looping */
  9881. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9882. /** defines a callback to call when animation loops */
  9883. onAnimationLoop?: (() => void) | null | undefined);
  9884. /**
  9885. * Synchronize and normalize current Animatable with a source Animatable
  9886. * This is useful when using animation weights and when animations are not of the same length
  9887. * @param root defines the root Animatable to synchronize with
  9888. * @returns the current Animatable
  9889. */
  9890. syncWith(root: Animatable): Animatable;
  9891. /**
  9892. * Gets the list of runtime animations
  9893. * @returns an array of RuntimeAnimation
  9894. */
  9895. getAnimations(): RuntimeAnimation[];
  9896. /**
  9897. * Adds more animations to the current animatable
  9898. * @param target defines the target of the animations
  9899. * @param animations defines the new animations to add
  9900. */
  9901. appendAnimations(target: any, animations: Animation[]): void;
  9902. /**
  9903. * Gets the source animation for a specific property
  9904. * @param property defines the propertyu to look for
  9905. * @returns null or the source animation for the given property
  9906. */
  9907. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9908. /**
  9909. * Gets the runtime animation for a specific property
  9910. * @param property defines the propertyu to look for
  9911. * @returns null or the runtime animation for the given property
  9912. */
  9913. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9914. /**
  9915. * Resets the animatable to its original state
  9916. */
  9917. reset(): void;
  9918. /**
  9919. * Allows the animatable to blend with current running animations
  9920. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9921. * @param blendingSpeed defines the blending speed to use
  9922. */
  9923. enableBlending(blendingSpeed: number): void;
  9924. /**
  9925. * Disable animation blending
  9926. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9927. */
  9928. disableBlending(): void;
  9929. /**
  9930. * Jump directly to a given frame
  9931. * @param frame defines the frame to jump to
  9932. */
  9933. goToFrame(frame: number): void;
  9934. /**
  9935. * Pause the animation
  9936. */
  9937. pause(): void;
  9938. /**
  9939. * Restart the animation
  9940. */
  9941. restart(): void;
  9942. private _raiseOnAnimationEnd;
  9943. /**
  9944. * Stop and delete the current animation
  9945. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9946. * @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)
  9947. */
  9948. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9949. /**
  9950. * Wait asynchronously for the animation to end
  9951. * @returns a promise which will be fullfilled when the animation ends
  9952. */
  9953. waitAsync(): Promise<Animatable>;
  9954. /** @hidden */
  9955. _animate(delay: number): boolean;
  9956. }
  9957. module "babylonjs/scene" {
  9958. interface Scene {
  9959. /** @hidden */
  9960. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9961. /** @hidden */
  9962. _processLateAnimationBindingsForMatrices(holder: {
  9963. totalWeight: number;
  9964. animations: RuntimeAnimation[];
  9965. originalValue: Matrix;
  9966. }): any;
  9967. /** @hidden */
  9968. _processLateAnimationBindingsForQuaternions(holder: {
  9969. totalWeight: number;
  9970. animations: RuntimeAnimation[];
  9971. originalValue: Quaternion;
  9972. }, refQuaternion: Quaternion): Quaternion;
  9973. /** @hidden */
  9974. _processLateAnimationBindings(): void;
  9975. /**
  9976. * Will start the animation sequence of a given target
  9977. * @param target defines the target
  9978. * @param from defines from which frame should animation start
  9979. * @param to defines until which frame should animation run.
  9980. * @param weight defines the weight to apply to the animation (1.0 by default)
  9981. * @param loop defines if the animation loops
  9982. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9983. * @param onAnimationEnd defines the function to be executed when the animation ends
  9984. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9985. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9986. * @param onAnimationLoop defines the callback to call when an animation loops
  9987. * @returns the animatable object created for this animation
  9988. */
  9989. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9990. /**
  9991. * Will start the animation sequence of a given target
  9992. * @param target defines the target
  9993. * @param from defines from which frame should animation start
  9994. * @param to defines until which frame should animation run.
  9995. * @param loop defines if the animation loops
  9996. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9997. * @param onAnimationEnd defines the function to be executed when the animation ends
  9998. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9999. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10000. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  10001. * @param onAnimationLoop defines the callback to call when an animation loops
  10002. * @returns the animatable object created for this animation
  10003. */
  10004. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  10005. /**
  10006. * Will start the animation sequence of a given target and its hierarchy
  10007. * @param target defines the target
  10008. * @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.
  10009. * @param from defines from which frame should animation start
  10010. * @param to defines until which frame should animation run.
  10011. * @param loop defines if the animation loops
  10012. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  10013. * @param onAnimationEnd defines the function to be executed when the animation ends
  10014. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  10015. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10016. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  10017. * @param onAnimationLoop defines the callback to call when an animation loops
  10018. * @returns the list of created animatables
  10019. */
  10020. 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[];
  10021. /**
  10022. * Begin a new animation on a given node
  10023. * @param target defines the target where the animation will take place
  10024. * @param animations defines the list of animations to start
  10025. * @param from defines the initial value
  10026. * @param to defines the final value
  10027. * @param loop defines if you want animation to loop (off by default)
  10028. * @param speedRatio defines the speed ratio to apply to all animations
  10029. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10030. * @param onAnimationLoop defines the callback to call when an animation loops
  10031. * @returns the list of created animatables
  10032. */
  10033. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  10034. /**
  10035. * Begin a new animation on a given node and its hierarchy
  10036. * @param target defines the root node where the animation will take place
  10037. * @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.
  10038. * @param animations defines the list of animations to start
  10039. * @param from defines the initial value
  10040. * @param to defines the final value
  10041. * @param loop defines if you want animation to loop (off by default)
  10042. * @param speedRatio defines the speed ratio to apply to all animations
  10043. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10044. * @param onAnimationLoop defines the callback to call when an animation loops
  10045. * @returns the list of animatables created for all nodes
  10046. */
  10047. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  10048. /**
  10049. * Gets the animatable associated with a specific target
  10050. * @param target defines the target of the animatable
  10051. * @returns the required animatable if found
  10052. */
  10053. getAnimatableByTarget(target: any): Nullable<Animatable>;
  10054. /**
  10055. * Gets all animatables associated with a given target
  10056. * @param target defines the target to look animatables for
  10057. * @returns an array of Animatables
  10058. */
  10059. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  10060. /**
  10061. * Stops and removes all animations that have been applied to the scene
  10062. */
  10063. stopAllAnimations(): void;
  10064. }
  10065. }
  10066. module "babylonjs/Bones/bone" {
  10067. interface Bone {
  10068. /**
  10069. * Copy an animation range from another bone
  10070. * @param source defines the source bone
  10071. * @param rangeName defines the range name to copy
  10072. * @param frameOffset defines the frame offset
  10073. * @param rescaleAsRequired defines if rescaling must be applied if required
  10074. * @param skelDimensionsRatio defines the scaling ratio
  10075. * @returns true if operation was successful
  10076. */
  10077. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  10078. }
  10079. }
  10080. }
  10081. declare module "babylonjs/Bones/skeleton" {
  10082. import { Bone } from "babylonjs/Bones/bone";
  10083. import { IAnimatable } from "babylonjs/Misc/tools";
  10084. import { Observable } from "babylonjs/Misc/observable";
  10085. import { Vector3, Matrix } from "babylonjs/Maths/math";
  10086. import { Scene } from "babylonjs/scene";
  10087. import { Nullable } from "babylonjs/types";
  10088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10089. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  10090. import { Animatable } from "babylonjs/Animations/animatable";
  10091. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10092. import { Animation } from "babylonjs/Animations/animation";
  10093. import { AnimationRange } from "babylonjs/Animations/animationRange";
  10094. import { IInspectable } from "babylonjs/Misc/iInspectable";
  10095. /**
  10096. * Class used to handle skinning animations
  10097. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  10098. */
  10099. export class Skeleton implements IAnimatable {
  10100. /** defines the skeleton name */
  10101. name: string;
  10102. /** defines the skeleton Id */
  10103. id: string;
  10104. /**
  10105. * Defines the list of child bones
  10106. */
  10107. bones: Bone[];
  10108. /**
  10109. * Defines an estimate of the dimension of the skeleton at rest
  10110. */
  10111. dimensionsAtRest: Vector3;
  10112. /**
  10113. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  10114. */
  10115. needInitialSkinMatrix: boolean;
  10116. /**
  10117. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  10118. */
  10119. overrideMesh: Nullable<AbstractMesh>;
  10120. /**
  10121. * Gets the list of animations attached to this skeleton
  10122. */
  10123. animations: Array<Animation>;
  10124. private _scene;
  10125. private _isDirty;
  10126. private _transformMatrices;
  10127. private _transformMatrixTexture;
  10128. private _meshesWithPoseMatrix;
  10129. private _animatables;
  10130. private _identity;
  10131. private _synchronizedWithMesh;
  10132. private _ranges;
  10133. private _lastAbsoluteTransformsUpdateId;
  10134. private _canUseTextureForBones;
  10135. private _uniqueId;
  10136. /** @hidden */
  10137. _numBonesWithLinkedTransformNode: number;
  10138. /** @hidden */
  10139. _hasWaitingData: Nullable<boolean>;
  10140. /**
  10141. * Specifies if the skeleton should be serialized
  10142. */
  10143. doNotSerialize: boolean;
  10144. private _useTextureToStoreBoneMatrices;
  10145. /**
  10146. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10147. * Please note that this option is not available if the hardware does not support it
  10148. */
  10149. useTextureToStoreBoneMatrices: boolean;
  10150. private _animationPropertiesOverride;
  10151. /**
  10152. * Gets or sets the animation properties override
  10153. */
  10154. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10155. /**
  10156. * List of inspectable custom properties (used by the Inspector)
  10157. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10158. */
  10159. inspectableCustomProperties: IInspectable[];
  10160. /**
  10161. * An observable triggered before computing the skeleton's matrices
  10162. */
  10163. onBeforeComputeObservable: Observable<Skeleton>;
  10164. /**
  10165. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10166. */
  10167. readonly isUsingTextureForMatrices: boolean;
  10168. /**
  10169. * Gets the unique ID of this skeleton
  10170. */
  10171. readonly uniqueId: number;
  10172. /**
  10173. * Creates a new skeleton
  10174. * @param name defines the skeleton name
  10175. * @param id defines the skeleton Id
  10176. * @param scene defines the hosting scene
  10177. */
  10178. constructor(
  10179. /** defines the skeleton name */
  10180. name: string,
  10181. /** defines the skeleton Id */
  10182. id: string, scene: Scene);
  10183. /**
  10184. * Gets the current object class name.
  10185. * @return the class name
  10186. */
  10187. getClassName(): string;
  10188. /**
  10189. * Returns an array containing the root bones
  10190. * @returns an array containing the root bones
  10191. */
  10192. getChildren(): Array<Bone>;
  10193. /**
  10194. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10195. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10196. * @returns a Float32Array containing matrices data
  10197. */
  10198. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10199. /**
  10200. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10201. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10202. * @returns a raw texture containing the data
  10203. */
  10204. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  10205. /**
  10206. * Gets the current hosting scene
  10207. * @returns a scene object
  10208. */
  10209. getScene(): Scene;
  10210. /**
  10211. * Gets a string representing the current skeleton data
  10212. * @param fullDetails defines a boolean indicating if we want a verbose version
  10213. * @returns a string representing the current skeleton data
  10214. */
  10215. toString(fullDetails?: boolean): string;
  10216. /**
  10217. * Get bone's index searching by name
  10218. * @param name defines bone's name to search for
  10219. * @return the indice of the bone. Returns -1 if not found
  10220. */
  10221. getBoneIndexByName(name: string): number;
  10222. /**
  10223. * Creater a new animation range
  10224. * @param name defines the name of the range
  10225. * @param from defines the start key
  10226. * @param to defines the end key
  10227. */
  10228. createAnimationRange(name: string, from: number, to: number): void;
  10229. /**
  10230. * Delete a specific animation range
  10231. * @param name defines the name of the range
  10232. * @param deleteFrames defines if frames must be removed as well
  10233. */
  10234. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10235. /**
  10236. * Gets a specific animation range
  10237. * @param name defines the name of the range to look for
  10238. * @returns the requested animation range or null if not found
  10239. */
  10240. getAnimationRange(name: string): Nullable<AnimationRange>;
  10241. /**
  10242. * Gets the list of all animation ranges defined on this skeleton
  10243. * @returns an array
  10244. */
  10245. getAnimationRanges(): Nullable<AnimationRange>[];
  10246. /**
  10247. * Copy animation range from a source skeleton.
  10248. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10249. * @param source defines the source skeleton
  10250. * @param name defines the name of the range to copy
  10251. * @param rescaleAsRequired defines if rescaling must be applied if required
  10252. * @returns true if operation was successful
  10253. */
  10254. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10255. /**
  10256. * Forces the skeleton to go to rest pose
  10257. */
  10258. returnToRest(): void;
  10259. private _getHighestAnimationFrame;
  10260. /**
  10261. * Begin a specific animation range
  10262. * @param name defines the name of the range to start
  10263. * @param loop defines if looping must be turned on (false by default)
  10264. * @param speedRatio defines the speed ratio to apply (1 by default)
  10265. * @param onAnimationEnd defines a callback which will be called when animation will end
  10266. * @returns a new animatable
  10267. */
  10268. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10269. /** @hidden */
  10270. _markAsDirty(): void;
  10271. /** @hidden */
  10272. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10273. /** @hidden */
  10274. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10275. private _computeTransformMatrices;
  10276. /**
  10277. * Build all resources required to render a skeleton
  10278. */
  10279. prepare(): void;
  10280. /**
  10281. * Gets the list of animatables currently running for this skeleton
  10282. * @returns an array of animatables
  10283. */
  10284. getAnimatables(): IAnimatable[];
  10285. /**
  10286. * Clone the current skeleton
  10287. * @param name defines the name of the new skeleton
  10288. * @param id defines the id of the new skeleton
  10289. * @returns the new skeleton
  10290. */
  10291. clone(name: string, id: string): Skeleton;
  10292. /**
  10293. * Enable animation blending for this skeleton
  10294. * @param blendingSpeed defines the blending speed to apply
  10295. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10296. */
  10297. enableBlending(blendingSpeed?: number): void;
  10298. /**
  10299. * Releases all resources associated with the current skeleton
  10300. */
  10301. dispose(): void;
  10302. /**
  10303. * Serialize the skeleton in a JSON object
  10304. * @returns a JSON object
  10305. */
  10306. serialize(): any;
  10307. /**
  10308. * Creates a new skeleton from serialized data
  10309. * @param parsedSkeleton defines the serialized data
  10310. * @param scene defines the hosting scene
  10311. * @returns a new skeleton
  10312. */
  10313. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10314. /**
  10315. * Compute all node absolute transforms
  10316. * @param forceUpdate defines if computation must be done even if cache is up to date
  10317. */
  10318. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10319. /**
  10320. * Gets the root pose matrix
  10321. * @returns a matrix
  10322. */
  10323. getPoseMatrix(): Nullable<Matrix>;
  10324. /**
  10325. * Sorts bones per internal index
  10326. */
  10327. sortBones(): void;
  10328. private _sortBones;
  10329. }
  10330. }
  10331. declare module "babylonjs/Morph/morphTarget" {
  10332. import { IAnimatable } from "babylonjs/Misc/tools";
  10333. import { Observable } from "babylonjs/Misc/observable";
  10334. import { Nullable, FloatArray } from "babylonjs/types";
  10335. import { Scene } from "babylonjs/scene";
  10336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10337. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10338. /**
  10339. * Defines a target to use with MorphTargetManager
  10340. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10341. */
  10342. export class MorphTarget implements IAnimatable {
  10343. /** defines the name of the target */
  10344. name: string;
  10345. /**
  10346. * Gets or sets the list of animations
  10347. */
  10348. animations: import("babylonjs/Animations/animation").Animation[];
  10349. private _scene;
  10350. private _positions;
  10351. private _normals;
  10352. private _tangents;
  10353. private _uvs;
  10354. private _influence;
  10355. /**
  10356. * Observable raised when the influence changes
  10357. */
  10358. onInfluenceChanged: Observable<boolean>;
  10359. /** @hidden */
  10360. _onDataLayoutChanged: Observable<void>;
  10361. /**
  10362. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10363. */
  10364. influence: number;
  10365. /**
  10366. * Gets or sets the id of the morph Target
  10367. */
  10368. id: string;
  10369. private _animationPropertiesOverride;
  10370. /**
  10371. * Gets or sets the animation properties override
  10372. */
  10373. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10374. /**
  10375. * Creates a new MorphTarget
  10376. * @param name defines the name of the target
  10377. * @param influence defines the influence to use
  10378. * @param scene defines the scene the morphtarget belongs to
  10379. */
  10380. constructor(
  10381. /** defines the name of the target */
  10382. name: string, influence?: number, scene?: Nullable<Scene>);
  10383. /**
  10384. * Gets a boolean defining if the target contains position data
  10385. */
  10386. readonly hasPositions: boolean;
  10387. /**
  10388. * Gets a boolean defining if the target contains normal data
  10389. */
  10390. readonly hasNormals: boolean;
  10391. /**
  10392. * Gets a boolean defining if the target contains tangent data
  10393. */
  10394. readonly hasTangents: boolean;
  10395. /**
  10396. * Gets a boolean defining if the target contains texture coordinates data
  10397. */
  10398. readonly hasUVs: boolean;
  10399. /**
  10400. * Affects position data to this target
  10401. * @param data defines the position data to use
  10402. */
  10403. setPositions(data: Nullable<FloatArray>): void;
  10404. /**
  10405. * Gets the position data stored in this target
  10406. * @returns a FloatArray containing the position data (or null if not present)
  10407. */
  10408. getPositions(): Nullable<FloatArray>;
  10409. /**
  10410. * Affects normal data to this target
  10411. * @param data defines the normal data to use
  10412. */
  10413. setNormals(data: Nullable<FloatArray>): void;
  10414. /**
  10415. * Gets the normal data stored in this target
  10416. * @returns a FloatArray containing the normal data (or null if not present)
  10417. */
  10418. getNormals(): Nullable<FloatArray>;
  10419. /**
  10420. * Affects tangent data to this target
  10421. * @param data defines the tangent data to use
  10422. */
  10423. setTangents(data: Nullable<FloatArray>): void;
  10424. /**
  10425. * Gets the tangent data stored in this target
  10426. * @returns a FloatArray containing the tangent data (or null if not present)
  10427. */
  10428. getTangents(): Nullable<FloatArray>;
  10429. /**
  10430. * Affects texture coordinates data to this target
  10431. * @param data defines the texture coordinates data to use
  10432. */
  10433. setUVs(data: Nullable<FloatArray>): void;
  10434. /**
  10435. * Gets the texture coordinates data stored in this target
  10436. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10437. */
  10438. getUVs(): Nullable<FloatArray>;
  10439. /**
  10440. * Serializes the current target into a Serialization object
  10441. * @returns the serialized object
  10442. */
  10443. serialize(): any;
  10444. /**
  10445. * Returns the string "MorphTarget"
  10446. * @returns "MorphTarget"
  10447. */
  10448. getClassName(): string;
  10449. /**
  10450. * Creates a new target from serialized data
  10451. * @param serializationObject defines the serialized data to use
  10452. * @returns a new MorphTarget
  10453. */
  10454. static Parse(serializationObject: any): MorphTarget;
  10455. /**
  10456. * Creates a MorphTarget from mesh data
  10457. * @param mesh defines the source mesh
  10458. * @param name defines the name to use for the new target
  10459. * @param influence defines the influence to attach to the target
  10460. * @returns a new MorphTarget
  10461. */
  10462. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10463. }
  10464. }
  10465. declare module "babylonjs/Morph/morphTargetManager" {
  10466. import { Nullable } from "babylonjs/types";
  10467. import { Scene } from "babylonjs/scene";
  10468. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  10469. /**
  10470. * This class is used to deform meshes using morphing between different targets
  10471. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10472. */
  10473. export class MorphTargetManager {
  10474. private _targets;
  10475. private _targetInfluenceChangedObservers;
  10476. private _targetDataLayoutChangedObservers;
  10477. private _activeTargets;
  10478. private _scene;
  10479. private _influences;
  10480. private _supportsNormals;
  10481. private _supportsTangents;
  10482. private _supportsUVs;
  10483. private _vertexCount;
  10484. private _uniqueId;
  10485. private _tempInfluences;
  10486. /**
  10487. * Gets or sets a boolean indicating if normals must be morphed
  10488. */
  10489. enableNormalMorphing: boolean;
  10490. /**
  10491. * Gets or sets a boolean indicating if tangents must be morphed
  10492. */
  10493. enableTangentMorphing: boolean;
  10494. /**
  10495. * Gets or sets a boolean indicating if UV must be morphed
  10496. */
  10497. enableUVMorphing: boolean;
  10498. /**
  10499. * Creates a new MorphTargetManager
  10500. * @param scene defines the current scene
  10501. */
  10502. constructor(scene?: Nullable<Scene>);
  10503. /**
  10504. * Gets the unique ID of this manager
  10505. */
  10506. readonly uniqueId: number;
  10507. /**
  10508. * Gets the number of vertices handled by this manager
  10509. */
  10510. readonly vertexCount: number;
  10511. /**
  10512. * Gets a boolean indicating if this manager supports morphing of normals
  10513. */
  10514. readonly supportsNormals: boolean;
  10515. /**
  10516. * Gets a boolean indicating if this manager supports morphing of tangents
  10517. */
  10518. readonly supportsTangents: boolean;
  10519. /**
  10520. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10521. */
  10522. readonly supportsUVs: boolean;
  10523. /**
  10524. * Gets the number of targets stored in this manager
  10525. */
  10526. readonly numTargets: number;
  10527. /**
  10528. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10529. */
  10530. readonly numInfluencers: number;
  10531. /**
  10532. * Gets the list of influences (one per target)
  10533. */
  10534. readonly influences: Float32Array;
  10535. /**
  10536. * Gets the active target at specified index. An active target is a target with an influence > 0
  10537. * @param index defines the index to check
  10538. * @returns the requested target
  10539. */
  10540. getActiveTarget(index: number): MorphTarget;
  10541. /**
  10542. * Gets the target at specified index
  10543. * @param index defines the index to check
  10544. * @returns the requested target
  10545. */
  10546. getTarget(index: number): MorphTarget;
  10547. /**
  10548. * Add a new target to this manager
  10549. * @param target defines the target to add
  10550. */
  10551. addTarget(target: MorphTarget): void;
  10552. /**
  10553. * Removes a target from the manager
  10554. * @param target defines the target to remove
  10555. */
  10556. removeTarget(target: MorphTarget): void;
  10557. /**
  10558. * Serializes the current manager into a Serialization object
  10559. * @returns the serialized object
  10560. */
  10561. serialize(): any;
  10562. private _syncActiveTargets;
  10563. /**
  10564. * Syncrhonize the targets with all the meshes using this morph target manager
  10565. */
  10566. synchronize(): void;
  10567. /**
  10568. * Creates a new MorphTargetManager from serialized data
  10569. * @param serializationObject defines the serialized data
  10570. * @param scene defines the hosting scene
  10571. * @returns the new MorphTargetManager
  10572. */
  10573. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10574. }
  10575. }
  10576. declare module "babylonjs/sceneComponent" {
  10577. import { Scene } from "babylonjs/scene";
  10578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10579. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10580. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10581. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10582. import { Nullable } from "babylonjs/types";
  10583. import { Camera } from "babylonjs/Cameras/camera";
  10584. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10585. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10586. import { AbstractScene } from "babylonjs/abstractScene";
  10587. /**
  10588. * Groups all the scene component constants in one place to ease maintenance.
  10589. * @hidden
  10590. */
  10591. export class SceneComponentConstants {
  10592. static readonly NAME_EFFECTLAYER: string;
  10593. static readonly NAME_LAYER: string;
  10594. static readonly NAME_LENSFLARESYSTEM: string;
  10595. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10596. static readonly NAME_PARTICLESYSTEM: string;
  10597. static readonly NAME_GAMEPAD: string;
  10598. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10599. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10600. static readonly NAME_DEPTHRENDERER: string;
  10601. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10602. static readonly NAME_SPRITE: string;
  10603. static readonly NAME_OUTLINERENDERER: string;
  10604. static readonly NAME_PROCEDURALTEXTURE: string;
  10605. static readonly NAME_SHADOWGENERATOR: string;
  10606. static readonly NAME_OCTREE: string;
  10607. static readonly NAME_PHYSICSENGINE: string;
  10608. static readonly NAME_AUDIO: string;
  10609. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10610. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10611. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10612. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10613. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10614. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10615. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10616. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10617. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10618. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10619. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10620. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10621. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10622. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10623. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10624. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10625. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10626. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10627. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10628. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10629. static readonly STEP_AFTERRENDER_AUDIO: number;
  10630. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10631. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10632. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10633. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10634. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10635. static readonly STEP_POINTERMOVE_SPRITE: number;
  10636. static readonly STEP_POINTERDOWN_SPRITE: number;
  10637. static readonly STEP_POINTERUP_SPRITE: number;
  10638. }
  10639. /**
  10640. * This represents a scene component.
  10641. *
  10642. * This is used to decouple the dependency the scene is having on the different workloads like
  10643. * layers, post processes...
  10644. */
  10645. export interface ISceneComponent {
  10646. /**
  10647. * The name of the component. Each component must have a unique name.
  10648. */
  10649. name: string;
  10650. /**
  10651. * The scene the component belongs to.
  10652. */
  10653. scene: Scene;
  10654. /**
  10655. * Register the component to one instance of a scene.
  10656. */
  10657. register(): void;
  10658. /**
  10659. * Rebuilds the elements related to this component in case of
  10660. * context lost for instance.
  10661. */
  10662. rebuild(): void;
  10663. /**
  10664. * Disposes the component and the associated ressources.
  10665. */
  10666. dispose(): void;
  10667. }
  10668. /**
  10669. * This represents a SERIALIZABLE scene component.
  10670. *
  10671. * This extends Scene Component to add Serialization methods on top.
  10672. */
  10673. export interface ISceneSerializableComponent extends ISceneComponent {
  10674. /**
  10675. * Adds all the elements from the container to the scene
  10676. * @param container the container holding the elements
  10677. */
  10678. addFromContainer(container: AbstractScene): void;
  10679. /**
  10680. * Removes all the elements in the container from the scene
  10681. * @param container contains the elements to remove
  10682. * @param dispose if the removed element should be disposed (default: false)
  10683. */
  10684. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10685. /**
  10686. * Serializes the component data to the specified json object
  10687. * @param serializationObject The object to serialize to
  10688. */
  10689. serialize(serializationObject: any): void;
  10690. }
  10691. /**
  10692. * Strong typing of a Mesh related stage step action
  10693. */
  10694. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10695. /**
  10696. * Strong typing of a Evaluate Sub Mesh related stage step action
  10697. */
  10698. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10699. /**
  10700. * Strong typing of a Active Mesh related stage step action
  10701. */
  10702. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10703. /**
  10704. * Strong typing of a Camera related stage step action
  10705. */
  10706. export type CameraStageAction = (camera: Camera) => void;
  10707. /**
  10708. * Strong typing of a Camera Frame buffer related stage step action
  10709. */
  10710. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10711. /**
  10712. * Strong typing of a Render Target related stage step action
  10713. */
  10714. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10715. /**
  10716. * Strong typing of a RenderingGroup related stage step action
  10717. */
  10718. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10719. /**
  10720. * Strong typing of a Mesh Render related stage step action
  10721. */
  10722. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10723. /**
  10724. * Strong typing of a simple stage step action
  10725. */
  10726. export type SimpleStageAction = () => void;
  10727. /**
  10728. * Strong typing of a render target action.
  10729. */
  10730. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10731. /**
  10732. * Strong typing of a pointer move action.
  10733. */
  10734. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10735. /**
  10736. * Strong typing of a pointer up/down action.
  10737. */
  10738. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10739. /**
  10740. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10741. * @hidden
  10742. */
  10743. export class Stage<T extends Function> extends Array<{
  10744. index: number;
  10745. component: ISceneComponent;
  10746. action: T;
  10747. }> {
  10748. /**
  10749. * Hide ctor from the rest of the world.
  10750. * @param items The items to add.
  10751. */
  10752. private constructor();
  10753. /**
  10754. * Creates a new Stage.
  10755. * @returns A new instance of a Stage
  10756. */
  10757. static Create<T extends Function>(): Stage<T>;
  10758. /**
  10759. * Registers a step in an ordered way in the targeted stage.
  10760. * @param index Defines the position to register the step in
  10761. * @param component Defines the component attached to the step
  10762. * @param action Defines the action to launch during the step
  10763. */
  10764. registerStep(index: number, component: ISceneComponent, action: T): void;
  10765. /**
  10766. * Clears all the steps from the stage.
  10767. */
  10768. clear(): void;
  10769. }
  10770. }
  10771. declare module "babylonjs/Meshes/meshLODLevel" {
  10772. import { Mesh } from "babylonjs/Meshes/mesh";
  10773. import { Nullable } from "babylonjs/types";
  10774. /**
  10775. * Class used to represent a specific level of detail of a mesh
  10776. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10777. */
  10778. export class MeshLODLevel {
  10779. /** Defines the distance where this level should star being displayed */
  10780. distance: number;
  10781. /** Defines the mesh to use to render this level */
  10782. mesh: Nullable<Mesh>;
  10783. /**
  10784. * Creates a new LOD level
  10785. * @param distance defines the distance where this level should star being displayed
  10786. * @param mesh defines the mesh to use to render this level
  10787. */
  10788. constructor(
  10789. /** Defines the distance where this level should star being displayed */
  10790. distance: number,
  10791. /** Defines the mesh to use to render this level */
  10792. mesh: Nullable<Mesh>);
  10793. }
  10794. }
  10795. declare module "babylonjs/Lights/shadowLight" {
  10796. import { Camera } from "babylonjs/Cameras/camera";
  10797. import { Scene } from "babylonjs/scene";
  10798. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10800. import { Light } from "babylonjs/Lights/light";
  10801. /**
  10802. * Interface describing all the common properties and methods a shadow light needs to implement.
  10803. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10804. * as well as binding the different shadow properties to the effects.
  10805. */
  10806. export interface IShadowLight extends Light {
  10807. /**
  10808. * The light id in the scene (used in scene.findLighById for instance)
  10809. */
  10810. id: string;
  10811. /**
  10812. * The position the shdow will be casted from.
  10813. */
  10814. position: Vector3;
  10815. /**
  10816. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10817. */
  10818. direction: Vector3;
  10819. /**
  10820. * The transformed position. Position of the light in world space taking parenting in account.
  10821. */
  10822. transformedPosition: Vector3;
  10823. /**
  10824. * The transformed direction. Direction of the light in world space taking parenting in account.
  10825. */
  10826. transformedDirection: Vector3;
  10827. /**
  10828. * The friendly name of the light in the scene.
  10829. */
  10830. name: string;
  10831. /**
  10832. * Defines the shadow projection clipping minimum z value.
  10833. */
  10834. shadowMinZ: number;
  10835. /**
  10836. * Defines the shadow projection clipping maximum z value.
  10837. */
  10838. shadowMaxZ: number;
  10839. /**
  10840. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10841. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10842. */
  10843. computeTransformedInformation(): boolean;
  10844. /**
  10845. * Gets the scene the light belongs to.
  10846. * @returns The scene
  10847. */
  10848. getScene(): Scene;
  10849. /**
  10850. * Callback defining a custom Projection Matrix Builder.
  10851. * This can be used to override the default projection matrix computation.
  10852. */
  10853. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10854. /**
  10855. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10856. * @param matrix The materix to updated with the projection information
  10857. * @param viewMatrix The transform matrix of the light
  10858. * @param renderList The list of mesh to render in the map
  10859. * @returns The current light
  10860. */
  10861. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10862. /**
  10863. * Gets the current depth scale used in ESM.
  10864. * @returns The scale
  10865. */
  10866. getDepthScale(): number;
  10867. /**
  10868. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10869. * @returns true if a cube texture needs to be use
  10870. */
  10871. needCube(): boolean;
  10872. /**
  10873. * Detects if the projection matrix requires to be recomputed this frame.
  10874. * @returns true if it requires to be recomputed otherwise, false.
  10875. */
  10876. needProjectionMatrixCompute(): boolean;
  10877. /**
  10878. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10879. */
  10880. forceProjectionMatrixCompute(): void;
  10881. /**
  10882. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10883. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10884. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10885. */
  10886. getShadowDirection(faceIndex?: number): Vector3;
  10887. /**
  10888. * Gets the minZ used for shadow according to both the scene and the light.
  10889. * @param activeCamera The camera we are returning the min for
  10890. * @returns the depth min z
  10891. */
  10892. getDepthMinZ(activeCamera: Camera): number;
  10893. /**
  10894. * Gets the maxZ used for shadow according to both the scene and the light.
  10895. * @param activeCamera The camera we are returning the max for
  10896. * @returns the depth max z
  10897. */
  10898. getDepthMaxZ(activeCamera: Camera): number;
  10899. }
  10900. /**
  10901. * Base implementation IShadowLight
  10902. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10903. */
  10904. export abstract class ShadowLight extends Light implements IShadowLight {
  10905. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10906. protected _position: Vector3;
  10907. protected _setPosition(value: Vector3): void;
  10908. /**
  10909. * Sets the position the shadow will be casted from. Also use as the light position for both
  10910. * point and spot lights.
  10911. */
  10912. /**
  10913. * Sets the position the shadow will be casted from. Also use as the light position for both
  10914. * point and spot lights.
  10915. */
  10916. position: Vector3;
  10917. protected _direction: Vector3;
  10918. protected _setDirection(value: Vector3): void;
  10919. /**
  10920. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10921. * Also use as the light direction on spot and directional lights.
  10922. */
  10923. /**
  10924. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10925. * Also use as the light direction on spot and directional lights.
  10926. */
  10927. direction: Vector3;
  10928. private _shadowMinZ;
  10929. /**
  10930. * Gets the shadow projection clipping minimum z value.
  10931. */
  10932. /**
  10933. * Sets the shadow projection clipping minimum z value.
  10934. */
  10935. shadowMinZ: number;
  10936. private _shadowMaxZ;
  10937. /**
  10938. * Sets the shadow projection clipping maximum z value.
  10939. */
  10940. /**
  10941. * Gets the shadow projection clipping maximum z value.
  10942. */
  10943. shadowMaxZ: number;
  10944. /**
  10945. * Callback defining a custom Projection Matrix Builder.
  10946. * This can be used to override the default projection matrix computation.
  10947. */
  10948. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10949. /**
  10950. * The transformed position. Position of the light in world space taking parenting in account.
  10951. */
  10952. transformedPosition: Vector3;
  10953. /**
  10954. * The transformed direction. Direction of the light in world space taking parenting in account.
  10955. */
  10956. transformedDirection: Vector3;
  10957. private _needProjectionMatrixCompute;
  10958. /**
  10959. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10960. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10961. */
  10962. computeTransformedInformation(): boolean;
  10963. /**
  10964. * Return the depth scale used for the shadow map.
  10965. * @returns the depth scale.
  10966. */
  10967. getDepthScale(): number;
  10968. /**
  10969. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10970. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10971. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10972. */
  10973. getShadowDirection(faceIndex?: number): Vector3;
  10974. /**
  10975. * Returns the ShadowLight absolute position in the World.
  10976. * @returns the position vector in world space
  10977. */
  10978. getAbsolutePosition(): Vector3;
  10979. /**
  10980. * Sets the ShadowLight direction toward the passed target.
  10981. * @param target The point to target in local space
  10982. * @returns the updated ShadowLight direction
  10983. */
  10984. setDirectionToTarget(target: Vector3): Vector3;
  10985. /**
  10986. * Returns the light rotation in euler definition.
  10987. * @returns the x y z rotation in local space.
  10988. */
  10989. getRotation(): Vector3;
  10990. /**
  10991. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10992. * @returns true if a cube texture needs to be use
  10993. */
  10994. needCube(): boolean;
  10995. /**
  10996. * Detects if the projection matrix requires to be recomputed this frame.
  10997. * @returns true if it requires to be recomputed otherwise, false.
  10998. */
  10999. needProjectionMatrixCompute(): boolean;
  11000. /**
  11001. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11002. */
  11003. forceProjectionMatrixCompute(): void;
  11004. /** @hidden */
  11005. _initCache(): void;
  11006. /** @hidden */
  11007. _isSynchronized(): boolean;
  11008. /**
  11009. * Computes the world matrix of the node
  11010. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  11011. * @returns the world matrix
  11012. */
  11013. computeWorldMatrix(force?: boolean): Matrix;
  11014. /**
  11015. * Gets the minZ used for shadow according to both the scene and the light.
  11016. * @param activeCamera The camera we are returning the min for
  11017. * @returns the depth min z
  11018. */
  11019. getDepthMinZ(activeCamera: Camera): number;
  11020. /**
  11021. * Gets the maxZ used for shadow according to both the scene and the light.
  11022. * @param activeCamera The camera we are returning the max for
  11023. * @returns the depth max z
  11024. */
  11025. getDepthMaxZ(activeCamera: Camera): number;
  11026. /**
  11027. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11028. * @param matrix The materix to updated with the projection information
  11029. * @param viewMatrix The transform matrix of the light
  11030. * @param renderList The list of mesh to render in the map
  11031. * @returns The current light
  11032. */
  11033. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11034. }
  11035. }
  11036. declare module "babylonjs/Materials/materialHelper" {
  11037. import { Nullable } from "babylonjs/types";
  11038. import { Scene } from "babylonjs/scene";
  11039. import { Engine } from "babylonjs/Engines/engine";
  11040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11041. import { Light } from "babylonjs/Lights/light";
  11042. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11043. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  11044. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11045. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11046. /**
  11047. * "Static Class" containing the most commonly used helper while dealing with material for
  11048. * rendering purpose.
  11049. *
  11050. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  11051. *
  11052. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  11053. */
  11054. export class MaterialHelper {
  11055. /**
  11056. * Bind the current view position to an effect.
  11057. * @param effect The effect to be bound
  11058. * @param scene The scene the eyes position is used from
  11059. */
  11060. static BindEyePosition(effect: Effect, scene: Scene): void;
  11061. /**
  11062. * Helps preparing the defines values about the UVs in used in the effect.
  11063. * UVs are shared as much as we can accross channels in the shaders.
  11064. * @param texture The texture we are preparing the UVs for
  11065. * @param defines The defines to update
  11066. * @param key The channel key "diffuse", "specular"... used in the shader
  11067. */
  11068. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  11069. /**
  11070. * Binds a texture matrix value to its corrsponding uniform
  11071. * @param texture The texture to bind the matrix for
  11072. * @param uniformBuffer The uniform buffer receivin the data
  11073. * @param key The channel key "diffuse", "specular"... used in the shader
  11074. */
  11075. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  11076. /**
  11077. * Gets the current status of the fog (should it be enabled?)
  11078. * @param mesh defines the mesh to evaluate for fog support
  11079. * @param scene defines the hosting scene
  11080. * @returns true if fog must be enabled
  11081. */
  11082. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  11083. /**
  11084. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  11085. * @param mesh defines the current mesh
  11086. * @param scene defines the current scene
  11087. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  11088. * @param pointsCloud defines if point cloud rendering has to be turned on
  11089. * @param fogEnabled defines if fog has to be turned on
  11090. * @param alphaTest defines if alpha testing has to be turned on
  11091. * @param defines defines the current list of defines
  11092. */
  11093. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  11094. /**
  11095. * Helper used to prepare the list of defines associated with frame values for shader compilation
  11096. * @param scene defines the current scene
  11097. * @param engine defines the current engine
  11098. * @param defines specifies the list of active defines
  11099. * @param useInstances defines if instances have to be turned on
  11100. * @param useClipPlane defines if clip plane have to be turned on
  11101. */
  11102. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  11103. /**
  11104. * Prepares the defines for bones
  11105. * @param mesh The mesh containing the geometry data we will draw
  11106. * @param defines The defines to update
  11107. */
  11108. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  11109. /**
  11110. * Prepares the defines for morph targets
  11111. * @param mesh The mesh containing the geometry data we will draw
  11112. * @param defines The defines to update
  11113. */
  11114. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  11115. /**
  11116. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  11117. * @param mesh The mesh containing the geometry data we will draw
  11118. * @param defines The defines to update
  11119. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  11120. * @param useBones Precise whether bones should be used or not (override mesh info)
  11121. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  11122. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  11123. * @returns false if defines are considered not dirty and have not been checked
  11124. */
  11125. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  11126. /**
  11127. * Prepares the defines related to multiview
  11128. * @param scene The scene we are intending to draw
  11129. * @param defines The defines to update
  11130. */
  11131. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  11132. /**
  11133. * Prepares the defines related to the light information passed in parameter
  11134. * @param scene The scene we are intending to draw
  11135. * @param mesh The mesh the effect is compiling for
  11136. * @param light The light the effect is compiling for
  11137. * @param lightIndex The index of the light
  11138. * @param defines The defines to update
  11139. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11140. * @param state Defines the current state regarding what is needed (normals, etc...)
  11141. */
  11142. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  11143. needNormals: boolean;
  11144. needRebuild: boolean;
  11145. shadowEnabled: boolean;
  11146. specularEnabled: boolean;
  11147. lightmapMode: boolean;
  11148. }): void;
  11149. /**
  11150. * Prepares the defines related to the light information passed in parameter
  11151. * @param scene The scene we are intending to draw
  11152. * @param mesh The mesh the effect is compiling for
  11153. * @param defines The defines to update
  11154. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11155. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  11156. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  11157. * @returns true if normals will be required for the rest of the effect
  11158. */
  11159. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  11160. /**
  11161. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  11162. * @param lightIndex defines the light index
  11163. * @param uniformsList The uniform list
  11164. * @param samplersList The sampler list
  11165. * @param projectedLightTexture defines if projected texture must be used
  11166. * @param uniformBuffersList defines an optional list of uniform buffers
  11167. */
  11168. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  11169. /**
  11170. * Prepares the uniforms and samplers list to be used in the effect
  11171. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  11172. * @param samplersList The sampler list
  11173. * @param defines The defines helping in the list generation
  11174. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  11175. */
  11176. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11177. /**
  11178. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11179. * @param defines The defines to update while falling back
  11180. * @param fallbacks The authorized effect fallbacks
  11181. * @param maxSimultaneousLights The maximum number of lights allowed
  11182. * @param rank the current rank of the Effect
  11183. * @returns The newly affected rank
  11184. */
  11185. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11186. private static _TmpMorphInfluencers;
  11187. /**
  11188. * Prepares the list of attributes required for morph targets according to the effect defines.
  11189. * @param attribs The current list of supported attribs
  11190. * @param mesh The mesh to prepare the morph targets attributes for
  11191. * @param influencers The number of influencers
  11192. */
  11193. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  11194. /**
  11195. * Prepares the list of attributes required for morph targets according to the effect defines.
  11196. * @param attribs The current list of supported attribs
  11197. * @param mesh The mesh to prepare the morph targets attributes for
  11198. * @param defines The current Defines of the effect
  11199. */
  11200. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11201. /**
  11202. * Prepares the list of attributes required for bones according to the effect defines.
  11203. * @param attribs The current list of supported attribs
  11204. * @param mesh The mesh to prepare the bones attributes for
  11205. * @param defines The current Defines of the effect
  11206. * @param fallbacks The current efffect fallback strategy
  11207. */
  11208. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11209. /**
  11210. * Check and prepare the list of attributes required for instances according to the effect defines.
  11211. * @param attribs The current list of supported attribs
  11212. * @param defines The current MaterialDefines of the effect
  11213. */
  11214. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11215. /**
  11216. * Add the list of attributes required for instances to the attribs array.
  11217. * @param attribs The current list of supported attribs
  11218. */
  11219. static PushAttributesForInstances(attribs: string[]): void;
  11220. /**
  11221. * Binds the light shadow information to the effect for the given mesh.
  11222. * @param light The light containing the generator
  11223. * @param scene The scene the lights belongs to
  11224. * @param mesh The mesh we are binding the information to render
  11225. * @param lightIndex The light index in the effect used to render the mesh
  11226. * @param effect The effect we are binding the data to
  11227. */
  11228. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11229. /**
  11230. * Binds the light information to the effect.
  11231. * @param light The light containing the generator
  11232. * @param effect The effect we are binding the data to
  11233. * @param lightIndex The light index in the effect used to render
  11234. */
  11235. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11236. /**
  11237. * Binds the lights information from the scene to the effect for the given mesh.
  11238. * @param light Light to bind
  11239. * @param lightIndex Light index
  11240. * @param scene The scene where the light belongs to
  11241. * @param mesh The mesh we are binding the information to render
  11242. * @param effect The effect we are binding the data to
  11243. * @param useSpecular Defines if specular is supported
  11244. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11245. */
  11246. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  11247. /**
  11248. * Binds the lights information from the scene to the effect for the given mesh.
  11249. * @param scene The scene the lights belongs to
  11250. * @param mesh The mesh we are binding the information to render
  11251. * @param effect The effect we are binding the data to
  11252. * @param defines The generated defines for the effect
  11253. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11254. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11255. */
  11256. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11257. private static _tempFogColor;
  11258. /**
  11259. * Binds the fog information from the scene to the effect for the given mesh.
  11260. * @param scene The scene the lights belongs to
  11261. * @param mesh The mesh we are binding the information to render
  11262. * @param effect The effect we are binding the data to
  11263. * @param linearSpace Defines if the fog effect is applied in linear space
  11264. */
  11265. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11266. /**
  11267. * Binds the bones information from the mesh to the effect.
  11268. * @param mesh The mesh we are binding the information to render
  11269. * @param effect The effect we are binding the data to
  11270. */
  11271. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11272. /**
  11273. * Binds the morph targets information from the mesh to the effect.
  11274. * @param abstractMesh The mesh we are binding the information to render
  11275. * @param effect The effect we are binding the data to
  11276. */
  11277. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11278. /**
  11279. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11280. * @param defines The generated defines used in the effect
  11281. * @param effect The effect we are binding the data to
  11282. * @param scene The scene we are willing to render with logarithmic scale for
  11283. */
  11284. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11285. /**
  11286. * Binds the clip plane information from the scene to the effect.
  11287. * @param scene The scene the clip plane information are extracted from
  11288. * @param effect The effect we are binding the data to
  11289. */
  11290. static BindClipPlane(effect: Effect, scene: Scene): void;
  11291. }
  11292. }
  11293. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  11294. /** @hidden */
  11295. export var packingFunctions: {
  11296. name: string;
  11297. shader: string;
  11298. };
  11299. }
  11300. declare module "babylonjs/Shaders/shadowMap.fragment" {
  11301. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  11302. /** @hidden */
  11303. export var shadowMapPixelShader: {
  11304. name: string;
  11305. shader: string;
  11306. };
  11307. }
  11308. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  11309. /** @hidden */
  11310. export var bonesDeclaration: {
  11311. name: string;
  11312. shader: string;
  11313. };
  11314. }
  11315. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  11316. /** @hidden */
  11317. export var morphTargetsVertexGlobalDeclaration: {
  11318. name: string;
  11319. shader: string;
  11320. };
  11321. }
  11322. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  11323. /** @hidden */
  11324. export var morphTargetsVertexDeclaration: {
  11325. name: string;
  11326. shader: string;
  11327. };
  11328. }
  11329. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  11330. /** @hidden */
  11331. export var instancesDeclaration: {
  11332. name: string;
  11333. shader: string;
  11334. };
  11335. }
  11336. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  11337. /** @hidden */
  11338. export var helperFunctions: {
  11339. name: string;
  11340. shader: string;
  11341. };
  11342. }
  11343. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  11344. /** @hidden */
  11345. export var morphTargetsVertex: {
  11346. name: string;
  11347. shader: string;
  11348. };
  11349. }
  11350. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  11351. /** @hidden */
  11352. export var instancesVertex: {
  11353. name: string;
  11354. shader: string;
  11355. };
  11356. }
  11357. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  11358. /** @hidden */
  11359. export var bonesVertex: {
  11360. name: string;
  11361. shader: string;
  11362. };
  11363. }
  11364. declare module "babylonjs/Shaders/shadowMap.vertex" {
  11365. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  11366. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  11367. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  11368. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  11369. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11370. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  11371. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  11372. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  11373. /** @hidden */
  11374. export var shadowMapVertexShader: {
  11375. name: string;
  11376. shader: string;
  11377. };
  11378. }
  11379. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  11380. /** @hidden */
  11381. export var depthBoxBlurPixelShader: {
  11382. name: string;
  11383. shader: string;
  11384. };
  11385. }
  11386. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  11387. import { Nullable } from "babylonjs/types";
  11388. import { Scene } from "babylonjs/scene";
  11389. import { Matrix } from "babylonjs/Maths/math";
  11390. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11392. import { Mesh } from "babylonjs/Meshes/mesh";
  11393. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  11394. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11395. import { Effect } from "babylonjs/Materials/effect";
  11396. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11397. import "babylonjs/Shaders/shadowMap.fragment";
  11398. import "babylonjs/Shaders/shadowMap.vertex";
  11399. import "babylonjs/Shaders/depthBoxBlur.fragment";
  11400. import { Observable } from "babylonjs/Misc/observable";
  11401. /**
  11402. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11403. */
  11404. export interface ICustomShaderOptions {
  11405. /**
  11406. * Gets or sets the custom shader name to use
  11407. */
  11408. shaderName: string;
  11409. /**
  11410. * The list of attribute names used in the shader
  11411. */
  11412. attributes?: string[];
  11413. /**
  11414. * The list of unifrom names used in the shader
  11415. */
  11416. uniforms?: string[];
  11417. /**
  11418. * The list of sampler names used in the shader
  11419. */
  11420. samplers?: string[];
  11421. /**
  11422. * The list of defines used in the shader
  11423. */
  11424. defines?: string[];
  11425. }
  11426. /**
  11427. * Interface to implement to create a shadow generator compatible with BJS.
  11428. */
  11429. export interface IShadowGenerator {
  11430. /**
  11431. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11432. * @returns The render target texture if present otherwise, null
  11433. */
  11434. getShadowMap(): Nullable<RenderTargetTexture>;
  11435. /**
  11436. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11437. * @returns The render target texture if the shadow map is present otherwise, null
  11438. */
  11439. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11440. /**
  11441. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11442. * @param subMesh The submesh we want to render in the shadow map
  11443. * @param useInstances Defines wether will draw in the map using instances
  11444. * @returns true if ready otherwise, false
  11445. */
  11446. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11447. /**
  11448. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11449. * @param defines Defines of the material we want to update
  11450. * @param lightIndex Index of the light in the enabled light list of the material
  11451. */
  11452. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11453. /**
  11454. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11455. * defined in the generator but impacting the effect).
  11456. * It implies the unifroms available on the materials are the standard BJS ones.
  11457. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11458. * @param effect The effect we are binfing the information for
  11459. */
  11460. bindShadowLight(lightIndex: string, effect: Effect): void;
  11461. /**
  11462. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11463. * (eq to shadow prjection matrix * light transform matrix)
  11464. * @returns The transform matrix used to create the shadow map
  11465. */
  11466. getTransformMatrix(): Matrix;
  11467. /**
  11468. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11469. * Cube and 2D textures for instance.
  11470. */
  11471. recreateShadowMap(): void;
  11472. /**
  11473. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11474. * @param onCompiled Callback triggered at the and of the effects compilation
  11475. * @param options Sets of optional options forcing the compilation with different modes
  11476. */
  11477. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11478. useInstances: boolean;
  11479. }>): void;
  11480. /**
  11481. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11482. * @param options Sets of optional options forcing the compilation with different modes
  11483. * @returns A promise that resolves when the compilation completes
  11484. */
  11485. forceCompilationAsync(options?: Partial<{
  11486. useInstances: boolean;
  11487. }>): Promise<void>;
  11488. /**
  11489. * Serializes the shadow generator setup to a json object.
  11490. * @returns The serialized JSON object
  11491. */
  11492. serialize(): any;
  11493. /**
  11494. * Disposes the Shadow map and related Textures and effects.
  11495. */
  11496. dispose(): void;
  11497. }
  11498. /**
  11499. * Default implementation IShadowGenerator.
  11500. * This is the main object responsible of generating shadows in the framework.
  11501. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11502. */
  11503. export class ShadowGenerator implements IShadowGenerator {
  11504. /**
  11505. * Shadow generator mode None: no filtering applied.
  11506. */
  11507. static readonly FILTER_NONE: number;
  11508. /**
  11509. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11510. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11511. */
  11512. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11513. /**
  11514. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11515. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11516. */
  11517. static readonly FILTER_POISSONSAMPLING: number;
  11518. /**
  11519. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11520. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11521. */
  11522. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11523. /**
  11524. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11525. * edge artifacts on steep falloff.
  11526. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11527. */
  11528. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11529. /**
  11530. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11531. * edge artifacts on steep falloff.
  11532. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11533. */
  11534. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11535. /**
  11536. * Shadow generator mode PCF: Percentage Closer Filtering
  11537. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11538. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11539. */
  11540. static readonly FILTER_PCF: number;
  11541. /**
  11542. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11543. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11544. * Contact Hardening
  11545. */
  11546. static readonly FILTER_PCSS: number;
  11547. /**
  11548. * Reserved for PCF and PCSS
  11549. * Highest Quality.
  11550. *
  11551. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11552. *
  11553. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11554. */
  11555. static readonly QUALITY_HIGH: number;
  11556. /**
  11557. * Reserved for PCF and PCSS
  11558. * Good tradeoff for quality/perf cross devices
  11559. *
  11560. * Execute PCF on a 3*3 kernel.
  11561. *
  11562. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11563. */
  11564. static readonly QUALITY_MEDIUM: number;
  11565. /**
  11566. * Reserved for PCF and PCSS
  11567. * The lowest quality but the fastest.
  11568. *
  11569. * Execute PCF on a 1*1 kernel.
  11570. *
  11571. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11572. */
  11573. static readonly QUALITY_LOW: number;
  11574. /** Gets or sets the custom shader name to use */
  11575. customShaderOptions: ICustomShaderOptions;
  11576. /**
  11577. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11578. */
  11579. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11580. /**
  11581. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11582. */
  11583. onAfterShadowMapRenderObservable: Observable<Effect>;
  11584. /**
  11585. * Observable triggered before a mesh is rendered in the shadow map.
  11586. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11587. */
  11588. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11589. /**
  11590. * Observable triggered after a mesh is rendered in the shadow map.
  11591. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11592. */
  11593. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11594. private _bias;
  11595. /**
  11596. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11597. */
  11598. /**
  11599. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11600. */
  11601. bias: number;
  11602. private _normalBias;
  11603. /**
  11604. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11605. */
  11606. /**
  11607. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11608. */
  11609. normalBias: number;
  11610. private _blurBoxOffset;
  11611. /**
  11612. * Gets the blur box offset: offset applied during the blur pass.
  11613. * Only useful if useKernelBlur = false
  11614. */
  11615. /**
  11616. * Sets the blur box offset: offset applied during the blur pass.
  11617. * Only useful if useKernelBlur = false
  11618. */
  11619. blurBoxOffset: number;
  11620. private _blurScale;
  11621. /**
  11622. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11623. * 2 means half of the size.
  11624. */
  11625. /**
  11626. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11627. * 2 means half of the size.
  11628. */
  11629. blurScale: number;
  11630. private _blurKernel;
  11631. /**
  11632. * Gets the blur kernel: kernel size of the blur pass.
  11633. * Only useful if useKernelBlur = true
  11634. */
  11635. /**
  11636. * Sets the blur kernel: kernel size of the blur pass.
  11637. * Only useful if useKernelBlur = true
  11638. */
  11639. blurKernel: number;
  11640. private _useKernelBlur;
  11641. /**
  11642. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11643. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11644. */
  11645. /**
  11646. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11647. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11648. */
  11649. useKernelBlur: boolean;
  11650. private _depthScale;
  11651. /**
  11652. * Gets the depth scale used in ESM mode.
  11653. */
  11654. /**
  11655. * Sets the depth scale used in ESM mode.
  11656. * This can override the scale stored on the light.
  11657. */
  11658. depthScale: number;
  11659. private _filter;
  11660. /**
  11661. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11662. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11663. */
  11664. /**
  11665. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11666. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11667. */
  11668. filter: number;
  11669. /**
  11670. * Gets if the current filter is set to Poisson Sampling.
  11671. */
  11672. /**
  11673. * Sets the current filter to Poisson Sampling.
  11674. */
  11675. usePoissonSampling: boolean;
  11676. /**
  11677. * Gets if the current filter is set to ESM.
  11678. */
  11679. /**
  11680. * Sets the current filter is to ESM.
  11681. */
  11682. useExponentialShadowMap: boolean;
  11683. /**
  11684. * Gets if the current filter is set to filtered ESM.
  11685. */
  11686. /**
  11687. * Gets if the current filter is set to filtered ESM.
  11688. */
  11689. useBlurExponentialShadowMap: boolean;
  11690. /**
  11691. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11692. * exponential to prevent steep falloff artifacts).
  11693. */
  11694. /**
  11695. * Sets the current filter to "close ESM" (using the inverse of the
  11696. * exponential to prevent steep falloff artifacts).
  11697. */
  11698. useCloseExponentialShadowMap: boolean;
  11699. /**
  11700. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11701. * exponential to prevent steep falloff artifacts).
  11702. */
  11703. /**
  11704. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11705. * exponential to prevent steep falloff artifacts).
  11706. */
  11707. useBlurCloseExponentialShadowMap: boolean;
  11708. /**
  11709. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11710. */
  11711. /**
  11712. * Sets the current filter to "PCF" (percentage closer filtering).
  11713. */
  11714. usePercentageCloserFiltering: boolean;
  11715. private _filteringQuality;
  11716. /**
  11717. * Gets the PCF or PCSS Quality.
  11718. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11719. */
  11720. /**
  11721. * Sets the PCF or PCSS Quality.
  11722. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11723. */
  11724. filteringQuality: number;
  11725. /**
  11726. * Gets if the current filter is set to "PCSS" (contact hardening).
  11727. */
  11728. /**
  11729. * Sets the current filter to "PCSS" (contact hardening).
  11730. */
  11731. useContactHardeningShadow: boolean;
  11732. private _contactHardeningLightSizeUVRatio;
  11733. /**
  11734. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11735. * Using a ratio helps keeping shape stability independently of the map size.
  11736. *
  11737. * It does not account for the light projection as it was having too much
  11738. * instability during the light setup or during light position changes.
  11739. *
  11740. * Only valid if useContactHardeningShadow is true.
  11741. */
  11742. /**
  11743. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11744. * Using a ratio helps keeping shape stability independently of the map size.
  11745. *
  11746. * It does not account for the light projection as it was having too much
  11747. * instability during the light setup or during light position changes.
  11748. *
  11749. * Only valid if useContactHardeningShadow is true.
  11750. */
  11751. contactHardeningLightSizeUVRatio: number;
  11752. private _darkness;
  11753. /** Gets or sets the actual darkness of a shadow */
  11754. darkness: number;
  11755. /**
  11756. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11757. * 0 means strongest and 1 would means no shadow.
  11758. * @returns the darkness.
  11759. */
  11760. getDarkness(): number;
  11761. /**
  11762. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11763. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11764. * @returns the shadow generator allowing fluent coding.
  11765. */
  11766. setDarkness(darkness: number): ShadowGenerator;
  11767. private _transparencyShadow;
  11768. /** Gets or sets the ability to have transparent shadow */
  11769. transparencyShadow: boolean;
  11770. /**
  11771. * Sets the ability to have transparent shadow (boolean).
  11772. * @param transparent True if transparent else False
  11773. * @returns the shadow generator allowing fluent coding
  11774. */
  11775. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11776. private _shadowMap;
  11777. private _shadowMap2;
  11778. /**
  11779. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11780. * @returns The render target texture if present otherwise, null
  11781. */
  11782. getShadowMap(): Nullable<RenderTargetTexture>;
  11783. /**
  11784. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11785. * @returns The render target texture if the shadow map is present otherwise, null
  11786. */
  11787. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11788. /**
  11789. * Gets the class name of that object
  11790. * @returns "ShadowGenerator"
  11791. */
  11792. getClassName(): string;
  11793. /**
  11794. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11795. * @param mesh Mesh to add
  11796. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11797. * @returns the Shadow Generator itself
  11798. */
  11799. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11800. /**
  11801. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11802. * @param mesh Mesh to remove
  11803. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11804. * @returns the Shadow Generator itself
  11805. */
  11806. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11807. /**
  11808. * Controls the extent to which the shadows fade out at the edge of the frustum
  11809. * Used only by directionals and spots
  11810. */
  11811. frustumEdgeFalloff: number;
  11812. private _light;
  11813. /**
  11814. * Returns the associated light object.
  11815. * @returns the light generating the shadow
  11816. */
  11817. getLight(): IShadowLight;
  11818. /**
  11819. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11820. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11821. * It might on the other hand introduce peter panning.
  11822. */
  11823. forceBackFacesOnly: boolean;
  11824. private _scene;
  11825. private _lightDirection;
  11826. private _effect;
  11827. private _viewMatrix;
  11828. private _projectionMatrix;
  11829. private _transformMatrix;
  11830. private _cachedPosition;
  11831. private _cachedDirection;
  11832. private _cachedDefines;
  11833. private _currentRenderID;
  11834. private _boxBlurPostprocess;
  11835. private _kernelBlurXPostprocess;
  11836. private _kernelBlurYPostprocess;
  11837. private _blurPostProcesses;
  11838. private _mapSize;
  11839. private _currentFaceIndex;
  11840. private _currentFaceIndexCache;
  11841. private _textureType;
  11842. private _defaultTextureMatrix;
  11843. /** @hidden */
  11844. static _SceneComponentInitialization: (scene: Scene) => void;
  11845. /**
  11846. * Creates a ShadowGenerator object.
  11847. * A ShadowGenerator is the required tool to use the shadows.
  11848. * Each light casting shadows needs to use its own ShadowGenerator.
  11849. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11850. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11851. * @param light The light object generating the shadows.
  11852. * @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.
  11853. */
  11854. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11855. private _initializeGenerator;
  11856. private _initializeShadowMap;
  11857. private _initializeBlurRTTAndPostProcesses;
  11858. private _renderForShadowMap;
  11859. private _renderSubMeshForShadowMap;
  11860. private _applyFilterValues;
  11861. /**
  11862. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11863. * @param onCompiled Callback triggered at the and of the effects compilation
  11864. * @param options Sets of optional options forcing the compilation with different modes
  11865. */
  11866. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11867. useInstances: boolean;
  11868. }>): void;
  11869. /**
  11870. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11871. * @param options Sets of optional options forcing the compilation with different modes
  11872. * @returns A promise that resolves when the compilation completes
  11873. */
  11874. forceCompilationAsync(options?: Partial<{
  11875. useInstances: boolean;
  11876. }>): Promise<void>;
  11877. /**
  11878. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11879. * @param subMesh The submesh we want to render in the shadow map
  11880. * @param useInstances Defines wether will draw in the map using instances
  11881. * @returns true if ready otherwise, false
  11882. */
  11883. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11884. /**
  11885. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11886. * @param defines Defines of the material we want to update
  11887. * @param lightIndex Index of the light in the enabled light list of the material
  11888. */
  11889. prepareDefines(defines: any, lightIndex: number): void;
  11890. /**
  11891. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11892. * defined in the generator but impacting the effect).
  11893. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11894. * @param effect The effect we are binfing the information for
  11895. */
  11896. bindShadowLight(lightIndex: string, effect: Effect): void;
  11897. /**
  11898. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11899. * (eq to shadow prjection matrix * light transform matrix)
  11900. * @returns The transform matrix used to create the shadow map
  11901. */
  11902. getTransformMatrix(): Matrix;
  11903. /**
  11904. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11905. * Cube and 2D textures for instance.
  11906. */
  11907. recreateShadowMap(): void;
  11908. private _disposeBlurPostProcesses;
  11909. private _disposeRTTandPostProcesses;
  11910. /**
  11911. * Disposes the ShadowGenerator.
  11912. * Returns nothing.
  11913. */
  11914. dispose(): void;
  11915. /**
  11916. * Serializes the shadow generator setup to a json object.
  11917. * @returns The serialized JSON object
  11918. */
  11919. serialize(): any;
  11920. /**
  11921. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11922. * @param parsedShadowGenerator The JSON object to parse
  11923. * @param scene The scene to create the shadow map for
  11924. * @returns The parsed shadow generator
  11925. */
  11926. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11927. }
  11928. }
  11929. declare module "babylonjs/Lights/light" {
  11930. import { Nullable } from "babylonjs/types";
  11931. import { Scene } from "babylonjs/scene";
  11932. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11933. import { Node } from "babylonjs/node";
  11934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11935. import { Effect } from "babylonjs/Materials/effect";
  11936. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11937. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11938. /**
  11939. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11940. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11941. * 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.
  11942. */
  11943. export abstract class Light extends Node {
  11944. /**
  11945. * Falloff Default: light is falling off following the material specification:
  11946. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11947. */
  11948. static readonly FALLOFF_DEFAULT: number;
  11949. /**
  11950. * Falloff Physical: light is falling off following the inverse squared distance law.
  11951. */
  11952. static readonly FALLOFF_PHYSICAL: number;
  11953. /**
  11954. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11955. * to enhance interoperability with other engines.
  11956. */
  11957. static readonly FALLOFF_GLTF: number;
  11958. /**
  11959. * Falloff Standard: light is falling off like in the standard material
  11960. * to enhance interoperability with other materials.
  11961. */
  11962. static readonly FALLOFF_STANDARD: number;
  11963. /**
  11964. * If every light affecting the material is in this lightmapMode,
  11965. * material.lightmapTexture adds or multiplies
  11966. * (depends on material.useLightmapAsShadowmap)
  11967. * after every other light calculations.
  11968. */
  11969. static readonly LIGHTMAP_DEFAULT: number;
  11970. /**
  11971. * material.lightmapTexture as only diffuse lighting from this light
  11972. * adds only specular lighting from this light
  11973. * adds dynamic shadows
  11974. */
  11975. static readonly LIGHTMAP_SPECULAR: number;
  11976. /**
  11977. * material.lightmapTexture as only lighting
  11978. * no light calculation from this light
  11979. * only adds dynamic shadows from this light
  11980. */
  11981. static readonly LIGHTMAP_SHADOWSONLY: number;
  11982. /**
  11983. * Each light type uses the default quantity according to its type:
  11984. * point/spot lights use luminous intensity
  11985. * directional lights use illuminance
  11986. */
  11987. static readonly INTENSITYMODE_AUTOMATIC: number;
  11988. /**
  11989. * lumen (lm)
  11990. */
  11991. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11992. /**
  11993. * candela (lm/sr)
  11994. */
  11995. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11996. /**
  11997. * lux (lm/m^2)
  11998. */
  11999. static readonly INTENSITYMODE_ILLUMINANCE: number;
  12000. /**
  12001. * nit (cd/m^2)
  12002. */
  12003. static readonly INTENSITYMODE_LUMINANCE: number;
  12004. /**
  12005. * Light type const id of the point light.
  12006. */
  12007. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12008. /**
  12009. * Light type const id of the directional light.
  12010. */
  12011. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12012. /**
  12013. * Light type const id of the spot light.
  12014. */
  12015. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12016. /**
  12017. * Light type const id of the hemispheric light.
  12018. */
  12019. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12020. /**
  12021. * Diffuse gives the basic color to an object.
  12022. */
  12023. diffuse: Color3;
  12024. /**
  12025. * Specular produces a highlight color on an object.
  12026. * Note: This is note affecting PBR materials.
  12027. */
  12028. specular: Color3;
  12029. /**
  12030. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12031. * falling off base on range or angle.
  12032. * This can be set to any values in Light.FALLOFF_x.
  12033. *
  12034. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  12035. * other types of materials.
  12036. */
  12037. falloffType: number;
  12038. /**
  12039. * Strength of the light.
  12040. * Note: By default it is define in the framework own unit.
  12041. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12042. */
  12043. intensity: number;
  12044. private _range;
  12045. protected _inverseSquaredRange: number;
  12046. /**
  12047. * Defines how far from the source the light is impacting in scene units.
  12048. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12049. */
  12050. /**
  12051. * Defines how far from the source the light is impacting in scene units.
  12052. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12053. */
  12054. range: number;
  12055. /**
  12056. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12057. * of light.
  12058. */
  12059. private _photometricScale;
  12060. private _intensityMode;
  12061. /**
  12062. * Gets the photometric scale used to interpret the intensity.
  12063. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12064. */
  12065. /**
  12066. * Sets the photometric scale used to interpret the intensity.
  12067. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12068. */
  12069. intensityMode: number;
  12070. private _radius;
  12071. /**
  12072. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12073. */
  12074. /**
  12075. * sets the light radius used by PBR Materials to simulate soft area lights.
  12076. */
  12077. radius: number;
  12078. private _renderPriority;
  12079. /**
  12080. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12081. * exceeding the number allowed of the materials.
  12082. */
  12083. renderPriority: number;
  12084. private _shadowEnabled;
  12085. /**
  12086. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12087. * the current shadow generator.
  12088. */
  12089. /**
  12090. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12091. * the current shadow generator.
  12092. */
  12093. shadowEnabled: boolean;
  12094. private _includedOnlyMeshes;
  12095. /**
  12096. * Gets the only meshes impacted by this light.
  12097. */
  12098. /**
  12099. * Sets the only meshes impacted by this light.
  12100. */
  12101. includedOnlyMeshes: AbstractMesh[];
  12102. private _excludedMeshes;
  12103. /**
  12104. * Gets the meshes not impacted by this light.
  12105. */
  12106. /**
  12107. * Sets the meshes not impacted by this light.
  12108. */
  12109. excludedMeshes: AbstractMesh[];
  12110. private _excludeWithLayerMask;
  12111. /**
  12112. * Gets the layer id use to find what meshes are not impacted by the light.
  12113. * Inactive if 0
  12114. */
  12115. /**
  12116. * Sets the layer id use to find what meshes are not impacted by the light.
  12117. * Inactive if 0
  12118. */
  12119. excludeWithLayerMask: number;
  12120. private _includeOnlyWithLayerMask;
  12121. /**
  12122. * Gets the layer id use to find what meshes are impacted by the light.
  12123. * Inactive if 0
  12124. */
  12125. /**
  12126. * Sets the layer id use to find what meshes are impacted by the light.
  12127. * Inactive if 0
  12128. */
  12129. includeOnlyWithLayerMask: number;
  12130. private _lightmapMode;
  12131. /**
  12132. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12133. */
  12134. /**
  12135. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12136. */
  12137. lightmapMode: number;
  12138. /**
  12139. * Shadow generator associted to the light.
  12140. * @hidden Internal use only.
  12141. */
  12142. _shadowGenerator: Nullable<IShadowGenerator>;
  12143. /**
  12144. * @hidden Internal use only.
  12145. */
  12146. _excludedMeshesIds: string[];
  12147. /**
  12148. * @hidden Internal use only.
  12149. */
  12150. _includedOnlyMeshesIds: string[];
  12151. /**
  12152. * The current light unifom buffer.
  12153. * @hidden Internal use only.
  12154. */
  12155. _uniformBuffer: UniformBuffer;
  12156. /**
  12157. * Creates a Light object in the scene.
  12158. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12159. * @param name The firendly name of the light
  12160. * @param scene The scene the light belongs too
  12161. */
  12162. constructor(name: string, scene: Scene);
  12163. protected abstract _buildUniformLayout(): void;
  12164. /**
  12165. * Sets the passed Effect "effect" with the Light information.
  12166. * @param effect The effect to update
  12167. * @param lightIndex The index of the light in the effect to update
  12168. * @returns The light
  12169. */
  12170. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12171. /**
  12172. * Returns the string "Light".
  12173. * @returns the class name
  12174. */
  12175. getClassName(): string;
  12176. /** @hidden */
  12177. readonly _isLight: boolean;
  12178. /**
  12179. * Converts the light information to a readable string for debug purpose.
  12180. * @param fullDetails Supports for multiple levels of logging within scene loading
  12181. * @returns the human readable light info
  12182. */
  12183. toString(fullDetails?: boolean): string;
  12184. /** @hidden */
  12185. protected _syncParentEnabledState(): void;
  12186. /**
  12187. * Set the enabled state of this node.
  12188. * @param value - the new enabled state
  12189. */
  12190. setEnabled(value: boolean): void;
  12191. /**
  12192. * Returns the Light associated shadow generator if any.
  12193. * @return the associated shadow generator.
  12194. */
  12195. getShadowGenerator(): Nullable<IShadowGenerator>;
  12196. /**
  12197. * Returns a Vector3, the absolute light position in the World.
  12198. * @returns the world space position of the light
  12199. */
  12200. getAbsolutePosition(): Vector3;
  12201. /**
  12202. * Specifies if the light will affect the passed mesh.
  12203. * @param mesh The mesh to test against the light
  12204. * @return true the mesh is affected otherwise, false.
  12205. */
  12206. canAffectMesh(mesh: AbstractMesh): boolean;
  12207. /**
  12208. * Sort function to order lights for rendering.
  12209. * @param a First Light object to compare to second.
  12210. * @param b Second Light object to compare first.
  12211. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12212. */
  12213. static CompareLightsPriority(a: Light, b: Light): number;
  12214. /**
  12215. * Releases resources associated with this node.
  12216. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12217. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12218. */
  12219. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12220. /**
  12221. * Returns the light type ID (integer).
  12222. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12223. */
  12224. getTypeID(): number;
  12225. /**
  12226. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12227. * @returns the scaled intensity in intensity mode unit
  12228. */
  12229. getScaledIntensity(): number;
  12230. /**
  12231. * Returns a new Light object, named "name", from the current one.
  12232. * @param name The name of the cloned light
  12233. * @returns the new created light
  12234. */
  12235. clone(name: string): Nullable<Light>;
  12236. /**
  12237. * Serializes the current light into a Serialization object.
  12238. * @returns the serialized object.
  12239. */
  12240. serialize(): any;
  12241. /**
  12242. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12243. * This new light is named "name" and added to the passed scene.
  12244. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12245. * @param name The friendly name of the light
  12246. * @param scene The scene the new light will belong to
  12247. * @returns the constructor function
  12248. */
  12249. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12250. /**
  12251. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12252. * @param parsedLight The JSON representation of the light
  12253. * @param scene The scene to create the parsed light in
  12254. * @returns the created light after parsing
  12255. */
  12256. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12257. private _hookArrayForExcluded;
  12258. private _hookArrayForIncludedOnly;
  12259. private _resyncMeshes;
  12260. /**
  12261. * Forces the meshes to update their light related information in their rendering used effects
  12262. * @hidden Internal Use Only
  12263. */
  12264. _markMeshesAsLightDirty(): void;
  12265. /**
  12266. * Recomputes the cached photometric scale if needed.
  12267. */
  12268. private _computePhotometricScale;
  12269. /**
  12270. * Returns the Photometric Scale according to the light type and intensity mode.
  12271. */
  12272. private _getPhotometricScale;
  12273. /**
  12274. * Reorder the light in the scene according to their defined priority.
  12275. * @hidden Internal Use Only
  12276. */
  12277. _reorderLightsInScene(): void;
  12278. /**
  12279. * Prepares the list of defines specific to the light type.
  12280. * @param defines the list of defines
  12281. * @param lightIndex defines the index of the light for the effect
  12282. */
  12283. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12284. }
  12285. }
  12286. declare module "babylonjs/Meshes/instancedMesh" {
  12287. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  12288. import { Vector3, Matrix } from "babylonjs/Maths/math";
  12289. import { Camera } from "babylonjs/Cameras/camera";
  12290. import { Node } from "babylonjs/node";
  12291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12292. import { Mesh } from "babylonjs/Meshes/mesh";
  12293. import { Material } from "babylonjs/Materials/material";
  12294. import { Skeleton } from "babylonjs/Bones/skeleton";
  12295. import { Light } from "babylonjs/Lights/light";
  12296. /**
  12297. * Creates an instance based on a source mesh.
  12298. */
  12299. export class InstancedMesh extends AbstractMesh {
  12300. private _sourceMesh;
  12301. private _currentLOD;
  12302. /** @hidden */
  12303. _indexInSourceMeshInstanceArray: number;
  12304. constructor(name: string, source: Mesh);
  12305. /**
  12306. * Returns the string "InstancedMesh".
  12307. */
  12308. getClassName(): string;
  12309. /** Gets the list of lights affecting that mesh */
  12310. readonly lightSources: Light[];
  12311. _resyncLightSources(): void;
  12312. _resyncLighSource(light: Light): void;
  12313. _removeLightSource(light: Light): void;
  12314. /**
  12315. * If the source mesh receives shadows
  12316. */
  12317. readonly receiveShadows: boolean;
  12318. /**
  12319. * The material of the source mesh
  12320. */
  12321. readonly material: Nullable<Material>;
  12322. /**
  12323. * Visibility of the source mesh
  12324. */
  12325. readonly visibility: number;
  12326. /**
  12327. * Skeleton of the source mesh
  12328. */
  12329. readonly skeleton: Nullable<Skeleton>;
  12330. /**
  12331. * Rendering ground id of the source mesh
  12332. */
  12333. renderingGroupId: number;
  12334. /**
  12335. * Returns the total number of vertices (integer).
  12336. */
  12337. getTotalVertices(): number;
  12338. /**
  12339. * Returns a positive integer : the total number of indices in this mesh geometry.
  12340. * @returns the numner of indices or zero if the mesh has no geometry.
  12341. */
  12342. getTotalIndices(): number;
  12343. /**
  12344. * The source mesh of the instance
  12345. */
  12346. readonly sourceMesh: Mesh;
  12347. /**
  12348. * Is this node ready to be used/rendered
  12349. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12350. * @return {boolean} is it ready
  12351. */
  12352. isReady(completeCheck?: boolean): boolean;
  12353. /**
  12354. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12355. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12356. * @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.
  12357. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12358. */
  12359. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12360. /**
  12361. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12362. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12363. * The `data` are either a numeric array either a Float32Array.
  12364. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12365. * 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).
  12366. * Note that a new underlying VertexBuffer object is created each call.
  12367. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12368. *
  12369. * Possible `kind` values :
  12370. * - VertexBuffer.PositionKind
  12371. * - VertexBuffer.UVKind
  12372. * - VertexBuffer.UV2Kind
  12373. * - VertexBuffer.UV3Kind
  12374. * - VertexBuffer.UV4Kind
  12375. * - VertexBuffer.UV5Kind
  12376. * - VertexBuffer.UV6Kind
  12377. * - VertexBuffer.ColorKind
  12378. * - VertexBuffer.MatricesIndicesKind
  12379. * - VertexBuffer.MatricesIndicesExtraKind
  12380. * - VertexBuffer.MatricesWeightsKind
  12381. * - VertexBuffer.MatricesWeightsExtraKind
  12382. *
  12383. * Returns the Mesh.
  12384. */
  12385. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12386. /**
  12387. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12388. * If the mesh has no geometry, it is simply returned as it is.
  12389. * The `data` are either a numeric array either a Float32Array.
  12390. * No new underlying VertexBuffer object is created.
  12391. * 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.
  12392. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12393. *
  12394. * Possible `kind` values :
  12395. * - VertexBuffer.PositionKind
  12396. * - VertexBuffer.UVKind
  12397. * - VertexBuffer.UV2Kind
  12398. * - VertexBuffer.UV3Kind
  12399. * - VertexBuffer.UV4Kind
  12400. * - VertexBuffer.UV5Kind
  12401. * - VertexBuffer.UV6Kind
  12402. * - VertexBuffer.ColorKind
  12403. * - VertexBuffer.MatricesIndicesKind
  12404. * - VertexBuffer.MatricesIndicesExtraKind
  12405. * - VertexBuffer.MatricesWeightsKind
  12406. * - VertexBuffer.MatricesWeightsExtraKind
  12407. *
  12408. * Returns the Mesh.
  12409. */
  12410. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12411. /**
  12412. * Sets the mesh indices.
  12413. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12414. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12415. * This method creates a new index buffer each call.
  12416. * Returns the Mesh.
  12417. */
  12418. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12419. /**
  12420. * Boolean : True if the mesh owns the requested kind of data.
  12421. */
  12422. isVerticesDataPresent(kind: string): boolean;
  12423. /**
  12424. * Returns an array of indices (IndicesArray).
  12425. */
  12426. getIndices(): Nullable<IndicesArray>;
  12427. readonly _positions: Nullable<Vector3[]>;
  12428. /**
  12429. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12430. * This means the mesh underlying bounding box and sphere are recomputed.
  12431. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12432. * @returns the current mesh
  12433. */
  12434. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12435. /** @hidden */
  12436. _preActivate(): InstancedMesh;
  12437. /** @hidden */
  12438. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12439. /** @hidden */
  12440. _postActivate(): void;
  12441. getWorldMatrix(): Matrix;
  12442. readonly isAnInstance: boolean;
  12443. /**
  12444. * Returns the current associated LOD AbstractMesh.
  12445. */
  12446. getLOD(camera: Camera): AbstractMesh;
  12447. /** @hidden */
  12448. _syncSubMeshes(): InstancedMesh;
  12449. /** @hidden */
  12450. _generatePointsArray(): boolean;
  12451. /**
  12452. * Creates a new InstancedMesh from the current mesh.
  12453. * - name (string) : the cloned mesh name
  12454. * - newParent (optional Node) : the optional Node to parent the clone to.
  12455. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12456. *
  12457. * Returns the clone.
  12458. */
  12459. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12460. /**
  12461. * Disposes the InstancedMesh.
  12462. * Returns nothing.
  12463. */
  12464. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12465. }
  12466. }
  12467. declare module "babylonjs/Materials/shaderMaterial" {
  12468. import { Scene } from "babylonjs/scene";
  12469. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  12470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12471. import { Mesh } from "babylonjs/Meshes/mesh";
  12472. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  12473. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12474. import { Texture } from "babylonjs/Materials/Textures/texture";
  12475. import { Material } from "babylonjs/Materials/material";
  12476. /**
  12477. * Defines the options associated with the creation of a shader material.
  12478. */
  12479. export interface IShaderMaterialOptions {
  12480. /**
  12481. * Does the material work in alpha blend mode
  12482. */
  12483. needAlphaBlending: boolean;
  12484. /**
  12485. * Does the material work in alpha test mode
  12486. */
  12487. needAlphaTesting: boolean;
  12488. /**
  12489. * The list of attribute names used in the shader
  12490. */
  12491. attributes: string[];
  12492. /**
  12493. * The list of unifrom names used in the shader
  12494. */
  12495. uniforms: string[];
  12496. /**
  12497. * The list of UBO names used in the shader
  12498. */
  12499. uniformBuffers: string[];
  12500. /**
  12501. * The list of sampler names used in the shader
  12502. */
  12503. samplers: string[];
  12504. /**
  12505. * The list of defines used in the shader
  12506. */
  12507. defines: string[];
  12508. }
  12509. /**
  12510. * 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.
  12511. *
  12512. * This returned material effects how the mesh will look based on the code in the shaders.
  12513. *
  12514. * @see http://doc.babylonjs.com/how_to/shader_material
  12515. */
  12516. export class ShaderMaterial extends Material {
  12517. private _shaderPath;
  12518. private _options;
  12519. private _textures;
  12520. private _textureArrays;
  12521. private _floats;
  12522. private _ints;
  12523. private _floatsArrays;
  12524. private _colors3;
  12525. private _colors3Arrays;
  12526. private _colors4;
  12527. private _colors4Arrays;
  12528. private _vectors2;
  12529. private _vectors3;
  12530. private _vectors4;
  12531. private _matrices;
  12532. private _matrices3x3;
  12533. private _matrices2x2;
  12534. private _vectors2Arrays;
  12535. private _vectors3Arrays;
  12536. private _vectors4Arrays;
  12537. private _cachedWorldViewMatrix;
  12538. private _cachedWorldViewProjectionMatrix;
  12539. private _renderId;
  12540. /**
  12541. * Instantiate a new shader material.
  12542. * 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.
  12543. * This returned material effects how the mesh will look based on the code in the shaders.
  12544. * @see http://doc.babylonjs.com/how_to/shader_material
  12545. * @param name Define the name of the material in the scene
  12546. * @param scene Define the scene the material belongs to
  12547. * @param shaderPath Defines the route to the shader code in one of three ways:
  12548. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12549. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12550. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12551. * @param options Define the options used to create the shader
  12552. */
  12553. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12554. /**
  12555. * Gets the options used to compile the shader.
  12556. * They can be modified to trigger a new compilation
  12557. */
  12558. readonly options: IShaderMaterialOptions;
  12559. /**
  12560. * Gets the current class name of the material e.g. "ShaderMaterial"
  12561. * Mainly use in serialization.
  12562. * @returns the class name
  12563. */
  12564. getClassName(): string;
  12565. /**
  12566. * Specifies if the material will require alpha blending
  12567. * @returns a boolean specifying if alpha blending is needed
  12568. */
  12569. needAlphaBlending(): boolean;
  12570. /**
  12571. * Specifies if this material should be rendered in alpha test mode
  12572. * @returns a boolean specifying if an alpha test is needed.
  12573. */
  12574. needAlphaTesting(): boolean;
  12575. private _checkUniform;
  12576. /**
  12577. * Set a texture in the shader.
  12578. * @param name Define the name of the uniform samplers as defined in the shader
  12579. * @param texture Define the texture to bind to this sampler
  12580. * @return the material itself allowing "fluent" like uniform updates
  12581. */
  12582. setTexture(name: string, texture: Texture): ShaderMaterial;
  12583. /**
  12584. * Set a texture array in the shader.
  12585. * @param name Define the name of the uniform sampler array as defined in the shader
  12586. * @param textures Define the list of textures to bind to this sampler
  12587. * @return the material itself allowing "fluent" like uniform updates
  12588. */
  12589. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12590. /**
  12591. * Set a float in the shader.
  12592. * @param name Define the name of the uniform as defined in the shader
  12593. * @param value Define the value to give to the uniform
  12594. * @return the material itself allowing "fluent" like uniform updates
  12595. */
  12596. setFloat(name: string, value: number): ShaderMaterial;
  12597. /**
  12598. * Set a int in the shader.
  12599. * @param name Define the name of the uniform as defined in the shader
  12600. * @param value Define the value to give to the uniform
  12601. * @return the material itself allowing "fluent" like uniform updates
  12602. */
  12603. setInt(name: string, value: number): ShaderMaterial;
  12604. /**
  12605. * Set an array of floats in the shader.
  12606. * @param name Define the name of the uniform as defined in the shader
  12607. * @param value Define the value to give to the uniform
  12608. * @return the material itself allowing "fluent" like uniform updates
  12609. */
  12610. setFloats(name: string, value: number[]): ShaderMaterial;
  12611. /**
  12612. * Set a vec3 in the shader from a Color3.
  12613. * @param name Define the name of the uniform as defined in the shader
  12614. * @param value Define the value to give to the uniform
  12615. * @return the material itself allowing "fluent" like uniform updates
  12616. */
  12617. setColor3(name: string, value: Color3): ShaderMaterial;
  12618. /**
  12619. * Set a vec3 array in the shader from a Color3 array.
  12620. * @param name Define the name of the uniform as defined in the shader
  12621. * @param value Define the value to give to the uniform
  12622. * @return the material itself allowing "fluent" like uniform updates
  12623. */
  12624. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12625. /**
  12626. * Set a vec4 in the shader from a Color4.
  12627. * @param name Define the name of the uniform as defined in the shader
  12628. * @param value Define the value to give to the uniform
  12629. * @return the material itself allowing "fluent" like uniform updates
  12630. */
  12631. setColor4(name: string, value: Color4): ShaderMaterial;
  12632. /**
  12633. * Set a vec4 array in the shader from a Color4 array.
  12634. * @param name Define the name of the uniform as defined in the shader
  12635. * @param value Define the value to give to the uniform
  12636. * @return the material itself allowing "fluent" like uniform updates
  12637. */
  12638. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12639. /**
  12640. * Set a vec2 in the shader from a Vector2.
  12641. * @param name Define the name of the uniform as defined in the shader
  12642. * @param value Define the value to give to the uniform
  12643. * @return the material itself allowing "fluent" like uniform updates
  12644. */
  12645. setVector2(name: string, value: Vector2): ShaderMaterial;
  12646. /**
  12647. * Set a vec3 in the shader from a Vector3.
  12648. * @param name Define the name of the uniform as defined in the shader
  12649. * @param value Define the value to give to the uniform
  12650. * @return the material itself allowing "fluent" like uniform updates
  12651. */
  12652. setVector3(name: string, value: Vector3): ShaderMaterial;
  12653. /**
  12654. * Set a vec4 in the shader from a Vector4.
  12655. * @param name Define the name of the uniform as defined in the shader
  12656. * @param value Define the value to give to the uniform
  12657. * @return the material itself allowing "fluent" like uniform updates
  12658. */
  12659. setVector4(name: string, value: Vector4): ShaderMaterial;
  12660. /**
  12661. * Set a mat4 in the shader from a Matrix.
  12662. * @param name Define the name of the uniform as defined in the shader
  12663. * @param value Define the value to give to the uniform
  12664. * @return the material itself allowing "fluent" like uniform updates
  12665. */
  12666. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12667. /**
  12668. * Set a mat3 in the shader from a Float32Array.
  12669. * @param name Define the name of the uniform as defined in the shader
  12670. * @param value Define the value to give to the uniform
  12671. * @return the material itself allowing "fluent" like uniform updates
  12672. */
  12673. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12674. /**
  12675. * Set a mat2 in the shader from a Float32Array.
  12676. * @param name Define the name of the uniform as defined in the shader
  12677. * @param value Define the value to give to the uniform
  12678. * @return the material itself allowing "fluent" like uniform updates
  12679. */
  12680. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12681. /**
  12682. * Set a vec2 array in the shader from a number array.
  12683. * @param name Define the name of the uniform as defined in the shader
  12684. * @param value Define the value to give to the uniform
  12685. * @return the material itself allowing "fluent" like uniform updates
  12686. */
  12687. setArray2(name: string, value: number[]): ShaderMaterial;
  12688. /**
  12689. * Set a vec3 array in the shader from a number array.
  12690. * @param name Define the name of the uniform as defined in the shader
  12691. * @param value Define the value to give to the uniform
  12692. * @return the material itself allowing "fluent" like uniform updates
  12693. */
  12694. setArray3(name: string, value: number[]): ShaderMaterial;
  12695. /**
  12696. * Set a vec4 array in the shader from a number array.
  12697. * @param name Define the name of the uniform as defined in the shader
  12698. * @param value Define the value to give to the uniform
  12699. * @return the material itself allowing "fluent" like uniform updates
  12700. */
  12701. setArray4(name: string, value: number[]): ShaderMaterial;
  12702. private _checkCache;
  12703. /**
  12704. * Specifies that the submesh is ready to be used
  12705. * @param mesh defines the mesh to check
  12706. * @param subMesh defines which submesh to check
  12707. * @param useInstances specifies that instances should be used
  12708. * @returns a boolean indicating that the submesh is ready or not
  12709. */
  12710. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12711. /**
  12712. * Checks if the material is ready to render the requested mesh
  12713. * @param mesh Define the mesh to render
  12714. * @param useInstances Define whether or not the material is used with instances
  12715. * @returns true if ready, otherwise false
  12716. */
  12717. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12718. /**
  12719. * Binds the world matrix to the material
  12720. * @param world defines the world transformation matrix
  12721. */
  12722. bindOnlyWorldMatrix(world: Matrix): void;
  12723. /**
  12724. * Binds the material to the mesh
  12725. * @param world defines the world transformation matrix
  12726. * @param mesh defines the mesh to bind the material to
  12727. */
  12728. bind(world: Matrix, mesh?: Mesh): void;
  12729. /**
  12730. * Gets the active textures from the material
  12731. * @returns an array of textures
  12732. */
  12733. getActiveTextures(): BaseTexture[];
  12734. /**
  12735. * Specifies if the material uses a texture
  12736. * @param texture defines the texture to check against the material
  12737. * @returns a boolean specifying if the material uses the texture
  12738. */
  12739. hasTexture(texture: BaseTexture): boolean;
  12740. /**
  12741. * Makes a duplicate of the material, and gives it a new name
  12742. * @param name defines the new name for the duplicated material
  12743. * @returns the cloned material
  12744. */
  12745. clone(name: string): ShaderMaterial;
  12746. /**
  12747. * Disposes the material
  12748. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12749. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12750. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12751. */
  12752. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12753. /**
  12754. * Serializes this material in a JSON representation
  12755. * @returns the serialized material object
  12756. */
  12757. serialize(): any;
  12758. /**
  12759. * Creates a shader material from parsed shader material data
  12760. * @param source defines the JSON represnetation of the material
  12761. * @param scene defines the hosting scene
  12762. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12763. * @returns a new material
  12764. */
  12765. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12766. }
  12767. }
  12768. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  12769. /** @hidden */
  12770. export var clipPlaneFragmentDeclaration: {
  12771. name: string;
  12772. shader: string;
  12773. };
  12774. }
  12775. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  12776. /** @hidden */
  12777. export var clipPlaneFragment: {
  12778. name: string;
  12779. shader: string;
  12780. };
  12781. }
  12782. declare module "babylonjs/Shaders/color.fragment" {
  12783. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12784. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12785. /** @hidden */
  12786. export var colorPixelShader: {
  12787. name: string;
  12788. shader: string;
  12789. };
  12790. }
  12791. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  12792. /** @hidden */
  12793. export var clipPlaneVertexDeclaration: {
  12794. name: string;
  12795. shader: string;
  12796. };
  12797. }
  12798. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  12799. /** @hidden */
  12800. export var clipPlaneVertex: {
  12801. name: string;
  12802. shader: string;
  12803. };
  12804. }
  12805. declare module "babylonjs/Shaders/color.vertex" {
  12806. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  12807. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12808. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  12809. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  12810. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  12811. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12812. /** @hidden */
  12813. export var colorVertexShader: {
  12814. name: string;
  12815. shader: string;
  12816. };
  12817. }
  12818. declare module "babylonjs/Meshes/linesMesh" {
  12819. import { Nullable } from "babylonjs/types";
  12820. import { Scene } from "babylonjs/scene";
  12821. import { Color3 } from "babylonjs/Maths/math";
  12822. import { Node } from "babylonjs/node";
  12823. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12824. import { Mesh } from "babylonjs/Meshes/mesh";
  12825. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  12826. import { Effect } from "babylonjs/Materials/effect";
  12827. import { Material } from "babylonjs/Materials/material";
  12828. import "babylonjs/Shaders/color.fragment";
  12829. import "babylonjs/Shaders/color.vertex";
  12830. /**
  12831. * Line mesh
  12832. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12833. */
  12834. export class LinesMesh extends Mesh {
  12835. /**
  12836. * If vertex color should be applied to the mesh
  12837. */
  12838. readonly useVertexColor?: boolean | undefined;
  12839. /**
  12840. * If vertex alpha should be applied to the mesh
  12841. */
  12842. readonly useVertexAlpha?: boolean | undefined;
  12843. /**
  12844. * Color of the line (Default: White)
  12845. */
  12846. color: Color3;
  12847. /**
  12848. * Alpha of the line (Default: 1)
  12849. */
  12850. alpha: number;
  12851. /**
  12852. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12853. * This margin is expressed in world space coordinates, so its value may vary.
  12854. * Default value is 0.1
  12855. */
  12856. intersectionThreshold: number;
  12857. private _colorShader;
  12858. private color4;
  12859. /**
  12860. * Creates a new LinesMesh
  12861. * @param name defines the name
  12862. * @param scene defines the hosting scene
  12863. * @param parent defines the parent mesh if any
  12864. * @param source defines the optional source LinesMesh used to clone data from
  12865. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12866. * When false, achieved by calling a clone(), also passing False.
  12867. * This will make creation of children, recursive.
  12868. * @param useVertexColor defines if this LinesMesh supports vertex color
  12869. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12870. */
  12871. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12872. /**
  12873. * If vertex color should be applied to the mesh
  12874. */
  12875. useVertexColor?: boolean | undefined,
  12876. /**
  12877. * If vertex alpha should be applied to the mesh
  12878. */
  12879. useVertexAlpha?: boolean | undefined);
  12880. private _addClipPlaneDefine;
  12881. private _removeClipPlaneDefine;
  12882. isReady(): boolean;
  12883. /**
  12884. * Returns the string "LineMesh"
  12885. */
  12886. getClassName(): string;
  12887. /**
  12888. * @hidden
  12889. */
  12890. /**
  12891. * @hidden
  12892. */
  12893. material: Material;
  12894. /**
  12895. * @hidden
  12896. */
  12897. readonly checkCollisions: boolean;
  12898. /** @hidden */
  12899. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12900. /** @hidden */
  12901. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12902. /**
  12903. * Disposes of the line mesh
  12904. * @param doNotRecurse If children should be disposed
  12905. */
  12906. dispose(doNotRecurse?: boolean): void;
  12907. /**
  12908. * Returns a new LineMesh object cloned from the current one.
  12909. */
  12910. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12911. /**
  12912. * Creates a new InstancedLinesMesh object from the mesh model.
  12913. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12914. * @param name defines the name of the new instance
  12915. * @returns a new InstancedLinesMesh
  12916. */
  12917. createInstance(name: string): InstancedLinesMesh;
  12918. }
  12919. /**
  12920. * Creates an instance based on a source LinesMesh
  12921. */
  12922. export class InstancedLinesMesh extends InstancedMesh {
  12923. /**
  12924. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12925. * This margin is expressed in world space coordinates, so its value may vary.
  12926. * Initilized with the intersectionThreshold value of the source LinesMesh
  12927. */
  12928. intersectionThreshold: number;
  12929. constructor(name: string, source: LinesMesh);
  12930. /**
  12931. * Returns the string "InstancedLinesMesh".
  12932. */
  12933. getClassName(): string;
  12934. }
  12935. }
  12936. declare module "babylonjs/Meshes/groundMesh" {
  12937. import { Scene } from "babylonjs/scene";
  12938. import { Vector3 } from "babylonjs/Maths/math";
  12939. import { Mesh } from "babylonjs/Meshes/mesh";
  12940. /**
  12941. * Mesh representing the gorund
  12942. */
  12943. export class GroundMesh extends Mesh {
  12944. /** If octree should be generated */
  12945. generateOctree: boolean;
  12946. private _heightQuads;
  12947. /** @hidden */
  12948. _subdivisionsX: number;
  12949. /** @hidden */
  12950. _subdivisionsY: number;
  12951. /** @hidden */
  12952. _width: number;
  12953. /** @hidden */
  12954. _height: number;
  12955. /** @hidden */
  12956. _minX: number;
  12957. /** @hidden */
  12958. _maxX: number;
  12959. /** @hidden */
  12960. _minZ: number;
  12961. /** @hidden */
  12962. _maxZ: number;
  12963. constructor(name: string, scene: Scene);
  12964. /**
  12965. * "GroundMesh"
  12966. * @returns "GroundMesh"
  12967. */
  12968. getClassName(): string;
  12969. /**
  12970. * The minimum of x and y subdivisions
  12971. */
  12972. readonly subdivisions: number;
  12973. /**
  12974. * X subdivisions
  12975. */
  12976. readonly subdivisionsX: number;
  12977. /**
  12978. * Y subdivisions
  12979. */
  12980. readonly subdivisionsY: number;
  12981. /**
  12982. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12983. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12984. * @param chunksCount the number of subdivisions for x and y
  12985. * @param octreeBlocksSize (Default: 32)
  12986. */
  12987. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12988. /**
  12989. * Returns a height (y) value in the Worl system :
  12990. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12991. * @param x x coordinate
  12992. * @param z z coordinate
  12993. * @returns the ground y position if (x, z) are outside the ground surface.
  12994. */
  12995. getHeightAtCoordinates(x: number, z: number): number;
  12996. /**
  12997. * Returns a normalized vector (Vector3) orthogonal to the ground
  12998. * at the ground coordinates (x, z) expressed in the World system.
  12999. * @param x x coordinate
  13000. * @param z z coordinate
  13001. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  13002. */
  13003. getNormalAtCoordinates(x: number, z: number): Vector3;
  13004. /**
  13005. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  13006. * at the ground coordinates (x, z) expressed in the World system.
  13007. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  13008. * @param x x coordinate
  13009. * @param z z coordinate
  13010. * @param ref vector to store the result
  13011. * @returns the GroundMesh.
  13012. */
  13013. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  13014. /**
  13015. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  13016. * if the ground has been updated.
  13017. * This can be used in the render loop.
  13018. * @returns the GroundMesh.
  13019. */
  13020. updateCoordinateHeights(): GroundMesh;
  13021. private _getFacetAt;
  13022. private _initHeightQuads;
  13023. private _computeHeightQuads;
  13024. /**
  13025. * Serializes this ground mesh
  13026. * @param serializationObject object to write serialization to
  13027. */
  13028. serialize(serializationObject: any): void;
  13029. /**
  13030. * Parses a serialized ground mesh
  13031. * @param parsedMesh the serialized mesh
  13032. * @param scene the scene to create the ground mesh in
  13033. * @returns the created ground mesh
  13034. */
  13035. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  13036. }
  13037. }
  13038. declare module "babylonjs/Physics/physicsJoint" {
  13039. import { Vector3 } from "babylonjs/Maths/math";
  13040. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  13041. /**
  13042. * Interface for Physics-Joint data
  13043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13044. */
  13045. export interface PhysicsJointData {
  13046. /**
  13047. * The main pivot of the joint
  13048. */
  13049. mainPivot?: Vector3;
  13050. /**
  13051. * The connected pivot of the joint
  13052. */
  13053. connectedPivot?: Vector3;
  13054. /**
  13055. * The main axis of the joint
  13056. */
  13057. mainAxis?: Vector3;
  13058. /**
  13059. * The connected axis of the joint
  13060. */
  13061. connectedAxis?: Vector3;
  13062. /**
  13063. * The collision of the joint
  13064. */
  13065. collision?: boolean;
  13066. /**
  13067. * Native Oimo/Cannon/Energy data
  13068. */
  13069. nativeParams?: any;
  13070. }
  13071. /**
  13072. * This is a holder class for the physics joint created by the physics plugin
  13073. * It holds a set of functions to control the underlying joint
  13074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13075. */
  13076. export class PhysicsJoint {
  13077. /**
  13078. * The type of the physics joint
  13079. */
  13080. type: number;
  13081. /**
  13082. * The data for the physics joint
  13083. */
  13084. jointData: PhysicsJointData;
  13085. private _physicsJoint;
  13086. protected _physicsPlugin: IPhysicsEnginePlugin;
  13087. /**
  13088. * Initializes the physics joint
  13089. * @param type The type of the physics joint
  13090. * @param jointData The data for the physics joint
  13091. */
  13092. constructor(
  13093. /**
  13094. * The type of the physics joint
  13095. */
  13096. type: number,
  13097. /**
  13098. * The data for the physics joint
  13099. */
  13100. jointData: PhysicsJointData);
  13101. /**
  13102. * Gets the physics joint
  13103. */
  13104. /**
  13105. * Sets the physics joint
  13106. */
  13107. physicsJoint: any;
  13108. /**
  13109. * Sets the physics plugin
  13110. */
  13111. physicsPlugin: IPhysicsEnginePlugin;
  13112. /**
  13113. * Execute a function that is physics-plugin specific.
  13114. * @param {Function} func the function that will be executed.
  13115. * It accepts two parameters: the physics world and the physics joint
  13116. */
  13117. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  13118. /**
  13119. * Distance-Joint type
  13120. */
  13121. static DistanceJoint: number;
  13122. /**
  13123. * Hinge-Joint type
  13124. */
  13125. static HingeJoint: number;
  13126. /**
  13127. * Ball-and-Socket joint type
  13128. */
  13129. static BallAndSocketJoint: number;
  13130. /**
  13131. * Wheel-Joint type
  13132. */
  13133. static WheelJoint: number;
  13134. /**
  13135. * Slider-Joint type
  13136. */
  13137. static SliderJoint: number;
  13138. /**
  13139. * Prismatic-Joint type
  13140. */
  13141. static PrismaticJoint: number;
  13142. /**
  13143. * Universal-Joint type
  13144. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  13145. */
  13146. static UniversalJoint: number;
  13147. /**
  13148. * Hinge-Joint 2 type
  13149. */
  13150. static Hinge2Joint: number;
  13151. /**
  13152. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  13153. */
  13154. static PointToPointJoint: number;
  13155. /**
  13156. * Spring-Joint type
  13157. */
  13158. static SpringJoint: number;
  13159. /**
  13160. * Lock-Joint type
  13161. */
  13162. static LockJoint: number;
  13163. }
  13164. /**
  13165. * A class representing a physics distance joint
  13166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13167. */
  13168. export class DistanceJoint extends PhysicsJoint {
  13169. /**
  13170. *
  13171. * @param jointData The data for the Distance-Joint
  13172. */
  13173. constructor(jointData: DistanceJointData);
  13174. /**
  13175. * Update the predefined distance.
  13176. * @param maxDistance The maximum preferred distance
  13177. * @param minDistance The minimum preferred distance
  13178. */
  13179. updateDistance(maxDistance: number, minDistance?: number): void;
  13180. }
  13181. /**
  13182. * Represents a Motor-Enabled Joint
  13183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13184. */
  13185. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  13186. /**
  13187. * Initializes the Motor-Enabled Joint
  13188. * @param type The type of the joint
  13189. * @param jointData The physica joint data for the joint
  13190. */
  13191. constructor(type: number, jointData: PhysicsJointData);
  13192. /**
  13193. * Set the motor values.
  13194. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13195. * @param force the force to apply
  13196. * @param maxForce max force for this motor.
  13197. */
  13198. setMotor(force?: number, maxForce?: number): void;
  13199. /**
  13200. * Set the motor's limits.
  13201. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13202. * @param upperLimit The upper limit of the motor
  13203. * @param lowerLimit The lower limit of the motor
  13204. */
  13205. setLimit(upperLimit: number, lowerLimit?: number): void;
  13206. }
  13207. /**
  13208. * This class represents a single physics Hinge-Joint
  13209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13210. */
  13211. export class HingeJoint extends MotorEnabledJoint {
  13212. /**
  13213. * Initializes the Hinge-Joint
  13214. * @param jointData The joint data for the Hinge-Joint
  13215. */
  13216. constructor(jointData: PhysicsJointData);
  13217. /**
  13218. * Set the motor values.
  13219. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13220. * @param {number} force the force to apply
  13221. * @param {number} maxForce max force for this motor.
  13222. */
  13223. setMotor(force?: number, maxForce?: number): void;
  13224. /**
  13225. * Set the motor's limits.
  13226. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13227. * @param upperLimit The upper limit of the motor
  13228. * @param lowerLimit The lower limit of the motor
  13229. */
  13230. setLimit(upperLimit: number, lowerLimit?: number): void;
  13231. }
  13232. /**
  13233. * This class represents a dual hinge physics joint (same as wheel joint)
  13234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13235. */
  13236. export class Hinge2Joint extends MotorEnabledJoint {
  13237. /**
  13238. * Initializes the Hinge2-Joint
  13239. * @param jointData The joint data for the Hinge2-Joint
  13240. */
  13241. constructor(jointData: PhysicsJointData);
  13242. /**
  13243. * Set the motor values.
  13244. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13245. * @param {number} targetSpeed the speed the motor is to reach
  13246. * @param {number} maxForce max force for this motor.
  13247. * @param {motorIndex} the motor's index, 0 or 1.
  13248. */
  13249. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13250. /**
  13251. * Set the motor limits.
  13252. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13253. * @param {number} upperLimit the upper limit
  13254. * @param {number} lowerLimit lower limit
  13255. * @param {motorIndex} the motor's index, 0 or 1.
  13256. */
  13257. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13258. }
  13259. /**
  13260. * Interface for a motor enabled joint
  13261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13262. */
  13263. export interface IMotorEnabledJoint {
  13264. /**
  13265. * Physics joint
  13266. */
  13267. physicsJoint: any;
  13268. /**
  13269. * Sets the motor of the motor-enabled joint
  13270. * @param force The force of the motor
  13271. * @param maxForce The maximum force of the motor
  13272. * @param motorIndex The index of the motor
  13273. */
  13274. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13275. /**
  13276. * Sets the limit of the motor
  13277. * @param upperLimit The upper limit of the motor
  13278. * @param lowerLimit The lower limit of the motor
  13279. * @param motorIndex The index of the motor
  13280. */
  13281. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13282. }
  13283. /**
  13284. * Joint data for a Distance-Joint
  13285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13286. */
  13287. export interface DistanceJointData extends PhysicsJointData {
  13288. /**
  13289. * Max distance the 2 joint objects can be apart
  13290. */
  13291. maxDistance: number;
  13292. }
  13293. /**
  13294. * Joint data from a spring joint
  13295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13296. */
  13297. export interface SpringJointData extends PhysicsJointData {
  13298. /**
  13299. * Length of the spring
  13300. */
  13301. length: number;
  13302. /**
  13303. * Stiffness of the spring
  13304. */
  13305. stiffness: number;
  13306. /**
  13307. * Damping of the spring
  13308. */
  13309. damping: number;
  13310. /** this callback will be called when applying the force to the impostors. */
  13311. forceApplicationCallback: () => void;
  13312. }
  13313. }
  13314. declare module "babylonjs/Physics/physicsRaycastResult" {
  13315. import { Vector3 } from "babylonjs/Maths/math";
  13316. /**
  13317. * Holds the data for the raycast result
  13318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13319. */
  13320. export class PhysicsRaycastResult {
  13321. private _hasHit;
  13322. private _hitDistance;
  13323. private _hitNormalWorld;
  13324. private _hitPointWorld;
  13325. private _rayFromWorld;
  13326. private _rayToWorld;
  13327. /**
  13328. * Gets if there was a hit
  13329. */
  13330. readonly hasHit: boolean;
  13331. /**
  13332. * Gets the distance from the hit
  13333. */
  13334. readonly hitDistance: number;
  13335. /**
  13336. * Gets the hit normal/direction in the world
  13337. */
  13338. readonly hitNormalWorld: Vector3;
  13339. /**
  13340. * Gets the hit point in the world
  13341. */
  13342. readonly hitPointWorld: Vector3;
  13343. /**
  13344. * Gets the ray "start point" of the ray in the world
  13345. */
  13346. readonly rayFromWorld: Vector3;
  13347. /**
  13348. * Gets the ray "end point" of the ray in the world
  13349. */
  13350. readonly rayToWorld: Vector3;
  13351. /**
  13352. * Sets the hit data (normal & point in world space)
  13353. * @param hitNormalWorld defines the normal in world space
  13354. * @param hitPointWorld defines the point in world space
  13355. */
  13356. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13357. /**
  13358. * Sets the distance from the start point to the hit point
  13359. * @param distance
  13360. */
  13361. setHitDistance(distance: number): void;
  13362. /**
  13363. * Calculates the distance manually
  13364. */
  13365. calculateHitDistance(): void;
  13366. /**
  13367. * Resets all the values to default
  13368. * @param from The from point on world space
  13369. * @param to The to point on world space
  13370. */
  13371. reset(from?: Vector3, to?: Vector3): void;
  13372. }
  13373. /**
  13374. * Interface for the size containing width and height
  13375. */
  13376. interface IXYZ {
  13377. /**
  13378. * X
  13379. */
  13380. x: number;
  13381. /**
  13382. * Y
  13383. */
  13384. y: number;
  13385. /**
  13386. * Z
  13387. */
  13388. z: number;
  13389. }
  13390. }
  13391. declare module "babylonjs/Physics/IPhysicsEngine" {
  13392. import { Nullable } from "babylonjs/types";
  13393. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  13394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13395. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  13396. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  13397. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  13398. /**
  13399. * Interface used to describe a physics joint
  13400. */
  13401. export interface PhysicsImpostorJoint {
  13402. /** Defines the main impostor to which the joint is linked */
  13403. mainImpostor: PhysicsImpostor;
  13404. /** Defines the impostor that is connected to the main impostor using this joint */
  13405. connectedImpostor: PhysicsImpostor;
  13406. /** Defines the joint itself */
  13407. joint: PhysicsJoint;
  13408. }
  13409. /** @hidden */
  13410. export interface IPhysicsEnginePlugin {
  13411. world: any;
  13412. name: string;
  13413. setGravity(gravity: Vector3): void;
  13414. setTimeStep(timeStep: number): void;
  13415. getTimeStep(): number;
  13416. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13417. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13418. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13419. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13420. removePhysicsBody(impostor: PhysicsImpostor): void;
  13421. generateJoint(joint: PhysicsImpostorJoint): void;
  13422. removeJoint(joint: PhysicsImpostorJoint): void;
  13423. isSupported(): boolean;
  13424. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13425. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13426. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13427. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13428. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13429. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13430. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13431. getBodyMass(impostor: PhysicsImpostor): number;
  13432. getBodyFriction(impostor: PhysicsImpostor): number;
  13433. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13434. getBodyRestitution(impostor: PhysicsImpostor): number;
  13435. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13436. getBodyPressure?(impostor: PhysicsImpostor): number;
  13437. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13438. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13439. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13440. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13441. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13442. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13443. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13444. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13445. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13446. sleepBody(impostor: PhysicsImpostor): void;
  13447. wakeUpBody(impostor: PhysicsImpostor): void;
  13448. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13449. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13450. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13451. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13452. getRadius(impostor: PhysicsImpostor): number;
  13453. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13454. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13455. dispose(): void;
  13456. }
  13457. /**
  13458. * Interface used to define a physics engine
  13459. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13460. */
  13461. export interface IPhysicsEngine {
  13462. /**
  13463. * Gets the gravity vector used by the simulation
  13464. */
  13465. gravity: Vector3;
  13466. /**
  13467. * Sets the gravity vector used by the simulation
  13468. * @param gravity defines the gravity vector to use
  13469. */
  13470. setGravity(gravity: Vector3): void;
  13471. /**
  13472. * Set the time step of the physics engine.
  13473. * Default is 1/60.
  13474. * To slow it down, enter 1/600 for example.
  13475. * To speed it up, 1/30
  13476. * @param newTimeStep the new timestep to apply to this world.
  13477. */
  13478. setTimeStep(newTimeStep: number): void;
  13479. /**
  13480. * Get the time step of the physics engine.
  13481. * @returns the current time step
  13482. */
  13483. getTimeStep(): number;
  13484. /**
  13485. * Release all resources
  13486. */
  13487. dispose(): void;
  13488. /**
  13489. * Gets the name of the current physics plugin
  13490. * @returns the name of the plugin
  13491. */
  13492. getPhysicsPluginName(): string;
  13493. /**
  13494. * Adding a new impostor for the impostor tracking.
  13495. * This will be done by the impostor itself.
  13496. * @param impostor the impostor to add
  13497. */
  13498. addImpostor(impostor: PhysicsImpostor): void;
  13499. /**
  13500. * Remove an impostor from the engine.
  13501. * This impostor and its mesh will not longer be updated by the physics engine.
  13502. * @param impostor the impostor to remove
  13503. */
  13504. removeImpostor(impostor: PhysicsImpostor): void;
  13505. /**
  13506. * Add a joint to the physics engine
  13507. * @param mainImpostor defines the main impostor to which the joint is added.
  13508. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13509. * @param joint defines the joint that will connect both impostors.
  13510. */
  13511. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13512. /**
  13513. * Removes a joint from the simulation
  13514. * @param mainImpostor defines the impostor used with the joint
  13515. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13516. * @param joint defines the joint to remove
  13517. */
  13518. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13519. /**
  13520. * Gets the current plugin used to run the simulation
  13521. * @returns current plugin
  13522. */
  13523. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13524. /**
  13525. * Gets the list of physic impostors
  13526. * @returns an array of PhysicsImpostor
  13527. */
  13528. getImpostors(): Array<PhysicsImpostor>;
  13529. /**
  13530. * Gets the impostor for a physics enabled object
  13531. * @param object defines the object impersonated by the impostor
  13532. * @returns the PhysicsImpostor or null if not found
  13533. */
  13534. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13535. /**
  13536. * Gets the impostor for a physics body object
  13537. * @param body defines physics body used by the impostor
  13538. * @returns the PhysicsImpostor or null if not found
  13539. */
  13540. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13541. /**
  13542. * Does a raycast in the physics world
  13543. * @param from when should the ray start?
  13544. * @param to when should the ray end?
  13545. * @returns PhysicsRaycastResult
  13546. */
  13547. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13548. /**
  13549. * Called by the scene. No need to call it.
  13550. * @param delta defines the timespam between frames
  13551. */
  13552. _step(delta: number): void;
  13553. }
  13554. }
  13555. declare module "babylonjs/Physics/physicsImpostor" {
  13556. import { Nullable, IndicesArray } from "babylonjs/types";
  13557. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  13558. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13560. import { Scene } from "babylonjs/scene";
  13561. import { Bone } from "babylonjs/Bones/bone";
  13562. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  13563. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  13564. /**
  13565. * The interface for the physics imposter parameters
  13566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13567. */
  13568. export interface PhysicsImpostorParameters {
  13569. /**
  13570. * The mass of the physics imposter
  13571. */
  13572. mass: number;
  13573. /**
  13574. * The friction of the physics imposter
  13575. */
  13576. friction?: number;
  13577. /**
  13578. * The coefficient of restitution of the physics imposter
  13579. */
  13580. restitution?: number;
  13581. /**
  13582. * The native options of the physics imposter
  13583. */
  13584. nativeOptions?: any;
  13585. /**
  13586. * Specifies if the parent should be ignored
  13587. */
  13588. ignoreParent?: boolean;
  13589. /**
  13590. * Specifies if bi-directional transformations should be disabled
  13591. */
  13592. disableBidirectionalTransformation?: boolean;
  13593. /**
  13594. * The pressure inside the physics imposter, soft object only
  13595. */
  13596. pressure?: number;
  13597. /**
  13598. * The stiffness the physics imposter, soft object only
  13599. */
  13600. stiffness?: number;
  13601. /**
  13602. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13603. */
  13604. velocityIterations?: number;
  13605. /**
  13606. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13607. */
  13608. positionIterations?: number;
  13609. /**
  13610. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13611. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13612. * Add to fix multiple points
  13613. */
  13614. fixedPoints?: number;
  13615. /**
  13616. * The collision margin around a soft object
  13617. */
  13618. margin?: number;
  13619. /**
  13620. * The collision margin around a soft object
  13621. */
  13622. damping?: number;
  13623. /**
  13624. * The path for a rope based on an extrusion
  13625. */
  13626. path?: any;
  13627. /**
  13628. * The shape of an extrusion used for a rope based on an extrusion
  13629. */
  13630. shape?: any;
  13631. }
  13632. /**
  13633. * Interface for a physics-enabled object
  13634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13635. */
  13636. export interface IPhysicsEnabledObject {
  13637. /**
  13638. * The position of the physics-enabled object
  13639. */
  13640. position: Vector3;
  13641. /**
  13642. * The rotation of the physics-enabled object
  13643. */
  13644. rotationQuaternion: Nullable<Quaternion>;
  13645. /**
  13646. * The scale of the physics-enabled object
  13647. */
  13648. scaling: Vector3;
  13649. /**
  13650. * The rotation of the physics-enabled object
  13651. */
  13652. rotation?: Vector3;
  13653. /**
  13654. * The parent of the physics-enabled object
  13655. */
  13656. parent?: any;
  13657. /**
  13658. * The bounding info of the physics-enabled object
  13659. * @returns The bounding info of the physics-enabled object
  13660. */
  13661. getBoundingInfo(): BoundingInfo;
  13662. /**
  13663. * Computes the world matrix
  13664. * @param force Specifies if the world matrix should be computed by force
  13665. * @returns A world matrix
  13666. */
  13667. computeWorldMatrix(force: boolean): Matrix;
  13668. /**
  13669. * Gets the world matrix
  13670. * @returns A world matrix
  13671. */
  13672. getWorldMatrix?(): Matrix;
  13673. /**
  13674. * Gets the child meshes
  13675. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13676. * @returns An array of abstract meshes
  13677. */
  13678. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13679. /**
  13680. * Gets the vertex data
  13681. * @param kind The type of vertex data
  13682. * @returns A nullable array of numbers, or a float32 array
  13683. */
  13684. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13685. /**
  13686. * Gets the indices from the mesh
  13687. * @returns A nullable array of index arrays
  13688. */
  13689. getIndices?(): Nullable<IndicesArray>;
  13690. /**
  13691. * Gets the scene from the mesh
  13692. * @returns the indices array or null
  13693. */
  13694. getScene?(): Scene;
  13695. /**
  13696. * Gets the absolute position from the mesh
  13697. * @returns the absolute position
  13698. */
  13699. getAbsolutePosition(): Vector3;
  13700. /**
  13701. * Gets the absolute pivot point from the mesh
  13702. * @returns the absolute pivot point
  13703. */
  13704. getAbsolutePivotPoint(): Vector3;
  13705. /**
  13706. * Rotates the mesh
  13707. * @param axis The axis of rotation
  13708. * @param amount The amount of rotation
  13709. * @param space The space of the rotation
  13710. * @returns The rotation transform node
  13711. */
  13712. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13713. /**
  13714. * Translates the mesh
  13715. * @param axis The axis of translation
  13716. * @param distance The distance of translation
  13717. * @param space The space of the translation
  13718. * @returns The transform node
  13719. */
  13720. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13721. /**
  13722. * Sets the absolute position of the mesh
  13723. * @param absolutePosition The absolute position of the mesh
  13724. * @returns The transform node
  13725. */
  13726. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13727. /**
  13728. * Gets the class name of the mesh
  13729. * @returns The class name
  13730. */
  13731. getClassName(): string;
  13732. }
  13733. /**
  13734. * Represents a physics imposter
  13735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13736. */
  13737. export class PhysicsImpostor {
  13738. /**
  13739. * The physics-enabled object used as the physics imposter
  13740. */
  13741. object: IPhysicsEnabledObject;
  13742. /**
  13743. * The type of the physics imposter
  13744. */
  13745. type: number;
  13746. private _options;
  13747. private _scene?;
  13748. /**
  13749. * The default object size of the imposter
  13750. */
  13751. static DEFAULT_OBJECT_SIZE: Vector3;
  13752. /**
  13753. * The identity quaternion of the imposter
  13754. */
  13755. static IDENTITY_QUATERNION: Quaternion;
  13756. /** @hidden */
  13757. _pluginData: any;
  13758. private _physicsEngine;
  13759. private _physicsBody;
  13760. private _bodyUpdateRequired;
  13761. private _onBeforePhysicsStepCallbacks;
  13762. private _onAfterPhysicsStepCallbacks;
  13763. /** @hidden */
  13764. _onPhysicsCollideCallbacks: Array<{
  13765. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13766. otherImpostors: Array<PhysicsImpostor>;
  13767. }>;
  13768. private _deltaPosition;
  13769. private _deltaRotation;
  13770. private _deltaRotationConjugated;
  13771. /** @hidden */
  13772. _isFromLine: boolean;
  13773. private _parent;
  13774. private _isDisposed;
  13775. private static _tmpVecs;
  13776. private static _tmpQuat;
  13777. /**
  13778. * Specifies if the physics imposter is disposed
  13779. */
  13780. readonly isDisposed: boolean;
  13781. /**
  13782. * Gets the mass of the physics imposter
  13783. */
  13784. mass: number;
  13785. /**
  13786. * Gets the coefficient of friction
  13787. */
  13788. /**
  13789. * Sets the coefficient of friction
  13790. */
  13791. friction: number;
  13792. /**
  13793. * Gets the coefficient of restitution
  13794. */
  13795. /**
  13796. * Sets the coefficient of restitution
  13797. */
  13798. restitution: number;
  13799. /**
  13800. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13801. */
  13802. /**
  13803. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13804. */
  13805. pressure: number;
  13806. /**
  13807. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13808. */
  13809. /**
  13810. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13811. */
  13812. stiffness: number;
  13813. /**
  13814. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13815. */
  13816. /**
  13817. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13818. */
  13819. velocityIterations: number;
  13820. /**
  13821. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13822. */
  13823. /**
  13824. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13825. */
  13826. positionIterations: number;
  13827. /**
  13828. * The unique id of the physics imposter
  13829. * set by the physics engine when adding this impostor to the array
  13830. */
  13831. uniqueId: number;
  13832. /**
  13833. * @hidden
  13834. */
  13835. soft: boolean;
  13836. /**
  13837. * @hidden
  13838. */
  13839. segments: number;
  13840. private _joints;
  13841. /**
  13842. * Initializes the physics imposter
  13843. * @param object The physics-enabled object used as the physics imposter
  13844. * @param type The type of the physics imposter
  13845. * @param _options The options for the physics imposter
  13846. * @param _scene The Babylon scene
  13847. */
  13848. constructor(
  13849. /**
  13850. * The physics-enabled object used as the physics imposter
  13851. */
  13852. object: IPhysicsEnabledObject,
  13853. /**
  13854. * The type of the physics imposter
  13855. */
  13856. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13857. /**
  13858. * This function will completly initialize this impostor.
  13859. * It will create a new body - but only if this mesh has no parent.
  13860. * If it has, this impostor will not be used other than to define the impostor
  13861. * of the child mesh.
  13862. * @hidden
  13863. */
  13864. _init(): void;
  13865. private _getPhysicsParent;
  13866. /**
  13867. * Should a new body be generated.
  13868. * @returns boolean specifying if body initialization is required
  13869. */
  13870. isBodyInitRequired(): boolean;
  13871. /**
  13872. * Sets the updated scaling
  13873. * @param updated Specifies if the scaling is updated
  13874. */
  13875. setScalingUpdated(): void;
  13876. /**
  13877. * Force a regeneration of this or the parent's impostor's body.
  13878. * Use under cautious - This will remove all joints already implemented.
  13879. */
  13880. forceUpdate(): void;
  13881. /**
  13882. * Gets the body that holds this impostor. Either its own, or its parent.
  13883. */
  13884. /**
  13885. * Set the physics body. Used mainly by the physics engine/plugin
  13886. */
  13887. physicsBody: any;
  13888. /**
  13889. * Get the parent of the physics imposter
  13890. * @returns Physics imposter or null
  13891. */
  13892. /**
  13893. * Sets the parent of the physics imposter
  13894. */
  13895. parent: Nullable<PhysicsImpostor>;
  13896. /**
  13897. * Resets the update flags
  13898. */
  13899. resetUpdateFlags(): void;
  13900. /**
  13901. * Gets the object extend size
  13902. * @returns the object extend size
  13903. */
  13904. getObjectExtendSize(): Vector3;
  13905. /**
  13906. * Gets the object center
  13907. * @returns The object center
  13908. */
  13909. getObjectCenter(): Vector3;
  13910. /**
  13911. * Get a specific parametes from the options parameter
  13912. * @param paramName The object parameter name
  13913. * @returns The object parameter
  13914. */
  13915. getParam(paramName: string): any;
  13916. /**
  13917. * Sets a specific parameter in the options given to the physics plugin
  13918. * @param paramName The parameter name
  13919. * @param value The value of the parameter
  13920. */
  13921. setParam(paramName: string, value: number): void;
  13922. /**
  13923. * Specifically change the body's mass option. Won't recreate the physics body object
  13924. * @param mass The mass of the physics imposter
  13925. */
  13926. setMass(mass: number): void;
  13927. /**
  13928. * Gets the linear velocity
  13929. * @returns linear velocity or null
  13930. */
  13931. getLinearVelocity(): Nullable<Vector3>;
  13932. /**
  13933. * Sets the linear velocity
  13934. * @param velocity linear velocity or null
  13935. */
  13936. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13937. /**
  13938. * Gets the angular velocity
  13939. * @returns angular velocity or null
  13940. */
  13941. getAngularVelocity(): Nullable<Vector3>;
  13942. /**
  13943. * Sets the angular velocity
  13944. * @param velocity The velocity or null
  13945. */
  13946. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13947. /**
  13948. * Execute a function with the physics plugin native code
  13949. * Provide a function the will have two variables - the world object and the physics body object
  13950. * @param func The function to execute with the physics plugin native code
  13951. */
  13952. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13953. /**
  13954. * Register a function that will be executed before the physics world is stepping forward
  13955. * @param func The function to execute before the physics world is stepped forward
  13956. */
  13957. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13958. /**
  13959. * Unregister a function that will be executed before the physics world is stepping forward
  13960. * @param func The function to execute before the physics world is stepped forward
  13961. */
  13962. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13963. /**
  13964. * Register a function that will be executed after the physics step
  13965. * @param func The function to execute after physics step
  13966. */
  13967. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13968. /**
  13969. * Unregisters a function that will be executed after the physics step
  13970. * @param func The function to execute after physics step
  13971. */
  13972. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13973. /**
  13974. * register a function that will be executed when this impostor collides against a different body
  13975. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13976. * @param func Callback that is executed on collision
  13977. */
  13978. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13979. /**
  13980. * Unregisters the physics imposter on contact
  13981. * @param collideAgainst The physics object to collide against
  13982. * @param func Callback to execute on collision
  13983. */
  13984. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13985. private _tmpQuat;
  13986. private _tmpQuat2;
  13987. /**
  13988. * Get the parent rotation
  13989. * @returns The parent rotation
  13990. */
  13991. getParentsRotation(): Quaternion;
  13992. /**
  13993. * this function is executed by the physics engine.
  13994. */
  13995. beforeStep: () => void;
  13996. /**
  13997. * this function is executed by the physics engine
  13998. */
  13999. afterStep: () => void;
  14000. /**
  14001. * Legacy collision detection event support
  14002. */
  14003. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  14004. /**
  14005. * event and body object due to cannon's event-based architecture.
  14006. */
  14007. onCollide: (e: {
  14008. body: any;
  14009. }) => void;
  14010. /**
  14011. * Apply a force
  14012. * @param force The force to apply
  14013. * @param contactPoint The contact point for the force
  14014. * @returns The physics imposter
  14015. */
  14016. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14017. /**
  14018. * Apply an impulse
  14019. * @param force The impulse force
  14020. * @param contactPoint The contact point for the impulse force
  14021. * @returns The physics imposter
  14022. */
  14023. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14024. /**
  14025. * A help function to create a joint
  14026. * @param otherImpostor A physics imposter used to create a joint
  14027. * @param jointType The type of joint
  14028. * @param jointData The data for the joint
  14029. * @returns The physics imposter
  14030. */
  14031. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  14032. /**
  14033. * Add a joint to this impostor with a different impostor
  14034. * @param otherImpostor A physics imposter used to add a joint
  14035. * @param joint The joint to add
  14036. * @returns The physics imposter
  14037. */
  14038. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  14039. /**
  14040. * Add an anchor to a cloth impostor
  14041. * @param otherImpostor rigid impostor to anchor to
  14042. * @param width ratio across width from 0 to 1
  14043. * @param height ratio up height from 0 to 1
  14044. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  14045. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  14046. * @returns impostor the soft imposter
  14047. */
  14048. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14049. /**
  14050. * Add a hook to a rope impostor
  14051. * @param otherImpostor rigid impostor to anchor to
  14052. * @param length ratio across rope from 0 to 1
  14053. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  14054. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  14055. * @returns impostor the rope imposter
  14056. */
  14057. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14058. /**
  14059. * Will keep this body still, in a sleep mode.
  14060. * @returns the physics imposter
  14061. */
  14062. sleep(): PhysicsImpostor;
  14063. /**
  14064. * Wake the body up.
  14065. * @returns The physics imposter
  14066. */
  14067. wakeUp(): PhysicsImpostor;
  14068. /**
  14069. * Clones the physics imposter
  14070. * @param newObject The physics imposter clones to this physics-enabled object
  14071. * @returns A nullable physics imposter
  14072. */
  14073. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  14074. /**
  14075. * Disposes the physics imposter
  14076. */
  14077. dispose(): void;
  14078. /**
  14079. * Sets the delta position
  14080. * @param position The delta position amount
  14081. */
  14082. setDeltaPosition(position: Vector3): void;
  14083. /**
  14084. * Sets the delta rotation
  14085. * @param rotation The delta rotation amount
  14086. */
  14087. setDeltaRotation(rotation: Quaternion): void;
  14088. /**
  14089. * Gets the box size of the physics imposter and stores the result in the input parameter
  14090. * @param result Stores the box size
  14091. * @returns The physics imposter
  14092. */
  14093. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  14094. /**
  14095. * Gets the radius of the physics imposter
  14096. * @returns Radius of the physics imposter
  14097. */
  14098. getRadius(): number;
  14099. /**
  14100. * Sync a bone with this impostor
  14101. * @param bone The bone to sync to the impostor.
  14102. * @param boneMesh The mesh that the bone is influencing.
  14103. * @param jointPivot The pivot of the joint / bone in local space.
  14104. * @param distToJoint Optional distance from the impostor to the joint.
  14105. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14106. */
  14107. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  14108. /**
  14109. * Sync impostor to a bone
  14110. * @param bone The bone that the impostor will be synced to.
  14111. * @param boneMesh The mesh that the bone is influencing.
  14112. * @param jointPivot The pivot of the joint / bone in local space.
  14113. * @param distToJoint Optional distance from the impostor to the joint.
  14114. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14115. * @param boneAxis Optional vector3 axis the bone is aligned with
  14116. */
  14117. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  14118. /**
  14119. * No-Imposter type
  14120. */
  14121. static NoImpostor: number;
  14122. /**
  14123. * Sphere-Imposter type
  14124. */
  14125. static SphereImpostor: number;
  14126. /**
  14127. * Box-Imposter type
  14128. */
  14129. static BoxImpostor: number;
  14130. /**
  14131. * Plane-Imposter type
  14132. */
  14133. static PlaneImpostor: number;
  14134. /**
  14135. * Mesh-imposter type
  14136. */
  14137. static MeshImpostor: number;
  14138. /**
  14139. * Capsule-Impostor type (Ammo.js plugin only)
  14140. */
  14141. static CapsuleImpostor: number;
  14142. /**
  14143. * Cylinder-Imposter type
  14144. */
  14145. static CylinderImpostor: number;
  14146. /**
  14147. * Particle-Imposter type
  14148. */
  14149. static ParticleImpostor: number;
  14150. /**
  14151. * Heightmap-Imposter type
  14152. */
  14153. static HeightmapImpostor: number;
  14154. /**
  14155. * ConvexHull-Impostor type (Ammo.js plugin only)
  14156. */
  14157. static ConvexHullImpostor: number;
  14158. /**
  14159. * Rope-Imposter type
  14160. */
  14161. static RopeImpostor: number;
  14162. /**
  14163. * Cloth-Imposter type
  14164. */
  14165. static ClothImpostor: number;
  14166. /**
  14167. * Softbody-Imposter type
  14168. */
  14169. static SoftbodyImpostor: number;
  14170. }
  14171. }
  14172. declare module "babylonjs/Meshes/mesh" {
  14173. import { Observable } from "babylonjs/Misc/observable";
  14174. import { IAnimatable } from "babylonjs/Misc/tools";
  14175. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  14176. import { Camera } from "babylonjs/Cameras/camera";
  14177. import { Scene } from "babylonjs/scene";
  14178. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  14179. import { Engine } from "babylonjs/Engines/engine";
  14180. import { Node } from "babylonjs/node";
  14181. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  14182. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  14183. import { Buffer } from "babylonjs/Meshes/buffer";
  14184. import { Geometry } from "babylonjs/Meshes/geometry";
  14185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14186. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14187. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  14188. import { Effect } from "babylonjs/Materials/effect";
  14189. import { Material } from "babylonjs/Materials/material";
  14190. import { Skeleton } from "babylonjs/Bones/skeleton";
  14191. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  14192. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  14193. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  14194. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  14195. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  14196. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  14197. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  14198. /**
  14199. * @hidden
  14200. **/
  14201. export class _CreationDataStorage {
  14202. closePath?: boolean;
  14203. closeArray?: boolean;
  14204. idx: number[];
  14205. dashSize: number;
  14206. gapSize: number;
  14207. path3D: Path3D;
  14208. pathArray: Vector3[][];
  14209. arc: number;
  14210. radius: number;
  14211. cap: number;
  14212. tessellation: number;
  14213. }
  14214. /**
  14215. * @hidden
  14216. **/
  14217. class _InstanceDataStorage {
  14218. visibleInstances: any;
  14219. batchCache: _InstancesBatch;
  14220. instancesBufferSize: number;
  14221. instancesBuffer: Nullable<Buffer>;
  14222. instancesData: Float32Array;
  14223. overridenInstanceCount: number;
  14224. isFrozen: boolean;
  14225. previousBatch: Nullable<_InstancesBatch>;
  14226. hardwareInstancedRendering: boolean;
  14227. sideOrientation: number;
  14228. }
  14229. /**
  14230. * @hidden
  14231. **/
  14232. export class _InstancesBatch {
  14233. mustReturn: boolean;
  14234. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  14235. renderSelf: boolean[];
  14236. hardwareInstancedRendering: boolean[];
  14237. }
  14238. /**
  14239. * Class used to represent renderable models
  14240. */
  14241. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  14242. /**
  14243. * Mesh side orientation : usually the external or front surface
  14244. */
  14245. static readonly FRONTSIDE: number;
  14246. /**
  14247. * Mesh side orientation : usually the internal or back surface
  14248. */
  14249. static readonly BACKSIDE: number;
  14250. /**
  14251. * Mesh side orientation : both internal and external or front and back surfaces
  14252. */
  14253. static readonly DOUBLESIDE: number;
  14254. /**
  14255. * Mesh side orientation : by default, `FRONTSIDE`
  14256. */
  14257. static readonly DEFAULTSIDE: number;
  14258. /**
  14259. * Mesh cap setting : no cap
  14260. */
  14261. static readonly NO_CAP: number;
  14262. /**
  14263. * Mesh cap setting : one cap at the beginning of the mesh
  14264. */
  14265. static readonly CAP_START: number;
  14266. /**
  14267. * Mesh cap setting : one cap at the end of the mesh
  14268. */
  14269. static readonly CAP_END: number;
  14270. /**
  14271. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  14272. */
  14273. static readonly CAP_ALL: number;
  14274. /**
  14275. * Mesh pattern setting : no flip or rotate
  14276. */
  14277. static readonly NO_FLIP: number;
  14278. /**
  14279. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  14280. */
  14281. static readonly FLIP_TILE: number;
  14282. /**
  14283. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  14284. */
  14285. static readonly ROTATE_TILE: number;
  14286. /**
  14287. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14288. */
  14289. static readonly FLIP_ROW: number;
  14290. /**
  14291. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14292. */
  14293. static readonly ROTATE_ROW: number;
  14294. /**
  14295. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14296. */
  14297. static readonly FLIP_N_ROTATE_TILE: number;
  14298. /**
  14299. * Mesh pattern setting : rotate pattern and rotate
  14300. */
  14301. static readonly FLIP_N_ROTATE_ROW: number;
  14302. /**
  14303. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14304. */
  14305. static readonly CENTER: number;
  14306. /**
  14307. * Mesh tile positioning : part tiles on left
  14308. */
  14309. static readonly LEFT: number;
  14310. /**
  14311. * Mesh tile positioning : part tiles on right
  14312. */
  14313. static readonly RIGHT: number;
  14314. /**
  14315. * Mesh tile positioning : part tiles on top
  14316. */
  14317. static readonly TOP: number;
  14318. /**
  14319. * Mesh tile positioning : part tiles on bottom
  14320. */
  14321. static readonly BOTTOM: number;
  14322. /**
  14323. * Gets the default side orientation.
  14324. * @param orientation the orientation to value to attempt to get
  14325. * @returns the default orientation
  14326. * @hidden
  14327. */
  14328. static _GetDefaultSideOrientation(orientation?: number): number;
  14329. private _internalMeshDataInfo;
  14330. /**
  14331. * An event triggered before rendering the mesh
  14332. */
  14333. readonly onBeforeRenderObservable: Observable<Mesh>;
  14334. /**
  14335. * An event triggered before binding the mesh
  14336. */
  14337. readonly onBeforeBindObservable: Observable<Mesh>;
  14338. /**
  14339. * An event triggered after rendering the mesh
  14340. */
  14341. readonly onAfterRenderObservable: Observable<Mesh>;
  14342. /**
  14343. * An event triggered before drawing the mesh
  14344. */
  14345. readonly onBeforeDrawObservable: Observable<Mesh>;
  14346. private _onBeforeDrawObserver;
  14347. /**
  14348. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14349. */
  14350. onBeforeDraw: () => void;
  14351. /**
  14352. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14353. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14354. */
  14355. delayLoadState: number;
  14356. /**
  14357. * Gets the list of instances created from this mesh
  14358. * it is not supposed to be modified manually.
  14359. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14360. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14361. */
  14362. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  14363. /**
  14364. * Gets the file containing delay loading data for this mesh
  14365. */
  14366. delayLoadingFile: string;
  14367. /** @hidden */
  14368. _binaryInfo: any;
  14369. /**
  14370. * User defined function used to change how LOD level selection is done
  14371. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14372. */
  14373. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14374. /**
  14375. * Gets or sets the morph target manager
  14376. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14377. */
  14378. morphTargetManager: Nullable<MorphTargetManager>;
  14379. /** @hidden */
  14380. _creationDataStorage: Nullable<_CreationDataStorage>;
  14381. /** @hidden */
  14382. _geometry: Nullable<Geometry>;
  14383. /** @hidden */
  14384. _delayInfo: Array<string>;
  14385. /** @hidden */
  14386. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14387. /** @hidden */
  14388. _instanceDataStorage: _InstanceDataStorage;
  14389. private _effectiveMaterial;
  14390. /** @hidden */
  14391. _shouldGenerateFlatShading: boolean;
  14392. /** @hidden */
  14393. _originalBuilderSideOrientation: number;
  14394. /**
  14395. * Use this property to change the original side orientation defined at construction time
  14396. */
  14397. overrideMaterialSideOrientation: Nullable<number>;
  14398. /**
  14399. * Gets the source mesh (the one used to clone this one from)
  14400. */
  14401. readonly source: Nullable<Mesh>;
  14402. /**
  14403. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14404. */
  14405. isUnIndexed: boolean;
  14406. /**
  14407. * @constructor
  14408. * @param name The value used by scene.getMeshByName() to do a lookup.
  14409. * @param scene The scene to add this mesh to.
  14410. * @param parent The parent of this mesh, if it has one
  14411. * @param source An optional Mesh from which geometry is shared, cloned.
  14412. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14413. * When false, achieved by calling a clone(), also passing False.
  14414. * This will make creation of children, recursive.
  14415. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14416. */
  14417. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14418. /**
  14419. * Gets the class name
  14420. * @returns the string "Mesh".
  14421. */
  14422. getClassName(): string;
  14423. /** @hidden */
  14424. readonly _isMesh: boolean;
  14425. /**
  14426. * Returns a description of this mesh
  14427. * @param fullDetails define if full details about this mesh must be used
  14428. * @returns a descriptive string representing this mesh
  14429. */
  14430. toString(fullDetails?: boolean): string;
  14431. /** @hidden */
  14432. _unBindEffect(): void;
  14433. /**
  14434. * Gets a boolean indicating if this mesh has LOD
  14435. */
  14436. readonly hasLODLevels: boolean;
  14437. /**
  14438. * Gets the list of MeshLODLevel associated with the current mesh
  14439. * @returns an array of MeshLODLevel
  14440. */
  14441. getLODLevels(): MeshLODLevel[];
  14442. private _sortLODLevels;
  14443. /**
  14444. * Add a mesh as LOD level triggered at the given distance.
  14445. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14446. * @param distance The distance from the center of the object to show this level
  14447. * @param mesh The mesh to be added as LOD level (can be null)
  14448. * @return This mesh (for chaining)
  14449. */
  14450. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14451. /**
  14452. * Returns the LOD level mesh at the passed distance or null if not found.
  14453. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14454. * @param distance The distance from the center of the object to show this level
  14455. * @returns a Mesh or `null`
  14456. */
  14457. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14458. /**
  14459. * Remove a mesh from the LOD array
  14460. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14461. * @param mesh defines the mesh to be removed
  14462. * @return This mesh (for chaining)
  14463. */
  14464. removeLODLevel(mesh: Mesh): Mesh;
  14465. /**
  14466. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14467. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14468. * @param camera defines the camera to use to compute distance
  14469. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14470. * @return This mesh (for chaining)
  14471. */
  14472. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14473. /**
  14474. * Gets the mesh internal Geometry object
  14475. */
  14476. readonly geometry: Nullable<Geometry>;
  14477. /**
  14478. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14479. * @returns the total number of vertices
  14480. */
  14481. getTotalVertices(): number;
  14482. /**
  14483. * Returns the content of an associated vertex buffer
  14484. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14485. * - VertexBuffer.PositionKind
  14486. * - VertexBuffer.UVKind
  14487. * - VertexBuffer.UV2Kind
  14488. * - VertexBuffer.UV3Kind
  14489. * - VertexBuffer.UV4Kind
  14490. * - VertexBuffer.UV5Kind
  14491. * - VertexBuffer.UV6Kind
  14492. * - VertexBuffer.ColorKind
  14493. * - VertexBuffer.MatricesIndicesKind
  14494. * - VertexBuffer.MatricesIndicesExtraKind
  14495. * - VertexBuffer.MatricesWeightsKind
  14496. * - VertexBuffer.MatricesWeightsExtraKind
  14497. * @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
  14498. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14499. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14500. */
  14501. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14502. /**
  14503. * Returns the mesh VertexBuffer object from the requested `kind`
  14504. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14505. * - VertexBuffer.PositionKind
  14506. * - VertexBuffer.NormalKind
  14507. * - VertexBuffer.UVKind
  14508. * - VertexBuffer.UV2Kind
  14509. * - VertexBuffer.UV3Kind
  14510. * - VertexBuffer.UV4Kind
  14511. * - VertexBuffer.UV5Kind
  14512. * - VertexBuffer.UV6Kind
  14513. * - VertexBuffer.ColorKind
  14514. * - VertexBuffer.MatricesIndicesKind
  14515. * - VertexBuffer.MatricesIndicesExtraKind
  14516. * - VertexBuffer.MatricesWeightsKind
  14517. * - VertexBuffer.MatricesWeightsExtraKind
  14518. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14519. */
  14520. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14521. /**
  14522. * Tests if a specific vertex buffer is associated with this mesh
  14523. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14524. * - VertexBuffer.PositionKind
  14525. * - VertexBuffer.NormalKind
  14526. * - VertexBuffer.UVKind
  14527. * - VertexBuffer.UV2Kind
  14528. * - VertexBuffer.UV3Kind
  14529. * - VertexBuffer.UV4Kind
  14530. * - VertexBuffer.UV5Kind
  14531. * - VertexBuffer.UV6Kind
  14532. * - VertexBuffer.ColorKind
  14533. * - VertexBuffer.MatricesIndicesKind
  14534. * - VertexBuffer.MatricesIndicesExtraKind
  14535. * - VertexBuffer.MatricesWeightsKind
  14536. * - VertexBuffer.MatricesWeightsExtraKind
  14537. * @returns a boolean
  14538. */
  14539. isVerticesDataPresent(kind: string): boolean;
  14540. /**
  14541. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14542. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14543. * - VertexBuffer.PositionKind
  14544. * - VertexBuffer.UVKind
  14545. * - VertexBuffer.UV2Kind
  14546. * - VertexBuffer.UV3Kind
  14547. * - VertexBuffer.UV4Kind
  14548. * - VertexBuffer.UV5Kind
  14549. * - VertexBuffer.UV6Kind
  14550. * - VertexBuffer.ColorKind
  14551. * - VertexBuffer.MatricesIndicesKind
  14552. * - VertexBuffer.MatricesIndicesExtraKind
  14553. * - VertexBuffer.MatricesWeightsKind
  14554. * - VertexBuffer.MatricesWeightsExtraKind
  14555. * @returns a boolean
  14556. */
  14557. isVertexBufferUpdatable(kind: string): boolean;
  14558. /**
  14559. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14560. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14561. * - VertexBuffer.PositionKind
  14562. * - VertexBuffer.NormalKind
  14563. * - VertexBuffer.UVKind
  14564. * - VertexBuffer.UV2Kind
  14565. * - VertexBuffer.UV3Kind
  14566. * - VertexBuffer.UV4Kind
  14567. * - VertexBuffer.UV5Kind
  14568. * - VertexBuffer.UV6Kind
  14569. * - VertexBuffer.ColorKind
  14570. * - VertexBuffer.MatricesIndicesKind
  14571. * - VertexBuffer.MatricesIndicesExtraKind
  14572. * - VertexBuffer.MatricesWeightsKind
  14573. * - VertexBuffer.MatricesWeightsExtraKind
  14574. * @returns an array of strings
  14575. */
  14576. getVerticesDataKinds(): string[];
  14577. /**
  14578. * Returns a positive integer : the total number of indices in this mesh geometry.
  14579. * @returns the numner of indices or zero if the mesh has no geometry.
  14580. */
  14581. getTotalIndices(): number;
  14582. /**
  14583. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14584. * @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.
  14585. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14586. * @returns the indices array or an empty array if the mesh has no geometry
  14587. */
  14588. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14589. readonly isBlocked: boolean;
  14590. /**
  14591. * Determine if the current mesh is ready to be rendered
  14592. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14593. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14594. * @returns true if all associated assets are ready (material, textures, shaders)
  14595. */
  14596. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14597. /**
  14598. * 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.
  14599. */
  14600. readonly areNormalsFrozen: boolean;
  14601. /**
  14602. * 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.
  14603. * @returns the current mesh
  14604. */
  14605. freezeNormals(): Mesh;
  14606. /**
  14607. * 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
  14608. * @returns the current mesh
  14609. */
  14610. unfreezeNormals(): Mesh;
  14611. /**
  14612. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14613. */
  14614. overridenInstanceCount: number;
  14615. /** @hidden */
  14616. _preActivate(): Mesh;
  14617. /** @hidden */
  14618. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14619. /** @hidden */
  14620. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14621. /**
  14622. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14623. * This means the mesh underlying bounding box and sphere are recomputed.
  14624. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14625. * @returns the current mesh
  14626. */
  14627. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14628. /** @hidden */
  14629. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14630. /**
  14631. * This function will subdivide the mesh into multiple submeshes
  14632. * @param count defines the expected number of submeshes
  14633. */
  14634. subdivide(count: number): void;
  14635. /**
  14636. * Copy a FloatArray into a specific associated vertex buffer
  14637. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14638. * - VertexBuffer.PositionKind
  14639. * - VertexBuffer.UVKind
  14640. * - VertexBuffer.UV2Kind
  14641. * - VertexBuffer.UV3Kind
  14642. * - VertexBuffer.UV4Kind
  14643. * - VertexBuffer.UV5Kind
  14644. * - VertexBuffer.UV6Kind
  14645. * - VertexBuffer.ColorKind
  14646. * - VertexBuffer.MatricesIndicesKind
  14647. * - VertexBuffer.MatricesIndicesExtraKind
  14648. * - VertexBuffer.MatricesWeightsKind
  14649. * - VertexBuffer.MatricesWeightsExtraKind
  14650. * @param data defines the data source
  14651. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14652. * @param stride defines the data stride size (can be null)
  14653. * @returns the current mesh
  14654. */
  14655. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14656. /**
  14657. * Flags an associated vertex buffer as updatable
  14658. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14659. * - VertexBuffer.PositionKind
  14660. * - VertexBuffer.UVKind
  14661. * - VertexBuffer.UV2Kind
  14662. * - VertexBuffer.UV3Kind
  14663. * - VertexBuffer.UV4Kind
  14664. * - VertexBuffer.UV5Kind
  14665. * - VertexBuffer.UV6Kind
  14666. * - VertexBuffer.ColorKind
  14667. * - VertexBuffer.MatricesIndicesKind
  14668. * - VertexBuffer.MatricesIndicesExtraKind
  14669. * - VertexBuffer.MatricesWeightsKind
  14670. * - VertexBuffer.MatricesWeightsExtraKind
  14671. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14672. */
  14673. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14674. /**
  14675. * Sets the mesh global Vertex Buffer
  14676. * @param buffer defines the buffer to use
  14677. * @returns the current mesh
  14678. */
  14679. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14680. /**
  14681. * Update a specific associated vertex buffer
  14682. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14683. * - VertexBuffer.PositionKind
  14684. * - VertexBuffer.UVKind
  14685. * - VertexBuffer.UV2Kind
  14686. * - VertexBuffer.UV3Kind
  14687. * - VertexBuffer.UV4Kind
  14688. * - VertexBuffer.UV5Kind
  14689. * - VertexBuffer.UV6Kind
  14690. * - VertexBuffer.ColorKind
  14691. * - VertexBuffer.MatricesIndicesKind
  14692. * - VertexBuffer.MatricesIndicesExtraKind
  14693. * - VertexBuffer.MatricesWeightsKind
  14694. * - VertexBuffer.MatricesWeightsExtraKind
  14695. * @param data defines the data source
  14696. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14697. * @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)
  14698. * @returns the current mesh
  14699. */
  14700. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14701. /**
  14702. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14703. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14704. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14705. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14706. * @returns the current mesh
  14707. */
  14708. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14709. /**
  14710. * Creates a un-shared specific occurence of the geometry for the mesh.
  14711. * @returns the current mesh
  14712. */
  14713. makeGeometryUnique(): Mesh;
  14714. /**
  14715. * Set the index buffer of this mesh
  14716. * @param indices defines the source data
  14717. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14718. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14719. * @returns the current mesh
  14720. */
  14721. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14722. /**
  14723. * Update the current index buffer
  14724. * @param indices defines the source data
  14725. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14726. * @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)
  14727. * @returns the current mesh
  14728. */
  14729. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14730. /**
  14731. * Invert the geometry to move from a right handed system to a left handed one.
  14732. * @returns the current mesh
  14733. */
  14734. toLeftHanded(): Mesh;
  14735. /** @hidden */
  14736. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14737. /** @hidden */
  14738. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14739. /**
  14740. * Registers for this mesh a javascript function called just before the rendering process
  14741. * @param func defines the function to call before rendering this mesh
  14742. * @returns the current mesh
  14743. */
  14744. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14745. /**
  14746. * Disposes a previously registered javascript function called before the rendering
  14747. * @param func defines the function to remove
  14748. * @returns the current mesh
  14749. */
  14750. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14751. /**
  14752. * Registers for this mesh a javascript function called just after the rendering is complete
  14753. * @param func defines the function to call after rendering this mesh
  14754. * @returns the current mesh
  14755. */
  14756. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14757. /**
  14758. * Disposes a previously registered javascript function called after the rendering.
  14759. * @param func defines the function to remove
  14760. * @returns the current mesh
  14761. */
  14762. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14763. /** @hidden */
  14764. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14765. /** @hidden */
  14766. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14767. /** @hidden */
  14768. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14769. /** @hidden */
  14770. _rebuild(): void;
  14771. /** @hidden */
  14772. _freeze(): void;
  14773. /** @hidden */
  14774. _unFreeze(): void;
  14775. /**
  14776. * 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
  14777. * @param subMesh defines the subMesh to render
  14778. * @param enableAlphaMode defines if alpha mode can be changed
  14779. * @returns the current mesh
  14780. */
  14781. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14782. private _onBeforeDraw;
  14783. /**
  14784. * Renormalize the mesh and patch it up if there are no weights
  14785. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14786. * However in the case of zero weights then we set just a single influence to 1.
  14787. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14788. */
  14789. cleanMatrixWeights(): void;
  14790. private normalizeSkinFourWeights;
  14791. private normalizeSkinWeightsAndExtra;
  14792. /**
  14793. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14794. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14795. * the user know there was an issue with importing the mesh
  14796. * @returns a validation object with skinned, valid and report string
  14797. */
  14798. validateSkinning(): {
  14799. skinned: boolean;
  14800. valid: boolean;
  14801. report: string;
  14802. };
  14803. /** @hidden */
  14804. _checkDelayState(): Mesh;
  14805. private _queueLoad;
  14806. /**
  14807. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14808. * A mesh is in the frustum if its bounding box intersects the frustum
  14809. * @param frustumPlanes defines the frustum to test
  14810. * @returns true if the mesh is in the frustum planes
  14811. */
  14812. isInFrustum(frustumPlanes: Plane[]): boolean;
  14813. /**
  14814. * Sets the mesh material by the material or multiMaterial `id` property
  14815. * @param id is a string identifying the material or the multiMaterial
  14816. * @returns the current mesh
  14817. */
  14818. setMaterialByID(id: string): Mesh;
  14819. /**
  14820. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14821. * @returns an array of IAnimatable
  14822. */
  14823. getAnimatables(): IAnimatable[];
  14824. /**
  14825. * Modifies the mesh geometry according to the passed transformation matrix.
  14826. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14827. * The mesh normals are modified using the same transformation.
  14828. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14829. * @param transform defines the transform matrix to use
  14830. * @see http://doc.babylonjs.com/resources/baking_transformations
  14831. * @returns the current mesh
  14832. */
  14833. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14834. /**
  14835. * Modifies the mesh geometry according to its own current World Matrix.
  14836. * The mesh World Matrix is then reset.
  14837. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14838. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14839. * @see http://doc.babylonjs.com/resources/baking_transformations
  14840. * @returns the current mesh
  14841. */
  14842. bakeCurrentTransformIntoVertices(): Mesh;
  14843. /** @hidden */
  14844. readonly _positions: Nullable<Vector3[]>;
  14845. /** @hidden */
  14846. _resetPointsArrayCache(): Mesh;
  14847. /** @hidden */
  14848. _generatePointsArray(): boolean;
  14849. /**
  14850. * Returns a new Mesh object generated from the current mesh properties.
  14851. * This method must not get confused with createInstance()
  14852. * @param name is a string, the name given to the new mesh
  14853. * @param newParent can be any Node object (default `null`)
  14854. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14855. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14856. * @returns a new mesh
  14857. */
  14858. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14859. /**
  14860. * Releases resources associated with this mesh.
  14861. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14862. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14863. */
  14864. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14865. /**
  14866. * Modifies the mesh geometry according to a displacement map.
  14867. * 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.
  14868. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14869. * @param url is a string, the URL from the image file is to be downloaded.
  14870. * @param minHeight is the lower limit of the displacement.
  14871. * @param maxHeight is the upper limit of the displacement.
  14872. * @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.
  14873. * @param uvOffset is an optional vector2 used to offset UV.
  14874. * @param uvScale is an optional vector2 used to scale UV.
  14875. * @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.
  14876. * @returns the Mesh.
  14877. */
  14878. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14879. /**
  14880. * Modifies the mesh geometry according to a displacementMap buffer.
  14881. * 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.
  14882. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14883. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14884. * @param heightMapWidth is the width of the buffer image.
  14885. * @param heightMapHeight is the height of the buffer image.
  14886. * @param minHeight is the lower limit of the displacement.
  14887. * @param maxHeight is the upper limit of the displacement.
  14888. * @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.
  14889. * @param uvOffset is an optional vector2 used to offset UV.
  14890. * @param uvScale is an optional vector2 used to scale UV.
  14891. * @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.
  14892. * @returns the Mesh.
  14893. */
  14894. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14895. /**
  14896. * Modify the mesh to get a flat shading rendering.
  14897. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14898. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14899. * @returns current mesh
  14900. */
  14901. convertToFlatShadedMesh(): Mesh;
  14902. /**
  14903. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14904. * In other words, more vertices, no more indices and a single bigger VBO.
  14905. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14906. * @returns current mesh
  14907. */
  14908. convertToUnIndexedMesh(): Mesh;
  14909. /**
  14910. * Inverses facet orientations.
  14911. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14912. * @param flipNormals will also inverts the normals
  14913. * @returns current mesh
  14914. */
  14915. flipFaces(flipNormals?: boolean): Mesh;
  14916. /**
  14917. * Increase the number of facets and hence vertices in a mesh
  14918. * Vertex normals are interpolated from existing vertex normals
  14919. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14920. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14921. */
  14922. increaseVertices(numberPerEdge: number): void;
  14923. /**
  14924. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14925. * This will undo any application of covertToFlatShadedMesh
  14926. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14927. */
  14928. forceSharedVertices(): void;
  14929. /** @hidden */
  14930. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14931. /** @hidden */
  14932. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14933. /**
  14934. * Creates a new InstancedMesh object from the mesh model.
  14935. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14936. * @param name defines the name of the new instance
  14937. * @returns a new InstancedMesh
  14938. */
  14939. createInstance(name: string): InstancedMesh;
  14940. /**
  14941. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14942. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14943. * @returns the current mesh
  14944. */
  14945. synchronizeInstances(): Mesh;
  14946. /**
  14947. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14948. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14949. * This should be used together with the simplification to avoid disappearing triangles.
  14950. * @param successCallback an optional success callback to be called after the optimization finished.
  14951. * @returns the current mesh
  14952. */
  14953. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14954. /**
  14955. * Serialize current mesh
  14956. * @param serializationObject defines the object which will receive the serialization data
  14957. */
  14958. serialize(serializationObject: any): void;
  14959. /** @hidden */
  14960. _syncGeometryWithMorphTargetManager(): void;
  14961. /** @hidden */
  14962. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14963. /**
  14964. * Returns a new Mesh object parsed from the source provided.
  14965. * @param parsedMesh is the source
  14966. * @param scene defines the hosting scene
  14967. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14968. * @returns a new Mesh
  14969. */
  14970. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14971. /**
  14972. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14973. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14974. * @param name defines the name of the mesh to create
  14975. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14976. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14977. * @param closePath creates a seam between the first and the last points of each path of the path array
  14978. * @param offset is taken in account only if the `pathArray` is containing a single path
  14979. * @param scene defines the hosting scene
  14980. * @param updatable defines if the mesh must be flagged as updatable
  14981. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14982. * @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)
  14983. * @returns a new Mesh
  14984. */
  14985. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14986. /**
  14987. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14988. * @param name defines the name of the mesh to create
  14989. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14990. * @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
  14991. * @param scene defines the hosting scene
  14992. * @param updatable defines if the mesh must be flagged as updatable
  14993. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14994. * @returns a new Mesh
  14995. */
  14996. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14997. /**
  14998. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14999. * @param name defines the name of the mesh to create
  15000. * @param size sets the size (float) of each box side (default 1)
  15001. * @param scene defines the hosting scene
  15002. * @param updatable defines if the mesh must be flagged as updatable
  15003. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15004. * @returns a new Mesh
  15005. */
  15006. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  15007. /**
  15008. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  15009. * @param name defines the name of the mesh to create
  15010. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  15011. * @param diameter sets the diameter size (float) of the sphere (default 1)
  15012. * @param scene defines the hosting scene
  15013. * @param updatable defines if the mesh must be flagged as updatable
  15014. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15015. * @returns a new Mesh
  15016. */
  15017. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15018. /**
  15019. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  15020. * @param name defines the name of the mesh to create
  15021. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  15022. * @param diameter sets the diameter size (float) of the sphere (default 1)
  15023. * @param scene defines the hosting scene
  15024. * @returns a new Mesh
  15025. */
  15026. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  15027. /**
  15028. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  15029. * @param name defines the name of the mesh to create
  15030. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  15031. * @param diameterTop set the top cap diameter (floats, default 1)
  15032. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  15033. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  15034. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  15035. * @param scene defines the hosting scene
  15036. * @param updatable defines if the mesh must be flagged as updatable
  15037. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15038. * @returns a new Mesh
  15039. */
  15040. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  15041. /**
  15042. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  15043. * @param name defines the name of the mesh to create
  15044. * @param diameter sets the diameter size (float) of the torus (default 1)
  15045. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  15046. * @param tessellation sets the number of torus sides (postive integer, default 16)
  15047. * @param scene defines the hosting scene
  15048. * @param updatable defines if the mesh must be flagged as updatable
  15049. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15050. * @returns a new Mesh
  15051. */
  15052. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15053. /**
  15054. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  15055. * @param name defines the name of the mesh to create
  15056. * @param radius sets the global radius size (float) of the torus knot (default 2)
  15057. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  15058. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  15059. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  15060. * @param p the number of windings on X axis (positive integers, default 2)
  15061. * @param q the number of windings on Y axis (positive integers, default 3)
  15062. * @param scene defines the hosting scene
  15063. * @param updatable defines if the mesh must be flagged as updatable
  15064. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15065. * @returns a new Mesh
  15066. */
  15067. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15068. /**
  15069. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  15070. * @param name defines the name of the mesh to create
  15071. * @param points is an array successive Vector3
  15072. * @param scene defines the hosting scene
  15073. * @param updatable defines if the mesh must be flagged as updatable
  15074. * @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).
  15075. * @returns a new Mesh
  15076. */
  15077. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  15078. /**
  15079. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  15080. * @param name defines the name of the mesh to create
  15081. * @param points is an array successive Vector3
  15082. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  15083. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  15084. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  15085. * @param scene defines the hosting scene
  15086. * @param updatable defines if the mesh must be flagged as updatable
  15087. * @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)
  15088. * @returns a new Mesh
  15089. */
  15090. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  15091. /**
  15092. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  15093. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  15094. * 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.
  15095. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15096. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15097. * Remember you can only change the shape positions, not their number when updating a polygon.
  15098. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  15099. * @param name defines the name of the mesh to create
  15100. * @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
  15101. * @param scene defines the hosting scene
  15102. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15103. * @param updatable defines if the mesh must be flagged as updatable
  15104. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15105. * @param earcutInjection can be used to inject your own earcut reference
  15106. * @returns a new Mesh
  15107. */
  15108. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15109. /**
  15110. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  15111. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  15112. * @param name defines the name of the mesh to create
  15113. * @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
  15114. * @param depth defines the height of extrusion
  15115. * @param scene defines the hosting scene
  15116. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15117. * @param updatable defines if the mesh must be flagged as updatable
  15118. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15119. * @param earcutInjection can be used to inject your own earcut reference
  15120. * @returns a new Mesh
  15121. */
  15122. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15123. /**
  15124. * Creates an extruded shape mesh.
  15125. * 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
  15126. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15127. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15128. * @param name defines the name of the mesh to create
  15129. * @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
  15130. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15131. * @param scale is the value to scale the shape
  15132. * @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
  15133. * @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
  15134. * @param scene defines the hosting scene
  15135. * @param updatable defines if the mesh must be flagged as updatable
  15136. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15137. * @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)
  15138. * @returns a new Mesh
  15139. */
  15140. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15141. /**
  15142. * Creates an custom extruded shape mesh.
  15143. * The custom extrusion is a parametric shape.
  15144. * It has no predefined shape. Its final shape will depend on the input parameters.
  15145. * Please consider using the same method from the MeshBuilder class instead
  15146. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15147. * @param name defines the name of the mesh to create
  15148. * @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
  15149. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15150. * @param scaleFunction is a custom Javascript function called on each path point
  15151. * @param rotationFunction is a custom Javascript function called on each path point
  15152. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  15153. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  15154. * @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
  15155. * @param scene defines the hosting scene
  15156. * @param updatable defines if the mesh must be flagged as updatable
  15157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15158. * @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)
  15159. * @returns a new Mesh
  15160. */
  15161. 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;
  15162. /**
  15163. * Creates lathe mesh.
  15164. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15165. * Please consider using the same method from the MeshBuilder class instead
  15166. * @param name defines the name of the mesh to create
  15167. * @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
  15168. * @param radius is the radius value of the lathe
  15169. * @param tessellation is the side number of the lathe.
  15170. * @param scene defines the hosting scene
  15171. * @param updatable defines if the mesh must be flagged as updatable
  15172. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15173. * @returns a new Mesh
  15174. */
  15175. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15176. /**
  15177. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  15178. * @param name defines the name of the mesh to create
  15179. * @param size sets the size (float) of both sides of the plane at once (default 1)
  15180. * @param scene defines the hosting scene
  15181. * @param updatable defines if the mesh must be flagged as updatable
  15182. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15183. * @returns a new Mesh
  15184. */
  15185. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15186. /**
  15187. * Creates a ground mesh.
  15188. * Please consider using the same method from the MeshBuilder class instead
  15189. * @param name defines the name of the mesh to create
  15190. * @param width set the width of the ground
  15191. * @param height set the height of the ground
  15192. * @param subdivisions sets the number of subdivisions per side
  15193. * @param scene defines the hosting scene
  15194. * @param updatable defines if the mesh must be flagged as updatable
  15195. * @returns a new Mesh
  15196. */
  15197. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15198. /**
  15199. * Creates a tiled ground mesh.
  15200. * Please consider using the same method from the MeshBuilder class instead
  15201. * @param name defines the name of the mesh to create
  15202. * @param xmin set the ground minimum X coordinate
  15203. * @param zmin set the ground minimum Y coordinate
  15204. * @param xmax set the ground maximum X coordinate
  15205. * @param zmax set the ground maximum Z coordinate
  15206. * @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
  15207. * @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
  15208. * @param scene defines the hosting scene
  15209. * @param updatable defines if the mesh must be flagged as updatable
  15210. * @returns a new Mesh
  15211. */
  15212. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15213. w: number;
  15214. h: number;
  15215. }, precision: {
  15216. w: number;
  15217. h: number;
  15218. }, scene: Scene, updatable?: boolean): Mesh;
  15219. /**
  15220. * Creates a ground mesh from a height map.
  15221. * Please consider using the same method from the MeshBuilder class instead
  15222. * @see http://doc.babylonjs.com/babylon101/height_map
  15223. * @param name defines the name of the mesh to create
  15224. * @param url sets the URL of the height map image resource
  15225. * @param width set the ground width size
  15226. * @param height set the ground height size
  15227. * @param subdivisions sets the number of subdivision per side
  15228. * @param minHeight is the minimum altitude on the ground
  15229. * @param maxHeight is the maximum altitude on the ground
  15230. * @param scene defines the hosting scene
  15231. * @param updatable defines if the mesh must be flagged as updatable
  15232. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  15233. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  15234. * @returns a new Mesh
  15235. */
  15236. 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;
  15237. /**
  15238. * Creates a tube mesh.
  15239. * The tube is a parametric shape.
  15240. * It has no predefined shape. Its final shape will depend on the input parameters.
  15241. * Please consider using the same method from the MeshBuilder class instead
  15242. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15243. * @param name defines the name of the mesh to create
  15244. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  15245. * @param radius sets the tube radius size
  15246. * @param tessellation is the number of sides on the tubular surface
  15247. * @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
  15248. * @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
  15249. * @param scene defines the hosting scene
  15250. * @param updatable defines if the mesh must be flagged as updatable
  15251. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15252. * @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)
  15253. * @returns a new Mesh
  15254. */
  15255. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15256. (i: number, distance: number): number;
  15257. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15258. /**
  15259. * Creates a polyhedron mesh.
  15260. * Please consider using the same method from the MeshBuilder class instead.
  15261. * * 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
  15262. * * The parameter `size` (positive float, default 1) sets the polygon size
  15263. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  15264. * * 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`
  15265. * * 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
  15266. * * 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)`)
  15267. * * 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
  15268. * * 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
  15269. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15270. * * If you create a double-sided mesh, you can choose what parts of 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
  15271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15272. * @param name defines the name of the mesh to create
  15273. * @param options defines the options used to create the mesh
  15274. * @param scene defines the hosting scene
  15275. * @returns a new Mesh
  15276. */
  15277. static CreatePolyhedron(name: string, options: {
  15278. type?: number;
  15279. size?: number;
  15280. sizeX?: number;
  15281. sizeY?: number;
  15282. sizeZ?: number;
  15283. custom?: any;
  15284. faceUV?: Vector4[];
  15285. faceColors?: Color4[];
  15286. updatable?: boolean;
  15287. sideOrientation?: number;
  15288. }, scene: Scene): Mesh;
  15289. /**
  15290. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15291. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15292. * * 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`)
  15293. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15294. * * 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
  15295. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15296. * * If you create a double-sided mesh, you can choose what parts of 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
  15297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15298. * @param name defines the name of the mesh
  15299. * @param options defines the options used to create the mesh
  15300. * @param scene defines the hosting scene
  15301. * @returns a new Mesh
  15302. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15303. */
  15304. static CreateIcoSphere(name: string, options: {
  15305. radius?: number;
  15306. flat?: boolean;
  15307. subdivisions?: number;
  15308. sideOrientation?: number;
  15309. updatable?: boolean;
  15310. }, scene: Scene): Mesh;
  15311. /**
  15312. * Creates a decal mesh.
  15313. * Please consider using the same method from the MeshBuilder class instead.
  15314. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15315. * @param name defines the name of the mesh
  15316. * @param sourceMesh defines the mesh receiving the decal
  15317. * @param position sets the position of the decal in world coordinates
  15318. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15319. * @param size sets the decal scaling
  15320. * @param angle sets the angle to rotate the decal
  15321. * @returns a new Mesh
  15322. */
  15323. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15324. /**
  15325. * Prepare internal position array for software CPU skinning
  15326. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15327. */
  15328. setPositionsForCPUSkinning(): Float32Array;
  15329. /**
  15330. * Prepare internal normal array for software CPU skinning
  15331. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15332. */
  15333. setNormalsForCPUSkinning(): Float32Array;
  15334. /**
  15335. * Updates the vertex buffer by applying transformation from the bones
  15336. * @param skeleton defines the skeleton to apply to current mesh
  15337. * @returns the current mesh
  15338. */
  15339. applySkeleton(skeleton: Skeleton): Mesh;
  15340. /**
  15341. * 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
  15342. * @param meshes defines the list of meshes to scan
  15343. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15344. */
  15345. static MinMax(meshes: AbstractMesh[]): {
  15346. min: Vector3;
  15347. max: Vector3;
  15348. };
  15349. /**
  15350. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15351. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15352. * @returns a vector3
  15353. */
  15354. static Center(meshesOrMinMaxVector: {
  15355. min: Vector3;
  15356. max: Vector3;
  15357. } | AbstractMesh[]): Vector3;
  15358. /**
  15359. * Merge the array of meshes into a single mesh for performance reasons.
  15360. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15361. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15362. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15363. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15364. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15365. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15366. * @returns a new mesh
  15367. */
  15368. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15369. /** @hidden */
  15370. addInstance(instance: InstancedMesh): void;
  15371. /** @hidden */
  15372. removeInstance(instance: InstancedMesh): void;
  15373. }
  15374. }
  15375. declare module "babylonjs/Actions/action" {
  15376. import { Observable } from "babylonjs/Misc/observable";
  15377. import { Condition } from "babylonjs/Actions/condition";
  15378. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15379. import { ActionManager } from "babylonjs/Actions/actionManager";
  15380. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15381. /**
  15382. * Interface used to define Action
  15383. */
  15384. export interface IAction {
  15385. /**
  15386. * Trigger for the action
  15387. */
  15388. trigger: number;
  15389. /** Options of the trigger */
  15390. triggerOptions: any;
  15391. /**
  15392. * Gets the trigger parameters
  15393. * @returns the trigger parameters
  15394. */
  15395. getTriggerParameter(): any;
  15396. /**
  15397. * Internal only - executes current action event
  15398. * @hidden
  15399. */
  15400. _executeCurrent(evt?: ActionEvent): void;
  15401. /**
  15402. * Serialize placeholder for child classes
  15403. * @param parent of child
  15404. * @returns the serialized object
  15405. */
  15406. serialize(parent: any): any;
  15407. /**
  15408. * Internal only
  15409. * @hidden
  15410. */
  15411. _prepare(): void;
  15412. /**
  15413. * Internal only - manager for action
  15414. * @hidden
  15415. */
  15416. _actionManager: AbstractActionManager;
  15417. /**
  15418. * Adds action to chain of actions, may be a DoNothingAction
  15419. * @param action defines the next action to execute
  15420. * @returns The action passed in
  15421. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15422. */
  15423. then(action: IAction): IAction;
  15424. }
  15425. /**
  15426. * The action to be carried out following a trigger
  15427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15428. */
  15429. export class Action implements IAction {
  15430. /** the trigger, with or without parameters, for the action */
  15431. triggerOptions: any;
  15432. /**
  15433. * Trigger for the action
  15434. */
  15435. trigger: number;
  15436. /**
  15437. * Internal only - manager for action
  15438. * @hidden
  15439. */
  15440. _actionManager: ActionManager;
  15441. private _nextActiveAction;
  15442. private _child;
  15443. private _condition?;
  15444. private _triggerParameter;
  15445. /**
  15446. * An event triggered prior to action being executed.
  15447. */
  15448. onBeforeExecuteObservable: Observable<Action>;
  15449. /**
  15450. * Creates a new Action
  15451. * @param triggerOptions the trigger, with or without parameters, for the action
  15452. * @param condition an optional determinant of action
  15453. */
  15454. constructor(
  15455. /** the trigger, with or without parameters, for the action */
  15456. triggerOptions: any, condition?: Condition);
  15457. /**
  15458. * Internal only
  15459. * @hidden
  15460. */
  15461. _prepare(): void;
  15462. /**
  15463. * Gets the trigger parameters
  15464. * @returns the trigger parameters
  15465. */
  15466. getTriggerParameter(): any;
  15467. /**
  15468. * Internal only - executes current action event
  15469. * @hidden
  15470. */
  15471. _executeCurrent(evt?: ActionEvent): void;
  15472. /**
  15473. * Execute placeholder for child classes
  15474. * @param evt optional action event
  15475. */
  15476. execute(evt?: ActionEvent): void;
  15477. /**
  15478. * Skips to next active action
  15479. */
  15480. skipToNextActiveAction(): void;
  15481. /**
  15482. * Adds action to chain of actions, may be a DoNothingAction
  15483. * @param action defines the next action to execute
  15484. * @returns The action passed in
  15485. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15486. */
  15487. then(action: Action): Action;
  15488. /**
  15489. * Internal only
  15490. * @hidden
  15491. */
  15492. _getProperty(propertyPath: string): string;
  15493. /**
  15494. * Internal only
  15495. * @hidden
  15496. */
  15497. _getEffectiveTarget(target: any, propertyPath: string): any;
  15498. /**
  15499. * Serialize placeholder for child classes
  15500. * @param parent of child
  15501. * @returns the serialized object
  15502. */
  15503. serialize(parent: any): any;
  15504. /**
  15505. * Internal only called by serialize
  15506. * @hidden
  15507. */
  15508. protected _serialize(serializedAction: any, parent?: any): any;
  15509. /**
  15510. * Internal only
  15511. * @hidden
  15512. */
  15513. static _SerializeValueAsString: (value: any) => string;
  15514. /**
  15515. * Internal only
  15516. * @hidden
  15517. */
  15518. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  15519. name: string;
  15520. targetType: string;
  15521. value: string;
  15522. };
  15523. }
  15524. }
  15525. declare module "babylonjs/Actions/condition" {
  15526. import { ActionManager } from "babylonjs/Actions/actionManager";
  15527. /**
  15528. * A Condition applied to an Action
  15529. */
  15530. export class Condition {
  15531. /**
  15532. * Internal only - manager for action
  15533. * @hidden
  15534. */
  15535. _actionManager: ActionManager;
  15536. /**
  15537. * Internal only
  15538. * @hidden
  15539. */
  15540. _evaluationId: number;
  15541. /**
  15542. * Internal only
  15543. * @hidden
  15544. */
  15545. _currentResult: boolean;
  15546. /**
  15547. * Creates a new Condition
  15548. * @param actionManager the manager of the action the condition is applied to
  15549. */
  15550. constructor(actionManager: ActionManager);
  15551. /**
  15552. * Check if the current condition is valid
  15553. * @returns a boolean
  15554. */
  15555. isValid(): boolean;
  15556. /**
  15557. * Internal only
  15558. * @hidden
  15559. */
  15560. _getProperty(propertyPath: string): string;
  15561. /**
  15562. * Internal only
  15563. * @hidden
  15564. */
  15565. _getEffectiveTarget(target: any, propertyPath: string): any;
  15566. /**
  15567. * Serialize placeholder for child classes
  15568. * @returns the serialized object
  15569. */
  15570. serialize(): any;
  15571. /**
  15572. * Internal only
  15573. * @hidden
  15574. */
  15575. protected _serialize(serializedCondition: any): any;
  15576. }
  15577. /**
  15578. * Defines specific conditional operators as extensions of Condition
  15579. */
  15580. export class ValueCondition extends Condition {
  15581. /** path to specify the property of the target the conditional operator uses */
  15582. propertyPath: string;
  15583. /** the value compared by the conditional operator against the current value of the property */
  15584. value: any;
  15585. /** the conditional operator, default ValueCondition.IsEqual */
  15586. operator: number;
  15587. /**
  15588. * Internal only
  15589. * @hidden
  15590. */
  15591. private static _IsEqual;
  15592. /**
  15593. * Internal only
  15594. * @hidden
  15595. */
  15596. private static _IsDifferent;
  15597. /**
  15598. * Internal only
  15599. * @hidden
  15600. */
  15601. private static _IsGreater;
  15602. /**
  15603. * Internal only
  15604. * @hidden
  15605. */
  15606. private static _IsLesser;
  15607. /**
  15608. * returns the number for IsEqual
  15609. */
  15610. static readonly IsEqual: number;
  15611. /**
  15612. * Returns the number for IsDifferent
  15613. */
  15614. static readonly IsDifferent: number;
  15615. /**
  15616. * Returns the number for IsGreater
  15617. */
  15618. static readonly IsGreater: number;
  15619. /**
  15620. * Returns the number for IsLesser
  15621. */
  15622. static readonly IsLesser: number;
  15623. /**
  15624. * Internal only The action manager for the condition
  15625. * @hidden
  15626. */
  15627. _actionManager: ActionManager;
  15628. /**
  15629. * Internal only
  15630. * @hidden
  15631. */
  15632. private _target;
  15633. /**
  15634. * Internal only
  15635. * @hidden
  15636. */
  15637. private _effectiveTarget;
  15638. /**
  15639. * Internal only
  15640. * @hidden
  15641. */
  15642. private _property;
  15643. /**
  15644. * Creates a new ValueCondition
  15645. * @param actionManager manager for the action the condition applies to
  15646. * @param target for the action
  15647. * @param propertyPath path to specify the property of the target the conditional operator uses
  15648. * @param value the value compared by the conditional operator against the current value of the property
  15649. * @param operator the conditional operator, default ValueCondition.IsEqual
  15650. */
  15651. constructor(actionManager: ActionManager, target: any,
  15652. /** path to specify the property of the target the conditional operator uses */
  15653. propertyPath: string,
  15654. /** the value compared by the conditional operator against the current value of the property */
  15655. value: any,
  15656. /** the conditional operator, default ValueCondition.IsEqual */
  15657. operator?: number);
  15658. /**
  15659. * Compares the given value with the property value for the specified conditional operator
  15660. * @returns the result of the comparison
  15661. */
  15662. isValid(): boolean;
  15663. /**
  15664. * Serialize the ValueCondition into a JSON compatible object
  15665. * @returns serialization object
  15666. */
  15667. serialize(): any;
  15668. /**
  15669. * Gets the name of the conditional operator for the ValueCondition
  15670. * @param operator the conditional operator
  15671. * @returns the name
  15672. */
  15673. static GetOperatorName(operator: number): string;
  15674. }
  15675. /**
  15676. * Defines a predicate condition as an extension of Condition
  15677. */
  15678. export class PredicateCondition extends Condition {
  15679. /** defines the predicate function used to validate the condition */
  15680. predicate: () => boolean;
  15681. /**
  15682. * Internal only - manager for action
  15683. * @hidden
  15684. */
  15685. _actionManager: ActionManager;
  15686. /**
  15687. * Creates a new PredicateCondition
  15688. * @param actionManager manager for the action the condition applies to
  15689. * @param predicate defines the predicate function used to validate the condition
  15690. */
  15691. constructor(actionManager: ActionManager,
  15692. /** defines the predicate function used to validate the condition */
  15693. predicate: () => boolean);
  15694. /**
  15695. * @returns the validity of the predicate condition
  15696. */
  15697. isValid(): boolean;
  15698. }
  15699. /**
  15700. * Defines a state condition as an extension of Condition
  15701. */
  15702. export class StateCondition extends Condition {
  15703. /** Value to compare with target state */
  15704. value: string;
  15705. /**
  15706. * Internal only - manager for action
  15707. * @hidden
  15708. */
  15709. _actionManager: ActionManager;
  15710. /**
  15711. * Internal only
  15712. * @hidden
  15713. */
  15714. private _target;
  15715. /**
  15716. * Creates a new StateCondition
  15717. * @param actionManager manager for the action the condition applies to
  15718. * @param target of the condition
  15719. * @param value to compare with target state
  15720. */
  15721. constructor(actionManager: ActionManager, target: any,
  15722. /** Value to compare with target state */
  15723. value: string);
  15724. /**
  15725. * Gets a boolean indicating if the current condition is met
  15726. * @returns the validity of the state
  15727. */
  15728. isValid(): boolean;
  15729. /**
  15730. * Serialize the StateCondition into a JSON compatible object
  15731. * @returns serialization object
  15732. */
  15733. serialize(): any;
  15734. }
  15735. }
  15736. declare module "babylonjs/Actions/directActions" {
  15737. import { Action } from "babylonjs/Actions/action";
  15738. import { Condition } from "babylonjs/Actions/condition";
  15739. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15740. /**
  15741. * This defines an action responsible to toggle a boolean once triggered.
  15742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15743. */
  15744. export class SwitchBooleanAction extends Action {
  15745. /**
  15746. * The path to the boolean property in the target object
  15747. */
  15748. propertyPath: string;
  15749. private _target;
  15750. private _effectiveTarget;
  15751. private _property;
  15752. /**
  15753. * Instantiate the action
  15754. * @param triggerOptions defines the trigger options
  15755. * @param target defines the object containing the boolean
  15756. * @param propertyPath defines the path to the boolean property in the target object
  15757. * @param condition defines the trigger related conditions
  15758. */
  15759. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15760. /** @hidden */
  15761. _prepare(): void;
  15762. /**
  15763. * Execute the action toggle the boolean value.
  15764. */
  15765. execute(): void;
  15766. /**
  15767. * Serializes the actions and its related information.
  15768. * @param parent defines the object to serialize in
  15769. * @returns the serialized object
  15770. */
  15771. serialize(parent: any): any;
  15772. }
  15773. /**
  15774. * This defines an action responsible to set a the state field of the target
  15775. * to a desired value once triggered.
  15776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15777. */
  15778. export class SetStateAction extends Action {
  15779. /**
  15780. * The value to store in the state field.
  15781. */
  15782. value: string;
  15783. private _target;
  15784. /**
  15785. * Instantiate the action
  15786. * @param triggerOptions defines the trigger options
  15787. * @param target defines the object containing the state property
  15788. * @param value defines the value to store in the state field
  15789. * @param condition defines the trigger related conditions
  15790. */
  15791. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15792. /**
  15793. * Execute the action and store the value on the target state property.
  15794. */
  15795. execute(): void;
  15796. /**
  15797. * Serializes the actions and its related information.
  15798. * @param parent defines the object to serialize in
  15799. * @returns the serialized object
  15800. */
  15801. serialize(parent: any): any;
  15802. }
  15803. /**
  15804. * This defines an action responsible to set a property of the target
  15805. * to a desired value once triggered.
  15806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15807. */
  15808. export class SetValueAction extends Action {
  15809. /**
  15810. * The path of the property to set in the target.
  15811. */
  15812. propertyPath: string;
  15813. /**
  15814. * The value to set in the property
  15815. */
  15816. value: any;
  15817. private _target;
  15818. private _effectiveTarget;
  15819. private _property;
  15820. /**
  15821. * Instantiate the action
  15822. * @param triggerOptions defines the trigger options
  15823. * @param target defines the object containing the property
  15824. * @param propertyPath defines the path of the property to set in the target
  15825. * @param value defines the value to set in the property
  15826. * @param condition defines the trigger related conditions
  15827. */
  15828. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15829. /** @hidden */
  15830. _prepare(): void;
  15831. /**
  15832. * Execute the action and set the targetted property to the desired value.
  15833. */
  15834. execute(): void;
  15835. /**
  15836. * Serializes the actions and its related information.
  15837. * @param parent defines the object to serialize in
  15838. * @returns the serialized object
  15839. */
  15840. serialize(parent: any): any;
  15841. }
  15842. /**
  15843. * This defines an action responsible to increment the target value
  15844. * to a desired value once triggered.
  15845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15846. */
  15847. export class IncrementValueAction extends Action {
  15848. /**
  15849. * The path of the property to increment in the target.
  15850. */
  15851. propertyPath: string;
  15852. /**
  15853. * The value we should increment the property by.
  15854. */
  15855. value: any;
  15856. private _target;
  15857. private _effectiveTarget;
  15858. private _property;
  15859. /**
  15860. * Instantiate the action
  15861. * @param triggerOptions defines the trigger options
  15862. * @param target defines the object containing the property
  15863. * @param propertyPath defines the path of the property to increment in the target
  15864. * @param value defines the value value we should increment the property by
  15865. * @param condition defines the trigger related conditions
  15866. */
  15867. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15868. /** @hidden */
  15869. _prepare(): void;
  15870. /**
  15871. * Execute the action and increment the target of the value amount.
  15872. */
  15873. execute(): void;
  15874. /**
  15875. * Serializes the actions and its related information.
  15876. * @param parent defines the object to serialize in
  15877. * @returns the serialized object
  15878. */
  15879. serialize(parent: any): any;
  15880. }
  15881. /**
  15882. * This defines an action responsible to start an animation once triggered.
  15883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15884. */
  15885. export class PlayAnimationAction extends Action {
  15886. /**
  15887. * Where the animation should start (animation frame)
  15888. */
  15889. from: number;
  15890. /**
  15891. * Where the animation should stop (animation frame)
  15892. */
  15893. to: number;
  15894. /**
  15895. * Define if the animation should loop or stop after the first play.
  15896. */
  15897. loop?: boolean;
  15898. private _target;
  15899. /**
  15900. * Instantiate the action
  15901. * @param triggerOptions defines the trigger options
  15902. * @param target defines the target animation or animation name
  15903. * @param from defines from where the animation should start (animation frame)
  15904. * @param end defines where the animation should stop (animation frame)
  15905. * @param loop defines if the animation should loop or stop after the first play
  15906. * @param condition defines the trigger related conditions
  15907. */
  15908. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15909. /** @hidden */
  15910. _prepare(): void;
  15911. /**
  15912. * Execute the action and play the animation.
  15913. */
  15914. execute(): void;
  15915. /**
  15916. * Serializes the actions and its related information.
  15917. * @param parent defines the object to serialize in
  15918. * @returns the serialized object
  15919. */
  15920. serialize(parent: any): any;
  15921. }
  15922. /**
  15923. * This defines an action responsible to stop an animation once triggered.
  15924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15925. */
  15926. export class StopAnimationAction extends Action {
  15927. private _target;
  15928. /**
  15929. * Instantiate the action
  15930. * @param triggerOptions defines the trigger options
  15931. * @param target defines the target animation or animation name
  15932. * @param condition defines the trigger related conditions
  15933. */
  15934. constructor(triggerOptions: any, target: any, condition?: Condition);
  15935. /** @hidden */
  15936. _prepare(): void;
  15937. /**
  15938. * Execute the action and stop the animation.
  15939. */
  15940. execute(): void;
  15941. /**
  15942. * Serializes the actions and its related information.
  15943. * @param parent defines the object to serialize in
  15944. * @returns the serialized object
  15945. */
  15946. serialize(parent: any): any;
  15947. }
  15948. /**
  15949. * This defines an action responsible that does nothing once triggered.
  15950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15951. */
  15952. export class DoNothingAction extends Action {
  15953. /**
  15954. * Instantiate the action
  15955. * @param triggerOptions defines the trigger options
  15956. * @param condition defines the trigger related conditions
  15957. */
  15958. constructor(triggerOptions?: any, condition?: Condition);
  15959. /**
  15960. * Execute the action and do nothing.
  15961. */
  15962. execute(): void;
  15963. /**
  15964. * Serializes the actions and its related information.
  15965. * @param parent defines the object to serialize in
  15966. * @returns the serialized object
  15967. */
  15968. serialize(parent: any): any;
  15969. }
  15970. /**
  15971. * This defines an action responsible to trigger several actions once triggered.
  15972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15973. */
  15974. export class CombineAction extends Action {
  15975. /**
  15976. * The list of aggregated animations to run.
  15977. */
  15978. children: Action[];
  15979. /**
  15980. * Instantiate the action
  15981. * @param triggerOptions defines the trigger options
  15982. * @param children defines the list of aggregated animations to run
  15983. * @param condition defines the trigger related conditions
  15984. */
  15985. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15986. /** @hidden */
  15987. _prepare(): void;
  15988. /**
  15989. * Execute the action and executes all the aggregated actions.
  15990. */
  15991. execute(evt: ActionEvent): void;
  15992. /**
  15993. * Serializes the actions and its related information.
  15994. * @param parent defines the object to serialize in
  15995. * @returns the serialized object
  15996. */
  15997. serialize(parent: any): any;
  15998. }
  15999. /**
  16000. * This defines an action responsible to run code (external event) once triggered.
  16001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16002. */
  16003. export class ExecuteCodeAction extends Action {
  16004. /**
  16005. * The callback function to run.
  16006. */
  16007. func: (evt: ActionEvent) => void;
  16008. /**
  16009. * Instantiate the action
  16010. * @param triggerOptions defines the trigger options
  16011. * @param func defines the callback function to run
  16012. * @param condition defines the trigger related conditions
  16013. */
  16014. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  16015. /**
  16016. * Execute the action and run the attached code.
  16017. */
  16018. execute(evt: ActionEvent): void;
  16019. }
  16020. /**
  16021. * This defines an action responsible to set the parent property of the target once triggered.
  16022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16023. */
  16024. export class SetParentAction extends Action {
  16025. private _parent;
  16026. private _target;
  16027. /**
  16028. * Instantiate the action
  16029. * @param triggerOptions defines the trigger options
  16030. * @param target defines the target containing the parent property
  16031. * @param parent defines from where the animation should start (animation frame)
  16032. * @param condition defines the trigger related conditions
  16033. */
  16034. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  16035. /** @hidden */
  16036. _prepare(): void;
  16037. /**
  16038. * Execute the action and set the parent property.
  16039. */
  16040. execute(): void;
  16041. /**
  16042. * Serializes the actions and its related information.
  16043. * @param parent defines the object to serialize in
  16044. * @returns the serialized object
  16045. */
  16046. serialize(parent: any): any;
  16047. }
  16048. }
  16049. declare module "babylonjs/Actions/actionManager" {
  16050. import { Nullable } from "babylonjs/types";
  16051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16052. import { Scene } from "babylonjs/scene";
  16053. import { IAction } from "babylonjs/Actions/action";
  16054. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  16055. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  16056. /**
  16057. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  16058. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  16059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16060. */
  16061. export class ActionManager extends AbstractActionManager {
  16062. /**
  16063. * Nothing
  16064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16065. */
  16066. static readonly NothingTrigger: number;
  16067. /**
  16068. * On pick
  16069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16070. */
  16071. static readonly OnPickTrigger: number;
  16072. /**
  16073. * On left pick
  16074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16075. */
  16076. static readonly OnLeftPickTrigger: number;
  16077. /**
  16078. * On right pick
  16079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16080. */
  16081. static readonly OnRightPickTrigger: number;
  16082. /**
  16083. * On center pick
  16084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16085. */
  16086. static readonly OnCenterPickTrigger: number;
  16087. /**
  16088. * On pick down
  16089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16090. */
  16091. static readonly OnPickDownTrigger: number;
  16092. /**
  16093. * On double pick
  16094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16095. */
  16096. static readonly OnDoublePickTrigger: number;
  16097. /**
  16098. * On pick up
  16099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16100. */
  16101. static readonly OnPickUpTrigger: number;
  16102. /**
  16103. * On pick out.
  16104. * This trigger will only be raised if you also declared a OnPickDown
  16105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16106. */
  16107. static readonly OnPickOutTrigger: number;
  16108. /**
  16109. * On long press
  16110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16111. */
  16112. static readonly OnLongPressTrigger: number;
  16113. /**
  16114. * On pointer over
  16115. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16116. */
  16117. static readonly OnPointerOverTrigger: number;
  16118. /**
  16119. * On pointer out
  16120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16121. */
  16122. static readonly OnPointerOutTrigger: number;
  16123. /**
  16124. * On every frame
  16125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16126. */
  16127. static readonly OnEveryFrameTrigger: number;
  16128. /**
  16129. * On intersection enter
  16130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16131. */
  16132. static readonly OnIntersectionEnterTrigger: number;
  16133. /**
  16134. * On intersection exit
  16135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16136. */
  16137. static readonly OnIntersectionExitTrigger: number;
  16138. /**
  16139. * On key down
  16140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16141. */
  16142. static readonly OnKeyDownTrigger: number;
  16143. /**
  16144. * On key up
  16145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16146. */
  16147. static readonly OnKeyUpTrigger: number;
  16148. private _scene;
  16149. /**
  16150. * Creates a new action manager
  16151. * @param scene defines the hosting scene
  16152. */
  16153. constructor(scene: Scene);
  16154. /**
  16155. * Releases all associated resources
  16156. */
  16157. dispose(): void;
  16158. /**
  16159. * Gets hosting scene
  16160. * @returns the hosting scene
  16161. */
  16162. getScene(): Scene;
  16163. /**
  16164. * Does this action manager handles actions of any of the given triggers
  16165. * @param triggers defines the triggers to be tested
  16166. * @return a boolean indicating whether one (or more) of the triggers is handled
  16167. */
  16168. hasSpecificTriggers(triggers: number[]): boolean;
  16169. /**
  16170. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  16171. * speed.
  16172. * @param triggerA defines the trigger to be tested
  16173. * @param triggerB defines the trigger to be tested
  16174. * @return a boolean indicating whether one (or more) of the triggers is handled
  16175. */
  16176. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  16177. /**
  16178. * Does this action manager handles actions of a given trigger
  16179. * @param trigger defines the trigger to be tested
  16180. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  16181. * @return whether the trigger is handled
  16182. */
  16183. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  16184. /**
  16185. * Does this action manager has pointer triggers
  16186. */
  16187. readonly hasPointerTriggers: boolean;
  16188. /**
  16189. * Does this action manager has pick triggers
  16190. */
  16191. readonly hasPickTriggers: boolean;
  16192. /**
  16193. * Registers an action to this action manager
  16194. * @param action defines the action to be registered
  16195. * @return the action amended (prepared) after registration
  16196. */
  16197. registerAction(action: IAction): Nullable<IAction>;
  16198. /**
  16199. * Unregisters an action to this action manager
  16200. * @param action defines the action to be unregistered
  16201. * @return a boolean indicating whether the action has been unregistered
  16202. */
  16203. unregisterAction(action: IAction): Boolean;
  16204. /**
  16205. * Process a specific trigger
  16206. * @param trigger defines the trigger to process
  16207. * @param evt defines the event details to be processed
  16208. */
  16209. processTrigger(trigger: number, evt?: IActionEvent): void;
  16210. /** @hidden */
  16211. _getEffectiveTarget(target: any, propertyPath: string): any;
  16212. /** @hidden */
  16213. _getProperty(propertyPath: string): string;
  16214. /**
  16215. * Serialize this manager to a JSON object
  16216. * @param name defines the property name to store this manager
  16217. * @returns a JSON representation of this manager
  16218. */
  16219. serialize(name: string): any;
  16220. /**
  16221. * Creates a new ActionManager from a JSON data
  16222. * @param parsedActions defines the JSON data to read from
  16223. * @param object defines the hosting mesh
  16224. * @param scene defines the hosting scene
  16225. */
  16226. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  16227. /**
  16228. * Get a trigger name by index
  16229. * @param trigger defines the trigger index
  16230. * @returns a trigger name
  16231. */
  16232. static GetTriggerName(trigger: number): string;
  16233. }
  16234. }
  16235. declare module "babylonjs/Culling/ray" {
  16236. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  16237. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  16238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16239. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16240. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  16241. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  16242. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  16243. /**
  16244. * Class representing a ray with position and direction
  16245. */
  16246. export class Ray {
  16247. /** origin point */
  16248. origin: Vector3;
  16249. /** direction */
  16250. direction: Vector3;
  16251. /** length of the ray */
  16252. length: number;
  16253. private static readonly TmpVector3;
  16254. private _tmpRay;
  16255. /**
  16256. * Creates a new ray
  16257. * @param origin origin point
  16258. * @param direction direction
  16259. * @param length length of the ray
  16260. */
  16261. constructor(
  16262. /** origin point */
  16263. origin: Vector3,
  16264. /** direction */
  16265. direction: Vector3,
  16266. /** length of the ray */
  16267. length?: number);
  16268. /**
  16269. * Checks if the ray intersects a box
  16270. * @param minimum bound of the box
  16271. * @param maximum bound of the box
  16272. * @param intersectionTreshold extra extend to be added to the box in all direction
  16273. * @returns if the box was hit
  16274. */
  16275. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  16276. /**
  16277. * Checks if the ray intersects a box
  16278. * @param box the bounding box to check
  16279. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  16280. * @returns if the box was hit
  16281. */
  16282. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  16283. /**
  16284. * If the ray hits a sphere
  16285. * @param sphere the bounding sphere to check
  16286. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  16287. * @returns true if it hits the sphere
  16288. */
  16289. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  16290. /**
  16291. * If the ray hits a triange
  16292. * @param vertex0 triangle vertex
  16293. * @param vertex1 triangle vertex
  16294. * @param vertex2 triangle vertex
  16295. * @returns intersection information if hit
  16296. */
  16297. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  16298. /**
  16299. * Checks if ray intersects a plane
  16300. * @param plane the plane to check
  16301. * @returns the distance away it was hit
  16302. */
  16303. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  16304. /**
  16305. * Calculate the intercept of a ray on a given axis
  16306. * @param axis to check 'x' | 'y' | 'z'
  16307. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  16308. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  16309. */
  16310. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  16311. /**
  16312. * Checks if ray intersects a mesh
  16313. * @param mesh the mesh to check
  16314. * @param fastCheck if only the bounding box should checked
  16315. * @returns picking info of the intersecton
  16316. */
  16317. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16318. /**
  16319. * Checks if ray intersects a mesh
  16320. * @param meshes the meshes to check
  16321. * @param fastCheck if only the bounding box should checked
  16322. * @param results array to store result in
  16323. * @returns Array of picking infos
  16324. */
  16325. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16326. private _comparePickingInfo;
  16327. private static smallnum;
  16328. private static rayl;
  16329. /**
  16330. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16331. * @param sega the first point of the segment to test the intersection against
  16332. * @param segb the second point of the segment to test the intersection against
  16333. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16334. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16335. */
  16336. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16337. /**
  16338. * Update the ray from viewport position
  16339. * @param x position
  16340. * @param y y position
  16341. * @param viewportWidth viewport width
  16342. * @param viewportHeight viewport height
  16343. * @param world world matrix
  16344. * @param view view matrix
  16345. * @param projection projection matrix
  16346. * @returns this ray updated
  16347. */
  16348. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16349. /**
  16350. * Creates a ray with origin and direction of 0,0,0
  16351. * @returns the new ray
  16352. */
  16353. static Zero(): Ray;
  16354. /**
  16355. * Creates a new ray from screen space and viewport
  16356. * @param x position
  16357. * @param y y position
  16358. * @param viewportWidth viewport width
  16359. * @param viewportHeight viewport height
  16360. * @param world world matrix
  16361. * @param view view matrix
  16362. * @param projection projection matrix
  16363. * @returns new ray
  16364. */
  16365. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16366. /**
  16367. * 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
  16368. * transformed to the given world matrix.
  16369. * @param origin The origin point
  16370. * @param end The end point
  16371. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16372. * @returns the new ray
  16373. */
  16374. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16375. /**
  16376. * Transforms a ray by a matrix
  16377. * @param ray ray to transform
  16378. * @param matrix matrix to apply
  16379. * @returns the resulting new ray
  16380. */
  16381. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16382. /**
  16383. * Transforms a ray by a matrix
  16384. * @param ray ray to transform
  16385. * @param matrix matrix to apply
  16386. * @param result ray to store result in
  16387. */
  16388. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16389. /**
  16390. * Unproject a ray from screen space to object space
  16391. * @param sourceX defines the screen space x coordinate to use
  16392. * @param sourceY defines the screen space y coordinate to use
  16393. * @param viewportWidth defines the current width of the viewport
  16394. * @param viewportHeight defines the current height of the viewport
  16395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16396. * @param view defines the view matrix to use
  16397. * @param projection defines the projection matrix to use
  16398. */
  16399. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16400. }
  16401. /**
  16402. * Type used to define predicate used to select faces when a mesh intersection is detected
  16403. */
  16404. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16405. module "babylonjs/scene" {
  16406. interface Scene {
  16407. /** @hidden */
  16408. _tempPickingRay: Nullable<Ray>;
  16409. /** @hidden */
  16410. _cachedRayForTransform: Ray;
  16411. /** @hidden */
  16412. _pickWithRayInverseMatrix: Matrix;
  16413. /** @hidden */
  16414. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16415. /** @hidden */
  16416. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16417. }
  16418. }
  16419. }
  16420. declare module "babylonjs/Sprites/spriteSceneComponent" {
  16421. import { Nullable } from "babylonjs/types";
  16422. import { Observable } from "babylonjs/Misc/observable";
  16423. import { Scene } from "babylonjs/scene";
  16424. import { Sprite } from "babylonjs/Sprites/sprite";
  16425. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16426. import { Ray } from "babylonjs/Culling/ray";
  16427. import { Camera } from "babylonjs/Cameras/camera";
  16428. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16429. import { ISceneComponent } from "babylonjs/sceneComponent";
  16430. module "babylonjs/scene" {
  16431. interface Scene {
  16432. /** @hidden */
  16433. _pointerOverSprite: Nullable<Sprite>;
  16434. /** @hidden */
  16435. _pickedDownSprite: Nullable<Sprite>;
  16436. /** @hidden */
  16437. _tempSpritePickingRay: Nullable<Ray>;
  16438. /**
  16439. * All of the sprite managers added to this scene
  16440. * @see http://doc.babylonjs.com/babylon101/sprites
  16441. */
  16442. spriteManagers: Array<ISpriteManager>;
  16443. /**
  16444. * An event triggered when sprites rendering is about to start
  16445. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16446. */
  16447. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16448. /**
  16449. * An event triggered when sprites rendering is done
  16450. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16451. */
  16452. onAfterSpritesRenderingObservable: Observable<Scene>;
  16453. /** @hidden */
  16454. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16455. /** Launch a ray to try to pick a sprite in the scene
  16456. * @param x position on screen
  16457. * @param y position on screen
  16458. * @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
  16459. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16460. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16461. * @returns a PickingInfo
  16462. */
  16463. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16464. /** Use the given ray to pick a sprite in the scene
  16465. * @param ray The ray (in world space) to use to pick meshes
  16466. * @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
  16467. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16468. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16469. * @returns a PickingInfo
  16470. */
  16471. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16472. /**
  16473. * Force the sprite under the pointer
  16474. * @param sprite defines the sprite to use
  16475. */
  16476. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16477. /**
  16478. * Gets the sprite under the pointer
  16479. * @returns a Sprite or null if no sprite is under the pointer
  16480. */
  16481. getPointerOverSprite(): Nullable<Sprite>;
  16482. }
  16483. }
  16484. /**
  16485. * Defines the sprite scene component responsible to manage sprites
  16486. * in a given scene.
  16487. */
  16488. export class SpriteSceneComponent implements ISceneComponent {
  16489. /**
  16490. * The component name helpfull to identify the component in the list of scene components.
  16491. */
  16492. readonly name: string;
  16493. /**
  16494. * The scene the component belongs to.
  16495. */
  16496. scene: Scene;
  16497. /** @hidden */
  16498. private _spritePredicate;
  16499. /**
  16500. * Creates a new instance of the component for the given scene
  16501. * @param scene Defines the scene to register the component in
  16502. */
  16503. constructor(scene: Scene);
  16504. /**
  16505. * Registers the component in a given scene
  16506. */
  16507. register(): void;
  16508. /**
  16509. * Rebuilds the elements related to this component in case of
  16510. * context lost for instance.
  16511. */
  16512. rebuild(): void;
  16513. /**
  16514. * Disposes the component and the associated ressources.
  16515. */
  16516. dispose(): void;
  16517. private _pickSpriteButKeepRay;
  16518. private _pointerMove;
  16519. private _pointerDown;
  16520. private _pointerUp;
  16521. }
  16522. }
  16523. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  16524. /** @hidden */
  16525. export var fogFragmentDeclaration: {
  16526. name: string;
  16527. shader: string;
  16528. };
  16529. }
  16530. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  16531. /** @hidden */
  16532. export var fogFragment: {
  16533. name: string;
  16534. shader: string;
  16535. };
  16536. }
  16537. declare module "babylonjs/Shaders/sprites.fragment" {
  16538. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  16539. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  16540. /** @hidden */
  16541. export var spritesPixelShader: {
  16542. name: string;
  16543. shader: string;
  16544. };
  16545. }
  16546. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  16547. /** @hidden */
  16548. export var fogVertexDeclaration: {
  16549. name: string;
  16550. shader: string;
  16551. };
  16552. }
  16553. declare module "babylonjs/Shaders/sprites.vertex" {
  16554. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  16555. /** @hidden */
  16556. export var spritesVertexShader: {
  16557. name: string;
  16558. shader: string;
  16559. };
  16560. }
  16561. declare module "babylonjs/Sprites/spriteManager" {
  16562. import { IDisposable, Scene } from "babylonjs/scene";
  16563. import { Nullable } from "babylonjs/types";
  16564. import { Observable } from "babylonjs/Misc/observable";
  16565. import { Sprite } from "babylonjs/Sprites/sprite";
  16566. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16567. import { Camera } from "babylonjs/Cameras/camera";
  16568. import { Texture } from "babylonjs/Materials/Textures/texture";
  16569. import "babylonjs/Shaders/sprites.fragment";
  16570. import "babylonjs/Shaders/sprites.vertex";
  16571. import { Ray } from "babylonjs/Culling/ray";
  16572. /**
  16573. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16574. */
  16575. export interface ISpriteManager extends IDisposable {
  16576. /**
  16577. * Restricts the camera to viewing objects with the same layerMask.
  16578. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16579. */
  16580. layerMask: number;
  16581. /**
  16582. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16583. */
  16584. isPickable: boolean;
  16585. /**
  16586. * Specifies the rendering group id for this mesh (0 by default)
  16587. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16588. */
  16589. renderingGroupId: number;
  16590. /**
  16591. * Defines the list of sprites managed by the manager.
  16592. */
  16593. sprites: Array<Sprite>;
  16594. /**
  16595. * Tests the intersection of a sprite with a specific ray.
  16596. * @param ray The ray we are sending to test the collision
  16597. * @param camera The camera space we are sending rays in
  16598. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16599. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16600. * @returns picking info or null.
  16601. */
  16602. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16603. /**
  16604. * Renders the list of sprites on screen.
  16605. */
  16606. render(): void;
  16607. }
  16608. /**
  16609. * Class used to manage multiple sprites on the same spritesheet
  16610. * @see http://doc.babylonjs.com/babylon101/sprites
  16611. */
  16612. export class SpriteManager implements ISpriteManager {
  16613. /** defines the manager's name */
  16614. name: string;
  16615. /** Gets the list of sprites */
  16616. sprites: Sprite[];
  16617. /** Gets or sets the rendering group id (0 by default) */
  16618. renderingGroupId: number;
  16619. /** Gets or sets camera layer mask */
  16620. layerMask: number;
  16621. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16622. fogEnabled: boolean;
  16623. /** Gets or sets a boolean indicating if the sprites are pickable */
  16624. isPickable: boolean;
  16625. /** Defines the default width of a cell in the spritesheet */
  16626. cellWidth: number;
  16627. /** Defines the default height of a cell in the spritesheet */
  16628. cellHeight: number;
  16629. /**
  16630. * An event triggered when the manager is disposed.
  16631. */
  16632. onDisposeObservable: Observable<SpriteManager>;
  16633. private _onDisposeObserver;
  16634. /**
  16635. * Callback called when the manager is disposed
  16636. */
  16637. onDispose: () => void;
  16638. private _capacity;
  16639. private _spriteTexture;
  16640. private _epsilon;
  16641. private _scene;
  16642. private _vertexData;
  16643. private _buffer;
  16644. private _vertexBuffers;
  16645. private _indexBuffer;
  16646. private _effectBase;
  16647. private _effectFog;
  16648. /**
  16649. * Gets or sets the spritesheet texture
  16650. */
  16651. texture: Texture;
  16652. /**
  16653. * Creates a new sprite manager
  16654. * @param name defines the manager's name
  16655. * @param imgUrl defines the sprite sheet url
  16656. * @param capacity defines the maximum allowed number of sprites
  16657. * @param cellSize defines the size of a sprite cell
  16658. * @param scene defines the hosting scene
  16659. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16660. * @param samplingMode defines the smapling mode to use with spritesheet
  16661. */
  16662. constructor(
  16663. /** defines the manager's name */
  16664. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16665. private _appendSpriteVertex;
  16666. /**
  16667. * Intersects the sprites with a ray
  16668. * @param ray defines the ray to intersect with
  16669. * @param camera defines the current active camera
  16670. * @param predicate defines a predicate used to select candidate sprites
  16671. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16672. * @returns null if no hit or a PickingInfo
  16673. */
  16674. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16675. /**
  16676. * Render all child sprites
  16677. */
  16678. render(): void;
  16679. /**
  16680. * Release associated resources
  16681. */
  16682. dispose(): void;
  16683. }
  16684. }
  16685. declare module "babylonjs/Sprites/sprite" {
  16686. import { Vector3, Color4 } from "babylonjs/Maths/math";
  16687. import { Nullable } from "babylonjs/types";
  16688. import { ActionManager } from "babylonjs/Actions/actionManager";
  16689. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16690. /**
  16691. * Class used to represent a sprite
  16692. * @see http://doc.babylonjs.com/babylon101/sprites
  16693. */
  16694. export class Sprite {
  16695. /** defines the name */
  16696. name: string;
  16697. /** Gets or sets the current world position */
  16698. position: Vector3;
  16699. /** Gets or sets the main color */
  16700. color: Color4;
  16701. /** Gets or sets the width */
  16702. width: number;
  16703. /** Gets or sets the height */
  16704. height: number;
  16705. /** Gets or sets rotation angle */
  16706. angle: number;
  16707. /** Gets or sets the cell index in the sprite sheet */
  16708. cellIndex: number;
  16709. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16710. invertU: number;
  16711. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16712. invertV: number;
  16713. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16714. disposeWhenFinishedAnimating: boolean;
  16715. /** Gets the list of attached animations */
  16716. animations: Animation[];
  16717. /** Gets or sets a boolean indicating if the sprite can be picked */
  16718. isPickable: boolean;
  16719. /**
  16720. * Gets or sets the associated action manager
  16721. */
  16722. actionManager: Nullable<ActionManager>;
  16723. private _animationStarted;
  16724. private _loopAnimation;
  16725. private _fromIndex;
  16726. private _toIndex;
  16727. private _delay;
  16728. private _direction;
  16729. private _manager;
  16730. private _time;
  16731. private _onAnimationEnd;
  16732. /**
  16733. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16734. */
  16735. isVisible: boolean;
  16736. /**
  16737. * Gets or sets the sprite size
  16738. */
  16739. size: number;
  16740. /**
  16741. * Creates a new Sprite
  16742. * @param name defines the name
  16743. * @param manager defines the manager
  16744. */
  16745. constructor(
  16746. /** defines the name */
  16747. name: string, manager: ISpriteManager);
  16748. /**
  16749. * Starts an animation
  16750. * @param from defines the initial key
  16751. * @param to defines the end key
  16752. * @param loop defines if the animation must loop
  16753. * @param delay defines the start delay (in ms)
  16754. * @param onAnimationEnd defines a callback to call when animation ends
  16755. */
  16756. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16757. /** Stops current animation (if any) */
  16758. stopAnimation(): void;
  16759. /** @hidden */
  16760. _animate(deltaTime: number): void;
  16761. /** Release associated resources */
  16762. dispose(): void;
  16763. }
  16764. }
  16765. declare module "babylonjs/Collisions/pickingInfo" {
  16766. import { Nullable } from "babylonjs/types";
  16767. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  16768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16769. import { Sprite } from "babylonjs/Sprites/sprite";
  16770. import { Ray } from "babylonjs/Culling/ray";
  16771. /**
  16772. * Information about the result of picking within a scene
  16773. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16774. */
  16775. export class PickingInfo {
  16776. /** @hidden */
  16777. _pickingUnavailable: boolean;
  16778. /**
  16779. * If the pick collided with an object
  16780. */
  16781. hit: boolean;
  16782. /**
  16783. * Distance away where the pick collided
  16784. */
  16785. distance: number;
  16786. /**
  16787. * The location of pick collision
  16788. */
  16789. pickedPoint: Nullable<Vector3>;
  16790. /**
  16791. * The mesh corresponding the the pick collision
  16792. */
  16793. pickedMesh: Nullable<AbstractMesh>;
  16794. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16795. bu: number;
  16796. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16797. bv: number;
  16798. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16799. faceId: number;
  16800. /** Id of the the submesh that was picked */
  16801. subMeshId: number;
  16802. /** If a sprite was picked, this will be the sprite the pick collided with */
  16803. pickedSprite: Nullable<Sprite>;
  16804. /**
  16805. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16806. */
  16807. originMesh: Nullable<AbstractMesh>;
  16808. /**
  16809. * The ray that was used to perform the picking.
  16810. */
  16811. ray: Nullable<Ray>;
  16812. /**
  16813. * Gets the normal correspodning to the face the pick collided with
  16814. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16815. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16816. * @returns The normal correspodning to the face the pick collided with
  16817. */
  16818. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16819. /**
  16820. * Gets the texture coordinates of where the pick occured
  16821. * @returns the vector containing the coordnates of the texture
  16822. */
  16823. getTextureCoordinates(): Nullable<Vector2>;
  16824. }
  16825. }
  16826. declare module "babylonjs/Events/pointerEvents" {
  16827. import { Nullable } from "babylonjs/types";
  16828. import { Vector2 } from "babylonjs/Maths/math";
  16829. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16830. import { Ray } from "babylonjs/Culling/ray";
  16831. /**
  16832. * Gather the list of pointer event types as constants.
  16833. */
  16834. export class PointerEventTypes {
  16835. /**
  16836. * 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.
  16837. */
  16838. static readonly POINTERDOWN: number;
  16839. /**
  16840. * The pointerup event is fired when a pointer is no longer active.
  16841. */
  16842. static readonly POINTERUP: number;
  16843. /**
  16844. * The pointermove event is fired when a pointer changes coordinates.
  16845. */
  16846. static readonly POINTERMOVE: number;
  16847. /**
  16848. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16849. */
  16850. static readonly POINTERWHEEL: number;
  16851. /**
  16852. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16853. */
  16854. static readonly POINTERPICK: number;
  16855. /**
  16856. * The pointertap event is fired when a the object has been touched and released without drag.
  16857. */
  16858. static readonly POINTERTAP: number;
  16859. /**
  16860. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16861. */
  16862. static readonly POINTERDOUBLETAP: number;
  16863. }
  16864. /**
  16865. * Base class of pointer info types.
  16866. */
  16867. export class PointerInfoBase {
  16868. /**
  16869. * Defines the type of event (PointerEventTypes)
  16870. */
  16871. type: number;
  16872. /**
  16873. * Defines the related dom event
  16874. */
  16875. event: PointerEvent | MouseWheelEvent;
  16876. /**
  16877. * Instantiates the base class of pointers info.
  16878. * @param type Defines the type of event (PointerEventTypes)
  16879. * @param event Defines the related dom event
  16880. */
  16881. constructor(
  16882. /**
  16883. * Defines the type of event (PointerEventTypes)
  16884. */
  16885. type: number,
  16886. /**
  16887. * Defines the related dom event
  16888. */
  16889. event: PointerEvent | MouseWheelEvent);
  16890. }
  16891. /**
  16892. * This class is used to store pointer related info for the onPrePointerObservable event.
  16893. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16894. */
  16895. export class PointerInfoPre extends PointerInfoBase {
  16896. /**
  16897. * Ray from a pointer if availible (eg. 6dof controller)
  16898. */
  16899. ray: Nullable<Ray>;
  16900. /**
  16901. * Defines the local position of the pointer on the canvas.
  16902. */
  16903. localPosition: Vector2;
  16904. /**
  16905. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16906. */
  16907. skipOnPointerObservable: boolean;
  16908. /**
  16909. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16910. * @param type Defines the type of event (PointerEventTypes)
  16911. * @param event Defines the related dom event
  16912. * @param localX Defines the local x coordinates of the pointer when the event occured
  16913. * @param localY Defines the local y coordinates of the pointer when the event occured
  16914. */
  16915. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16916. }
  16917. /**
  16918. * This type contains all the data related to a pointer event in Babylon.js.
  16919. * 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.
  16920. */
  16921. export class PointerInfo extends PointerInfoBase {
  16922. /**
  16923. * Defines the picking info associated to the info (if any)\
  16924. */
  16925. pickInfo: Nullable<PickingInfo>;
  16926. /**
  16927. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16928. * @param type Defines the type of event (PointerEventTypes)
  16929. * @param event Defines the related dom event
  16930. * @param pickInfo Defines the picking info associated to the info (if any)\
  16931. */
  16932. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16933. /**
  16934. * Defines the picking info associated to the info (if any)\
  16935. */
  16936. pickInfo: Nullable<PickingInfo>);
  16937. }
  16938. /**
  16939. * Data relating to a touch event on the screen.
  16940. */
  16941. export interface PointerTouch {
  16942. /**
  16943. * X coordinate of touch.
  16944. */
  16945. x: number;
  16946. /**
  16947. * Y coordinate of touch.
  16948. */
  16949. y: number;
  16950. /**
  16951. * Id of touch. Unique for each finger.
  16952. */
  16953. pointerId: number;
  16954. /**
  16955. * Event type passed from DOM.
  16956. */
  16957. type: any;
  16958. }
  16959. }
  16960. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  16961. import { Observable } from "babylonjs/Misc/observable";
  16962. import { Nullable } from "babylonjs/types";
  16963. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16964. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16965. /**
  16966. * Manage the mouse inputs to control the movement of a free camera.
  16967. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16968. */
  16969. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16970. /**
  16971. * Define if touch is enabled in the mouse input
  16972. */
  16973. touchEnabled: boolean;
  16974. /**
  16975. * Defines the camera the input is attached to.
  16976. */
  16977. camera: FreeCamera;
  16978. /**
  16979. * Defines the buttons associated with the input to handle camera move.
  16980. */
  16981. buttons: number[];
  16982. /**
  16983. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16984. */
  16985. angularSensibility: number;
  16986. private _pointerInput;
  16987. private _onMouseMove;
  16988. private _observer;
  16989. private previousPosition;
  16990. /**
  16991. * Observable for when a pointer move event occurs containing the move offset
  16992. */
  16993. onPointerMovedObservable: Observable<{
  16994. offsetX: number;
  16995. offsetY: number;
  16996. }>;
  16997. /**
  16998. * @hidden
  16999. * If the camera should be rotated automatically based on pointer movement
  17000. */
  17001. _allowCameraRotation: boolean;
  17002. /**
  17003. * Manage the mouse inputs to control the movement of a free camera.
  17004. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17005. * @param touchEnabled Defines if touch is enabled or not
  17006. */
  17007. constructor(
  17008. /**
  17009. * Define if touch is enabled in the mouse input
  17010. */
  17011. touchEnabled?: boolean);
  17012. /**
  17013. * Attach the input controls to a specific dom element to get the input from.
  17014. * @param element Defines the element the controls should be listened from
  17015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17016. */
  17017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17018. /**
  17019. * Called on JS contextmenu event.
  17020. * Override this method to provide functionality.
  17021. */
  17022. protected onContextMenu(evt: PointerEvent): void;
  17023. /**
  17024. * Detach the current controls from the specified dom element.
  17025. * @param element Defines the element to stop listening the inputs from
  17026. */
  17027. detachControl(element: Nullable<HTMLElement>): void;
  17028. /**
  17029. * Gets the class name of the current intput.
  17030. * @returns the class name
  17031. */
  17032. getClassName(): string;
  17033. /**
  17034. * Get the friendly name associated with the input class.
  17035. * @returns the input friendly name
  17036. */
  17037. getSimpleName(): string;
  17038. }
  17039. }
  17040. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  17041. import { Nullable } from "babylonjs/types";
  17042. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  17043. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17044. /**
  17045. * Manage the touch inputs to control the movement of a free camera.
  17046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17047. */
  17048. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  17049. /**
  17050. * Defines the camera the input is attached to.
  17051. */
  17052. camera: FreeCamera;
  17053. /**
  17054. * Defines the touch sensibility for rotation.
  17055. * The higher the faster.
  17056. */
  17057. touchAngularSensibility: number;
  17058. /**
  17059. * Defines the touch sensibility for move.
  17060. * The higher the faster.
  17061. */
  17062. touchMoveSensibility: number;
  17063. private _offsetX;
  17064. private _offsetY;
  17065. private _pointerPressed;
  17066. private _pointerInput;
  17067. private _observer;
  17068. private _onLostFocus;
  17069. /**
  17070. * Attach the input controls to a specific dom element to get the input from.
  17071. * @param element Defines the element the controls should be listened from
  17072. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17073. */
  17074. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17075. /**
  17076. * Detach the current controls from the specified dom element.
  17077. * @param element Defines the element to stop listening the inputs from
  17078. */
  17079. detachControl(element: Nullable<HTMLElement>): void;
  17080. /**
  17081. * Update the current camera state depending on the inputs that have been used this frame.
  17082. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  17083. */
  17084. checkInputs(): void;
  17085. /**
  17086. * Gets the class name of the current intput.
  17087. * @returns the class name
  17088. */
  17089. getClassName(): string;
  17090. /**
  17091. * Get the friendly name associated with the input class.
  17092. * @returns the input friendly name
  17093. */
  17094. getSimpleName(): string;
  17095. }
  17096. }
  17097. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  17098. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17099. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  17100. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  17101. import { Nullable } from "babylonjs/types";
  17102. /**
  17103. * Default Inputs manager for the FreeCamera.
  17104. * It groups all the default supported inputs for ease of use.
  17105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17106. */
  17107. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  17108. /**
  17109. * @hidden
  17110. */
  17111. _mouseInput: Nullable<FreeCameraMouseInput>;
  17112. /**
  17113. * Instantiates a new FreeCameraInputsManager.
  17114. * @param camera Defines the camera the inputs belong to
  17115. */
  17116. constructor(camera: FreeCamera);
  17117. /**
  17118. * Add keyboard input support to the input manager.
  17119. * @returns the current input manager
  17120. */
  17121. addKeyboard(): FreeCameraInputsManager;
  17122. /**
  17123. * Add mouse input support to the input manager.
  17124. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  17125. * @returns the current input manager
  17126. */
  17127. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  17128. /**
  17129. * Removes the mouse input support from the manager
  17130. * @returns the current input manager
  17131. */
  17132. removeMouse(): FreeCameraInputsManager;
  17133. /**
  17134. * Add touch input support to the input manager.
  17135. * @returns the current input manager
  17136. */
  17137. addTouch(): FreeCameraInputsManager;
  17138. /**
  17139. * Remove all attached input methods from a camera
  17140. */
  17141. clear(): void;
  17142. }
  17143. }
  17144. declare module "babylonjs/Cameras/freeCamera" {
  17145. import { Vector3 } from "babylonjs/Maths/math";
  17146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17147. import { Scene } from "babylonjs/scene";
  17148. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17149. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  17150. /**
  17151. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17152. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  17153. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17154. */
  17155. export class FreeCamera extends TargetCamera {
  17156. /**
  17157. * Define the collision ellipsoid of the camera.
  17158. * This is helpful to simulate a camera body like the player body around the camera
  17159. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  17160. */
  17161. ellipsoid: Vector3;
  17162. /**
  17163. * Define an offset for the position of the ellipsoid around the camera.
  17164. * This can be helpful to determine the center of the body near the gravity center of the body
  17165. * instead of its head.
  17166. */
  17167. ellipsoidOffset: Vector3;
  17168. /**
  17169. * Enable or disable collisions of the camera with the rest of the scene objects.
  17170. */
  17171. checkCollisions: boolean;
  17172. /**
  17173. * Enable or disable gravity on the camera.
  17174. */
  17175. applyGravity: boolean;
  17176. /**
  17177. * Define the input manager associated to the camera.
  17178. */
  17179. inputs: FreeCameraInputsManager;
  17180. /**
  17181. * Gets the input sensibility for a mouse input. (default is 2000.0)
  17182. * Higher values reduce sensitivity.
  17183. */
  17184. /**
  17185. * Sets the input sensibility for a mouse input. (default is 2000.0)
  17186. * Higher values reduce sensitivity.
  17187. */
  17188. angularSensibility: number;
  17189. /**
  17190. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  17191. */
  17192. keysUp: number[];
  17193. /**
  17194. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  17195. */
  17196. keysDown: number[];
  17197. /**
  17198. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  17199. */
  17200. keysLeft: number[];
  17201. /**
  17202. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  17203. */
  17204. keysRight: number[];
  17205. /**
  17206. * Event raised when the camera collide with a mesh in the scene.
  17207. */
  17208. onCollide: (collidedMesh: AbstractMesh) => void;
  17209. private _collider;
  17210. private _needMoveForGravity;
  17211. private _oldPosition;
  17212. private _diffPosition;
  17213. private _newPosition;
  17214. /** @hidden */
  17215. _localDirection: Vector3;
  17216. /** @hidden */
  17217. _transformedDirection: Vector3;
  17218. /**
  17219. * Instantiates a Free Camera.
  17220. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17221. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  17222. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17223. * @param name Define the name of the camera in the scene
  17224. * @param position Define the start position of the camera in the scene
  17225. * @param scene Define the scene the camera belongs to
  17226. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  17227. */
  17228. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  17229. /**
  17230. * Attached controls to the current camera.
  17231. * @param element Defines the element the controls should be listened from
  17232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17233. */
  17234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17235. /**
  17236. * Detach the current controls from the camera.
  17237. * The camera will stop reacting to inputs.
  17238. * @param element Defines the element to stop listening the inputs from
  17239. */
  17240. detachControl(element: HTMLElement): void;
  17241. private _collisionMask;
  17242. /**
  17243. * Define a collision mask to limit the list of object the camera can collide with
  17244. */
  17245. collisionMask: number;
  17246. /** @hidden */
  17247. _collideWithWorld(displacement: Vector3): void;
  17248. private _onCollisionPositionChange;
  17249. /** @hidden */
  17250. _checkInputs(): void;
  17251. /** @hidden */
  17252. _decideIfNeedsToMove(): boolean;
  17253. /** @hidden */
  17254. _updatePosition(): void;
  17255. /**
  17256. * Destroy the camera and release the current resources hold by it.
  17257. */
  17258. dispose(): void;
  17259. /**
  17260. * Gets the current object class name.
  17261. * @return the class name
  17262. */
  17263. getClassName(): string;
  17264. }
  17265. }
  17266. declare module "babylonjs/Gamepads/gamepad" {
  17267. import { Observable } from "babylonjs/Misc/observable";
  17268. /**
  17269. * Represents a gamepad control stick position
  17270. */
  17271. export class StickValues {
  17272. /**
  17273. * The x component of the control stick
  17274. */
  17275. x: number;
  17276. /**
  17277. * The y component of the control stick
  17278. */
  17279. y: number;
  17280. /**
  17281. * Initializes the gamepad x and y control stick values
  17282. * @param x The x component of the gamepad control stick value
  17283. * @param y The y component of the gamepad control stick value
  17284. */
  17285. constructor(
  17286. /**
  17287. * The x component of the control stick
  17288. */
  17289. x: number,
  17290. /**
  17291. * The y component of the control stick
  17292. */
  17293. y: number);
  17294. }
  17295. /**
  17296. * An interface which manages callbacks for gamepad button changes
  17297. */
  17298. export interface GamepadButtonChanges {
  17299. /**
  17300. * Called when a gamepad has been changed
  17301. */
  17302. changed: boolean;
  17303. /**
  17304. * Called when a gamepad press event has been triggered
  17305. */
  17306. pressChanged: boolean;
  17307. /**
  17308. * Called when a touch event has been triggered
  17309. */
  17310. touchChanged: boolean;
  17311. /**
  17312. * Called when a value has changed
  17313. */
  17314. valueChanged: boolean;
  17315. }
  17316. /**
  17317. * Represents a gamepad
  17318. */
  17319. export class Gamepad {
  17320. /**
  17321. * The id of the gamepad
  17322. */
  17323. id: string;
  17324. /**
  17325. * The index of the gamepad
  17326. */
  17327. index: number;
  17328. /**
  17329. * The browser gamepad
  17330. */
  17331. browserGamepad: any;
  17332. /**
  17333. * Specifies what type of gamepad this represents
  17334. */
  17335. type: number;
  17336. private _leftStick;
  17337. private _rightStick;
  17338. /** @hidden */
  17339. _isConnected: boolean;
  17340. private _leftStickAxisX;
  17341. private _leftStickAxisY;
  17342. private _rightStickAxisX;
  17343. private _rightStickAxisY;
  17344. /**
  17345. * Triggered when the left control stick has been changed
  17346. */
  17347. private _onleftstickchanged;
  17348. /**
  17349. * Triggered when the right control stick has been changed
  17350. */
  17351. private _onrightstickchanged;
  17352. /**
  17353. * Represents a gamepad controller
  17354. */
  17355. static GAMEPAD: number;
  17356. /**
  17357. * Represents a generic controller
  17358. */
  17359. static GENERIC: number;
  17360. /**
  17361. * Represents an XBox controller
  17362. */
  17363. static XBOX: number;
  17364. /**
  17365. * Represents a pose-enabled controller
  17366. */
  17367. static POSE_ENABLED: number;
  17368. /**
  17369. * Specifies whether the left control stick should be Y-inverted
  17370. */
  17371. protected _invertLeftStickY: boolean;
  17372. /**
  17373. * Specifies if the gamepad has been connected
  17374. */
  17375. readonly isConnected: boolean;
  17376. /**
  17377. * Initializes the gamepad
  17378. * @param id The id of the gamepad
  17379. * @param index The index of the gamepad
  17380. * @param browserGamepad The browser gamepad
  17381. * @param leftStickX The x component of the left joystick
  17382. * @param leftStickY The y component of the left joystick
  17383. * @param rightStickX The x component of the right joystick
  17384. * @param rightStickY The y component of the right joystick
  17385. */
  17386. constructor(
  17387. /**
  17388. * The id of the gamepad
  17389. */
  17390. id: string,
  17391. /**
  17392. * The index of the gamepad
  17393. */
  17394. index: number,
  17395. /**
  17396. * The browser gamepad
  17397. */
  17398. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17399. /**
  17400. * Callback triggered when the left joystick has changed
  17401. * @param callback
  17402. */
  17403. onleftstickchanged(callback: (values: StickValues) => void): void;
  17404. /**
  17405. * Callback triggered when the right joystick has changed
  17406. * @param callback
  17407. */
  17408. onrightstickchanged(callback: (values: StickValues) => void): void;
  17409. /**
  17410. * Gets the left joystick
  17411. */
  17412. /**
  17413. * Sets the left joystick values
  17414. */
  17415. leftStick: StickValues;
  17416. /**
  17417. * Gets the right joystick
  17418. */
  17419. /**
  17420. * Sets the right joystick value
  17421. */
  17422. rightStick: StickValues;
  17423. /**
  17424. * Updates the gamepad joystick positions
  17425. */
  17426. update(): void;
  17427. /**
  17428. * Disposes the gamepad
  17429. */
  17430. dispose(): void;
  17431. }
  17432. /**
  17433. * Represents a generic gamepad
  17434. */
  17435. export class GenericPad extends Gamepad {
  17436. private _buttons;
  17437. private _onbuttondown;
  17438. private _onbuttonup;
  17439. /**
  17440. * Observable triggered when a button has been pressed
  17441. */
  17442. onButtonDownObservable: Observable<number>;
  17443. /**
  17444. * Observable triggered when a button has been released
  17445. */
  17446. onButtonUpObservable: Observable<number>;
  17447. /**
  17448. * Callback triggered when a button has been pressed
  17449. * @param callback Called when a button has been pressed
  17450. */
  17451. onbuttondown(callback: (buttonPressed: number) => void): void;
  17452. /**
  17453. * Callback triggered when a button has been released
  17454. * @param callback Called when a button has been released
  17455. */
  17456. onbuttonup(callback: (buttonReleased: number) => void): void;
  17457. /**
  17458. * Initializes the generic gamepad
  17459. * @param id The id of the generic gamepad
  17460. * @param index The index of the generic gamepad
  17461. * @param browserGamepad The browser gamepad
  17462. */
  17463. constructor(id: string, index: number, browserGamepad: any);
  17464. private _setButtonValue;
  17465. /**
  17466. * Updates the generic gamepad
  17467. */
  17468. update(): void;
  17469. /**
  17470. * Disposes the generic gamepad
  17471. */
  17472. dispose(): void;
  17473. }
  17474. }
  17475. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  17476. import { Observable } from "babylonjs/Misc/observable";
  17477. import { Nullable } from "babylonjs/types";
  17478. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17479. import { TransformNode } from "babylonjs/Meshes/transformNode";
  17480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17481. import { Ray } from "babylonjs/Culling/ray";
  17482. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  17483. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  17484. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17485. /**
  17486. * Defines the types of pose enabled controllers that are supported
  17487. */
  17488. export enum PoseEnabledControllerType {
  17489. /**
  17490. * HTC Vive
  17491. */
  17492. VIVE = 0,
  17493. /**
  17494. * Oculus Rift
  17495. */
  17496. OCULUS = 1,
  17497. /**
  17498. * Windows mixed reality
  17499. */
  17500. WINDOWS = 2,
  17501. /**
  17502. * Samsung gear VR
  17503. */
  17504. GEAR_VR = 3,
  17505. /**
  17506. * Google Daydream
  17507. */
  17508. DAYDREAM = 4,
  17509. /**
  17510. * Generic
  17511. */
  17512. GENERIC = 5
  17513. }
  17514. /**
  17515. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17516. */
  17517. export interface MutableGamepadButton {
  17518. /**
  17519. * Value of the button/trigger
  17520. */
  17521. value: number;
  17522. /**
  17523. * If the button/trigger is currently touched
  17524. */
  17525. touched: boolean;
  17526. /**
  17527. * If the button/trigger is currently pressed
  17528. */
  17529. pressed: boolean;
  17530. }
  17531. /**
  17532. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17533. * @hidden
  17534. */
  17535. export interface ExtendedGamepadButton extends GamepadButton {
  17536. /**
  17537. * If the button/trigger is currently pressed
  17538. */
  17539. readonly pressed: boolean;
  17540. /**
  17541. * If the button/trigger is currently touched
  17542. */
  17543. readonly touched: boolean;
  17544. /**
  17545. * Value of the button/trigger
  17546. */
  17547. readonly value: number;
  17548. }
  17549. /** @hidden */
  17550. export interface _GamePadFactory {
  17551. /**
  17552. * Returns wether or not the current gamepad can be created for this type of controller.
  17553. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17554. * @returns true if it can be created, otherwise false
  17555. */
  17556. canCreate(gamepadInfo: any): boolean;
  17557. /**
  17558. * Creates a new instance of the Gamepad.
  17559. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17560. * @returns the new gamepad instance
  17561. */
  17562. create(gamepadInfo: any): Gamepad;
  17563. }
  17564. /**
  17565. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17566. */
  17567. export class PoseEnabledControllerHelper {
  17568. /** @hidden */
  17569. static _ControllerFactories: _GamePadFactory[];
  17570. /** @hidden */
  17571. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17572. /**
  17573. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17574. * @param vrGamepad the gamepad to initialized
  17575. * @returns a vr controller of the type the gamepad identified as
  17576. */
  17577. static InitiateController(vrGamepad: any): Gamepad;
  17578. }
  17579. /**
  17580. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17581. */
  17582. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17583. private _deviceRoomPosition;
  17584. private _deviceRoomRotationQuaternion;
  17585. /**
  17586. * The device position in babylon space
  17587. */
  17588. devicePosition: Vector3;
  17589. /**
  17590. * The device rotation in babylon space
  17591. */
  17592. deviceRotationQuaternion: Quaternion;
  17593. /**
  17594. * The scale factor of the device in babylon space
  17595. */
  17596. deviceScaleFactor: number;
  17597. /**
  17598. * (Likely devicePosition should be used instead) The device position in its room space
  17599. */
  17600. position: Vector3;
  17601. /**
  17602. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17603. */
  17604. rotationQuaternion: Quaternion;
  17605. /**
  17606. * The type of controller (Eg. Windows mixed reality)
  17607. */
  17608. controllerType: PoseEnabledControllerType;
  17609. protected _calculatedPosition: Vector3;
  17610. private _calculatedRotation;
  17611. /**
  17612. * The raw pose from the device
  17613. */
  17614. rawPose: DevicePose;
  17615. private _trackPosition;
  17616. private _maxRotationDistFromHeadset;
  17617. private _draggedRoomRotation;
  17618. /**
  17619. * @hidden
  17620. */
  17621. _disableTrackPosition(fixedPosition: Vector3): void;
  17622. /**
  17623. * Internal, the mesh attached to the controller
  17624. * @hidden
  17625. */
  17626. _mesh: Nullable<AbstractMesh>;
  17627. private _poseControlledCamera;
  17628. private _leftHandSystemQuaternion;
  17629. /**
  17630. * Internal, matrix used to convert room space to babylon space
  17631. * @hidden
  17632. */
  17633. _deviceToWorld: Matrix;
  17634. /**
  17635. * Node to be used when casting a ray from the controller
  17636. * @hidden
  17637. */
  17638. _pointingPoseNode: Nullable<TransformNode>;
  17639. /**
  17640. * Name of the child mesh that can be used to cast a ray from the controller
  17641. */
  17642. static readonly POINTING_POSE: string;
  17643. /**
  17644. * Creates a new PoseEnabledController from a gamepad
  17645. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17646. */
  17647. constructor(browserGamepad: any);
  17648. private _workingMatrix;
  17649. /**
  17650. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17651. */
  17652. update(): void;
  17653. /**
  17654. * Updates only the pose device and mesh without doing any button event checking
  17655. */
  17656. protected _updatePoseAndMesh(): void;
  17657. /**
  17658. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17659. * @param poseData raw pose fromthe device
  17660. */
  17661. updateFromDevice(poseData: DevicePose): void;
  17662. /**
  17663. * @hidden
  17664. */
  17665. _meshAttachedObservable: Observable<AbstractMesh>;
  17666. /**
  17667. * Attaches a mesh to the controller
  17668. * @param mesh the mesh to be attached
  17669. */
  17670. attachToMesh(mesh: AbstractMesh): void;
  17671. /**
  17672. * Attaches the controllers mesh to a camera
  17673. * @param camera the camera the mesh should be attached to
  17674. */
  17675. attachToPoseControlledCamera(camera: TargetCamera): void;
  17676. /**
  17677. * Disposes of the controller
  17678. */
  17679. dispose(): void;
  17680. /**
  17681. * The mesh that is attached to the controller
  17682. */
  17683. readonly mesh: Nullable<AbstractMesh>;
  17684. /**
  17685. * Gets the ray of the controller in the direction the controller is pointing
  17686. * @param length the length the resulting ray should be
  17687. * @returns a ray in the direction the controller is pointing
  17688. */
  17689. getForwardRay(length?: number): Ray;
  17690. }
  17691. }
  17692. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  17693. import { Observable } from "babylonjs/Misc/observable";
  17694. import { Scene } from "babylonjs/scene";
  17695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17696. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  17697. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  17698. /**
  17699. * Defines the WebVRController object that represents controllers tracked in 3D space
  17700. */
  17701. export abstract class WebVRController extends PoseEnabledController {
  17702. /**
  17703. * Internal, the default controller model for the controller
  17704. */
  17705. protected _defaultModel: AbstractMesh;
  17706. /**
  17707. * Fired when the trigger state has changed
  17708. */
  17709. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17710. /**
  17711. * Fired when the main button state has changed
  17712. */
  17713. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17714. /**
  17715. * Fired when the secondary button state has changed
  17716. */
  17717. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17718. /**
  17719. * Fired when the pad state has changed
  17720. */
  17721. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17722. /**
  17723. * Fired when controllers stick values have changed
  17724. */
  17725. onPadValuesChangedObservable: Observable<StickValues>;
  17726. /**
  17727. * Array of button availible on the controller
  17728. */
  17729. protected _buttons: Array<MutableGamepadButton>;
  17730. private _onButtonStateChange;
  17731. /**
  17732. * Fired when a controller button's state has changed
  17733. * @param callback the callback containing the button that was modified
  17734. */
  17735. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17736. /**
  17737. * X and Y axis corresponding to the controllers joystick
  17738. */
  17739. pad: StickValues;
  17740. /**
  17741. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17742. */
  17743. hand: string;
  17744. /**
  17745. * The default controller model for the controller
  17746. */
  17747. readonly defaultModel: AbstractMesh;
  17748. /**
  17749. * Creates a new WebVRController from a gamepad
  17750. * @param vrGamepad the gamepad that the WebVRController should be created from
  17751. */
  17752. constructor(vrGamepad: any);
  17753. /**
  17754. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17755. */
  17756. update(): void;
  17757. /**
  17758. * Function to be called when a button is modified
  17759. */
  17760. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17761. /**
  17762. * Loads a mesh and attaches it to the controller
  17763. * @param scene the scene the mesh should be added to
  17764. * @param meshLoaded callback for when the mesh has been loaded
  17765. */
  17766. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17767. private _setButtonValue;
  17768. private _changes;
  17769. private _checkChanges;
  17770. /**
  17771. * Disposes of th webVRCOntroller
  17772. */
  17773. dispose(): void;
  17774. }
  17775. }
  17776. declare module "babylonjs/Lights/hemisphericLight" {
  17777. import { Nullable } from "babylonjs/types";
  17778. import { Scene } from "babylonjs/scene";
  17779. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  17780. import { Effect } from "babylonjs/Materials/effect";
  17781. import { Light } from "babylonjs/Lights/light";
  17782. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17783. /**
  17784. * The HemisphericLight simulates the ambient environment light,
  17785. * so the passed direction is the light reflection direction, not the incoming direction.
  17786. */
  17787. export class HemisphericLight extends Light {
  17788. /**
  17789. * The groundColor is the light in the opposite direction to the one specified during creation.
  17790. * 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.
  17791. */
  17792. groundColor: Color3;
  17793. /**
  17794. * The light reflection direction, not the incoming direction.
  17795. */
  17796. direction: Vector3;
  17797. /**
  17798. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17799. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17800. * The HemisphericLight can't cast shadows.
  17801. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17802. * @param name The friendly name of the light
  17803. * @param direction The direction of the light reflection
  17804. * @param scene The scene the light belongs to
  17805. */
  17806. constructor(name: string, direction: Vector3, scene: Scene);
  17807. protected _buildUniformLayout(): void;
  17808. /**
  17809. * Returns the string "HemisphericLight".
  17810. * @return The class name
  17811. */
  17812. getClassName(): string;
  17813. /**
  17814. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17815. * Returns the updated direction.
  17816. * @param target The target the direction should point to
  17817. * @return The computed direction
  17818. */
  17819. setDirectionToTarget(target: Vector3): Vector3;
  17820. /**
  17821. * Returns the shadow generator associated to the light.
  17822. * @returns Always null for hemispheric lights because it does not support shadows.
  17823. */
  17824. getShadowGenerator(): Nullable<IShadowGenerator>;
  17825. /**
  17826. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17827. * @param effect The effect to update
  17828. * @param lightIndex The index of the light in the effect to update
  17829. * @returns The hemispheric light
  17830. */
  17831. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17832. /**
  17833. * Computes the world matrix of the node
  17834. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17835. * @param useWasUpdatedFlag defines a reserved property
  17836. * @returns the world matrix
  17837. */
  17838. computeWorldMatrix(): Matrix;
  17839. /**
  17840. * Returns the integer 3.
  17841. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17842. */
  17843. getTypeID(): number;
  17844. /**
  17845. * Prepares the list of defines specific to the light type.
  17846. * @param defines the list of defines
  17847. * @param lightIndex defines the index of the light for the effect
  17848. */
  17849. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17850. }
  17851. }
  17852. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  17853. /** @hidden */
  17854. export var vrMultiviewToSingleviewPixelShader: {
  17855. name: string;
  17856. shader: string;
  17857. };
  17858. }
  17859. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  17860. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17861. import { Scene } from "babylonjs/scene";
  17862. /**
  17863. * Renders to multiple views with a single draw call
  17864. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17865. */
  17866. export class MultiviewRenderTarget extends RenderTargetTexture {
  17867. /**
  17868. * Creates a multiview render target
  17869. * @param scene scene used with the render target
  17870. * @param size the size of the render target (used for each view)
  17871. */
  17872. constructor(scene: Scene, size?: number | {
  17873. width: number;
  17874. height: number;
  17875. } | {
  17876. ratio: number;
  17877. });
  17878. /**
  17879. * @hidden
  17880. * @param faceIndex the face index, if its a cube texture
  17881. */
  17882. _bindFrameBuffer(faceIndex?: number): void;
  17883. /**
  17884. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17885. * @returns the view count
  17886. */
  17887. getViewCount(): number;
  17888. }
  17889. }
  17890. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  17891. import { Camera } from "babylonjs/Cameras/camera";
  17892. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17893. import { Nullable } from "babylonjs/types";
  17894. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17895. import { Matrix } from "babylonjs/Maths/math";
  17896. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17897. module "babylonjs/Engines/engine" {
  17898. interface Engine {
  17899. /**
  17900. * Creates a new multiview render target
  17901. * @param width defines the width of the texture
  17902. * @param height defines the height of the texture
  17903. * @returns the created multiview texture
  17904. */
  17905. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17906. /**
  17907. * Binds a multiview framebuffer to be drawn to
  17908. * @param multiviewTexture texture to bind
  17909. */
  17910. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17911. }
  17912. }
  17913. module "babylonjs/Cameras/camera" {
  17914. interface Camera {
  17915. /**
  17916. * @hidden
  17917. * 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)
  17918. */
  17919. _useMultiviewToSingleView: boolean;
  17920. /**
  17921. * @hidden
  17922. * 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)
  17923. */
  17924. _multiviewTexture: Nullable<RenderTargetTexture>;
  17925. /**
  17926. * @hidden
  17927. * ensures the multiview texture of the camera exists and has the specified width/height
  17928. * @param width height to set on the multiview texture
  17929. * @param height width to set on the multiview texture
  17930. */
  17931. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17932. }
  17933. }
  17934. module "babylonjs/scene" {
  17935. interface Scene {
  17936. /** @hidden */
  17937. _transformMatrixR: Matrix;
  17938. /** @hidden */
  17939. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17940. /** @hidden */
  17941. _createMultiviewUbo(): void;
  17942. /** @hidden */
  17943. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17944. /** @hidden */
  17945. _renderMultiviewToSingleView(camera: Camera): void;
  17946. }
  17947. }
  17948. }
  17949. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  17950. import { Camera } from "babylonjs/Cameras/camera";
  17951. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17952. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  17953. import "babylonjs/Engines/Extensions/engine.multiview";
  17954. /**
  17955. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17956. * This will not be used for webXR as it supports displaying texture arrays directly
  17957. */
  17958. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17959. /**
  17960. * Initializes a VRMultiviewToSingleview
  17961. * @param name name of the post process
  17962. * @param camera camera to be applied to
  17963. * @param scaleFactor scaling factor to the size of the output texture
  17964. */
  17965. constructor(name: string, camera: Camera, scaleFactor: number);
  17966. }
  17967. }
  17968. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  17969. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  17970. import { Nullable } from "babylonjs/types";
  17971. import { Size } from "babylonjs/Maths/math";
  17972. import { Observable } from "babylonjs/Misc/observable";
  17973. module "babylonjs/Engines/engine" {
  17974. interface Engine {
  17975. /** @hidden */
  17976. _vrDisplay: any;
  17977. /** @hidden */
  17978. _vrSupported: boolean;
  17979. /** @hidden */
  17980. _oldSize: Size;
  17981. /** @hidden */
  17982. _oldHardwareScaleFactor: number;
  17983. /** @hidden */
  17984. _vrExclusivePointerMode: boolean;
  17985. /** @hidden */
  17986. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17987. /** @hidden */
  17988. _onVRDisplayPointerRestricted: () => void;
  17989. /** @hidden */
  17990. _onVRDisplayPointerUnrestricted: () => void;
  17991. /** @hidden */
  17992. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17993. /** @hidden */
  17994. _onVrDisplayDisconnect: Nullable<() => void>;
  17995. /** @hidden */
  17996. _onVrDisplayPresentChange: Nullable<() => void>;
  17997. /**
  17998. * Observable signaled when VR display mode changes
  17999. */
  18000. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  18001. /**
  18002. * Observable signaled when VR request present is complete
  18003. */
  18004. onVRRequestPresentComplete: Observable<boolean>;
  18005. /**
  18006. * Observable signaled when VR request present starts
  18007. */
  18008. onVRRequestPresentStart: Observable<Engine>;
  18009. /**
  18010. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  18011. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  18012. */
  18013. isInVRExclusivePointerMode: boolean;
  18014. /**
  18015. * Gets a boolean indicating if a webVR device was detected
  18016. * @returns true if a webVR device was detected
  18017. */
  18018. isVRDevicePresent(): boolean;
  18019. /**
  18020. * Gets the current webVR device
  18021. * @returns the current webVR device (or null)
  18022. */
  18023. getVRDevice(): any;
  18024. /**
  18025. * Initializes a webVR display and starts listening to display change events
  18026. * The onVRDisplayChangedObservable will be notified upon these changes
  18027. * @returns A promise containing a VRDisplay and if vr is supported
  18028. */
  18029. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  18030. /** @hidden */
  18031. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  18032. /**
  18033. * Call this function to switch to webVR mode
  18034. * Will do nothing if webVR is not supported or if there is no webVR device
  18035. * @see http://doc.babylonjs.com/how_to/webvr_camera
  18036. */
  18037. enableVR(): void;
  18038. /** @hidden */
  18039. _onVRFullScreenTriggered(): void;
  18040. }
  18041. }
  18042. }
  18043. declare module "babylonjs/Cameras/VR/webVRCamera" {
  18044. import { Nullable } from "babylonjs/types";
  18045. import { Observable } from "babylonjs/Misc/observable";
  18046. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18047. import { Scene } from "babylonjs/scene";
  18048. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  18049. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  18050. import { Node } from "babylonjs/node";
  18051. import { Ray } from "babylonjs/Culling/ray";
  18052. import "babylonjs/Cameras/RigModes/webVRRigMode";
  18053. import "babylonjs/Engines/Extensions/engine.webVR";
  18054. /**
  18055. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  18056. * IMPORTANT!! The data is right-hand data.
  18057. * @export
  18058. * @interface DevicePose
  18059. */
  18060. export interface DevicePose {
  18061. /**
  18062. * The position of the device, values in array are [x,y,z].
  18063. */
  18064. readonly position: Nullable<Float32Array>;
  18065. /**
  18066. * The linearVelocity of the device, values in array are [x,y,z].
  18067. */
  18068. readonly linearVelocity: Nullable<Float32Array>;
  18069. /**
  18070. * The linearAcceleration of the device, values in array are [x,y,z].
  18071. */
  18072. readonly linearAcceleration: Nullable<Float32Array>;
  18073. /**
  18074. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  18075. */
  18076. readonly orientation: Nullable<Float32Array>;
  18077. /**
  18078. * The angularVelocity of the device, values in array are [x,y,z].
  18079. */
  18080. readonly angularVelocity: Nullable<Float32Array>;
  18081. /**
  18082. * The angularAcceleration of the device, values in array are [x,y,z].
  18083. */
  18084. readonly angularAcceleration: Nullable<Float32Array>;
  18085. }
  18086. /**
  18087. * Interface representing a pose controlled object in Babylon.
  18088. * A pose controlled object has both regular pose values as well as pose values
  18089. * from an external device such as a VR head mounted display
  18090. */
  18091. export interface PoseControlled {
  18092. /**
  18093. * The position of the object in babylon space.
  18094. */
  18095. position: Vector3;
  18096. /**
  18097. * The rotation quaternion of the object in babylon space.
  18098. */
  18099. rotationQuaternion: Quaternion;
  18100. /**
  18101. * The position of the device in babylon space.
  18102. */
  18103. devicePosition?: Vector3;
  18104. /**
  18105. * The rotation quaternion of the device in babylon space.
  18106. */
  18107. deviceRotationQuaternion: Quaternion;
  18108. /**
  18109. * The raw pose coming from the device.
  18110. */
  18111. rawPose: Nullable<DevicePose>;
  18112. /**
  18113. * The scale of the device to be used when translating from device space to babylon space.
  18114. */
  18115. deviceScaleFactor: number;
  18116. /**
  18117. * Updates the poseControlled values based on the input device pose.
  18118. * @param poseData the pose data to update the object with
  18119. */
  18120. updateFromDevice(poseData: DevicePose): void;
  18121. }
  18122. /**
  18123. * Set of options to customize the webVRCamera
  18124. */
  18125. export interface WebVROptions {
  18126. /**
  18127. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  18128. */
  18129. trackPosition?: boolean;
  18130. /**
  18131. * Sets the scale of the vrDevice in babylon space. (default: 1)
  18132. */
  18133. positionScale?: number;
  18134. /**
  18135. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  18136. */
  18137. displayName?: string;
  18138. /**
  18139. * Should the native controller meshes be initialized. (default: true)
  18140. */
  18141. controllerMeshes?: boolean;
  18142. /**
  18143. * Creating a default HemiLight only on controllers. (default: true)
  18144. */
  18145. defaultLightingOnControllers?: boolean;
  18146. /**
  18147. * If you don't want to use the default VR button of the helper. (default: false)
  18148. */
  18149. useCustomVRButton?: boolean;
  18150. /**
  18151. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  18152. */
  18153. customVRButton?: HTMLButtonElement;
  18154. /**
  18155. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  18156. */
  18157. rayLength?: number;
  18158. /**
  18159. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  18160. */
  18161. defaultHeight?: number;
  18162. /**
  18163. * If multiview should be used if availible (default: false)
  18164. */
  18165. useMultiview?: boolean;
  18166. }
  18167. /**
  18168. * This represents a WebVR camera.
  18169. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  18170. * @example http://doc.babylonjs.com/how_to/webvr_camera
  18171. */
  18172. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  18173. private webVROptions;
  18174. /**
  18175. * @hidden
  18176. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  18177. */
  18178. _vrDevice: any;
  18179. /**
  18180. * The rawPose of the vrDevice.
  18181. */
  18182. rawPose: Nullable<DevicePose>;
  18183. private _onVREnabled;
  18184. private _specsVersion;
  18185. private _attached;
  18186. private _frameData;
  18187. protected _descendants: Array<Node>;
  18188. private _deviceRoomPosition;
  18189. /** @hidden */
  18190. _deviceRoomRotationQuaternion: Quaternion;
  18191. private _standingMatrix;
  18192. /**
  18193. * Represents device position in babylon space.
  18194. */
  18195. devicePosition: Vector3;
  18196. /**
  18197. * Represents device rotation in babylon space.
  18198. */
  18199. deviceRotationQuaternion: Quaternion;
  18200. /**
  18201. * The scale of the device to be used when translating from device space to babylon space.
  18202. */
  18203. deviceScaleFactor: number;
  18204. private _deviceToWorld;
  18205. private _worldToDevice;
  18206. /**
  18207. * References to the webVR controllers for the vrDevice.
  18208. */
  18209. controllers: Array<WebVRController>;
  18210. /**
  18211. * Emits an event when a controller is attached.
  18212. */
  18213. onControllersAttachedObservable: Observable<WebVRController[]>;
  18214. /**
  18215. * Emits an event when a controller's mesh has been loaded;
  18216. */
  18217. onControllerMeshLoadedObservable: Observable<WebVRController>;
  18218. /**
  18219. * Emits an event when the HMD's pose has been updated.
  18220. */
  18221. onPoseUpdatedFromDeviceObservable: Observable<any>;
  18222. private _poseSet;
  18223. /**
  18224. * If the rig cameras be used as parent instead of this camera.
  18225. */
  18226. rigParenting: boolean;
  18227. private _lightOnControllers;
  18228. private _defaultHeight?;
  18229. /**
  18230. * Instantiates a WebVRFreeCamera.
  18231. * @param name The name of the WebVRFreeCamera
  18232. * @param position The starting anchor position for the camera
  18233. * @param scene The scene the camera belongs to
  18234. * @param webVROptions a set of customizable options for the webVRCamera
  18235. */
  18236. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  18237. /**
  18238. * Gets the device distance from the ground in meters.
  18239. * @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.
  18240. */
  18241. deviceDistanceToRoomGround(): number;
  18242. /**
  18243. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18244. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18245. */
  18246. useStandingMatrix(callback?: (bool: boolean) => void): void;
  18247. /**
  18248. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18249. * @returns A promise with a boolean set to if the standing matrix is supported.
  18250. */
  18251. useStandingMatrixAsync(): Promise<boolean>;
  18252. /**
  18253. * Disposes the camera
  18254. */
  18255. dispose(): void;
  18256. /**
  18257. * Gets a vrController by name.
  18258. * @param name The name of the controller to retreive
  18259. * @returns the controller matching the name specified or null if not found
  18260. */
  18261. getControllerByName(name: string): Nullable<WebVRController>;
  18262. private _leftController;
  18263. /**
  18264. * The controller corresponding to the users left hand.
  18265. */
  18266. readonly leftController: Nullable<WebVRController>;
  18267. private _rightController;
  18268. /**
  18269. * The controller corresponding to the users right hand.
  18270. */
  18271. readonly rightController: Nullable<WebVRController>;
  18272. /**
  18273. * Casts a ray forward from the vrCamera's gaze.
  18274. * @param length Length of the ray (default: 100)
  18275. * @returns the ray corresponding to the gaze
  18276. */
  18277. getForwardRay(length?: number): Ray;
  18278. /**
  18279. * @hidden
  18280. * Updates the camera based on device's frame data
  18281. */
  18282. _checkInputs(): void;
  18283. /**
  18284. * Updates the poseControlled values based on the input device pose.
  18285. * @param poseData Pose coming from the device
  18286. */
  18287. updateFromDevice(poseData: DevicePose): void;
  18288. private _htmlElementAttached;
  18289. private _detachIfAttached;
  18290. /**
  18291. * WebVR's attach control will start broadcasting frames to the device.
  18292. * Note that in certain browsers (chrome for example) this function must be called
  18293. * within a user-interaction callback. Example:
  18294. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18295. *
  18296. * @param element html element to attach the vrDevice to
  18297. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18298. */
  18299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18300. /**
  18301. * Detaches the camera from the html element and disables VR
  18302. *
  18303. * @param element html element to detach from
  18304. */
  18305. detachControl(element: HTMLElement): void;
  18306. /**
  18307. * @returns the name of this class
  18308. */
  18309. getClassName(): string;
  18310. /**
  18311. * Calls resetPose on the vrDisplay
  18312. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18313. */
  18314. resetToCurrentRotation(): void;
  18315. /**
  18316. * @hidden
  18317. * Updates the rig cameras (left and right eye)
  18318. */
  18319. _updateRigCameras(): void;
  18320. private _workingVector;
  18321. private _oneVector;
  18322. private _workingMatrix;
  18323. private updateCacheCalled;
  18324. private _correctPositionIfNotTrackPosition;
  18325. /**
  18326. * @hidden
  18327. * Updates the cached values of the camera
  18328. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18329. */
  18330. _updateCache(ignoreParentClass?: boolean): void;
  18331. /**
  18332. * @hidden
  18333. * Get current device position in babylon world
  18334. */
  18335. _computeDevicePosition(): void;
  18336. /**
  18337. * Updates the current device position and rotation in the babylon world
  18338. */
  18339. update(): void;
  18340. /**
  18341. * @hidden
  18342. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18343. * @returns an identity matrix
  18344. */
  18345. _getViewMatrix(): Matrix;
  18346. private _tmpMatrix;
  18347. /**
  18348. * This function is called by the two RIG cameras.
  18349. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18350. * @hidden
  18351. */
  18352. _getWebVRViewMatrix(): Matrix;
  18353. /** @hidden */
  18354. _getWebVRProjectionMatrix(): Matrix;
  18355. private _onGamepadConnectedObserver;
  18356. private _onGamepadDisconnectedObserver;
  18357. private _updateCacheWhenTrackingDisabledObserver;
  18358. /**
  18359. * Initializes the controllers and their meshes
  18360. */
  18361. initControllers(): void;
  18362. }
  18363. }
  18364. declare module "babylonjs/PostProcesses/postProcess" {
  18365. import { Nullable } from "babylonjs/types";
  18366. import { SmartArray } from "babylonjs/Misc/smartArray";
  18367. import { Observable } from "babylonjs/Misc/observable";
  18368. import { Color4, Vector2 } from "babylonjs/Maths/math";
  18369. import { Camera } from "babylonjs/Cameras/camera";
  18370. import { Effect } from "babylonjs/Materials/effect";
  18371. import "babylonjs/Shaders/postprocess.vertex";
  18372. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18373. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18374. import { Engine } from "babylonjs/Engines/engine";
  18375. /**
  18376. * Size options for a post process
  18377. */
  18378. export type PostProcessOptions = {
  18379. width: number;
  18380. height: number;
  18381. };
  18382. /**
  18383. * PostProcess can be used to apply a shader to a texture after it has been rendered
  18384. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18385. */
  18386. export class PostProcess {
  18387. /** Name of the PostProcess. */
  18388. name: string;
  18389. /**
  18390. * Gets or sets the unique id of the post process
  18391. */
  18392. uniqueId: number;
  18393. /**
  18394. * Width of the texture to apply the post process on
  18395. */
  18396. width: number;
  18397. /**
  18398. * Height of the texture to apply the post process on
  18399. */
  18400. height: number;
  18401. /**
  18402. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  18403. * @hidden
  18404. */
  18405. _outputTexture: Nullable<InternalTexture>;
  18406. /**
  18407. * Sampling mode used by the shader
  18408. * See https://doc.babylonjs.com/classes/3.1/texture
  18409. */
  18410. renderTargetSamplingMode: number;
  18411. /**
  18412. * Clear color to use when screen clearing
  18413. */
  18414. clearColor: Color4;
  18415. /**
  18416. * If the buffer needs to be cleared before applying the post process. (default: true)
  18417. * Should be set to false if shader will overwrite all previous pixels.
  18418. */
  18419. autoClear: boolean;
  18420. /**
  18421. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18422. */
  18423. alphaMode: number;
  18424. /**
  18425. * Sets the setAlphaBlendConstants of the babylon engine
  18426. */
  18427. alphaConstants: Color4;
  18428. /**
  18429. * Animations to be used for the post processing
  18430. */
  18431. animations: import("babylonjs/Animations/animation").Animation[];
  18432. /**
  18433. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18434. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18435. */
  18436. enablePixelPerfectMode: boolean;
  18437. /**
  18438. * Force the postprocess to be applied without taking in account viewport
  18439. */
  18440. forceFullscreenViewport: boolean;
  18441. /**
  18442. * List of inspectable custom properties (used by the Inspector)
  18443. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18444. */
  18445. inspectableCustomProperties: IInspectable[];
  18446. /**
  18447. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18448. *
  18449. * | Value | Type | Description |
  18450. * | ----- | ----------------------------------- | ----------- |
  18451. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18452. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18453. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18454. *
  18455. */
  18456. scaleMode: number;
  18457. /**
  18458. * Force textures to be a power of two (default: false)
  18459. */
  18460. alwaysForcePOT: boolean;
  18461. private _samples;
  18462. /**
  18463. * Number of sample textures (default: 1)
  18464. */
  18465. samples: number;
  18466. /**
  18467. * Modify the scale of the post process to be the same as the viewport (default: false)
  18468. */
  18469. adaptScaleToCurrentViewport: boolean;
  18470. private _camera;
  18471. private _scene;
  18472. private _engine;
  18473. private _options;
  18474. private _reusable;
  18475. private _textureType;
  18476. /**
  18477. * Smart array of input and output textures for the post process.
  18478. * @hidden
  18479. */
  18480. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  18481. /**
  18482. * The index in _textures that corresponds to the output texture.
  18483. * @hidden
  18484. */
  18485. _currentRenderTextureInd: number;
  18486. private _effect;
  18487. private _samplers;
  18488. private _fragmentUrl;
  18489. private _vertexUrl;
  18490. private _parameters;
  18491. private _scaleRatio;
  18492. protected _indexParameters: any;
  18493. private _shareOutputWithPostProcess;
  18494. private _texelSize;
  18495. private _forcedOutputTexture;
  18496. /**
  18497. * Returns the fragment url or shader name used in the post process.
  18498. * @returns the fragment url or name in the shader store.
  18499. */
  18500. getEffectName(): string;
  18501. /**
  18502. * An event triggered when the postprocess is activated.
  18503. */
  18504. onActivateObservable: Observable<Camera>;
  18505. private _onActivateObserver;
  18506. /**
  18507. * A function that is added to the onActivateObservable
  18508. */
  18509. onActivate: Nullable<(camera: Camera) => void>;
  18510. /**
  18511. * An event triggered when the postprocess changes its size.
  18512. */
  18513. onSizeChangedObservable: Observable<PostProcess>;
  18514. private _onSizeChangedObserver;
  18515. /**
  18516. * A function that is added to the onSizeChangedObservable
  18517. */
  18518. onSizeChanged: (postProcess: PostProcess) => void;
  18519. /**
  18520. * An event triggered when the postprocess applies its effect.
  18521. */
  18522. onApplyObservable: Observable<Effect>;
  18523. private _onApplyObserver;
  18524. /**
  18525. * A function that is added to the onApplyObservable
  18526. */
  18527. onApply: (effect: Effect) => void;
  18528. /**
  18529. * An event triggered before rendering the postprocess
  18530. */
  18531. onBeforeRenderObservable: Observable<Effect>;
  18532. private _onBeforeRenderObserver;
  18533. /**
  18534. * A function that is added to the onBeforeRenderObservable
  18535. */
  18536. onBeforeRender: (effect: Effect) => void;
  18537. /**
  18538. * An event triggered after rendering the postprocess
  18539. */
  18540. onAfterRenderObservable: Observable<Effect>;
  18541. private _onAfterRenderObserver;
  18542. /**
  18543. * A function that is added to the onAfterRenderObservable
  18544. */
  18545. onAfterRender: (efect: Effect) => void;
  18546. /**
  18547. * 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
  18548. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18549. */
  18550. inputTexture: InternalTexture;
  18551. /**
  18552. * Gets the camera which post process is applied to.
  18553. * @returns The camera the post process is applied to.
  18554. */
  18555. getCamera(): Camera;
  18556. /**
  18557. * Gets the texel size of the postprocess.
  18558. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18559. */
  18560. readonly texelSize: Vector2;
  18561. /**
  18562. * Creates a new instance PostProcess
  18563. * @param name The name of the PostProcess.
  18564. * @param fragmentUrl The url of the fragment shader to be used.
  18565. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18566. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18567. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18568. * @param camera The camera to apply the render pass to.
  18569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18570. * @param engine The engine which the post process will be applied. (default: current engine)
  18571. * @param reusable If the post process can be reused on the same frame. (default: false)
  18572. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18573. * @param textureType Type of textures used when performing the post process. (default: 0)
  18574. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18575. * @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
  18576. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18577. */
  18578. constructor(
  18579. /** Name of the PostProcess. */
  18580. 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);
  18581. /**
  18582. * Gets a string idenfifying the name of the class
  18583. * @returns "PostProcess" string
  18584. */
  18585. getClassName(): string;
  18586. /**
  18587. * Gets the engine which this post process belongs to.
  18588. * @returns The engine the post process was enabled with.
  18589. */
  18590. getEngine(): Engine;
  18591. /**
  18592. * The effect that is created when initializing the post process.
  18593. * @returns The created effect corresponding the the postprocess.
  18594. */
  18595. getEffect(): Effect;
  18596. /**
  18597. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18598. * @param postProcess The post process to share the output with.
  18599. * @returns This post process.
  18600. */
  18601. shareOutputWith(postProcess: PostProcess): PostProcess;
  18602. /**
  18603. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18604. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18605. */
  18606. useOwnOutput(): void;
  18607. /**
  18608. * Updates the effect with the current post process compile time values and recompiles the shader.
  18609. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18610. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18611. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18612. * @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
  18613. * @param onCompiled Called when the shader has been compiled.
  18614. * @param onError Called if there is an error when compiling a shader.
  18615. */
  18616. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18617. /**
  18618. * The post process is reusable if it can be used multiple times within one frame.
  18619. * @returns If the post process is reusable
  18620. */
  18621. isReusable(): boolean;
  18622. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18623. markTextureDirty(): void;
  18624. /**
  18625. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18626. * 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.
  18627. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18628. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18629. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18630. * @returns The target texture that was bound to be written to.
  18631. */
  18632. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18633. /**
  18634. * If the post process is supported.
  18635. */
  18636. readonly isSupported: boolean;
  18637. /**
  18638. * The aspect ratio of the output texture.
  18639. */
  18640. readonly aspectRatio: number;
  18641. /**
  18642. * Get a value indicating if the post-process is ready to be used
  18643. * @returns true if the post-process is ready (shader is compiled)
  18644. */
  18645. isReady(): boolean;
  18646. /**
  18647. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18648. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18649. */
  18650. apply(): Nullable<Effect>;
  18651. private _disposeTextures;
  18652. /**
  18653. * Disposes the post process.
  18654. * @param camera The camera to dispose the post process on.
  18655. */
  18656. dispose(camera?: Camera): void;
  18657. }
  18658. }
  18659. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  18660. /** @hidden */
  18661. export var kernelBlurVaryingDeclaration: {
  18662. name: string;
  18663. shader: string;
  18664. };
  18665. }
  18666. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  18667. /** @hidden */
  18668. export var kernelBlurFragment: {
  18669. name: string;
  18670. shader: string;
  18671. };
  18672. }
  18673. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  18674. /** @hidden */
  18675. export var kernelBlurFragment2: {
  18676. name: string;
  18677. shader: string;
  18678. };
  18679. }
  18680. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  18681. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18682. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  18683. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  18684. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  18685. /** @hidden */
  18686. export var kernelBlurPixelShader: {
  18687. name: string;
  18688. shader: string;
  18689. };
  18690. }
  18691. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  18692. /** @hidden */
  18693. export var kernelBlurVertex: {
  18694. name: string;
  18695. shader: string;
  18696. };
  18697. }
  18698. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  18699. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18700. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  18701. /** @hidden */
  18702. export var kernelBlurVertexShader: {
  18703. name: string;
  18704. shader: string;
  18705. };
  18706. }
  18707. declare module "babylonjs/PostProcesses/blurPostProcess" {
  18708. import { Vector2 } from "babylonjs/Maths/math";
  18709. import { Nullable } from "babylonjs/types";
  18710. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18711. import { Camera } from "babylonjs/Cameras/camera";
  18712. import { Effect } from "babylonjs/Materials/effect";
  18713. import { Engine } from "babylonjs/Engines/engine";
  18714. import "babylonjs/Shaders/kernelBlur.fragment";
  18715. import "babylonjs/Shaders/kernelBlur.vertex";
  18716. /**
  18717. * The Blur Post Process which blurs an image based on a kernel and direction.
  18718. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18719. */
  18720. export class BlurPostProcess extends PostProcess {
  18721. /** The direction in which to blur the image. */
  18722. direction: Vector2;
  18723. private blockCompilation;
  18724. protected _kernel: number;
  18725. protected _idealKernel: number;
  18726. protected _packedFloat: boolean;
  18727. private _staticDefines;
  18728. /**
  18729. * Sets the length in pixels of the blur sample region
  18730. */
  18731. /**
  18732. * Gets the length in pixels of the blur sample region
  18733. */
  18734. kernel: number;
  18735. /**
  18736. * Sets wether or not the blur needs to unpack/repack floats
  18737. */
  18738. /**
  18739. * Gets wether or not the blur is unpacking/repacking floats
  18740. */
  18741. packedFloat: boolean;
  18742. /**
  18743. * Creates a new instance BlurPostProcess
  18744. * @param name The name of the effect.
  18745. * @param direction The direction in which to blur the image.
  18746. * @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.
  18747. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18748. * @param camera The camera to apply the render pass to.
  18749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18750. * @param engine The engine which the post process will be applied. (default: current engine)
  18751. * @param reusable If the post process can be reused on the same frame. (default: false)
  18752. * @param textureType Type of textures used when performing the post process. (default: 0)
  18753. * @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)
  18754. */
  18755. constructor(name: string,
  18756. /** The direction in which to blur the image. */
  18757. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18758. /**
  18759. * Updates the effect with the current post process compile time values and recompiles the shader.
  18760. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18761. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18762. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18763. * @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
  18764. * @param onCompiled Called when the shader has been compiled.
  18765. * @param onError Called if there is an error when compiling a shader.
  18766. */
  18767. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18768. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18769. /**
  18770. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18771. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18772. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18773. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18774. * The gaps between physical kernels are compensated for in the weighting of the samples
  18775. * @param idealKernel Ideal blur kernel.
  18776. * @return Nearest best kernel.
  18777. */
  18778. protected _nearestBestKernel(idealKernel: number): number;
  18779. /**
  18780. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18781. * @param x The point on the Gaussian distribution to sample.
  18782. * @return the value of the Gaussian function at x.
  18783. */
  18784. protected _gaussianWeight(x: number): number;
  18785. /**
  18786. * Generates a string that can be used as a floating point number in GLSL.
  18787. * @param x Value to print.
  18788. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18789. * @return GLSL float string.
  18790. */
  18791. protected _glslFloat(x: number, decimalFigures?: number): string;
  18792. }
  18793. }
  18794. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18795. import { Scene } from "babylonjs/scene";
  18796. import { Plane } from "babylonjs/Maths/math";
  18797. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18798. /**
  18799. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18800. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18801. * You can then easily use it as a reflectionTexture on a flat surface.
  18802. * In case the surface is not a plane, please consider relying on reflection probes.
  18803. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18804. */
  18805. export class MirrorTexture extends RenderTargetTexture {
  18806. private scene;
  18807. /**
  18808. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18809. * 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.
  18810. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18811. */
  18812. mirrorPlane: Plane;
  18813. /**
  18814. * Define the blur ratio used to blur the reflection if needed.
  18815. */
  18816. blurRatio: number;
  18817. /**
  18818. * Define the adaptive blur kernel used to blur the reflection if needed.
  18819. * This will autocompute the closest best match for the `blurKernel`
  18820. */
  18821. adaptiveBlurKernel: number;
  18822. /**
  18823. * Define the blur kernel used to blur the reflection if needed.
  18824. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18825. */
  18826. blurKernel: number;
  18827. /**
  18828. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18829. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18830. */
  18831. blurKernelX: number;
  18832. /**
  18833. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18834. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18835. */
  18836. blurKernelY: number;
  18837. private _autoComputeBlurKernel;
  18838. protected _onRatioRescale(): void;
  18839. private _updateGammaSpace;
  18840. private _imageProcessingConfigChangeObserver;
  18841. private _transformMatrix;
  18842. private _mirrorMatrix;
  18843. private _savedViewMatrix;
  18844. private _blurX;
  18845. private _blurY;
  18846. private _adaptiveBlurKernel;
  18847. private _blurKernelX;
  18848. private _blurKernelY;
  18849. private _blurRatio;
  18850. /**
  18851. * Instantiates a Mirror Texture.
  18852. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18853. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18854. * You can then easily use it as a reflectionTexture on a flat surface.
  18855. * In case the surface is not a plane, please consider relying on reflection probes.
  18856. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18857. * @param name
  18858. * @param size
  18859. * @param scene
  18860. * @param generateMipMaps
  18861. * @param type
  18862. * @param samplingMode
  18863. * @param generateDepthBuffer
  18864. */
  18865. constructor(name: string, size: number | {
  18866. width: number;
  18867. height: number;
  18868. } | {
  18869. ratio: number;
  18870. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18871. private _preparePostProcesses;
  18872. /**
  18873. * Clone the mirror texture.
  18874. * @returns the cloned texture
  18875. */
  18876. clone(): MirrorTexture;
  18877. /**
  18878. * Serialize the texture to a JSON representation you could use in Parse later on
  18879. * @returns the serialized JSON representation
  18880. */
  18881. serialize(): any;
  18882. /**
  18883. * Dispose the texture and release its associated resources.
  18884. */
  18885. dispose(): void;
  18886. }
  18887. }
  18888. declare module "babylonjs/Materials/Textures/texture" {
  18889. import { Observable } from "babylonjs/Misc/observable";
  18890. import { Nullable } from "babylonjs/types";
  18891. import { Scene } from "babylonjs/scene";
  18892. import { Matrix } from "babylonjs/Maths/math";
  18893. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18894. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18895. import { Engine } from "babylonjs/Engines/engine";
  18896. /**
  18897. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18898. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18899. */
  18900. export class Texture extends BaseTexture {
  18901. /** @hidden */
  18902. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18903. /** @hidden */
  18904. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18905. /** @hidden */
  18906. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18907. /** nearest is mag = nearest and min = nearest and mip = linear */
  18908. static readonly NEAREST_SAMPLINGMODE: number;
  18909. /** nearest is mag = nearest and min = nearest and mip = linear */
  18910. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18911. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18912. static readonly BILINEAR_SAMPLINGMODE: number;
  18913. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18914. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18915. /** Trilinear is mag = linear and min = linear and mip = linear */
  18916. static readonly TRILINEAR_SAMPLINGMODE: number;
  18917. /** Trilinear is mag = linear and min = linear and mip = linear */
  18918. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18919. /** mag = nearest and min = nearest and mip = nearest */
  18920. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18921. /** mag = nearest and min = linear and mip = nearest */
  18922. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18923. /** mag = nearest and min = linear and mip = linear */
  18924. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18925. /** mag = nearest and min = linear and mip = none */
  18926. static readonly NEAREST_LINEAR: number;
  18927. /** mag = nearest and min = nearest and mip = none */
  18928. static readonly NEAREST_NEAREST: number;
  18929. /** mag = linear and min = nearest and mip = nearest */
  18930. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18931. /** mag = linear and min = nearest and mip = linear */
  18932. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18933. /** mag = linear and min = linear and mip = none */
  18934. static readonly LINEAR_LINEAR: number;
  18935. /** mag = linear and min = nearest and mip = none */
  18936. static readonly LINEAR_NEAREST: number;
  18937. /** Explicit coordinates mode */
  18938. static readonly EXPLICIT_MODE: number;
  18939. /** Spherical coordinates mode */
  18940. static readonly SPHERICAL_MODE: number;
  18941. /** Planar coordinates mode */
  18942. static readonly PLANAR_MODE: number;
  18943. /** Cubic coordinates mode */
  18944. static readonly CUBIC_MODE: number;
  18945. /** Projection coordinates mode */
  18946. static readonly PROJECTION_MODE: number;
  18947. /** Inverse Cubic coordinates mode */
  18948. static readonly SKYBOX_MODE: number;
  18949. /** Inverse Cubic coordinates mode */
  18950. static readonly INVCUBIC_MODE: number;
  18951. /** Equirectangular coordinates mode */
  18952. static readonly EQUIRECTANGULAR_MODE: number;
  18953. /** Equirectangular Fixed coordinates mode */
  18954. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18955. /** Equirectangular Fixed Mirrored coordinates mode */
  18956. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18957. /** Texture is not repeating outside of 0..1 UVs */
  18958. static readonly CLAMP_ADDRESSMODE: number;
  18959. /** Texture is repeating outside of 0..1 UVs */
  18960. static readonly WRAP_ADDRESSMODE: number;
  18961. /** Texture is repeating and mirrored */
  18962. static readonly MIRROR_ADDRESSMODE: number;
  18963. /**
  18964. * 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
  18965. */
  18966. static UseSerializedUrlIfAny: boolean;
  18967. /**
  18968. * Define the url of the texture.
  18969. */
  18970. url: Nullable<string>;
  18971. /**
  18972. * Define an offset on the texture to offset the u coordinates of the UVs
  18973. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18974. */
  18975. uOffset: number;
  18976. /**
  18977. * Define an offset on the texture to offset the v coordinates of the UVs
  18978. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18979. */
  18980. vOffset: number;
  18981. /**
  18982. * Define an offset on the texture to scale the u coordinates of the UVs
  18983. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18984. */
  18985. uScale: number;
  18986. /**
  18987. * Define an offset on the texture to scale the v coordinates of the UVs
  18988. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18989. */
  18990. vScale: number;
  18991. /**
  18992. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18993. * @see http://doc.babylonjs.com/how_to/more_materials
  18994. */
  18995. uAng: number;
  18996. /**
  18997. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18998. * @see http://doc.babylonjs.com/how_to/more_materials
  18999. */
  19000. vAng: number;
  19001. /**
  19002. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  19003. * @see http://doc.babylonjs.com/how_to/more_materials
  19004. */
  19005. wAng: number;
  19006. /**
  19007. * Defines the center of rotation (U)
  19008. */
  19009. uRotationCenter: number;
  19010. /**
  19011. * Defines the center of rotation (V)
  19012. */
  19013. vRotationCenter: number;
  19014. /**
  19015. * Defines the center of rotation (W)
  19016. */
  19017. wRotationCenter: number;
  19018. /**
  19019. * Are mip maps generated for this texture or not.
  19020. */
  19021. readonly noMipmap: boolean;
  19022. /**
  19023. * List of inspectable custom properties (used by the Inspector)
  19024. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19025. */
  19026. inspectableCustomProperties: Nullable<IInspectable[]>;
  19027. private _noMipmap;
  19028. /** @hidden */
  19029. _invertY: boolean;
  19030. private _rowGenerationMatrix;
  19031. private _cachedTextureMatrix;
  19032. private _projectionModeMatrix;
  19033. private _t0;
  19034. private _t1;
  19035. private _t2;
  19036. private _cachedUOffset;
  19037. private _cachedVOffset;
  19038. private _cachedUScale;
  19039. private _cachedVScale;
  19040. private _cachedUAng;
  19041. private _cachedVAng;
  19042. private _cachedWAng;
  19043. private _cachedProjectionMatrixId;
  19044. private _cachedCoordinatesMode;
  19045. /** @hidden */
  19046. protected _initialSamplingMode: number;
  19047. /** @hidden */
  19048. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  19049. private _deleteBuffer;
  19050. protected _format: Nullable<number>;
  19051. private _delayedOnLoad;
  19052. private _delayedOnError;
  19053. /**
  19054. * Observable triggered once the texture has been loaded.
  19055. */
  19056. onLoadObservable: Observable<Texture>;
  19057. protected _isBlocking: boolean;
  19058. /**
  19059. * Is the texture preventing material to render while loading.
  19060. * If false, a default texture will be used instead of the loading one during the preparation step.
  19061. */
  19062. isBlocking: boolean;
  19063. /**
  19064. * Get the current sampling mode associated with the texture.
  19065. */
  19066. readonly samplingMode: number;
  19067. /**
  19068. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  19069. */
  19070. readonly invertY: boolean;
  19071. /**
  19072. * Instantiates a new texture.
  19073. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  19074. * @see http://doc.babylonjs.com/babylon101/materials#texture
  19075. * @param url define the url of the picture to load as a texture
  19076. * @param scene define the scene or engine the texture will belong to
  19077. * @param noMipmap define if the texture will require mip maps or not
  19078. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19079. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19080. * @param onLoad define a callback triggered when the texture has been loaded
  19081. * @param onError define a callback triggered when an error occurred during the loading session
  19082. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19083. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19084. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19085. */
  19086. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  19087. /**
  19088. * Update the url (and optional buffer) of this texture if url was null during construction.
  19089. * @param url the url of the texture
  19090. * @param buffer the buffer of the texture (defaults to null)
  19091. * @param onLoad callback called when the texture is loaded (defaults to null)
  19092. */
  19093. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  19094. /**
  19095. * Finish the loading sequence of a texture flagged as delayed load.
  19096. * @hidden
  19097. */
  19098. delayLoad(): void;
  19099. private _prepareRowForTextureGeneration;
  19100. /**
  19101. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  19102. * @returns the transform matrix of the texture.
  19103. */
  19104. getTextureMatrix(): Matrix;
  19105. /**
  19106. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  19107. * @returns The reflection texture transform
  19108. */
  19109. getReflectionTextureMatrix(): Matrix;
  19110. /**
  19111. * Clones the texture.
  19112. * @returns the cloned texture
  19113. */
  19114. clone(): Texture;
  19115. /**
  19116. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19117. * @returns The JSON representation of the texture
  19118. */
  19119. serialize(): any;
  19120. /**
  19121. * Get the current class name of the texture useful for serialization or dynamic coding.
  19122. * @returns "Texture"
  19123. */
  19124. getClassName(): string;
  19125. /**
  19126. * Dispose the texture and release its associated resources.
  19127. */
  19128. dispose(): void;
  19129. /**
  19130. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  19131. * @param parsedTexture Define the JSON representation of the texture
  19132. * @param scene Define the scene the parsed texture should be instantiated in
  19133. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  19134. * @returns The parsed texture if successful
  19135. */
  19136. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  19137. /**
  19138. * Creates a texture from its base 64 representation.
  19139. * @param data Define the base64 payload without the data: prefix
  19140. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19141. * @param scene Define the scene the texture should belong to
  19142. * @param noMipmap Forces the texture to not create mip map information if true
  19143. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19144. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19145. * @param onLoad define a callback triggered when the texture has been loaded
  19146. * @param onError define a callback triggered when an error occurred during the loading session
  19147. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19148. * @returns the created texture
  19149. */
  19150. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  19151. /**
  19152. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  19153. * @param data Define the base64 payload without the data: prefix
  19154. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19155. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19156. * @param scene Define the scene the texture should belong to
  19157. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19158. * @param noMipmap Forces the texture to not create mip map information if true
  19159. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19160. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19161. * @param onLoad define a callback triggered when the texture has been loaded
  19162. * @param onError define a callback triggered when an error occurred during the loading session
  19163. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19164. * @returns the created texture
  19165. */
  19166. 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;
  19167. }
  19168. }
  19169. declare module "babylonjs/PostProcesses/postProcessManager" {
  19170. import { Nullable } from "babylonjs/types";
  19171. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19172. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19173. import { Scene } from "babylonjs/scene";
  19174. /**
  19175. * PostProcessManager is used to manage one or more post processes or post process pipelines
  19176. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19177. */
  19178. export class PostProcessManager {
  19179. private _scene;
  19180. private _indexBuffer;
  19181. private _vertexBuffers;
  19182. /**
  19183. * Creates a new instance PostProcess
  19184. * @param scene The scene that the post process is associated with.
  19185. */
  19186. constructor(scene: Scene);
  19187. private _prepareBuffers;
  19188. private _buildIndexBuffer;
  19189. /**
  19190. * Rebuilds the vertex buffers of the manager.
  19191. * @hidden
  19192. */
  19193. _rebuild(): void;
  19194. /**
  19195. * Prepares a frame to be run through a post process.
  19196. * @param sourceTexture The input texture to the post procesess. (default: null)
  19197. * @param postProcesses An array of post processes to be run. (default: null)
  19198. * @returns True if the post processes were able to be run.
  19199. * @hidden
  19200. */
  19201. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  19202. /**
  19203. * Manually render a set of post processes to a texture.
  19204. * @param postProcesses An array of post processes to be run.
  19205. * @param targetTexture The target texture to render to.
  19206. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  19207. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  19208. * @param lodLevel defines which lod of the texture to render to
  19209. */
  19210. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  19211. /**
  19212. * Finalize the result of the output of the postprocesses.
  19213. * @param doNotPresent If true the result will not be displayed to the screen.
  19214. * @param targetTexture The target texture to render to.
  19215. * @param faceIndex The index of the face to bind the target texture to.
  19216. * @param postProcesses The array of post processes to render.
  19217. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  19218. * @hidden
  19219. */
  19220. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  19221. /**
  19222. * Disposes of the post process manager.
  19223. */
  19224. dispose(): void;
  19225. }
  19226. }
  19227. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  19228. import { Scene } from "babylonjs/scene";
  19229. import { ISceneComponent } from "babylonjs/sceneComponent";
  19230. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19231. module "babylonjs/abstractScene" {
  19232. interface AbstractScene {
  19233. /**
  19234. * The list of procedural textures added to the scene
  19235. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19236. */
  19237. proceduralTextures: Array<ProceduralTexture>;
  19238. }
  19239. }
  19240. /**
  19241. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  19242. * in a given scene.
  19243. */
  19244. export class ProceduralTextureSceneComponent implements ISceneComponent {
  19245. /**
  19246. * The component name helpfull to identify the component in the list of scene components.
  19247. */
  19248. readonly name: string;
  19249. /**
  19250. * The scene the component belongs to.
  19251. */
  19252. scene: Scene;
  19253. /**
  19254. * Creates a new instance of the component for the given scene
  19255. * @param scene Defines the scene to register the component in
  19256. */
  19257. constructor(scene: Scene);
  19258. /**
  19259. * Registers the component in a given scene
  19260. */
  19261. register(): void;
  19262. /**
  19263. * Rebuilds the elements related to this component in case of
  19264. * context lost for instance.
  19265. */
  19266. rebuild(): void;
  19267. /**
  19268. * Disposes the component and the associated ressources.
  19269. */
  19270. dispose(): void;
  19271. private _beforeClear;
  19272. }
  19273. }
  19274. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  19275. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19276. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  19277. module "babylonjs/Engines/engine" {
  19278. interface Engine {
  19279. /**
  19280. * Creates a new render target cube texture
  19281. * @param size defines the size of the texture
  19282. * @param options defines the options used to create the texture
  19283. * @returns a new render target cube texture stored in an InternalTexture
  19284. */
  19285. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  19286. }
  19287. }
  19288. }
  19289. declare module "babylonjs/Shaders/procedural.vertex" {
  19290. /** @hidden */
  19291. export var proceduralVertexShader: {
  19292. name: string;
  19293. shader: string;
  19294. };
  19295. }
  19296. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  19297. import { Observable } from "babylonjs/Misc/observable";
  19298. import { Nullable } from "babylonjs/types";
  19299. import { Scene } from "babylonjs/scene";
  19300. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  19301. import { Effect } from "babylonjs/Materials/effect";
  19302. import { Texture } from "babylonjs/Materials/Textures/texture";
  19303. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19304. import "babylonjs/Shaders/procedural.vertex";
  19305. /**
  19306. * 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.
  19307. * This is the base class of any Procedural texture and contains most of the shareable code.
  19308. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19309. */
  19310. export class ProceduralTexture extends Texture {
  19311. isCube: boolean;
  19312. /**
  19313. * Define if the texture is enabled or not (disabled texture will not render)
  19314. */
  19315. isEnabled: boolean;
  19316. /**
  19317. * Define if the texture must be cleared before rendering (default is true)
  19318. */
  19319. autoClear: boolean;
  19320. /**
  19321. * Callback called when the texture is generated
  19322. */
  19323. onGenerated: () => void;
  19324. /**
  19325. * Event raised when the texture is generated
  19326. */
  19327. onGeneratedObservable: Observable<ProceduralTexture>;
  19328. /** @hidden */
  19329. _generateMipMaps: boolean;
  19330. /** @hidden **/
  19331. _effect: Effect;
  19332. /** @hidden */
  19333. _textures: {
  19334. [key: string]: Texture;
  19335. };
  19336. private _size;
  19337. private _currentRefreshId;
  19338. private _refreshRate;
  19339. private _vertexBuffers;
  19340. private _indexBuffer;
  19341. private _uniforms;
  19342. private _samplers;
  19343. private _fragment;
  19344. private _floats;
  19345. private _ints;
  19346. private _floatsArrays;
  19347. private _colors3;
  19348. private _colors4;
  19349. private _vectors2;
  19350. private _vectors3;
  19351. private _matrices;
  19352. private _fallbackTexture;
  19353. private _fallbackTextureUsed;
  19354. private _engine;
  19355. private _cachedDefines;
  19356. private _contentUpdateId;
  19357. private _contentData;
  19358. /**
  19359. * Instantiates a new procedural texture.
  19360. * 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.
  19361. * This is the base class of any Procedural texture and contains most of the shareable code.
  19362. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19363. * @param name Define the name of the texture
  19364. * @param size Define the size of the texture to create
  19365. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  19366. * @param scene Define the scene the texture belongs to
  19367. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  19368. * @param generateMipMaps Define if the texture should creates mip maps or not
  19369. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  19370. */
  19371. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  19372. /**
  19373. * The effect that is created when initializing the post process.
  19374. * @returns The created effect corresponding the the postprocess.
  19375. */
  19376. getEffect(): Effect;
  19377. /**
  19378. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  19379. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  19380. */
  19381. getContent(): Nullable<ArrayBufferView>;
  19382. private _createIndexBuffer;
  19383. /** @hidden */
  19384. _rebuild(): void;
  19385. /**
  19386. * Resets the texture in order to recreate its associated resources.
  19387. * This can be called in case of context loss
  19388. */
  19389. reset(): void;
  19390. protected _getDefines(): string;
  19391. /**
  19392. * Is the texture ready to be used ? (rendered at least once)
  19393. * @returns true if ready, otherwise, false.
  19394. */
  19395. isReady(): boolean;
  19396. /**
  19397. * Resets the refresh counter of the texture and start bak from scratch.
  19398. * Could be useful to regenerate the texture if it is setup to render only once.
  19399. */
  19400. resetRefreshCounter(): void;
  19401. /**
  19402. * Set the fragment shader to use in order to render the texture.
  19403. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  19404. */
  19405. setFragment(fragment: any): void;
  19406. /**
  19407. * Define the refresh rate of the texture or the rendering frequency.
  19408. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19409. */
  19410. refreshRate: number;
  19411. /** @hidden */
  19412. _shouldRender(): boolean;
  19413. /**
  19414. * Get the size the texture is rendering at.
  19415. * @returns the size (texture is always squared)
  19416. */
  19417. getRenderSize(): number;
  19418. /**
  19419. * Resize the texture to new value.
  19420. * @param size Define the new size the texture should have
  19421. * @param generateMipMaps Define whether the new texture should create mip maps
  19422. */
  19423. resize(size: number, generateMipMaps: boolean): void;
  19424. private _checkUniform;
  19425. /**
  19426. * Set a texture in the shader program used to render.
  19427. * @param name Define the name of the uniform samplers as defined in the shader
  19428. * @param texture Define the texture to bind to this sampler
  19429. * @return the texture itself allowing "fluent" like uniform updates
  19430. */
  19431. setTexture(name: string, texture: Texture): ProceduralTexture;
  19432. /**
  19433. * Set a float in the shader.
  19434. * @param name Define the name of the uniform as defined in the shader
  19435. * @param value Define the value to give to the uniform
  19436. * @return the texture itself allowing "fluent" like uniform updates
  19437. */
  19438. setFloat(name: string, value: number): ProceduralTexture;
  19439. /**
  19440. * Set a int in the shader.
  19441. * @param name Define the name of the uniform as defined in the shader
  19442. * @param value Define the value to give to the uniform
  19443. * @return the texture itself allowing "fluent" like uniform updates
  19444. */
  19445. setInt(name: string, value: number): ProceduralTexture;
  19446. /**
  19447. * Set an array of floats in the shader.
  19448. * @param name Define the name of the uniform as defined in the shader
  19449. * @param value Define the value to give to the uniform
  19450. * @return the texture itself allowing "fluent" like uniform updates
  19451. */
  19452. setFloats(name: string, value: number[]): ProceduralTexture;
  19453. /**
  19454. * Set a vec3 in the shader from a Color3.
  19455. * @param name Define the name of the uniform as defined in the shader
  19456. * @param value Define the value to give to the uniform
  19457. * @return the texture itself allowing "fluent" like uniform updates
  19458. */
  19459. setColor3(name: string, value: Color3): ProceduralTexture;
  19460. /**
  19461. * Set a vec4 in the shader from a Color4.
  19462. * @param name Define the name of the uniform as defined in the shader
  19463. * @param value Define the value to give to the uniform
  19464. * @return the texture itself allowing "fluent" like uniform updates
  19465. */
  19466. setColor4(name: string, value: Color4): ProceduralTexture;
  19467. /**
  19468. * Set a vec2 in the shader from a Vector2.
  19469. * @param name Define the name of the uniform as defined in the shader
  19470. * @param value Define the value to give to the uniform
  19471. * @return the texture itself allowing "fluent" like uniform updates
  19472. */
  19473. setVector2(name: string, value: Vector2): ProceduralTexture;
  19474. /**
  19475. * Set a vec3 in the shader from a Vector3.
  19476. * @param name Define the name of the uniform as defined in the shader
  19477. * @param value Define the value to give to the uniform
  19478. * @return the texture itself allowing "fluent" like uniform updates
  19479. */
  19480. setVector3(name: string, value: Vector3): ProceduralTexture;
  19481. /**
  19482. * Set a mat4 in the shader from a MAtrix.
  19483. * @param name Define the name of the uniform as defined in the shader
  19484. * @param value Define the value to give to the uniform
  19485. * @return the texture itself allowing "fluent" like uniform updates
  19486. */
  19487. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19488. /**
  19489. * Render the texture to its associated render target.
  19490. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19491. */
  19492. render(useCameraPostProcess?: boolean): void;
  19493. /**
  19494. * Clone the texture.
  19495. * @returns the cloned texture
  19496. */
  19497. clone(): ProceduralTexture;
  19498. /**
  19499. * Dispose the texture and release its asoociated resources.
  19500. */
  19501. dispose(): void;
  19502. }
  19503. }
  19504. declare module "babylonjs/Particles/baseParticleSystem" {
  19505. import { Nullable } from "babylonjs/types";
  19506. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  19507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19508. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19509. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19510. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19511. import { Scene } from "babylonjs/scene";
  19512. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  19513. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19514. import { Texture } from "babylonjs/Materials/Textures/texture";
  19515. import { Animation } from "babylonjs/Animations/animation";
  19516. /**
  19517. * This represents the base class for particle system in Babylon.
  19518. * 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.
  19519. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19520. * @example https://doc.babylonjs.com/babylon101/particles
  19521. */
  19522. export class BaseParticleSystem {
  19523. /**
  19524. * Source color is added to the destination color without alpha affecting the result
  19525. */
  19526. static BLENDMODE_ONEONE: number;
  19527. /**
  19528. * Blend current color and particle color using particle’s alpha
  19529. */
  19530. static BLENDMODE_STANDARD: number;
  19531. /**
  19532. * Add current color and particle color multiplied by particle’s alpha
  19533. */
  19534. static BLENDMODE_ADD: number;
  19535. /**
  19536. * Multiply current color with particle color
  19537. */
  19538. static BLENDMODE_MULTIPLY: number;
  19539. /**
  19540. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19541. */
  19542. static BLENDMODE_MULTIPLYADD: number;
  19543. /**
  19544. * List of animations used by the particle system.
  19545. */
  19546. animations: Animation[];
  19547. /**
  19548. * The id of the Particle system.
  19549. */
  19550. id: string;
  19551. /**
  19552. * The friendly name of the Particle system.
  19553. */
  19554. name: string;
  19555. /**
  19556. * The rendering group used by the Particle system to chose when to render.
  19557. */
  19558. renderingGroupId: number;
  19559. /**
  19560. * The emitter represents the Mesh or position we are attaching the particle system to.
  19561. */
  19562. emitter: Nullable<AbstractMesh | Vector3>;
  19563. /**
  19564. * The maximum number of particles to emit per frame
  19565. */
  19566. emitRate: number;
  19567. /**
  19568. * If you want to launch only a few particles at once, that can be done, as well.
  19569. */
  19570. manualEmitCount: number;
  19571. /**
  19572. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19573. */
  19574. updateSpeed: number;
  19575. /**
  19576. * The amount of time the particle system is running (depends of the overall update speed).
  19577. */
  19578. targetStopDuration: number;
  19579. /**
  19580. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19581. */
  19582. disposeOnStop: boolean;
  19583. /**
  19584. * Minimum power of emitting particles.
  19585. */
  19586. minEmitPower: number;
  19587. /**
  19588. * Maximum power of emitting particles.
  19589. */
  19590. maxEmitPower: number;
  19591. /**
  19592. * Minimum life time of emitting particles.
  19593. */
  19594. minLifeTime: number;
  19595. /**
  19596. * Maximum life time of emitting particles.
  19597. */
  19598. maxLifeTime: number;
  19599. /**
  19600. * Minimum Size of emitting particles.
  19601. */
  19602. minSize: number;
  19603. /**
  19604. * Maximum Size of emitting particles.
  19605. */
  19606. maxSize: number;
  19607. /**
  19608. * Minimum scale of emitting particles on X axis.
  19609. */
  19610. minScaleX: number;
  19611. /**
  19612. * Maximum scale of emitting particles on X axis.
  19613. */
  19614. maxScaleX: number;
  19615. /**
  19616. * Minimum scale of emitting particles on Y axis.
  19617. */
  19618. minScaleY: number;
  19619. /**
  19620. * Maximum scale of emitting particles on Y axis.
  19621. */
  19622. maxScaleY: number;
  19623. /**
  19624. * Gets or sets the minimal initial rotation in radians.
  19625. */
  19626. minInitialRotation: number;
  19627. /**
  19628. * Gets or sets the maximal initial rotation in radians.
  19629. */
  19630. maxInitialRotation: number;
  19631. /**
  19632. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19633. */
  19634. minAngularSpeed: number;
  19635. /**
  19636. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19637. */
  19638. maxAngularSpeed: number;
  19639. /**
  19640. * The texture used to render each particle. (this can be a spritesheet)
  19641. */
  19642. particleTexture: Nullable<Texture>;
  19643. /**
  19644. * The layer mask we are rendering the particles through.
  19645. */
  19646. layerMask: number;
  19647. /**
  19648. * This can help using your own shader to render the particle system.
  19649. * The according effect will be created
  19650. */
  19651. customShader: any;
  19652. /**
  19653. * By default particle system starts as soon as they are created. This prevents the
  19654. * automatic start to happen and let you decide when to start emitting particles.
  19655. */
  19656. preventAutoStart: boolean;
  19657. private _noiseTexture;
  19658. /**
  19659. * Gets or sets a texture used to add random noise to particle positions
  19660. */
  19661. noiseTexture: Nullable<ProceduralTexture>;
  19662. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19663. noiseStrength: Vector3;
  19664. /**
  19665. * Callback triggered when the particle animation is ending.
  19666. */
  19667. onAnimationEnd: Nullable<() => void>;
  19668. /**
  19669. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19670. */
  19671. blendMode: number;
  19672. /**
  19673. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19674. * to override the particles.
  19675. */
  19676. forceDepthWrite: boolean;
  19677. /** 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 */
  19678. preWarmCycles: number;
  19679. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19680. preWarmStepOffset: number;
  19681. /**
  19682. * 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)
  19683. */
  19684. spriteCellChangeSpeed: number;
  19685. /**
  19686. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19687. */
  19688. startSpriteCellID: number;
  19689. /**
  19690. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19691. */
  19692. endSpriteCellID: number;
  19693. /**
  19694. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19695. */
  19696. spriteCellWidth: number;
  19697. /**
  19698. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19699. */
  19700. spriteCellHeight: number;
  19701. /**
  19702. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19703. */
  19704. spriteRandomStartCell: boolean;
  19705. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19706. translationPivot: Vector2;
  19707. /** @hidden */
  19708. protected _isAnimationSheetEnabled: boolean;
  19709. /**
  19710. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19711. */
  19712. beginAnimationOnStart: boolean;
  19713. /**
  19714. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19715. */
  19716. beginAnimationFrom: number;
  19717. /**
  19718. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19719. */
  19720. beginAnimationTo: number;
  19721. /**
  19722. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19723. */
  19724. beginAnimationLoop: boolean;
  19725. /**
  19726. * Gets or sets a world offset applied to all particles
  19727. */
  19728. worldOffset: Vector3;
  19729. /**
  19730. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19731. */
  19732. isAnimationSheetEnabled: boolean;
  19733. /**
  19734. * Get hosting scene
  19735. * @returns the scene
  19736. */
  19737. getScene(): Scene;
  19738. /**
  19739. * You can use gravity if you want to give an orientation to your particles.
  19740. */
  19741. gravity: Vector3;
  19742. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19743. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19744. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19745. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19746. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19747. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19748. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19749. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19750. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19751. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19752. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19753. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19754. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19755. /**
  19756. * Defines the delay in milliseconds before starting the system (0 by default)
  19757. */
  19758. startDelay: number;
  19759. /**
  19760. * Gets the current list of drag gradients.
  19761. * You must use addDragGradient and removeDragGradient to udpate this list
  19762. * @returns the list of drag gradients
  19763. */
  19764. getDragGradients(): Nullable<Array<FactorGradient>>;
  19765. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19766. limitVelocityDamping: number;
  19767. /**
  19768. * Gets the current list of limit velocity gradients.
  19769. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19770. * @returns the list of limit velocity gradients
  19771. */
  19772. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19773. /**
  19774. * Gets the current list of color gradients.
  19775. * You must use addColorGradient and removeColorGradient to udpate this list
  19776. * @returns the list of color gradients
  19777. */
  19778. getColorGradients(): Nullable<Array<ColorGradient>>;
  19779. /**
  19780. * Gets the current list of size gradients.
  19781. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19782. * @returns the list of size gradients
  19783. */
  19784. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19785. /**
  19786. * Gets the current list of color remap gradients.
  19787. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19788. * @returns the list of color remap gradients
  19789. */
  19790. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19791. /**
  19792. * Gets the current list of alpha remap gradients.
  19793. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19794. * @returns the list of alpha remap gradients
  19795. */
  19796. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19797. /**
  19798. * Gets the current list of life time gradients.
  19799. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19800. * @returns the list of life time gradients
  19801. */
  19802. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19803. /**
  19804. * Gets the current list of angular speed gradients.
  19805. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19806. * @returns the list of angular speed gradients
  19807. */
  19808. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19809. /**
  19810. * Gets the current list of velocity gradients.
  19811. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19812. * @returns the list of velocity gradients
  19813. */
  19814. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19815. /**
  19816. * Gets the current list of start size gradients.
  19817. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19818. * @returns the list of start size gradients
  19819. */
  19820. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19821. /**
  19822. * Gets the current list of emit rate gradients.
  19823. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19824. * @returns the list of emit rate gradients
  19825. */
  19826. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19827. /**
  19828. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19829. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19830. */
  19831. direction1: Vector3;
  19832. /**
  19833. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19834. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19835. */
  19836. direction2: Vector3;
  19837. /**
  19838. * 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.
  19839. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19840. */
  19841. minEmitBox: Vector3;
  19842. /**
  19843. * 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.
  19844. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19845. */
  19846. maxEmitBox: Vector3;
  19847. /**
  19848. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19849. */
  19850. color1: Color4;
  19851. /**
  19852. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19853. */
  19854. color2: Color4;
  19855. /**
  19856. * Color the particle will have at the end of its lifetime
  19857. */
  19858. colorDead: Color4;
  19859. /**
  19860. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19861. */
  19862. textureMask: Color4;
  19863. /**
  19864. * The particle emitter type defines the emitter used by the particle system.
  19865. * It can be for example box, sphere, or cone...
  19866. */
  19867. particleEmitterType: IParticleEmitterType;
  19868. /** @hidden */
  19869. _isSubEmitter: boolean;
  19870. /**
  19871. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19872. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19873. */
  19874. billboardMode: number;
  19875. protected _isBillboardBased: boolean;
  19876. /**
  19877. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19878. */
  19879. isBillboardBased: boolean;
  19880. /**
  19881. * The scene the particle system belongs to.
  19882. */
  19883. protected _scene: Scene;
  19884. /**
  19885. * Local cache of defines for image processing.
  19886. */
  19887. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19888. /**
  19889. * Default configuration related to image processing available in the standard Material.
  19890. */
  19891. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19892. /**
  19893. * Gets the image processing configuration used either in this material.
  19894. */
  19895. /**
  19896. * Sets the Default image processing configuration used either in the this material.
  19897. *
  19898. * If sets to null, the scene one is in use.
  19899. */
  19900. imageProcessingConfiguration: ImageProcessingConfiguration;
  19901. /**
  19902. * Attaches a new image processing configuration to the Standard Material.
  19903. * @param configuration
  19904. */
  19905. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19906. /** @hidden */
  19907. protected _reset(): void;
  19908. /** @hidden */
  19909. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19910. /**
  19911. * Instantiates a particle system.
  19912. * 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.
  19913. * @param name The name of the particle system
  19914. */
  19915. constructor(name: string);
  19916. /**
  19917. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19918. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19919. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19920. * @returns the emitter
  19921. */
  19922. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19923. /**
  19924. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19925. * @param radius The radius of the hemisphere to emit from
  19926. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19927. * @returns the emitter
  19928. */
  19929. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19930. /**
  19931. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19932. * @param radius The radius of the sphere to emit from
  19933. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19934. * @returns the emitter
  19935. */
  19936. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19937. /**
  19938. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19939. * @param radius The radius of the sphere to emit from
  19940. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19941. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19942. * @returns the emitter
  19943. */
  19944. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19945. /**
  19946. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19947. * @param radius The radius of the emission cylinder
  19948. * @param height The height of the emission cylinder
  19949. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19950. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19951. * @returns the emitter
  19952. */
  19953. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19954. /**
  19955. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19956. * @param radius The radius of the cylinder to emit from
  19957. * @param height The height of the emission cylinder
  19958. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19959. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19960. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19961. * @returns the emitter
  19962. */
  19963. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19964. /**
  19965. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19966. * @param radius The radius of the cone to emit from
  19967. * @param angle The base angle of the cone
  19968. * @returns the emitter
  19969. */
  19970. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19971. /**
  19972. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19973. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19974. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19975. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19976. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19977. * @returns the emitter
  19978. */
  19979. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19980. }
  19981. }
  19982. declare module "babylonjs/Particles/subEmitter" {
  19983. import { Scene } from "babylonjs/scene";
  19984. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  19985. /**
  19986. * Type of sub emitter
  19987. */
  19988. export enum SubEmitterType {
  19989. /**
  19990. * Attached to the particle over it's lifetime
  19991. */
  19992. ATTACHED = 0,
  19993. /**
  19994. * Created when the particle dies
  19995. */
  19996. END = 1
  19997. }
  19998. /**
  19999. * Sub emitter class used to emit particles from an existing particle
  20000. */
  20001. export class SubEmitter {
  20002. /**
  20003. * the particle system to be used by the sub emitter
  20004. */
  20005. particleSystem: ParticleSystem;
  20006. /**
  20007. * Type of the submitter (Default: END)
  20008. */
  20009. type: SubEmitterType;
  20010. /**
  20011. * 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)
  20012. * Note: This only is supported when using an emitter of type Mesh
  20013. */
  20014. inheritDirection: boolean;
  20015. /**
  20016. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  20017. */
  20018. inheritedVelocityAmount: number;
  20019. /**
  20020. * Creates a sub emitter
  20021. * @param particleSystem the particle system to be used by the sub emitter
  20022. */
  20023. constructor(
  20024. /**
  20025. * the particle system to be used by the sub emitter
  20026. */
  20027. particleSystem: ParticleSystem);
  20028. /**
  20029. * Clones the sub emitter
  20030. * @returns the cloned sub emitter
  20031. */
  20032. clone(): SubEmitter;
  20033. /**
  20034. * Serialize current object to a JSON object
  20035. * @returns the serialized object
  20036. */
  20037. serialize(): any;
  20038. /** @hidden */
  20039. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  20040. /**
  20041. * Creates a new SubEmitter from a serialized JSON version
  20042. * @param serializationObject defines the JSON object to read from
  20043. * @param scene defines the hosting scene
  20044. * @param rootUrl defines the rootUrl for data loading
  20045. * @returns a new SubEmitter
  20046. */
  20047. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  20048. /** Release associated resources */
  20049. dispose(): void;
  20050. }
  20051. }
  20052. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  20053. /** @hidden */
  20054. export var imageProcessingDeclaration: {
  20055. name: string;
  20056. shader: string;
  20057. };
  20058. }
  20059. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  20060. /** @hidden */
  20061. export var imageProcessingFunctions: {
  20062. name: string;
  20063. shader: string;
  20064. };
  20065. }
  20066. declare module "babylonjs/Shaders/particles.fragment" {
  20067. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20068. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  20069. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  20070. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  20071. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20072. /** @hidden */
  20073. export var particlesPixelShader: {
  20074. name: string;
  20075. shader: string;
  20076. };
  20077. }
  20078. declare module "babylonjs/Shaders/particles.vertex" {
  20079. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20080. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20081. /** @hidden */
  20082. export var particlesVertexShader: {
  20083. name: string;
  20084. shader: string;
  20085. };
  20086. }
  20087. declare module "babylonjs/Particles/particleSystem" {
  20088. import { Nullable } from "babylonjs/types";
  20089. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  20090. import { Observable } from "babylonjs/Misc/observable";
  20091. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  20092. import { Effect } from "babylonjs/Materials/effect";
  20093. import { Scene, IDisposable } from "babylonjs/scene";
  20094. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20095. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  20096. import { Particle } from "babylonjs/Particles/particle";
  20097. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20098. import "babylonjs/Shaders/particles.fragment";
  20099. import "babylonjs/Shaders/particles.vertex";
  20100. /**
  20101. * This represents a particle system in Babylon.
  20102. * 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.
  20103. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  20104. * @example https://doc.babylonjs.com/babylon101/particles
  20105. */
  20106. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  20107. /**
  20108. * Billboard mode will only apply to Y axis
  20109. */
  20110. static readonly BILLBOARDMODE_Y: number;
  20111. /**
  20112. * Billboard mode will apply to all axes
  20113. */
  20114. static readonly BILLBOARDMODE_ALL: number;
  20115. /**
  20116. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  20117. */
  20118. static readonly BILLBOARDMODE_STRETCHED: number;
  20119. /**
  20120. * This function can be defined to provide custom update for active particles.
  20121. * This function will be called instead of regular update (age, position, color, etc.).
  20122. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  20123. */
  20124. updateFunction: (particles: Particle[]) => void;
  20125. private _emitterWorldMatrix;
  20126. /**
  20127. * This function can be defined to specify initial direction for every new particle.
  20128. * It by default use the emitterType defined function
  20129. */
  20130. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  20131. /**
  20132. * This function can be defined to specify initial position for every new particle.
  20133. * It by default use the emitterType defined function
  20134. */
  20135. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  20136. /**
  20137. * @hidden
  20138. */
  20139. _inheritedVelocityOffset: Vector3;
  20140. /**
  20141. * An event triggered when the system is disposed
  20142. */
  20143. onDisposeObservable: Observable<ParticleSystem>;
  20144. private _onDisposeObserver;
  20145. /**
  20146. * Sets a callback that will be triggered when the system is disposed
  20147. */
  20148. onDispose: () => void;
  20149. private _particles;
  20150. private _epsilon;
  20151. private _capacity;
  20152. private _stockParticles;
  20153. private _newPartsExcess;
  20154. private _vertexData;
  20155. private _vertexBuffer;
  20156. private _vertexBuffers;
  20157. private _spriteBuffer;
  20158. private _indexBuffer;
  20159. private _effect;
  20160. private _customEffect;
  20161. private _cachedDefines;
  20162. private _scaledColorStep;
  20163. private _colorDiff;
  20164. private _scaledDirection;
  20165. private _scaledGravity;
  20166. private _currentRenderId;
  20167. private _alive;
  20168. private _useInstancing;
  20169. private _started;
  20170. private _stopped;
  20171. private _actualFrame;
  20172. private _scaledUpdateSpeed;
  20173. private _vertexBufferSize;
  20174. /** @hidden */
  20175. _currentEmitRateGradient: Nullable<FactorGradient>;
  20176. /** @hidden */
  20177. _currentEmitRate1: number;
  20178. /** @hidden */
  20179. _currentEmitRate2: number;
  20180. /** @hidden */
  20181. _currentStartSizeGradient: Nullable<FactorGradient>;
  20182. /** @hidden */
  20183. _currentStartSize1: number;
  20184. /** @hidden */
  20185. _currentStartSize2: number;
  20186. private readonly _rawTextureWidth;
  20187. private _rampGradientsTexture;
  20188. private _useRampGradients;
  20189. /** Gets or sets a boolean indicating that ramp gradients must be used
  20190. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20191. */
  20192. useRampGradients: boolean;
  20193. /**
  20194. * 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.
  20195. * 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: [])
  20196. */
  20197. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  20198. private _subEmitters;
  20199. /**
  20200. * @hidden
  20201. * If the particle systems emitter should be disposed when the particle system is disposed
  20202. */
  20203. _disposeEmitterOnDispose: boolean;
  20204. /**
  20205. * The current active Sub-systems, this property is used by the root particle system only.
  20206. */
  20207. activeSubSystems: Array<ParticleSystem>;
  20208. private _rootParticleSystem;
  20209. /**
  20210. * Gets the current list of active particles
  20211. */
  20212. readonly particles: Particle[];
  20213. /**
  20214. * Returns the string "ParticleSystem"
  20215. * @returns a string containing the class name
  20216. */
  20217. getClassName(): string;
  20218. /**
  20219. * Instantiates a particle system.
  20220. * 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.
  20221. * @param name The name of the particle system
  20222. * @param capacity The max number of particles alive at the same time
  20223. * @param scene The scene the particle system belongs to
  20224. * @param customEffect a custom effect used to change the way particles are rendered by default
  20225. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  20226. * @param epsilon Offset used to render the particles
  20227. */
  20228. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  20229. private _addFactorGradient;
  20230. private _removeFactorGradient;
  20231. /**
  20232. * Adds a new life time gradient
  20233. * @param gradient defines the gradient to use (between 0 and 1)
  20234. * @param factor defines the life time factor to affect to the specified gradient
  20235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20236. * @returns the current particle system
  20237. */
  20238. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20239. /**
  20240. * Remove a specific life time gradient
  20241. * @param gradient defines the gradient to remove
  20242. * @returns the current particle system
  20243. */
  20244. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20245. /**
  20246. * Adds a new size gradient
  20247. * @param gradient defines the gradient to use (between 0 and 1)
  20248. * @param factor defines the size factor to affect to the specified gradient
  20249. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20250. * @returns the current particle system
  20251. */
  20252. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20253. /**
  20254. * Remove a specific size gradient
  20255. * @param gradient defines the gradient to remove
  20256. * @returns the current particle system
  20257. */
  20258. removeSizeGradient(gradient: number): IParticleSystem;
  20259. /**
  20260. * Adds a new color remap gradient
  20261. * @param gradient defines the gradient to use (between 0 and 1)
  20262. * @param min defines the color remap minimal range
  20263. * @param max defines the color remap maximal range
  20264. * @returns the current particle system
  20265. */
  20266. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20267. /**
  20268. * Remove a specific color remap gradient
  20269. * @param gradient defines the gradient to remove
  20270. * @returns the current particle system
  20271. */
  20272. removeColorRemapGradient(gradient: number): IParticleSystem;
  20273. /**
  20274. * Adds a new alpha remap gradient
  20275. * @param gradient defines the gradient to use (between 0 and 1)
  20276. * @param min defines the alpha remap minimal range
  20277. * @param max defines the alpha remap maximal range
  20278. * @returns the current particle system
  20279. */
  20280. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20281. /**
  20282. * Remove a specific alpha remap gradient
  20283. * @param gradient defines the gradient to remove
  20284. * @returns the current particle system
  20285. */
  20286. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  20287. /**
  20288. * Adds a new angular speed gradient
  20289. * @param gradient defines the gradient to use (between 0 and 1)
  20290. * @param factor defines the angular speed to affect to the specified gradient
  20291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20292. * @returns the current particle system
  20293. */
  20294. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20295. /**
  20296. * Remove a specific angular speed gradient
  20297. * @param gradient defines the gradient to remove
  20298. * @returns the current particle system
  20299. */
  20300. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20301. /**
  20302. * Adds a new velocity gradient
  20303. * @param gradient defines the gradient to use (between 0 and 1)
  20304. * @param factor defines the velocity to affect to the specified gradient
  20305. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20306. * @returns the current particle system
  20307. */
  20308. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20309. /**
  20310. * Remove a specific velocity gradient
  20311. * @param gradient defines the gradient to remove
  20312. * @returns the current particle system
  20313. */
  20314. removeVelocityGradient(gradient: number): IParticleSystem;
  20315. /**
  20316. * Adds a new limit velocity gradient
  20317. * @param gradient defines the gradient to use (between 0 and 1)
  20318. * @param factor defines the limit velocity value to affect to the specified gradient
  20319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20320. * @returns the current particle system
  20321. */
  20322. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20323. /**
  20324. * Remove a specific limit velocity gradient
  20325. * @param gradient defines the gradient to remove
  20326. * @returns the current particle system
  20327. */
  20328. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20329. /**
  20330. * Adds a new drag gradient
  20331. * @param gradient defines the gradient to use (between 0 and 1)
  20332. * @param factor defines the drag value to affect to the specified gradient
  20333. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20334. * @returns the current particle system
  20335. */
  20336. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20337. /**
  20338. * Remove a specific drag gradient
  20339. * @param gradient defines the gradient to remove
  20340. * @returns the current particle system
  20341. */
  20342. removeDragGradient(gradient: number): IParticleSystem;
  20343. /**
  20344. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20345. * @param gradient defines the gradient to use (between 0 and 1)
  20346. * @param factor defines the emit rate value to affect to the specified gradient
  20347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20348. * @returns the current particle system
  20349. */
  20350. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20351. /**
  20352. * Remove a specific emit rate gradient
  20353. * @param gradient defines the gradient to remove
  20354. * @returns the current particle system
  20355. */
  20356. removeEmitRateGradient(gradient: number): IParticleSystem;
  20357. /**
  20358. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20359. * @param gradient defines the gradient to use (between 0 and 1)
  20360. * @param factor defines the start size value to affect to the specified gradient
  20361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20362. * @returns the current particle system
  20363. */
  20364. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20365. /**
  20366. * Remove a specific start size gradient
  20367. * @param gradient defines the gradient to remove
  20368. * @returns the current particle system
  20369. */
  20370. removeStartSizeGradient(gradient: number): IParticleSystem;
  20371. private _createRampGradientTexture;
  20372. /**
  20373. * Gets the current list of ramp gradients.
  20374. * You must use addRampGradient and removeRampGradient to udpate this list
  20375. * @returns the list of ramp gradients
  20376. */
  20377. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20378. /**
  20379. * Adds a new ramp gradient used to remap particle colors
  20380. * @param gradient defines the gradient to use (between 0 and 1)
  20381. * @param color defines the color to affect to the specified gradient
  20382. * @returns the current particle system
  20383. */
  20384. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  20385. /**
  20386. * Remove a specific ramp gradient
  20387. * @param gradient defines the gradient to remove
  20388. * @returns the current particle system
  20389. */
  20390. removeRampGradient(gradient: number): ParticleSystem;
  20391. /**
  20392. * Adds a new color gradient
  20393. * @param gradient defines the gradient to use (between 0 and 1)
  20394. * @param color1 defines the color to affect to the specified gradient
  20395. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20396. * @returns this particle system
  20397. */
  20398. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20399. /**
  20400. * Remove a specific color gradient
  20401. * @param gradient defines the gradient to remove
  20402. * @returns this particle system
  20403. */
  20404. removeColorGradient(gradient: number): IParticleSystem;
  20405. private _fetchR;
  20406. protected _reset(): void;
  20407. private _resetEffect;
  20408. private _createVertexBuffers;
  20409. private _createIndexBuffer;
  20410. /**
  20411. * Gets the maximum number of particles active at the same time.
  20412. * @returns The max number of active particles.
  20413. */
  20414. getCapacity(): number;
  20415. /**
  20416. * Gets whether there are still active particles in the system.
  20417. * @returns True if it is alive, otherwise false.
  20418. */
  20419. isAlive(): boolean;
  20420. /**
  20421. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20422. * @returns True if it has been started, otherwise false.
  20423. */
  20424. isStarted(): boolean;
  20425. private _prepareSubEmitterInternalArray;
  20426. /**
  20427. * Starts the particle system and begins to emit
  20428. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  20429. */
  20430. start(delay?: number): void;
  20431. /**
  20432. * Stops the particle system.
  20433. * @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.
  20434. */
  20435. stop(stopSubEmitters?: boolean): void;
  20436. /**
  20437. * Remove all active particles
  20438. */
  20439. reset(): void;
  20440. /**
  20441. * @hidden (for internal use only)
  20442. */
  20443. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20444. /**
  20445. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  20446. * Its lifetime will start back at 0.
  20447. */
  20448. recycleParticle: (particle: Particle) => void;
  20449. private _stopSubEmitters;
  20450. private _createParticle;
  20451. private _removeFromRoot;
  20452. private _emitFromParticle;
  20453. private _update;
  20454. /** @hidden */
  20455. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  20456. /** @hidden */
  20457. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  20458. /** @hidden */
  20459. private _getEffect;
  20460. /**
  20461. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20462. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  20463. */
  20464. animate(preWarmOnly?: boolean): void;
  20465. private _appendParticleVertices;
  20466. /**
  20467. * Rebuilds the particle system.
  20468. */
  20469. rebuild(): void;
  20470. /**
  20471. * Is this system ready to be used/rendered
  20472. * @return true if the system is ready
  20473. */
  20474. isReady(): boolean;
  20475. private _render;
  20476. /**
  20477. * Renders the particle system in its current state.
  20478. * @returns the current number of particles
  20479. */
  20480. render(): number;
  20481. /**
  20482. * Disposes the particle system and free the associated resources
  20483. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20484. */
  20485. dispose(disposeTexture?: boolean): void;
  20486. /**
  20487. * Clones the particle system.
  20488. * @param name The name of the cloned object
  20489. * @param newEmitter The new emitter to use
  20490. * @returns the cloned particle system
  20491. */
  20492. clone(name: string, newEmitter: any): ParticleSystem;
  20493. /**
  20494. * Serializes the particle system to a JSON object.
  20495. * @returns the JSON object
  20496. */
  20497. serialize(): any;
  20498. /** @hidden */
  20499. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20500. /** @hidden */
  20501. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20502. /**
  20503. * Parses a JSON object to create a particle system.
  20504. * @param parsedParticleSystem The JSON object to parse
  20505. * @param scene The scene to create the particle system in
  20506. * @param rootUrl The root url to use to load external dependencies like texture
  20507. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  20508. * @returns the Parsed particle system
  20509. */
  20510. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  20511. }
  20512. }
  20513. declare module "babylonjs/Particles/particle" {
  20514. import { Nullable } from "babylonjs/types";
  20515. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  20516. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  20517. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20518. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  20519. /**
  20520. * A particle represents one of the element emitted by a particle system.
  20521. * This is mainly define by its coordinates, direction, velocity and age.
  20522. */
  20523. export class Particle {
  20524. /**
  20525. * The particle system the particle belongs to.
  20526. */
  20527. particleSystem: ParticleSystem;
  20528. private static _Count;
  20529. /**
  20530. * Unique ID of the particle
  20531. */
  20532. id: number;
  20533. /**
  20534. * The world position of the particle in the scene.
  20535. */
  20536. position: Vector3;
  20537. /**
  20538. * The world direction of the particle in the scene.
  20539. */
  20540. direction: Vector3;
  20541. /**
  20542. * The color of the particle.
  20543. */
  20544. color: Color4;
  20545. /**
  20546. * The color change of the particle per step.
  20547. */
  20548. colorStep: Color4;
  20549. /**
  20550. * Defines how long will the life of the particle be.
  20551. */
  20552. lifeTime: number;
  20553. /**
  20554. * The current age of the particle.
  20555. */
  20556. age: number;
  20557. /**
  20558. * The current size of the particle.
  20559. */
  20560. size: number;
  20561. /**
  20562. * The current scale of the particle.
  20563. */
  20564. scale: Vector2;
  20565. /**
  20566. * The current angle of the particle.
  20567. */
  20568. angle: number;
  20569. /**
  20570. * Defines how fast is the angle changing.
  20571. */
  20572. angularSpeed: number;
  20573. /**
  20574. * Defines the cell index used by the particle to be rendered from a sprite.
  20575. */
  20576. cellIndex: number;
  20577. /**
  20578. * The information required to support color remapping
  20579. */
  20580. remapData: Vector4;
  20581. /** @hidden */
  20582. _randomCellOffset?: number;
  20583. /** @hidden */
  20584. _initialDirection: Nullable<Vector3>;
  20585. /** @hidden */
  20586. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20587. /** @hidden */
  20588. _initialStartSpriteCellID: number;
  20589. /** @hidden */
  20590. _initialEndSpriteCellID: number;
  20591. /** @hidden */
  20592. _currentColorGradient: Nullable<ColorGradient>;
  20593. /** @hidden */
  20594. _currentColor1: Color4;
  20595. /** @hidden */
  20596. _currentColor2: Color4;
  20597. /** @hidden */
  20598. _currentSizeGradient: Nullable<FactorGradient>;
  20599. /** @hidden */
  20600. _currentSize1: number;
  20601. /** @hidden */
  20602. _currentSize2: number;
  20603. /** @hidden */
  20604. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20605. /** @hidden */
  20606. _currentAngularSpeed1: number;
  20607. /** @hidden */
  20608. _currentAngularSpeed2: number;
  20609. /** @hidden */
  20610. _currentVelocityGradient: Nullable<FactorGradient>;
  20611. /** @hidden */
  20612. _currentVelocity1: number;
  20613. /** @hidden */
  20614. _currentVelocity2: number;
  20615. /** @hidden */
  20616. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20617. /** @hidden */
  20618. _currentLimitVelocity1: number;
  20619. /** @hidden */
  20620. _currentLimitVelocity2: number;
  20621. /** @hidden */
  20622. _currentDragGradient: Nullable<FactorGradient>;
  20623. /** @hidden */
  20624. _currentDrag1: number;
  20625. /** @hidden */
  20626. _currentDrag2: number;
  20627. /** @hidden */
  20628. _randomNoiseCoordinates1: Vector3;
  20629. /** @hidden */
  20630. _randomNoiseCoordinates2: Vector3;
  20631. /**
  20632. * Creates a new instance Particle
  20633. * @param particleSystem the particle system the particle belongs to
  20634. */
  20635. constructor(
  20636. /**
  20637. * The particle system the particle belongs to.
  20638. */
  20639. particleSystem: ParticleSystem);
  20640. private updateCellInfoFromSystem;
  20641. /**
  20642. * Defines how the sprite cell index is updated for the particle
  20643. */
  20644. updateCellIndex(): void;
  20645. /** @hidden */
  20646. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20647. /** @hidden */
  20648. _inheritParticleInfoToSubEmitters(): void;
  20649. /** @hidden */
  20650. _reset(): void;
  20651. /**
  20652. * Copy the properties of particle to another one.
  20653. * @param other the particle to copy the information to.
  20654. */
  20655. copyTo(other: Particle): void;
  20656. }
  20657. }
  20658. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  20659. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20660. import { Effect } from "babylonjs/Materials/effect";
  20661. import { Particle } from "babylonjs/Particles/particle";
  20662. /**
  20663. * Particle emitter represents a volume emitting particles.
  20664. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20665. */
  20666. export interface IParticleEmitterType {
  20667. /**
  20668. * Called by the particle System when the direction is computed for the created particle.
  20669. * @param worldMatrix is the world matrix of the particle system
  20670. * @param directionToUpdate is the direction vector to update with the result
  20671. * @param particle is the particle we are computed the direction for
  20672. */
  20673. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20674. /**
  20675. * Called by the particle System when the position is computed for the created particle.
  20676. * @param worldMatrix is the world matrix of the particle system
  20677. * @param positionToUpdate is the position vector to update with the result
  20678. * @param particle is the particle we are computed the position for
  20679. */
  20680. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20681. /**
  20682. * Clones the current emitter and returns a copy of it
  20683. * @returns the new emitter
  20684. */
  20685. clone(): IParticleEmitterType;
  20686. /**
  20687. * Called by the GPUParticleSystem to setup the update shader
  20688. * @param effect defines the update shader
  20689. */
  20690. applyToShader(effect: Effect): void;
  20691. /**
  20692. * Returns a string to use to update the GPU particles update shader
  20693. * @returns the effect defines string
  20694. */
  20695. getEffectDefines(): string;
  20696. /**
  20697. * Returns a string representing the class name
  20698. * @returns a string containing the class name
  20699. */
  20700. getClassName(): string;
  20701. /**
  20702. * Serializes the particle system to a JSON object.
  20703. * @returns the JSON object
  20704. */
  20705. serialize(): any;
  20706. /**
  20707. * Parse properties from a JSON object
  20708. * @param serializationObject defines the JSON object
  20709. */
  20710. parse(serializationObject: any): void;
  20711. }
  20712. }
  20713. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  20714. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20715. import { Effect } from "babylonjs/Materials/effect";
  20716. import { Particle } from "babylonjs/Particles/particle";
  20717. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20718. /**
  20719. * Particle emitter emitting particles from the inside of a box.
  20720. * It emits the particles randomly between 2 given directions.
  20721. */
  20722. export class BoxParticleEmitter implements IParticleEmitterType {
  20723. /**
  20724. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20725. */
  20726. direction1: Vector3;
  20727. /**
  20728. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20729. */
  20730. direction2: Vector3;
  20731. /**
  20732. * 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.
  20733. */
  20734. minEmitBox: Vector3;
  20735. /**
  20736. * 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.
  20737. */
  20738. maxEmitBox: Vector3;
  20739. /**
  20740. * Creates a new instance BoxParticleEmitter
  20741. */
  20742. constructor();
  20743. /**
  20744. * Called by the particle System when the direction is computed for the created particle.
  20745. * @param worldMatrix is the world matrix of the particle system
  20746. * @param directionToUpdate is the direction vector to update with the result
  20747. * @param particle is the particle we are computed the direction for
  20748. */
  20749. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20750. /**
  20751. * Called by the particle System when the position is computed for the created particle.
  20752. * @param worldMatrix is the world matrix of the particle system
  20753. * @param positionToUpdate is the position vector to update with the result
  20754. * @param particle is the particle we are computed the position for
  20755. */
  20756. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20757. /**
  20758. * Clones the current emitter and returns a copy of it
  20759. * @returns the new emitter
  20760. */
  20761. clone(): BoxParticleEmitter;
  20762. /**
  20763. * Called by the GPUParticleSystem to setup the update shader
  20764. * @param effect defines the update shader
  20765. */
  20766. applyToShader(effect: Effect): void;
  20767. /**
  20768. * Returns a string to use to update the GPU particles update shader
  20769. * @returns a string containng the defines string
  20770. */
  20771. getEffectDefines(): string;
  20772. /**
  20773. * Returns the string "BoxParticleEmitter"
  20774. * @returns a string containing the class name
  20775. */
  20776. getClassName(): string;
  20777. /**
  20778. * Serializes the particle system to a JSON object.
  20779. * @returns the JSON object
  20780. */
  20781. serialize(): any;
  20782. /**
  20783. * Parse properties from a JSON object
  20784. * @param serializationObject defines the JSON object
  20785. */
  20786. parse(serializationObject: any): void;
  20787. }
  20788. }
  20789. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  20790. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20791. import { Effect } from "babylonjs/Materials/effect";
  20792. import { Particle } from "babylonjs/Particles/particle";
  20793. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20794. /**
  20795. * Particle emitter emitting particles from the inside of a cone.
  20796. * It emits the particles alongside the cone volume from the base to the particle.
  20797. * The emission direction might be randomized.
  20798. */
  20799. export class ConeParticleEmitter implements IParticleEmitterType {
  20800. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20801. directionRandomizer: number;
  20802. private _radius;
  20803. private _angle;
  20804. private _height;
  20805. /**
  20806. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20807. */
  20808. radiusRange: number;
  20809. /**
  20810. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20811. */
  20812. heightRange: number;
  20813. /**
  20814. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20815. */
  20816. emitFromSpawnPointOnly: boolean;
  20817. /**
  20818. * Gets or sets the radius of the emission cone
  20819. */
  20820. radius: number;
  20821. /**
  20822. * Gets or sets the angle of the emission cone
  20823. */
  20824. angle: number;
  20825. private _buildHeight;
  20826. /**
  20827. * Creates a new instance ConeParticleEmitter
  20828. * @param radius the radius of the emission cone (1 by default)
  20829. * @param angle the cone base angle (PI by default)
  20830. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20831. */
  20832. constructor(radius?: number, angle?: number,
  20833. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20834. directionRandomizer?: number);
  20835. /**
  20836. * Called by the particle System when the direction is computed for the created particle.
  20837. * @param worldMatrix is the world matrix of the particle system
  20838. * @param directionToUpdate is the direction vector to update with the result
  20839. * @param particle is the particle we are computed the direction for
  20840. */
  20841. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20842. /**
  20843. * Called by the particle System when the position is computed for the created particle.
  20844. * @param worldMatrix is the world matrix of the particle system
  20845. * @param positionToUpdate is the position vector to update with the result
  20846. * @param particle is the particle we are computed the position for
  20847. */
  20848. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20849. /**
  20850. * Clones the current emitter and returns a copy of it
  20851. * @returns the new emitter
  20852. */
  20853. clone(): ConeParticleEmitter;
  20854. /**
  20855. * Called by the GPUParticleSystem to setup the update shader
  20856. * @param effect defines the update shader
  20857. */
  20858. applyToShader(effect: Effect): void;
  20859. /**
  20860. * Returns a string to use to update the GPU particles update shader
  20861. * @returns a string containng the defines string
  20862. */
  20863. getEffectDefines(): string;
  20864. /**
  20865. * Returns the string "ConeParticleEmitter"
  20866. * @returns a string containing the class name
  20867. */
  20868. getClassName(): string;
  20869. /**
  20870. * Serializes the particle system to a JSON object.
  20871. * @returns the JSON object
  20872. */
  20873. serialize(): any;
  20874. /**
  20875. * Parse properties from a JSON object
  20876. * @param serializationObject defines the JSON object
  20877. */
  20878. parse(serializationObject: any): void;
  20879. }
  20880. }
  20881. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  20882. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20883. import { Effect } from "babylonjs/Materials/effect";
  20884. import { Particle } from "babylonjs/Particles/particle";
  20885. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20886. /**
  20887. * Particle emitter emitting particles from the inside of a cylinder.
  20888. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20889. */
  20890. export class CylinderParticleEmitter implements IParticleEmitterType {
  20891. /**
  20892. * The radius of the emission cylinder.
  20893. */
  20894. radius: number;
  20895. /**
  20896. * The height of the emission cylinder.
  20897. */
  20898. height: number;
  20899. /**
  20900. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20901. */
  20902. radiusRange: number;
  20903. /**
  20904. * How much to randomize the particle direction [0-1].
  20905. */
  20906. directionRandomizer: number;
  20907. /**
  20908. * Creates a new instance CylinderParticleEmitter
  20909. * @param radius the radius of the emission cylinder (1 by default)
  20910. * @param height the height of the emission cylinder (1 by default)
  20911. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20912. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20913. */
  20914. constructor(
  20915. /**
  20916. * The radius of the emission cylinder.
  20917. */
  20918. radius?: number,
  20919. /**
  20920. * The height of the emission cylinder.
  20921. */
  20922. height?: number,
  20923. /**
  20924. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20925. */
  20926. radiusRange?: number,
  20927. /**
  20928. * How much to randomize the particle direction [0-1].
  20929. */
  20930. directionRandomizer?: number);
  20931. /**
  20932. * Called by the particle System when the direction is computed for the created particle.
  20933. * @param worldMatrix is the world matrix of the particle system
  20934. * @param directionToUpdate is the direction vector to update with the result
  20935. * @param particle is the particle we are computed the direction for
  20936. */
  20937. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20938. /**
  20939. * Called by the particle System when the position is computed for the created particle.
  20940. * @param worldMatrix is the world matrix of the particle system
  20941. * @param positionToUpdate is the position vector to update with the result
  20942. * @param particle is the particle we are computed the position for
  20943. */
  20944. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20945. /**
  20946. * Clones the current emitter and returns a copy of it
  20947. * @returns the new emitter
  20948. */
  20949. clone(): CylinderParticleEmitter;
  20950. /**
  20951. * Called by the GPUParticleSystem to setup the update shader
  20952. * @param effect defines the update shader
  20953. */
  20954. applyToShader(effect: Effect): void;
  20955. /**
  20956. * Returns a string to use to update the GPU particles update shader
  20957. * @returns a string containng the defines string
  20958. */
  20959. getEffectDefines(): string;
  20960. /**
  20961. * Returns the string "CylinderParticleEmitter"
  20962. * @returns a string containing the class name
  20963. */
  20964. getClassName(): string;
  20965. /**
  20966. * Serializes the particle system to a JSON object.
  20967. * @returns the JSON object
  20968. */
  20969. serialize(): any;
  20970. /**
  20971. * Parse properties from a JSON object
  20972. * @param serializationObject defines the JSON object
  20973. */
  20974. parse(serializationObject: any): void;
  20975. }
  20976. /**
  20977. * Particle emitter emitting particles from the inside of a cylinder.
  20978. * It emits the particles randomly between two vectors.
  20979. */
  20980. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20981. /**
  20982. * The min limit of the emission direction.
  20983. */
  20984. direction1: Vector3;
  20985. /**
  20986. * The max limit of the emission direction.
  20987. */
  20988. direction2: Vector3;
  20989. /**
  20990. * Creates a new instance CylinderDirectedParticleEmitter
  20991. * @param radius the radius of the emission cylinder (1 by default)
  20992. * @param height the height of the emission cylinder (1 by default)
  20993. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20994. * @param direction1 the min limit of the emission direction (up vector by default)
  20995. * @param direction2 the max limit of the emission direction (up vector by default)
  20996. */
  20997. constructor(radius?: number, height?: number, radiusRange?: number,
  20998. /**
  20999. * The min limit of the emission direction.
  21000. */
  21001. direction1?: Vector3,
  21002. /**
  21003. * The max limit of the emission direction.
  21004. */
  21005. direction2?: Vector3);
  21006. /**
  21007. * Called by the particle System when the direction is computed for the created particle.
  21008. * @param worldMatrix is the world matrix of the particle system
  21009. * @param directionToUpdate is the direction vector to update with the result
  21010. * @param particle is the particle we are computed the direction for
  21011. */
  21012. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21013. /**
  21014. * Clones the current emitter and returns a copy of it
  21015. * @returns the new emitter
  21016. */
  21017. clone(): CylinderDirectedParticleEmitter;
  21018. /**
  21019. * Called by the GPUParticleSystem to setup the update shader
  21020. * @param effect defines the update shader
  21021. */
  21022. applyToShader(effect: Effect): void;
  21023. /**
  21024. * Returns a string to use to update the GPU particles update shader
  21025. * @returns a string containng the defines string
  21026. */
  21027. getEffectDefines(): string;
  21028. /**
  21029. * Returns the string "CylinderDirectedParticleEmitter"
  21030. * @returns a string containing the class name
  21031. */
  21032. getClassName(): string;
  21033. /**
  21034. * Serializes the particle system to a JSON object.
  21035. * @returns the JSON object
  21036. */
  21037. serialize(): any;
  21038. /**
  21039. * Parse properties from a JSON object
  21040. * @param serializationObject defines the JSON object
  21041. */
  21042. parse(serializationObject: any): void;
  21043. }
  21044. }
  21045. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  21046. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21047. import { Effect } from "babylonjs/Materials/effect";
  21048. import { Particle } from "babylonjs/Particles/particle";
  21049. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21050. /**
  21051. * Particle emitter emitting particles from the inside of a hemisphere.
  21052. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  21053. */
  21054. export class HemisphericParticleEmitter implements IParticleEmitterType {
  21055. /**
  21056. * The radius of the emission hemisphere.
  21057. */
  21058. radius: number;
  21059. /**
  21060. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21061. */
  21062. radiusRange: number;
  21063. /**
  21064. * How much to randomize the particle direction [0-1].
  21065. */
  21066. directionRandomizer: number;
  21067. /**
  21068. * Creates a new instance HemisphericParticleEmitter
  21069. * @param radius the radius of the emission hemisphere (1 by default)
  21070. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21071. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21072. */
  21073. constructor(
  21074. /**
  21075. * The radius of the emission hemisphere.
  21076. */
  21077. radius?: number,
  21078. /**
  21079. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21080. */
  21081. radiusRange?: number,
  21082. /**
  21083. * How much to randomize the particle direction [0-1].
  21084. */
  21085. directionRandomizer?: number);
  21086. /**
  21087. * Called by the particle System when the direction is computed for the created particle.
  21088. * @param worldMatrix is the world matrix of the particle system
  21089. * @param directionToUpdate is the direction vector to update with the result
  21090. * @param particle is the particle we are computed the direction for
  21091. */
  21092. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21093. /**
  21094. * Called by the particle System when the position is computed for the created particle.
  21095. * @param worldMatrix is the world matrix of the particle system
  21096. * @param positionToUpdate is the position vector to update with the result
  21097. * @param particle is the particle we are computed the position for
  21098. */
  21099. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21100. /**
  21101. * Clones the current emitter and returns a copy of it
  21102. * @returns the new emitter
  21103. */
  21104. clone(): HemisphericParticleEmitter;
  21105. /**
  21106. * Called by the GPUParticleSystem to setup the update shader
  21107. * @param effect defines the update shader
  21108. */
  21109. applyToShader(effect: Effect): void;
  21110. /**
  21111. * Returns a string to use to update the GPU particles update shader
  21112. * @returns a string containng the defines string
  21113. */
  21114. getEffectDefines(): string;
  21115. /**
  21116. * Returns the string "HemisphericParticleEmitter"
  21117. * @returns a string containing the class name
  21118. */
  21119. getClassName(): string;
  21120. /**
  21121. * Serializes the particle system to a JSON object.
  21122. * @returns the JSON object
  21123. */
  21124. serialize(): any;
  21125. /**
  21126. * Parse properties from a JSON object
  21127. * @param serializationObject defines the JSON object
  21128. */
  21129. parse(serializationObject: any): void;
  21130. }
  21131. }
  21132. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  21133. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21134. import { Effect } from "babylonjs/Materials/effect";
  21135. import { Particle } from "babylonjs/Particles/particle";
  21136. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21137. /**
  21138. * Particle emitter emitting particles from a point.
  21139. * It emits the particles randomly between 2 given directions.
  21140. */
  21141. export class PointParticleEmitter implements IParticleEmitterType {
  21142. /**
  21143. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21144. */
  21145. direction1: Vector3;
  21146. /**
  21147. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21148. */
  21149. direction2: Vector3;
  21150. /**
  21151. * Creates a new instance PointParticleEmitter
  21152. */
  21153. constructor();
  21154. /**
  21155. * Called by the particle System when the direction is computed for the created particle.
  21156. * @param worldMatrix is the world matrix of the particle system
  21157. * @param directionToUpdate is the direction vector to update with the result
  21158. * @param particle is the particle we are computed the direction for
  21159. */
  21160. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21161. /**
  21162. * Called by the particle System when the position is computed for the created particle.
  21163. * @param worldMatrix is the world matrix of the particle system
  21164. * @param positionToUpdate is the position vector to update with the result
  21165. * @param particle is the particle we are computed the position for
  21166. */
  21167. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21168. /**
  21169. * Clones the current emitter and returns a copy of it
  21170. * @returns the new emitter
  21171. */
  21172. clone(): PointParticleEmitter;
  21173. /**
  21174. * Called by the GPUParticleSystem to setup the update shader
  21175. * @param effect defines the update shader
  21176. */
  21177. applyToShader(effect: Effect): void;
  21178. /**
  21179. * Returns a string to use to update the GPU particles update shader
  21180. * @returns a string containng the defines string
  21181. */
  21182. getEffectDefines(): string;
  21183. /**
  21184. * Returns the string "PointParticleEmitter"
  21185. * @returns a string containing the class name
  21186. */
  21187. getClassName(): string;
  21188. /**
  21189. * Serializes the particle system to a JSON object.
  21190. * @returns the JSON object
  21191. */
  21192. serialize(): any;
  21193. /**
  21194. * Parse properties from a JSON object
  21195. * @param serializationObject defines the JSON object
  21196. */
  21197. parse(serializationObject: any): void;
  21198. }
  21199. }
  21200. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  21201. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21202. import { Effect } from "babylonjs/Materials/effect";
  21203. import { Particle } from "babylonjs/Particles/particle";
  21204. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21205. /**
  21206. * Particle emitter emitting particles from the inside of a sphere.
  21207. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  21208. */
  21209. export class SphereParticleEmitter implements IParticleEmitterType {
  21210. /**
  21211. * The radius of the emission sphere.
  21212. */
  21213. radius: number;
  21214. /**
  21215. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21216. */
  21217. radiusRange: number;
  21218. /**
  21219. * How much to randomize the particle direction [0-1].
  21220. */
  21221. directionRandomizer: number;
  21222. /**
  21223. * Creates a new instance SphereParticleEmitter
  21224. * @param radius the radius of the emission sphere (1 by default)
  21225. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21226. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21227. */
  21228. constructor(
  21229. /**
  21230. * The radius of the emission sphere.
  21231. */
  21232. radius?: number,
  21233. /**
  21234. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21235. */
  21236. radiusRange?: number,
  21237. /**
  21238. * How much to randomize the particle direction [0-1].
  21239. */
  21240. directionRandomizer?: number);
  21241. /**
  21242. * Called by the particle System when the direction is computed for the created particle.
  21243. * @param worldMatrix is the world matrix of the particle system
  21244. * @param directionToUpdate is the direction vector to update with the result
  21245. * @param particle is the particle we are computed the direction for
  21246. */
  21247. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21248. /**
  21249. * Called by the particle System when the position is computed for the created particle.
  21250. * @param worldMatrix is the world matrix of the particle system
  21251. * @param positionToUpdate is the position vector to update with the result
  21252. * @param particle is the particle we are computed the position for
  21253. */
  21254. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21255. /**
  21256. * Clones the current emitter and returns a copy of it
  21257. * @returns the new emitter
  21258. */
  21259. clone(): SphereParticleEmitter;
  21260. /**
  21261. * Called by the GPUParticleSystem to setup the update shader
  21262. * @param effect defines the update shader
  21263. */
  21264. applyToShader(effect: Effect): void;
  21265. /**
  21266. * Returns a string to use to update the GPU particles update shader
  21267. * @returns a string containng the defines string
  21268. */
  21269. getEffectDefines(): string;
  21270. /**
  21271. * Returns the string "SphereParticleEmitter"
  21272. * @returns a string containing the class name
  21273. */
  21274. getClassName(): string;
  21275. /**
  21276. * Serializes the particle system to a JSON object.
  21277. * @returns the JSON object
  21278. */
  21279. serialize(): any;
  21280. /**
  21281. * Parse properties from a JSON object
  21282. * @param serializationObject defines the JSON object
  21283. */
  21284. parse(serializationObject: any): void;
  21285. }
  21286. /**
  21287. * Particle emitter emitting particles from the inside of a sphere.
  21288. * It emits the particles randomly between two vectors.
  21289. */
  21290. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  21291. /**
  21292. * The min limit of the emission direction.
  21293. */
  21294. direction1: Vector3;
  21295. /**
  21296. * The max limit of the emission direction.
  21297. */
  21298. direction2: Vector3;
  21299. /**
  21300. * Creates a new instance SphereDirectedParticleEmitter
  21301. * @param radius the radius of the emission sphere (1 by default)
  21302. * @param direction1 the min limit of the emission direction (up vector by default)
  21303. * @param direction2 the max limit of the emission direction (up vector by default)
  21304. */
  21305. constructor(radius?: number,
  21306. /**
  21307. * The min limit of the emission direction.
  21308. */
  21309. direction1?: Vector3,
  21310. /**
  21311. * The max limit of the emission direction.
  21312. */
  21313. direction2?: Vector3);
  21314. /**
  21315. * Called by the particle System when the direction is computed for the created particle.
  21316. * @param worldMatrix is the world matrix of the particle system
  21317. * @param directionToUpdate is the direction vector to update with the result
  21318. * @param particle is the particle we are computed the direction for
  21319. */
  21320. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21321. /**
  21322. * Clones the current emitter and returns a copy of it
  21323. * @returns the new emitter
  21324. */
  21325. clone(): SphereDirectedParticleEmitter;
  21326. /**
  21327. * Called by the GPUParticleSystem to setup the update shader
  21328. * @param effect defines the update shader
  21329. */
  21330. applyToShader(effect: Effect): void;
  21331. /**
  21332. * Returns a string to use to update the GPU particles update shader
  21333. * @returns a string containng the defines string
  21334. */
  21335. getEffectDefines(): string;
  21336. /**
  21337. * Returns the string "SphereDirectedParticleEmitter"
  21338. * @returns a string containing the class name
  21339. */
  21340. getClassName(): string;
  21341. /**
  21342. * Serializes the particle system to a JSON object.
  21343. * @returns the JSON object
  21344. */
  21345. serialize(): any;
  21346. /**
  21347. * Parse properties from a JSON object
  21348. * @param serializationObject defines the JSON object
  21349. */
  21350. parse(serializationObject: any): void;
  21351. }
  21352. }
  21353. declare module "babylonjs/Particles/EmitterTypes/index" {
  21354. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  21355. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  21356. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  21357. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  21358. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21359. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  21360. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  21361. }
  21362. declare module "babylonjs/Particles/IParticleSystem" {
  21363. import { Nullable } from "babylonjs/types";
  21364. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  21365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21366. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21367. import { Texture } from "babylonjs/Materials/Textures/texture";
  21368. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  21369. import { Scene } from "babylonjs/scene";
  21370. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  21371. import { Animation } from "babylonjs/Animations/animation";
  21372. /**
  21373. * Interface representing a particle system in Babylon.js.
  21374. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  21375. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  21376. */
  21377. export interface IParticleSystem {
  21378. /**
  21379. * List of animations used by the particle system.
  21380. */
  21381. animations: Animation[];
  21382. /**
  21383. * The id of the Particle system.
  21384. */
  21385. id: string;
  21386. /**
  21387. * The name of the Particle system.
  21388. */
  21389. name: string;
  21390. /**
  21391. * The emitter represents the Mesh or position we are attaching the particle system to.
  21392. */
  21393. emitter: Nullable<AbstractMesh | Vector3>;
  21394. /**
  21395. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  21396. */
  21397. isBillboardBased: boolean;
  21398. /**
  21399. * The rendering group used by the Particle system to chose when to render.
  21400. */
  21401. renderingGroupId: number;
  21402. /**
  21403. * The layer mask we are rendering the particles through.
  21404. */
  21405. layerMask: number;
  21406. /**
  21407. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  21408. */
  21409. updateSpeed: number;
  21410. /**
  21411. * The amount of time the particle system is running (depends of the overall update speed).
  21412. */
  21413. targetStopDuration: number;
  21414. /**
  21415. * The texture used to render each particle. (this can be a spritesheet)
  21416. */
  21417. particleTexture: Nullable<Texture>;
  21418. /**
  21419. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  21420. */
  21421. blendMode: number;
  21422. /**
  21423. * Minimum life time of emitting particles.
  21424. */
  21425. minLifeTime: number;
  21426. /**
  21427. * Maximum life time of emitting particles.
  21428. */
  21429. maxLifeTime: number;
  21430. /**
  21431. * Minimum Size of emitting particles.
  21432. */
  21433. minSize: number;
  21434. /**
  21435. * Maximum Size of emitting particles.
  21436. */
  21437. maxSize: number;
  21438. /**
  21439. * Minimum scale of emitting particles on X axis.
  21440. */
  21441. minScaleX: number;
  21442. /**
  21443. * Maximum scale of emitting particles on X axis.
  21444. */
  21445. maxScaleX: number;
  21446. /**
  21447. * Minimum scale of emitting particles on Y axis.
  21448. */
  21449. minScaleY: number;
  21450. /**
  21451. * Maximum scale of emitting particles on Y axis.
  21452. */
  21453. maxScaleY: number;
  21454. /**
  21455. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21456. */
  21457. color1: Color4;
  21458. /**
  21459. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21460. */
  21461. color2: Color4;
  21462. /**
  21463. * Color the particle will have at the end of its lifetime.
  21464. */
  21465. colorDead: Color4;
  21466. /**
  21467. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  21468. */
  21469. emitRate: number;
  21470. /**
  21471. * You can use gravity if you want to give an orientation to your particles.
  21472. */
  21473. gravity: Vector3;
  21474. /**
  21475. * Minimum power of emitting particles.
  21476. */
  21477. minEmitPower: number;
  21478. /**
  21479. * Maximum power of emitting particles.
  21480. */
  21481. maxEmitPower: number;
  21482. /**
  21483. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  21484. */
  21485. minAngularSpeed: number;
  21486. /**
  21487. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  21488. */
  21489. maxAngularSpeed: number;
  21490. /**
  21491. * Gets or sets the minimal initial rotation in radians.
  21492. */
  21493. minInitialRotation: number;
  21494. /**
  21495. * Gets or sets the maximal initial rotation in radians.
  21496. */
  21497. maxInitialRotation: number;
  21498. /**
  21499. * The particle emitter type defines the emitter used by the particle system.
  21500. * It can be for example box, sphere, or cone...
  21501. */
  21502. particleEmitterType: Nullable<IParticleEmitterType>;
  21503. /**
  21504. * Defines the delay in milliseconds before starting the system (0 by default)
  21505. */
  21506. startDelay: number;
  21507. /**
  21508. * 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
  21509. */
  21510. preWarmCycles: number;
  21511. /**
  21512. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  21513. */
  21514. preWarmStepOffset: number;
  21515. /**
  21516. * 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)
  21517. */
  21518. spriteCellChangeSpeed: number;
  21519. /**
  21520. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  21521. */
  21522. startSpriteCellID: number;
  21523. /**
  21524. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  21525. */
  21526. endSpriteCellID: number;
  21527. /**
  21528. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  21529. */
  21530. spriteCellWidth: number;
  21531. /**
  21532. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  21533. */
  21534. spriteCellHeight: number;
  21535. /**
  21536. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  21537. */
  21538. spriteRandomStartCell: boolean;
  21539. /**
  21540. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  21541. */
  21542. isAnimationSheetEnabled: boolean;
  21543. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  21544. translationPivot: Vector2;
  21545. /**
  21546. * Gets or sets a texture used to add random noise to particle positions
  21547. */
  21548. noiseTexture: Nullable<BaseTexture>;
  21549. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21550. noiseStrength: Vector3;
  21551. /**
  21552. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21553. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  21554. */
  21555. billboardMode: number;
  21556. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21557. limitVelocityDamping: number;
  21558. /**
  21559. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  21560. */
  21561. beginAnimationOnStart: boolean;
  21562. /**
  21563. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21564. */
  21565. beginAnimationFrom: number;
  21566. /**
  21567. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21568. */
  21569. beginAnimationTo: number;
  21570. /**
  21571. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21572. */
  21573. beginAnimationLoop: boolean;
  21574. /**
  21575. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21576. */
  21577. disposeOnStop: boolean;
  21578. /**
  21579. * Gets the maximum number of particles active at the same time.
  21580. * @returns The max number of active particles.
  21581. */
  21582. getCapacity(): number;
  21583. /**
  21584. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21585. * @returns True if it has been started, otherwise false.
  21586. */
  21587. isStarted(): boolean;
  21588. /**
  21589. * Animates the particle system for this frame.
  21590. */
  21591. animate(): void;
  21592. /**
  21593. * Renders the particle system in its current state.
  21594. * @returns the current number of particles
  21595. */
  21596. render(): number;
  21597. /**
  21598. * Dispose the particle system and frees its associated resources.
  21599. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21600. */
  21601. dispose(disposeTexture?: boolean): void;
  21602. /**
  21603. * Clones the particle system.
  21604. * @param name The name of the cloned object
  21605. * @param newEmitter The new emitter to use
  21606. * @returns the cloned particle system
  21607. */
  21608. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21609. /**
  21610. * Serializes the particle system to a JSON object.
  21611. * @returns the JSON object
  21612. */
  21613. serialize(): any;
  21614. /**
  21615. * Rebuild the particle system
  21616. */
  21617. rebuild(): void;
  21618. /**
  21619. * Starts the particle system and begins to emit
  21620. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21621. */
  21622. start(delay?: number): void;
  21623. /**
  21624. * Stops the particle system.
  21625. */
  21626. stop(): void;
  21627. /**
  21628. * Remove all active particles
  21629. */
  21630. reset(): void;
  21631. /**
  21632. * Is this system ready to be used/rendered
  21633. * @return true if the system is ready
  21634. */
  21635. isReady(): boolean;
  21636. /**
  21637. * Adds a new color gradient
  21638. * @param gradient defines the gradient to use (between 0 and 1)
  21639. * @param color1 defines the color to affect to the specified gradient
  21640. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21641. * @returns the current particle system
  21642. */
  21643. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21644. /**
  21645. * Remove a specific color gradient
  21646. * @param gradient defines the gradient to remove
  21647. * @returns the current particle system
  21648. */
  21649. removeColorGradient(gradient: number): IParticleSystem;
  21650. /**
  21651. * Adds a new size gradient
  21652. * @param gradient defines the gradient to use (between 0 and 1)
  21653. * @param factor defines the size factor to affect to the specified gradient
  21654. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21655. * @returns the current particle system
  21656. */
  21657. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21658. /**
  21659. * Remove a specific size gradient
  21660. * @param gradient defines the gradient to remove
  21661. * @returns the current particle system
  21662. */
  21663. removeSizeGradient(gradient: number): IParticleSystem;
  21664. /**
  21665. * Gets the current list of color gradients.
  21666. * You must use addColorGradient and removeColorGradient to udpate this list
  21667. * @returns the list of color gradients
  21668. */
  21669. getColorGradients(): Nullable<Array<ColorGradient>>;
  21670. /**
  21671. * Gets the current list of size gradients.
  21672. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21673. * @returns the list of size gradients
  21674. */
  21675. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21676. /**
  21677. * Gets the current list of angular speed gradients.
  21678. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21679. * @returns the list of angular speed gradients
  21680. */
  21681. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21682. /**
  21683. * Adds a new angular speed gradient
  21684. * @param gradient defines the gradient to use (between 0 and 1)
  21685. * @param factor defines the angular speed to affect to the specified gradient
  21686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21687. * @returns the current particle system
  21688. */
  21689. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21690. /**
  21691. * Remove a specific angular speed gradient
  21692. * @param gradient defines the gradient to remove
  21693. * @returns the current particle system
  21694. */
  21695. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21696. /**
  21697. * Gets the current list of velocity gradients.
  21698. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21699. * @returns the list of velocity gradients
  21700. */
  21701. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21702. /**
  21703. * Adds a new velocity gradient
  21704. * @param gradient defines the gradient to use (between 0 and 1)
  21705. * @param factor defines the velocity to affect to the specified gradient
  21706. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21707. * @returns the current particle system
  21708. */
  21709. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21710. /**
  21711. * Remove a specific velocity gradient
  21712. * @param gradient defines the gradient to remove
  21713. * @returns the current particle system
  21714. */
  21715. removeVelocityGradient(gradient: number): IParticleSystem;
  21716. /**
  21717. * Gets the current list of limit velocity gradients.
  21718. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21719. * @returns the list of limit velocity gradients
  21720. */
  21721. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21722. /**
  21723. * Adds a new limit velocity gradient
  21724. * @param gradient defines the gradient to use (between 0 and 1)
  21725. * @param factor defines the limit velocity to affect to the specified gradient
  21726. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21727. * @returns the current particle system
  21728. */
  21729. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21730. /**
  21731. * Remove a specific limit velocity gradient
  21732. * @param gradient defines the gradient to remove
  21733. * @returns the current particle system
  21734. */
  21735. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21736. /**
  21737. * Adds a new drag gradient
  21738. * @param gradient defines the gradient to use (between 0 and 1)
  21739. * @param factor defines the drag to affect to the specified gradient
  21740. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21741. * @returns the current particle system
  21742. */
  21743. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21744. /**
  21745. * Remove a specific drag gradient
  21746. * @param gradient defines the gradient to remove
  21747. * @returns the current particle system
  21748. */
  21749. removeDragGradient(gradient: number): IParticleSystem;
  21750. /**
  21751. * Gets the current list of drag gradients.
  21752. * You must use addDragGradient and removeDragGradient to udpate this list
  21753. * @returns the list of drag gradients
  21754. */
  21755. getDragGradients(): Nullable<Array<FactorGradient>>;
  21756. /**
  21757. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21758. * @param gradient defines the gradient to use (between 0 and 1)
  21759. * @param factor defines the emit rate to affect to the specified gradient
  21760. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21761. * @returns the current particle system
  21762. */
  21763. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21764. /**
  21765. * Remove a specific emit rate gradient
  21766. * @param gradient defines the gradient to remove
  21767. * @returns the current particle system
  21768. */
  21769. removeEmitRateGradient(gradient: number): IParticleSystem;
  21770. /**
  21771. * Gets the current list of emit rate gradients.
  21772. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21773. * @returns the list of emit rate gradients
  21774. */
  21775. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21776. /**
  21777. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21778. * @param gradient defines the gradient to use (between 0 and 1)
  21779. * @param factor defines the start size to affect to the specified gradient
  21780. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21781. * @returns the current particle system
  21782. */
  21783. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21784. /**
  21785. * Remove a specific start size gradient
  21786. * @param gradient defines the gradient to remove
  21787. * @returns the current particle system
  21788. */
  21789. removeStartSizeGradient(gradient: number): IParticleSystem;
  21790. /**
  21791. * Gets the current list of start size gradients.
  21792. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21793. * @returns the list of start size gradients
  21794. */
  21795. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21796. /**
  21797. * Adds a new life time gradient
  21798. * @param gradient defines the gradient to use (between 0 and 1)
  21799. * @param factor defines the life time factor to affect to the specified gradient
  21800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21801. * @returns the current particle system
  21802. */
  21803. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21804. /**
  21805. * Remove a specific life time gradient
  21806. * @param gradient defines the gradient to remove
  21807. * @returns the current particle system
  21808. */
  21809. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21810. /**
  21811. * Gets the current list of life time gradients.
  21812. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21813. * @returns the list of life time gradients
  21814. */
  21815. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21816. /**
  21817. * Gets the current list of color gradients.
  21818. * You must use addColorGradient and removeColorGradient to udpate this list
  21819. * @returns the list of color gradients
  21820. */
  21821. getColorGradients(): Nullable<Array<ColorGradient>>;
  21822. /**
  21823. * Adds a new ramp gradient used to remap particle colors
  21824. * @param gradient defines the gradient to use (between 0 and 1)
  21825. * @param color defines the color to affect to the specified gradient
  21826. * @returns the current particle system
  21827. */
  21828. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21829. /**
  21830. * Gets the current list of ramp gradients.
  21831. * You must use addRampGradient and removeRampGradient to udpate this list
  21832. * @returns the list of ramp gradients
  21833. */
  21834. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21835. /** Gets or sets a boolean indicating that ramp gradients must be used
  21836. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21837. */
  21838. useRampGradients: boolean;
  21839. /**
  21840. * Adds a new color remap gradient
  21841. * @param gradient defines the gradient to use (between 0 and 1)
  21842. * @param min defines the color remap minimal range
  21843. * @param max defines the color remap maximal range
  21844. * @returns the current particle system
  21845. */
  21846. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21847. /**
  21848. * Gets the current list of color remap gradients.
  21849. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21850. * @returns the list of color remap gradients
  21851. */
  21852. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21853. /**
  21854. * Adds a new alpha remap gradient
  21855. * @param gradient defines the gradient to use (between 0 and 1)
  21856. * @param min defines the alpha remap minimal range
  21857. * @param max defines the alpha remap maximal range
  21858. * @returns the current particle system
  21859. */
  21860. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21861. /**
  21862. * Gets the current list of alpha remap gradients.
  21863. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21864. * @returns the list of alpha remap gradients
  21865. */
  21866. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21867. /**
  21868. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21869. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21870. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21871. * @returns the emitter
  21872. */
  21873. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21874. /**
  21875. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21876. * @param radius The radius of the hemisphere to emit from
  21877. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21878. * @returns the emitter
  21879. */
  21880. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21881. /**
  21882. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21883. * @param radius The radius of the sphere to emit from
  21884. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21885. * @returns the emitter
  21886. */
  21887. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21888. /**
  21889. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21890. * @param radius The radius of the sphere to emit from
  21891. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21892. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21893. * @returns the emitter
  21894. */
  21895. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21896. /**
  21897. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21898. * @param radius The radius of the emission cylinder
  21899. * @param height The height of the emission cylinder
  21900. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21901. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21902. * @returns the emitter
  21903. */
  21904. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21905. /**
  21906. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21907. * @param radius The radius of the cylinder to emit from
  21908. * @param height The height of the emission cylinder
  21909. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21910. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21911. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21912. * @returns the emitter
  21913. */
  21914. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21915. /**
  21916. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21917. * @param radius The radius of the cone to emit from
  21918. * @param angle The base angle of the cone
  21919. * @returns the emitter
  21920. */
  21921. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21922. /**
  21923. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21924. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21925. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21926. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21927. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21928. * @returns the emitter
  21929. */
  21930. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21931. /**
  21932. * Get hosting scene
  21933. * @returns the scene
  21934. */
  21935. getScene(): Scene;
  21936. }
  21937. }
  21938. declare module "babylonjs/Shaders/line.fragment" {
  21939. /** @hidden */
  21940. export var linePixelShader: {
  21941. name: string;
  21942. shader: string;
  21943. };
  21944. }
  21945. declare module "babylonjs/Shaders/line.vertex" {
  21946. /** @hidden */
  21947. export var lineVertexShader: {
  21948. name: string;
  21949. shader: string;
  21950. };
  21951. }
  21952. declare module "babylonjs/Rendering/edgesRenderer" {
  21953. import { Nullable } from "babylonjs/types";
  21954. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21956. import { Vector3 } from "babylonjs/Maths/math";
  21957. import { IDisposable } from "babylonjs/scene";
  21958. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  21959. import "babylonjs/Shaders/line.fragment";
  21960. import "babylonjs/Shaders/line.vertex";
  21961. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21962. module "babylonjs/Meshes/abstractMesh" {
  21963. interface AbstractMesh {
  21964. /**
  21965. * Gets the edgesRenderer associated with the mesh
  21966. */
  21967. edgesRenderer: Nullable<EdgesRenderer>;
  21968. }
  21969. }
  21970. module "babylonjs/Meshes/linesMesh" {
  21971. interface LinesMesh {
  21972. /**
  21973. * Enables the edge rendering mode on the mesh.
  21974. * This mode makes the mesh edges visible
  21975. * @param epsilon defines the maximal distance between two angles to detect a face
  21976. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21977. * @returns the currentAbstractMesh
  21978. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21979. */
  21980. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21981. }
  21982. }
  21983. module "babylonjs/Meshes/linesMesh" {
  21984. interface InstancedLinesMesh {
  21985. /**
  21986. * Enables the edge rendering mode on the mesh.
  21987. * This mode makes the mesh edges visible
  21988. * @param epsilon defines the maximal distance between two angles to detect a face
  21989. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21990. * @returns the current InstancedLinesMesh
  21991. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21992. */
  21993. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21994. }
  21995. }
  21996. /**
  21997. * Defines the minimum contract an Edges renderer should follow.
  21998. */
  21999. export interface IEdgesRenderer extends IDisposable {
  22000. /**
  22001. * Gets or sets a boolean indicating if the edgesRenderer is active
  22002. */
  22003. isEnabled: boolean;
  22004. /**
  22005. * Renders the edges of the attached mesh,
  22006. */
  22007. render(): void;
  22008. /**
  22009. * Checks wether or not the edges renderer is ready to render.
  22010. * @return true if ready, otherwise false.
  22011. */
  22012. isReady(): boolean;
  22013. }
  22014. /**
  22015. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  22016. */
  22017. export class EdgesRenderer implements IEdgesRenderer {
  22018. /**
  22019. * Define the size of the edges with an orthographic camera
  22020. */
  22021. edgesWidthScalerForOrthographic: number;
  22022. /**
  22023. * Define the size of the edges with a perspective camera
  22024. */
  22025. edgesWidthScalerForPerspective: number;
  22026. protected _source: AbstractMesh;
  22027. protected _linesPositions: number[];
  22028. protected _linesNormals: number[];
  22029. protected _linesIndices: number[];
  22030. protected _epsilon: number;
  22031. protected _indicesCount: number;
  22032. protected _lineShader: ShaderMaterial;
  22033. protected _ib: DataBuffer;
  22034. protected _buffers: {
  22035. [key: string]: Nullable<VertexBuffer>;
  22036. };
  22037. protected _checkVerticesInsteadOfIndices: boolean;
  22038. private _meshRebuildObserver;
  22039. private _meshDisposeObserver;
  22040. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  22041. isEnabled: boolean;
  22042. /**
  22043. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  22044. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  22045. * @param source Mesh used to create edges
  22046. * @param epsilon sum of angles in adjacency to check for edge
  22047. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  22048. * @param generateEdgesLines - should generate Lines or only prepare resources.
  22049. */
  22050. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  22051. protected _prepareRessources(): void;
  22052. /** @hidden */
  22053. _rebuild(): void;
  22054. /**
  22055. * Releases the required resources for the edges renderer
  22056. */
  22057. dispose(): void;
  22058. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  22059. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  22060. /**
  22061. * Checks if the pair of p0 and p1 is en edge
  22062. * @param faceIndex
  22063. * @param edge
  22064. * @param faceNormals
  22065. * @param p0
  22066. * @param p1
  22067. * @private
  22068. */
  22069. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  22070. /**
  22071. * push line into the position, normal and index buffer
  22072. * @protected
  22073. */
  22074. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  22075. /**
  22076. * Generates lines edges from adjacencjes
  22077. * @private
  22078. */
  22079. _generateEdgesLines(): void;
  22080. /**
  22081. * Checks wether or not the edges renderer is ready to render.
  22082. * @return true if ready, otherwise false.
  22083. */
  22084. isReady(): boolean;
  22085. /**
  22086. * Renders the edges of the attached mesh,
  22087. */
  22088. render(): void;
  22089. }
  22090. /**
  22091. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  22092. */
  22093. export class LineEdgesRenderer extends EdgesRenderer {
  22094. /**
  22095. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  22096. * @param source LineMesh used to generate edges
  22097. * @param epsilon not important (specified angle for edge detection)
  22098. * @param checkVerticesInsteadOfIndices not important for LineMesh
  22099. */
  22100. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  22101. /**
  22102. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  22103. */
  22104. _generateEdgesLines(): void;
  22105. }
  22106. }
  22107. declare module "babylonjs/Rendering/renderingGroup" {
  22108. import { SmartArray } from "babylonjs/Misc/smartArray";
  22109. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22111. import { Nullable } from "babylonjs/types";
  22112. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22113. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  22114. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22115. import { Material } from "babylonjs/Materials/material";
  22116. import { Scene } from "babylonjs/scene";
  22117. /**
  22118. * This represents the object necessary to create a rendering group.
  22119. * This is exclusively used and created by the rendering manager.
  22120. * To modify the behavior, you use the available helpers in your scene or meshes.
  22121. * @hidden
  22122. */
  22123. export class RenderingGroup {
  22124. index: number;
  22125. private static _zeroVector;
  22126. private _scene;
  22127. private _opaqueSubMeshes;
  22128. private _transparentSubMeshes;
  22129. private _alphaTestSubMeshes;
  22130. private _depthOnlySubMeshes;
  22131. private _particleSystems;
  22132. private _spriteManagers;
  22133. private _opaqueSortCompareFn;
  22134. private _alphaTestSortCompareFn;
  22135. private _transparentSortCompareFn;
  22136. private _renderOpaque;
  22137. private _renderAlphaTest;
  22138. private _renderTransparent;
  22139. /** @hidden */
  22140. _edgesRenderers: SmartArray<IEdgesRenderer>;
  22141. onBeforeTransparentRendering: () => void;
  22142. /**
  22143. * Set the opaque sort comparison function.
  22144. * If null the sub meshes will be render in the order they were created
  22145. */
  22146. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22147. /**
  22148. * Set the alpha test sort comparison function.
  22149. * If null the sub meshes will be render in the order they were created
  22150. */
  22151. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22152. /**
  22153. * Set the transparent sort comparison function.
  22154. * If null the sub meshes will be render in the order they were created
  22155. */
  22156. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22157. /**
  22158. * Creates a new rendering group.
  22159. * @param index The rendering group index
  22160. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  22161. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  22162. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  22163. */
  22164. 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>);
  22165. /**
  22166. * Render all the sub meshes contained in the group.
  22167. * @param customRenderFunction Used to override the default render behaviour of the group.
  22168. * @returns true if rendered some submeshes.
  22169. */
  22170. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  22171. /**
  22172. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  22173. * @param subMeshes The submeshes to render
  22174. */
  22175. private renderOpaqueSorted;
  22176. /**
  22177. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  22178. * @param subMeshes The submeshes to render
  22179. */
  22180. private renderAlphaTestSorted;
  22181. /**
  22182. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  22183. * @param subMeshes The submeshes to render
  22184. */
  22185. private renderTransparentSorted;
  22186. /**
  22187. * Renders the submeshes in a specified order.
  22188. * @param subMeshes The submeshes to sort before render
  22189. * @param sortCompareFn The comparison function use to sort
  22190. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  22191. * @param transparent Specifies to activate blending if true
  22192. */
  22193. private static renderSorted;
  22194. /**
  22195. * Renders the submeshes in the order they were dispatched (no sort applied).
  22196. * @param subMeshes The submeshes to render
  22197. */
  22198. private static renderUnsorted;
  22199. /**
  22200. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22201. * are rendered back to front if in the same alpha index.
  22202. *
  22203. * @param a The first submesh
  22204. * @param b The second submesh
  22205. * @returns The result of the comparison
  22206. */
  22207. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  22208. /**
  22209. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22210. * are rendered back to front.
  22211. *
  22212. * @param a The first submesh
  22213. * @param b The second submesh
  22214. * @returns The result of the comparison
  22215. */
  22216. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  22217. /**
  22218. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22219. * are rendered front to back (prevent overdraw).
  22220. *
  22221. * @param a The first submesh
  22222. * @param b The second submesh
  22223. * @returns The result of the comparison
  22224. */
  22225. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  22226. /**
  22227. * Resets the different lists of submeshes to prepare a new frame.
  22228. */
  22229. prepare(): void;
  22230. dispose(): void;
  22231. /**
  22232. * Inserts the submesh in its correct queue depending on its material.
  22233. * @param subMesh The submesh to dispatch
  22234. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22235. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22236. */
  22237. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22238. dispatchSprites(spriteManager: ISpriteManager): void;
  22239. dispatchParticles(particleSystem: IParticleSystem): void;
  22240. private _renderParticles;
  22241. private _renderSprites;
  22242. }
  22243. }
  22244. declare module "babylonjs/Rendering/renderingManager" {
  22245. import { Nullable } from "babylonjs/types";
  22246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22247. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22248. import { SmartArray } from "babylonjs/Misc/smartArray";
  22249. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22250. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22251. import { Material } from "babylonjs/Materials/material";
  22252. import { Scene } from "babylonjs/scene";
  22253. import { Camera } from "babylonjs/Cameras/camera";
  22254. /**
  22255. * Interface describing the different options available in the rendering manager
  22256. * regarding Auto Clear between groups.
  22257. */
  22258. export interface IRenderingManagerAutoClearSetup {
  22259. /**
  22260. * Defines whether or not autoclear is enable.
  22261. */
  22262. autoClear: boolean;
  22263. /**
  22264. * Defines whether or not to autoclear the depth buffer.
  22265. */
  22266. depth: boolean;
  22267. /**
  22268. * Defines whether or not to autoclear the stencil buffer.
  22269. */
  22270. stencil: boolean;
  22271. }
  22272. /**
  22273. * This class is used by the onRenderingGroupObservable
  22274. */
  22275. export class RenderingGroupInfo {
  22276. /**
  22277. * The Scene that being rendered
  22278. */
  22279. scene: Scene;
  22280. /**
  22281. * The camera currently used for the rendering pass
  22282. */
  22283. camera: Nullable<Camera>;
  22284. /**
  22285. * The ID of the renderingGroup being processed
  22286. */
  22287. renderingGroupId: number;
  22288. }
  22289. /**
  22290. * This is the manager responsible of all the rendering for meshes sprites and particles.
  22291. * It is enable to manage the different groups as well as the different necessary sort functions.
  22292. * This should not be used directly aside of the few static configurations
  22293. */
  22294. export class RenderingManager {
  22295. /**
  22296. * The max id used for rendering groups (not included)
  22297. */
  22298. static MAX_RENDERINGGROUPS: number;
  22299. /**
  22300. * The min id used for rendering groups (included)
  22301. */
  22302. static MIN_RENDERINGGROUPS: number;
  22303. /**
  22304. * Used to globally prevent autoclearing scenes.
  22305. */
  22306. static AUTOCLEAR: boolean;
  22307. /**
  22308. * @hidden
  22309. */
  22310. _useSceneAutoClearSetup: boolean;
  22311. private _scene;
  22312. private _renderingGroups;
  22313. private _depthStencilBufferAlreadyCleaned;
  22314. private _autoClearDepthStencil;
  22315. private _customOpaqueSortCompareFn;
  22316. private _customAlphaTestSortCompareFn;
  22317. private _customTransparentSortCompareFn;
  22318. private _renderingGroupInfo;
  22319. /**
  22320. * Instantiates a new rendering group for a particular scene
  22321. * @param scene Defines the scene the groups belongs to
  22322. */
  22323. constructor(scene: Scene);
  22324. private _clearDepthStencilBuffer;
  22325. /**
  22326. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  22327. * @hidden
  22328. */
  22329. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  22330. /**
  22331. * Resets the different information of the group to prepare a new frame
  22332. * @hidden
  22333. */
  22334. reset(): void;
  22335. /**
  22336. * Dispose and release the group and its associated resources.
  22337. * @hidden
  22338. */
  22339. dispose(): void;
  22340. /**
  22341. * Clear the info related to rendering groups preventing retention points during dispose.
  22342. */
  22343. freeRenderingGroups(): void;
  22344. private _prepareRenderingGroup;
  22345. /**
  22346. * Add a sprite manager to the rendering manager in order to render it this frame.
  22347. * @param spriteManager Define the sprite manager to render
  22348. */
  22349. dispatchSprites(spriteManager: ISpriteManager): void;
  22350. /**
  22351. * Add a particle system to the rendering manager in order to render it this frame.
  22352. * @param particleSystem Define the particle system to render
  22353. */
  22354. dispatchParticles(particleSystem: IParticleSystem): void;
  22355. /**
  22356. * Add a submesh to the manager in order to render it this frame
  22357. * @param subMesh The submesh to dispatch
  22358. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22359. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22360. */
  22361. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22362. /**
  22363. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22364. * This allowed control for front to back rendering or reversly depending of the special needs.
  22365. *
  22366. * @param renderingGroupId The rendering group id corresponding to its index
  22367. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22368. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22369. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22370. */
  22371. 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;
  22372. /**
  22373. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22374. *
  22375. * @param renderingGroupId The rendering group id corresponding to its index
  22376. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22377. * @param depth Automatically clears depth between groups if true and autoClear is true.
  22378. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  22379. */
  22380. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  22381. /**
  22382. * Gets the current auto clear configuration for one rendering group of the rendering
  22383. * manager.
  22384. * @param index the rendering group index to get the information for
  22385. * @returns The auto clear setup for the requested rendering group
  22386. */
  22387. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  22388. }
  22389. }
  22390. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  22391. import { Observable } from "babylonjs/Misc/observable";
  22392. import { SmartArray } from "babylonjs/Misc/smartArray";
  22393. import { Nullable } from "babylonjs/types";
  22394. import { Camera } from "babylonjs/Cameras/camera";
  22395. import { Scene } from "babylonjs/scene";
  22396. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  22397. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  22398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22399. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22400. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22401. import { Texture } from "babylonjs/Materials/Textures/texture";
  22402. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  22403. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  22404. import "babylonjs/Engines/Extensions/engine.renderTarget";
  22405. import { Engine } from "babylonjs/Engines/engine";
  22406. /**
  22407. * This Helps creating a texture that will be created from a camera in your scene.
  22408. * It is basically a dynamic texture that could be used to create special effects for instance.
  22409. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  22410. */
  22411. export class RenderTargetTexture extends Texture {
  22412. isCube: boolean;
  22413. /**
  22414. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  22415. */
  22416. static readonly REFRESHRATE_RENDER_ONCE: number;
  22417. /**
  22418. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  22419. */
  22420. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  22421. /**
  22422. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  22423. * the central point of your effect and can save a lot of performances.
  22424. */
  22425. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  22426. /**
  22427. * Use this predicate to dynamically define the list of mesh you want to render.
  22428. * If set, the renderList property will be overwritten.
  22429. */
  22430. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  22431. private _renderList;
  22432. /**
  22433. * Use this list to define the list of mesh you want to render.
  22434. */
  22435. renderList: Nullable<Array<AbstractMesh>>;
  22436. private _hookArray;
  22437. /**
  22438. * Define if particles should be rendered in your texture.
  22439. */
  22440. renderParticles: boolean;
  22441. /**
  22442. * Define if sprites should be rendered in your texture.
  22443. */
  22444. renderSprites: boolean;
  22445. /**
  22446. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  22447. */
  22448. coordinatesMode: number;
  22449. /**
  22450. * Define the camera used to render the texture.
  22451. */
  22452. activeCamera: Nullable<Camera>;
  22453. /**
  22454. * Override the render function of the texture with your own one.
  22455. */
  22456. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  22457. /**
  22458. * Define if camera post processes should be use while rendering the texture.
  22459. */
  22460. useCameraPostProcesses: boolean;
  22461. /**
  22462. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  22463. */
  22464. ignoreCameraViewport: boolean;
  22465. private _postProcessManager;
  22466. private _postProcesses;
  22467. private _resizeObserver;
  22468. /**
  22469. * An event triggered when the texture is unbind.
  22470. */
  22471. onBeforeBindObservable: Observable<RenderTargetTexture>;
  22472. /**
  22473. * An event triggered when the texture is unbind.
  22474. */
  22475. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  22476. private _onAfterUnbindObserver;
  22477. /**
  22478. * Set a after unbind callback in the texture.
  22479. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  22480. */
  22481. onAfterUnbind: () => void;
  22482. /**
  22483. * An event triggered before rendering the texture
  22484. */
  22485. onBeforeRenderObservable: Observable<number>;
  22486. private _onBeforeRenderObserver;
  22487. /**
  22488. * Set a before render callback in the texture.
  22489. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  22490. */
  22491. onBeforeRender: (faceIndex: number) => void;
  22492. /**
  22493. * An event triggered after rendering the texture
  22494. */
  22495. onAfterRenderObservable: Observable<number>;
  22496. private _onAfterRenderObserver;
  22497. /**
  22498. * Set a after render callback in the texture.
  22499. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  22500. */
  22501. onAfterRender: (faceIndex: number) => void;
  22502. /**
  22503. * An event triggered after the texture clear
  22504. */
  22505. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  22506. private _onClearObserver;
  22507. /**
  22508. * Set a clear callback in the texture.
  22509. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  22510. */
  22511. onClear: (Engine: Engine) => void;
  22512. /**
  22513. * Define the clear color of the Render Target if it should be different from the scene.
  22514. */
  22515. clearColor: Color4;
  22516. protected _size: number | {
  22517. width: number;
  22518. height: number;
  22519. };
  22520. protected _initialSizeParameter: number | {
  22521. width: number;
  22522. height: number;
  22523. } | {
  22524. ratio: number;
  22525. };
  22526. protected _sizeRatio: Nullable<number>;
  22527. /** @hidden */
  22528. _generateMipMaps: boolean;
  22529. protected _renderingManager: RenderingManager;
  22530. /** @hidden */
  22531. _waitingRenderList: string[];
  22532. protected _doNotChangeAspectRatio: boolean;
  22533. protected _currentRefreshId: number;
  22534. protected _refreshRate: number;
  22535. protected _textureMatrix: Matrix;
  22536. protected _samples: number;
  22537. protected _renderTargetOptions: RenderTargetCreationOptions;
  22538. /**
  22539. * Gets render target creation options that were used.
  22540. */
  22541. readonly renderTargetOptions: RenderTargetCreationOptions;
  22542. protected _engine: Engine;
  22543. protected _onRatioRescale(): void;
  22544. /**
  22545. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  22546. * It must define where the camera used to render the texture is set
  22547. */
  22548. boundingBoxPosition: Vector3;
  22549. private _boundingBoxSize;
  22550. /**
  22551. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  22552. * When defined, the cubemap will switch to local mode
  22553. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  22554. * @example https://www.babylonjs-playground.com/#RNASML
  22555. */
  22556. boundingBoxSize: Vector3;
  22557. /**
  22558. * In case the RTT has been created with a depth texture, get the associated
  22559. * depth texture.
  22560. * Otherwise, return null.
  22561. */
  22562. depthStencilTexture: Nullable<InternalTexture>;
  22563. /**
  22564. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  22565. * or used a shadow, depth texture...
  22566. * @param name The friendly name of the texture
  22567. * @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)
  22568. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  22569. * @param generateMipMaps True if mip maps need to be generated after render.
  22570. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  22571. * @param type The type of the buffer in the RTT (int, half float, float...)
  22572. * @param isCube True if a cube texture needs to be created
  22573. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  22574. * @param generateDepthBuffer True to generate a depth buffer
  22575. * @param generateStencilBuffer True to generate a stencil buffer
  22576. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  22577. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  22578. * @param delayAllocation if the texture allocation should be delayed (default: false)
  22579. */
  22580. constructor(name: string, size: number | {
  22581. width: number;
  22582. height: number;
  22583. } | {
  22584. ratio: number;
  22585. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  22586. /**
  22587. * Creates a depth stencil texture.
  22588. * This is only available in WebGL 2 or with the depth texture extension available.
  22589. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  22590. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  22591. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  22592. */
  22593. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  22594. private _processSizeParameter;
  22595. /**
  22596. * Define the number of samples to use in case of MSAA.
  22597. * It defaults to one meaning no MSAA has been enabled.
  22598. */
  22599. samples: number;
  22600. /**
  22601. * Resets the refresh counter of the texture and start bak from scratch.
  22602. * Could be useful to regenerate the texture if it is setup to render only once.
  22603. */
  22604. resetRefreshCounter(): void;
  22605. /**
  22606. * Define the refresh rate of the texture or the rendering frequency.
  22607. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  22608. */
  22609. refreshRate: number;
  22610. /**
  22611. * Adds a post process to the render target rendering passes.
  22612. * @param postProcess define the post process to add
  22613. */
  22614. addPostProcess(postProcess: PostProcess): void;
  22615. /**
  22616. * Clear all the post processes attached to the render target
  22617. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22618. */
  22619. clearPostProcesses(dispose?: boolean): void;
  22620. /**
  22621. * Remove one of the post process from the list of attached post processes to the texture
  22622. * @param postProcess define the post process to remove from the list
  22623. */
  22624. removePostProcess(postProcess: PostProcess): void;
  22625. /** @hidden */
  22626. _shouldRender(): boolean;
  22627. /**
  22628. * Gets the actual render size of the texture.
  22629. * @returns the width of the render size
  22630. */
  22631. getRenderSize(): number;
  22632. /**
  22633. * Gets the actual render width of the texture.
  22634. * @returns the width of the render size
  22635. */
  22636. getRenderWidth(): number;
  22637. /**
  22638. * Gets the actual render height of the texture.
  22639. * @returns the height of the render size
  22640. */
  22641. getRenderHeight(): number;
  22642. /**
  22643. * Get if the texture can be rescaled or not.
  22644. */
  22645. readonly canRescale: boolean;
  22646. /**
  22647. * Resize the texture using a ratio.
  22648. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22649. */
  22650. scale(ratio: number): void;
  22651. /**
  22652. * Get the texture reflection matrix used to rotate/transform the reflection.
  22653. * @returns the reflection matrix
  22654. */
  22655. getReflectionTextureMatrix(): Matrix;
  22656. /**
  22657. * Resize the texture to a new desired size.
  22658. * Be carrefull as it will recreate all the data in the new texture.
  22659. * @param size Define the new size. It can be:
  22660. * - a number for squared texture,
  22661. * - an object containing { width: number, height: number }
  22662. * - or an object containing a ratio { ratio: number }
  22663. */
  22664. resize(size: number | {
  22665. width: number;
  22666. height: number;
  22667. } | {
  22668. ratio: number;
  22669. }): void;
  22670. /**
  22671. * Renders all the objects from the render list into the texture.
  22672. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22673. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22674. */
  22675. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22676. private _bestReflectionRenderTargetDimension;
  22677. /**
  22678. * @hidden
  22679. * @param faceIndex face index to bind to if this is a cubetexture
  22680. */
  22681. _bindFrameBuffer(faceIndex?: number): void;
  22682. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22683. private renderToTarget;
  22684. /**
  22685. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22686. * This allowed control for front to back rendering or reversly depending of the special needs.
  22687. *
  22688. * @param renderingGroupId The rendering group id corresponding to its index
  22689. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22690. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22691. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22692. */
  22693. 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;
  22694. /**
  22695. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22696. *
  22697. * @param renderingGroupId The rendering group id corresponding to its index
  22698. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22699. */
  22700. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22701. /**
  22702. * Clones the texture.
  22703. * @returns the cloned texture
  22704. */
  22705. clone(): RenderTargetTexture;
  22706. /**
  22707. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22708. * @returns The JSON representation of the texture
  22709. */
  22710. serialize(): any;
  22711. /**
  22712. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22713. */
  22714. disposeFramebufferObjects(): void;
  22715. /**
  22716. * Dispose the texture and release its associated resources.
  22717. */
  22718. dispose(): void;
  22719. /** @hidden */
  22720. _rebuild(): void;
  22721. /**
  22722. * Clear the info related to rendering groups preventing retention point in material dispose.
  22723. */
  22724. freeRenderingGroups(): void;
  22725. /**
  22726. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22727. * @returns the view count
  22728. */
  22729. getViewCount(): number;
  22730. }
  22731. }
  22732. declare module "babylonjs/Materials/material" {
  22733. import { IAnimatable } from "babylonjs/Misc/tools";
  22734. import { SmartArray } from "babylonjs/Misc/smartArray";
  22735. import { Observable } from "babylonjs/Misc/observable";
  22736. import { Nullable } from "babylonjs/types";
  22737. import { Scene } from "babylonjs/scene";
  22738. import { Matrix } from "babylonjs/Maths/math";
  22739. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22741. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22742. import { Effect } from "babylonjs/Materials/effect";
  22743. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22744. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22745. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22746. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22747. import { Mesh } from "babylonjs/Meshes/mesh";
  22748. import { Animation } from "babylonjs/Animations/animation";
  22749. /**
  22750. * Base class for the main features of a material in Babylon.js
  22751. */
  22752. export class Material implements IAnimatable {
  22753. /**
  22754. * Returns the triangle fill mode
  22755. */
  22756. static readonly TriangleFillMode: number;
  22757. /**
  22758. * Returns the wireframe mode
  22759. */
  22760. static readonly WireFrameFillMode: number;
  22761. /**
  22762. * Returns the point fill mode
  22763. */
  22764. static readonly PointFillMode: number;
  22765. /**
  22766. * Returns the point list draw mode
  22767. */
  22768. static readonly PointListDrawMode: number;
  22769. /**
  22770. * Returns the line list draw mode
  22771. */
  22772. static readonly LineListDrawMode: number;
  22773. /**
  22774. * Returns the line loop draw mode
  22775. */
  22776. static readonly LineLoopDrawMode: number;
  22777. /**
  22778. * Returns the line strip draw mode
  22779. */
  22780. static readonly LineStripDrawMode: number;
  22781. /**
  22782. * Returns the triangle strip draw mode
  22783. */
  22784. static readonly TriangleStripDrawMode: number;
  22785. /**
  22786. * Returns the triangle fan draw mode
  22787. */
  22788. static readonly TriangleFanDrawMode: number;
  22789. /**
  22790. * Stores the clock-wise side orientation
  22791. */
  22792. static readonly ClockWiseSideOrientation: number;
  22793. /**
  22794. * Stores the counter clock-wise side orientation
  22795. */
  22796. static readonly CounterClockWiseSideOrientation: number;
  22797. /**
  22798. * The dirty texture flag value
  22799. */
  22800. static readonly TextureDirtyFlag: number;
  22801. /**
  22802. * The dirty light flag value
  22803. */
  22804. static readonly LightDirtyFlag: number;
  22805. /**
  22806. * The dirty fresnel flag value
  22807. */
  22808. static readonly FresnelDirtyFlag: number;
  22809. /**
  22810. * The dirty attribute flag value
  22811. */
  22812. static readonly AttributesDirtyFlag: number;
  22813. /**
  22814. * The dirty misc flag value
  22815. */
  22816. static readonly MiscDirtyFlag: number;
  22817. /**
  22818. * The all dirty flag value
  22819. */
  22820. static readonly AllDirtyFlag: number;
  22821. /**
  22822. * The ID of the material
  22823. */
  22824. id: string;
  22825. /**
  22826. * Gets or sets the unique id of the material
  22827. */
  22828. uniqueId: number;
  22829. /**
  22830. * The name of the material
  22831. */
  22832. name: string;
  22833. /**
  22834. * Gets or sets user defined metadata
  22835. */
  22836. metadata: any;
  22837. /**
  22838. * For internal use only. Please do not use.
  22839. */
  22840. reservedDataStore: any;
  22841. /**
  22842. * Specifies if the ready state should be checked on each call
  22843. */
  22844. checkReadyOnEveryCall: boolean;
  22845. /**
  22846. * Specifies if the ready state should be checked once
  22847. */
  22848. checkReadyOnlyOnce: boolean;
  22849. /**
  22850. * The state of the material
  22851. */
  22852. state: string;
  22853. /**
  22854. * The alpha value of the material
  22855. */
  22856. protected _alpha: number;
  22857. /**
  22858. * List of inspectable custom properties (used by the Inspector)
  22859. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22860. */
  22861. inspectableCustomProperties: IInspectable[];
  22862. /**
  22863. * Sets the alpha value of the material
  22864. */
  22865. /**
  22866. * Gets the alpha value of the material
  22867. */
  22868. alpha: number;
  22869. /**
  22870. * Specifies if back face culling is enabled
  22871. */
  22872. protected _backFaceCulling: boolean;
  22873. /**
  22874. * Sets the back-face culling state
  22875. */
  22876. /**
  22877. * Gets the back-face culling state
  22878. */
  22879. backFaceCulling: boolean;
  22880. /**
  22881. * Stores the value for side orientation
  22882. */
  22883. sideOrientation: number;
  22884. /**
  22885. * Callback triggered when the material is compiled
  22886. */
  22887. onCompiled: Nullable<(effect: Effect) => void>;
  22888. /**
  22889. * Callback triggered when an error occurs
  22890. */
  22891. onError: Nullable<(effect: Effect, errors: string) => void>;
  22892. /**
  22893. * Callback triggered to get the render target textures
  22894. */
  22895. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22896. /**
  22897. * Gets a boolean indicating that current material needs to register RTT
  22898. */
  22899. readonly hasRenderTargetTextures: boolean;
  22900. /**
  22901. * Specifies if the material should be serialized
  22902. */
  22903. doNotSerialize: boolean;
  22904. /**
  22905. * @hidden
  22906. */
  22907. _storeEffectOnSubMeshes: boolean;
  22908. /**
  22909. * Stores the animations for the material
  22910. */
  22911. animations: Nullable<Array<Animation>>;
  22912. /**
  22913. * An event triggered when the material is disposed
  22914. */
  22915. onDisposeObservable: Observable<Material>;
  22916. /**
  22917. * An observer which watches for dispose events
  22918. */
  22919. private _onDisposeObserver;
  22920. private _onUnBindObservable;
  22921. /**
  22922. * Called during a dispose event
  22923. */
  22924. onDispose: () => void;
  22925. private _onBindObservable;
  22926. /**
  22927. * An event triggered when the material is bound
  22928. */
  22929. readonly onBindObservable: Observable<AbstractMesh>;
  22930. /**
  22931. * An observer which watches for bind events
  22932. */
  22933. private _onBindObserver;
  22934. /**
  22935. * Called during a bind event
  22936. */
  22937. onBind: (Mesh: AbstractMesh) => void;
  22938. /**
  22939. * An event triggered when the material is unbound
  22940. */
  22941. readonly onUnBindObservable: Observable<Material>;
  22942. /**
  22943. * Stores the value of the alpha mode
  22944. */
  22945. private _alphaMode;
  22946. /**
  22947. * Sets the value of the alpha mode.
  22948. *
  22949. * | Value | Type | Description |
  22950. * | --- | --- | --- |
  22951. * | 0 | ALPHA_DISABLE | |
  22952. * | 1 | ALPHA_ADD | |
  22953. * | 2 | ALPHA_COMBINE | |
  22954. * | 3 | ALPHA_SUBTRACT | |
  22955. * | 4 | ALPHA_MULTIPLY | |
  22956. * | 5 | ALPHA_MAXIMIZED | |
  22957. * | 6 | ALPHA_ONEONE | |
  22958. * | 7 | ALPHA_PREMULTIPLIED | |
  22959. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22960. * | 9 | ALPHA_INTERPOLATE | |
  22961. * | 10 | ALPHA_SCREENMODE | |
  22962. *
  22963. */
  22964. /**
  22965. * Gets the value of the alpha mode
  22966. */
  22967. alphaMode: number;
  22968. /**
  22969. * Stores the state of the need depth pre-pass value
  22970. */
  22971. private _needDepthPrePass;
  22972. /**
  22973. * Sets the need depth pre-pass value
  22974. */
  22975. /**
  22976. * Gets the depth pre-pass value
  22977. */
  22978. needDepthPrePass: boolean;
  22979. /**
  22980. * Specifies if depth writing should be disabled
  22981. */
  22982. disableDepthWrite: boolean;
  22983. /**
  22984. * Specifies if depth writing should be forced
  22985. */
  22986. forceDepthWrite: boolean;
  22987. /**
  22988. * Specifies if there should be a separate pass for culling
  22989. */
  22990. separateCullingPass: boolean;
  22991. /**
  22992. * Stores the state specifing if fog should be enabled
  22993. */
  22994. private _fogEnabled;
  22995. /**
  22996. * Sets the state for enabling fog
  22997. */
  22998. /**
  22999. * Gets the value of the fog enabled state
  23000. */
  23001. fogEnabled: boolean;
  23002. /**
  23003. * Stores the size of points
  23004. */
  23005. pointSize: number;
  23006. /**
  23007. * Stores the z offset value
  23008. */
  23009. zOffset: number;
  23010. /**
  23011. * Gets a value specifying if wireframe mode is enabled
  23012. */
  23013. /**
  23014. * Sets the state of wireframe mode
  23015. */
  23016. wireframe: boolean;
  23017. /**
  23018. * Gets the value specifying if point clouds are enabled
  23019. */
  23020. /**
  23021. * Sets the state of point cloud mode
  23022. */
  23023. pointsCloud: boolean;
  23024. /**
  23025. * Gets the material fill mode
  23026. */
  23027. /**
  23028. * Sets the material fill mode
  23029. */
  23030. fillMode: number;
  23031. /**
  23032. * @hidden
  23033. * Stores the effects for the material
  23034. */
  23035. _effect: Nullable<Effect>;
  23036. /**
  23037. * @hidden
  23038. * Specifies if the material was previously ready
  23039. */
  23040. _wasPreviouslyReady: boolean;
  23041. /**
  23042. * Specifies if uniform buffers should be used
  23043. */
  23044. private _useUBO;
  23045. /**
  23046. * Stores a reference to the scene
  23047. */
  23048. private _scene;
  23049. /**
  23050. * Stores the fill mode state
  23051. */
  23052. private _fillMode;
  23053. /**
  23054. * Specifies if the depth write state should be cached
  23055. */
  23056. private _cachedDepthWriteState;
  23057. /**
  23058. * Stores the uniform buffer
  23059. */
  23060. protected _uniformBuffer: UniformBuffer;
  23061. /** @hidden */
  23062. _indexInSceneMaterialArray: number;
  23063. /** @hidden */
  23064. meshMap: Nullable<{
  23065. [id: string]: AbstractMesh | undefined;
  23066. }>;
  23067. /**
  23068. * Creates a material instance
  23069. * @param name defines the name of the material
  23070. * @param scene defines the scene to reference
  23071. * @param doNotAdd specifies if the material should be added to the scene
  23072. */
  23073. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  23074. /**
  23075. * Returns a string representation of the current material
  23076. * @param fullDetails defines a boolean indicating which levels of logging is desired
  23077. * @returns a string with material information
  23078. */
  23079. toString(fullDetails?: boolean): string;
  23080. /**
  23081. * Gets the class name of the material
  23082. * @returns a string with the class name of the material
  23083. */
  23084. getClassName(): string;
  23085. /**
  23086. * Specifies if updates for the material been locked
  23087. */
  23088. readonly isFrozen: boolean;
  23089. /**
  23090. * Locks updates for the material
  23091. */
  23092. freeze(): void;
  23093. /**
  23094. * Unlocks updates for the material
  23095. */
  23096. unfreeze(): void;
  23097. /**
  23098. * Specifies if the material is ready to be used
  23099. * @param mesh defines the mesh to check
  23100. * @param useInstances specifies if instances should be used
  23101. * @returns a boolean indicating if the material is ready to be used
  23102. */
  23103. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23104. /**
  23105. * Specifies that the submesh is ready to be used
  23106. * @param mesh defines the mesh to check
  23107. * @param subMesh defines which submesh to check
  23108. * @param useInstances specifies that instances should be used
  23109. * @returns a boolean indicating that the submesh is ready or not
  23110. */
  23111. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23112. /**
  23113. * Returns the material effect
  23114. * @returns the effect associated with the material
  23115. */
  23116. getEffect(): Nullable<Effect>;
  23117. /**
  23118. * Returns the current scene
  23119. * @returns a Scene
  23120. */
  23121. getScene(): Scene;
  23122. /**
  23123. * Specifies if the material will require alpha blending
  23124. * @returns a boolean specifying if alpha blending is needed
  23125. */
  23126. needAlphaBlending(): boolean;
  23127. /**
  23128. * Specifies if the mesh will require alpha blending
  23129. * @param mesh defines the mesh to check
  23130. * @returns a boolean specifying if alpha blending is needed for the mesh
  23131. */
  23132. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23133. /**
  23134. * Specifies if this material should be rendered in alpha test mode
  23135. * @returns a boolean specifying if an alpha test is needed.
  23136. */
  23137. needAlphaTesting(): boolean;
  23138. /**
  23139. * Gets the texture used for the alpha test
  23140. * @returns the texture to use for alpha testing
  23141. */
  23142. getAlphaTestTexture(): Nullable<BaseTexture>;
  23143. /**
  23144. * Marks the material to indicate that it needs to be re-calculated
  23145. */
  23146. markDirty(): void;
  23147. /** @hidden */
  23148. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23149. /**
  23150. * Binds the material to the mesh
  23151. * @param world defines the world transformation matrix
  23152. * @param mesh defines the mesh to bind the material to
  23153. */
  23154. bind(world: Matrix, mesh?: Mesh): void;
  23155. /**
  23156. * Binds the submesh to the material
  23157. * @param world defines the world transformation matrix
  23158. * @param mesh defines the mesh containing the submesh
  23159. * @param subMesh defines the submesh to bind the material to
  23160. */
  23161. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23162. /**
  23163. * Binds the world matrix to the material
  23164. * @param world defines the world transformation matrix
  23165. */
  23166. bindOnlyWorldMatrix(world: Matrix): void;
  23167. /**
  23168. * Binds the scene's uniform buffer to the effect.
  23169. * @param effect defines the effect to bind to the scene uniform buffer
  23170. * @param sceneUbo defines the uniform buffer storing scene data
  23171. */
  23172. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23173. /**
  23174. * Binds the view matrix to the effect
  23175. * @param effect defines the effect to bind the view matrix to
  23176. */
  23177. bindView(effect: Effect): void;
  23178. /**
  23179. * Binds the view projection matrix to the effect
  23180. * @param effect defines the effect to bind the view projection matrix to
  23181. */
  23182. bindViewProjection(effect: Effect): void;
  23183. /**
  23184. * Specifies if material alpha testing should be turned on for the mesh
  23185. * @param mesh defines the mesh to check
  23186. */
  23187. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23188. /**
  23189. * Processes to execute after binding the material to a mesh
  23190. * @param mesh defines the rendered mesh
  23191. */
  23192. protected _afterBind(mesh?: Mesh): void;
  23193. /**
  23194. * Unbinds the material from the mesh
  23195. */
  23196. unbind(): void;
  23197. /**
  23198. * Gets the active textures from the material
  23199. * @returns an array of textures
  23200. */
  23201. getActiveTextures(): BaseTexture[];
  23202. /**
  23203. * Specifies if the material uses a texture
  23204. * @param texture defines the texture to check against the material
  23205. * @returns a boolean specifying if the material uses the texture
  23206. */
  23207. hasTexture(texture: BaseTexture): boolean;
  23208. /**
  23209. * Makes a duplicate of the material, and gives it a new name
  23210. * @param name defines the new name for the duplicated material
  23211. * @returns the cloned material
  23212. */
  23213. clone(name: string): Nullable<Material>;
  23214. /**
  23215. * Gets the meshes bound to the material
  23216. * @returns an array of meshes bound to the material
  23217. */
  23218. getBindedMeshes(): AbstractMesh[];
  23219. /**
  23220. * Force shader compilation
  23221. * @param mesh defines the mesh associated with this material
  23222. * @param onCompiled defines a function to execute once the material is compiled
  23223. * @param options defines the options to configure the compilation
  23224. */
  23225. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23226. clipPlane: boolean;
  23227. }>): void;
  23228. /**
  23229. * Force shader compilation
  23230. * @param mesh defines the mesh that will use this material
  23231. * @param options defines additional options for compiling the shaders
  23232. * @returns a promise that resolves when the compilation completes
  23233. */
  23234. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23235. clipPlane: boolean;
  23236. }>): Promise<void>;
  23237. private static readonly _AllDirtyCallBack;
  23238. private static readonly _ImageProcessingDirtyCallBack;
  23239. private static readonly _TextureDirtyCallBack;
  23240. private static readonly _FresnelDirtyCallBack;
  23241. private static readonly _MiscDirtyCallBack;
  23242. private static readonly _LightsDirtyCallBack;
  23243. private static readonly _AttributeDirtyCallBack;
  23244. private static _FresnelAndMiscDirtyCallBack;
  23245. private static _TextureAndMiscDirtyCallBack;
  23246. private static readonly _DirtyCallbackArray;
  23247. private static readonly _RunDirtyCallBacks;
  23248. /**
  23249. * Marks a define in the material to indicate that it needs to be re-computed
  23250. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23251. */
  23252. markAsDirty(flag: number): void;
  23253. /**
  23254. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23255. * @param func defines a function which checks material defines against the submeshes
  23256. */
  23257. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23258. /**
  23259. * Indicates that we need to re-calculated for all submeshes
  23260. */
  23261. protected _markAllSubMeshesAsAllDirty(): void;
  23262. /**
  23263. * Indicates that image processing needs to be re-calculated for all submeshes
  23264. */
  23265. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23266. /**
  23267. * Indicates that textures need to be re-calculated for all submeshes
  23268. */
  23269. protected _markAllSubMeshesAsTexturesDirty(): void;
  23270. /**
  23271. * Indicates that fresnel needs to be re-calculated for all submeshes
  23272. */
  23273. protected _markAllSubMeshesAsFresnelDirty(): void;
  23274. /**
  23275. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23276. */
  23277. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23278. /**
  23279. * Indicates that lights need to be re-calculated for all submeshes
  23280. */
  23281. protected _markAllSubMeshesAsLightsDirty(): void;
  23282. /**
  23283. * Indicates that attributes need to be re-calculated for all submeshes
  23284. */
  23285. protected _markAllSubMeshesAsAttributesDirty(): void;
  23286. /**
  23287. * Indicates that misc needs to be re-calculated for all submeshes
  23288. */
  23289. protected _markAllSubMeshesAsMiscDirty(): void;
  23290. /**
  23291. * Indicates that textures and misc need to be re-calculated for all submeshes
  23292. */
  23293. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23294. /**
  23295. * Disposes the material
  23296. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23297. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23298. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23299. */
  23300. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23301. /** @hidden */
  23302. private releaseVertexArrayObject;
  23303. /**
  23304. * Serializes this material
  23305. * @returns the serialized material object
  23306. */
  23307. serialize(): any;
  23308. /**
  23309. * Creates a material from parsed material data
  23310. * @param parsedMaterial defines parsed material data
  23311. * @param scene defines the hosting scene
  23312. * @param rootUrl defines the root URL to use to load textures
  23313. * @returns a new material
  23314. */
  23315. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23316. }
  23317. }
  23318. declare module "babylonjs/Meshes/subMesh" {
  23319. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23320. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23321. import { Engine } from "babylonjs/Engines/engine";
  23322. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23323. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23324. import { Effect } from "babylonjs/Materials/effect";
  23325. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23326. import { Collider } from "babylonjs/Collisions/collider";
  23327. import { Material } from "babylonjs/Materials/material";
  23328. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23330. import { Mesh } from "babylonjs/Meshes/mesh";
  23331. import { Ray } from "babylonjs/Culling/ray";
  23332. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23333. /**
  23334. * Base class for submeshes
  23335. */
  23336. export class BaseSubMesh {
  23337. /** @hidden */
  23338. _materialDefines: Nullable<MaterialDefines>;
  23339. /** @hidden */
  23340. _materialEffect: Nullable<Effect>;
  23341. /**
  23342. * Gets associated effect
  23343. */
  23344. readonly effect: Nullable<Effect>;
  23345. /**
  23346. * Sets associated effect (effect used to render this submesh)
  23347. * @param effect defines the effect to associate with
  23348. * @param defines defines the set of defines used to compile this effect
  23349. */
  23350. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23351. }
  23352. /**
  23353. * Defines a subdivision inside a mesh
  23354. */
  23355. export class SubMesh extends BaseSubMesh implements ICullable {
  23356. /** the material index to use */
  23357. materialIndex: number;
  23358. /** vertex index start */
  23359. verticesStart: number;
  23360. /** vertices count */
  23361. verticesCount: number;
  23362. /** index start */
  23363. indexStart: number;
  23364. /** indices count */
  23365. indexCount: number;
  23366. /** @hidden */
  23367. _linesIndexCount: number;
  23368. private _mesh;
  23369. private _renderingMesh;
  23370. private _boundingInfo;
  23371. private _linesIndexBuffer;
  23372. /** @hidden */
  23373. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23374. /** @hidden */
  23375. _trianglePlanes: Plane[];
  23376. /** @hidden */
  23377. _lastColliderTransformMatrix: Nullable<Matrix>;
  23378. /** @hidden */
  23379. _renderId: number;
  23380. /** @hidden */
  23381. _alphaIndex: number;
  23382. /** @hidden */
  23383. _distanceToCamera: number;
  23384. /** @hidden */
  23385. _id: number;
  23386. private _currentMaterial;
  23387. /**
  23388. * Add a new submesh to a mesh
  23389. * @param materialIndex defines the material index to use
  23390. * @param verticesStart defines vertex index start
  23391. * @param verticesCount defines vertices count
  23392. * @param indexStart defines index start
  23393. * @param indexCount defines indices count
  23394. * @param mesh defines the parent mesh
  23395. * @param renderingMesh defines an optional rendering mesh
  23396. * @param createBoundingBox defines if bounding box should be created for this submesh
  23397. * @returns the new submesh
  23398. */
  23399. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23400. /**
  23401. * Creates a new submesh
  23402. * @param materialIndex defines the material index to use
  23403. * @param verticesStart defines vertex index start
  23404. * @param verticesCount defines vertices count
  23405. * @param indexStart defines index start
  23406. * @param indexCount defines indices count
  23407. * @param mesh defines the parent mesh
  23408. * @param renderingMesh defines an optional rendering mesh
  23409. * @param createBoundingBox defines if bounding box should be created for this submesh
  23410. */
  23411. constructor(
  23412. /** the material index to use */
  23413. materialIndex: number,
  23414. /** vertex index start */
  23415. verticesStart: number,
  23416. /** vertices count */
  23417. verticesCount: number,
  23418. /** index start */
  23419. indexStart: number,
  23420. /** indices count */
  23421. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23422. /**
  23423. * Returns true if this submesh covers the entire parent mesh
  23424. * @ignorenaming
  23425. */
  23426. readonly IsGlobal: boolean;
  23427. /**
  23428. * Returns the submesh BoudingInfo object
  23429. * @returns current bounding info (or mesh's one if the submesh is global)
  23430. */
  23431. getBoundingInfo(): BoundingInfo;
  23432. /**
  23433. * Sets the submesh BoundingInfo
  23434. * @param boundingInfo defines the new bounding info to use
  23435. * @returns the SubMesh
  23436. */
  23437. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23438. /**
  23439. * Returns the mesh of the current submesh
  23440. * @return the parent mesh
  23441. */
  23442. getMesh(): AbstractMesh;
  23443. /**
  23444. * Returns the rendering mesh of the submesh
  23445. * @returns the rendering mesh (could be different from parent mesh)
  23446. */
  23447. getRenderingMesh(): Mesh;
  23448. /**
  23449. * Returns the submesh material
  23450. * @returns null or the current material
  23451. */
  23452. getMaterial(): Nullable<Material>;
  23453. /**
  23454. * Sets a new updated BoundingInfo object to the submesh
  23455. * @param data defines an optional position array to use to determine the bounding info
  23456. * @returns the SubMesh
  23457. */
  23458. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23459. /** @hidden */
  23460. _checkCollision(collider: Collider): boolean;
  23461. /**
  23462. * Updates the submesh BoundingInfo
  23463. * @param world defines the world matrix to use to update the bounding info
  23464. * @returns the submesh
  23465. */
  23466. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23467. /**
  23468. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23469. * @param frustumPlanes defines the frustum planes
  23470. * @returns true if the submesh is intersecting with the frustum
  23471. */
  23472. isInFrustum(frustumPlanes: Plane[]): boolean;
  23473. /**
  23474. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23475. * @param frustumPlanes defines the frustum planes
  23476. * @returns true if the submesh is inside the frustum
  23477. */
  23478. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23479. /**
  23480. * Renders the submesh
  23481. * @param enableAlphaMode defines if alpha needs to be used
  23482. * @returns the submesh
  23483. */
  23484. render(enableAlphaMode: boolean): SubMesh;
  23485. /**
  23486. * @hidden
  23487. */
  23488. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23489. /**
  23490. * Checks if the submesh intersects with a ray
  23491. * @param ray defines the ray to test
  23492. * @returns true is the passed ray intersects the submesh bounding box
  23493. */
  23494. canIntersects(ray: Ray): boolean;
  23495. /**
  23496. * Intersects current submesh with a ray
  23497. * @param ray defines the ray to test
  23498. * @param positions defines mesh's positions array
  23499. * @param indices defines mesh's indices array
  23500. * @param fastCheck defines if only bounding info should be used
  23501. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23502. * @returns intersection info or null if no intersection
  23503. */
  23504. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23505. /** @hidden */
  23506. private _intersectLines;
  23507. /** @hidden */
  23508. private _intersectUnIndexedLines;
  23509. /** @hidden */
  23510. private _intersectTriangles;
  23511. /** @hidden */
  23512. private _intersectUnIndexedTriangles;
  23513. /** @hidden */
  23514. _rebuild(): void;
  23515. /**
  23516. * Creates a new submesh from the passed mesh
  23517. * @param newMesh defines the new hosting mesh
  23518. * @param newRenderingMesh defines an optional rendering mesh
  23519. * @returns the new submesh
  23520. */
  23521. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23522. /**
  23523. * Release associated resources
  23524. */
  23525. dispose(): void;
  23526. /**
  23527. * Gets the class name
  23528. * @returns the string "SubMesh".
  23529. */
  23530. getClassName(): string;
  23531. /**
  23532. * Creates a new submesh from indices data
  23533. * @param materialIndex the index of the main mesh material
  23534. * @param startIndex the index where to start the copy in the mesh indices array
  23535. * @param indexCount the number of indices to copy then from the startIndex
  23536. * @param mesh the main mesh to create the submesh from
  23537. * @param renderingMesh the optional rendering mesh
  23538. * @returns a new submesh
  23539. */
  23540. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23541. }
  23542. }
  23543. declare module "babylonjs/Meshes/geometry" {
  23544. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23545. import { Scene } from "babylonjs/scene";
  23546. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23547. import { Engine } from "babylonjs/Engines/engine";
  23548. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23549. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23550. import { Effect } from "babylonjs/Materials/effect";
  23551. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23552. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23553. import { Mesh } from "babylonjs/Meshes/mesh";
  23554. /**
  23555. * Class used to store geometry data (vertex buffers + index buffer)
  23556. */
  23557. export class Geometry implements IGetSetVerticesData {
  23558. /**
  23559. * Gets or sets the ID of the geometry
  23560. */
  23561. id: string;
  23562. /**
  23563. * Gets or sets the unique ID of the geometry
  23564. */
  23565. uniqueId: number;
  23566. /**
  23567. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23568. */
  23569. delayLoadState: number;
  23570. /**
  23571. * Gets the file containing the data to load when running in delay load state
  23572. */
  23573. delayLoadingFile: Nullable<string>;
  23574. /**
  23575. * Callback called when the geometry is updated
  23576. */
  23577. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23578. private _scene;
  23579. private _engine;
  23580. private _meshes;
  23581. private _totalVertices;
  23582. /** @hidden */
  23583. _indices: IndicesArray;
  23584. /** @hidden */
  23585. _vertexBuffers: {
  23586. [key: string]: VertexBuffer;
  23587. };
  23588. private _isDisposed;
  23589. private _extend;
  23590. private _boundingBias;
  23591. /** @hidden */
  23592. _delayInfo: Array<string>;
  23593. private _indexBuffer;
  23594. private _indexBufferIsUpdatable;
  23595. /** @hidden */
  23596. _boundingInfo: Nullable<BoundingInfo>;
  23597. /** @hidden */
  23598. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23599. /** @hidden */
  23600. _softwareSkinningFrameId: number;
  23601. private _vertexArrayObjects;
  23602. private _updatable;
  23603. /** @hidden */
  23604. _positions: Nullable<Vector3[]>;
  23605. /**
  23606. * 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
  23607. */
  23608. /**
  23609. * 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
  23610. */
  23611. boundingBias: Vector2;
  23612. /**
  23613. * Static function used to attach a new empty geometry to a mesh
  23614. * @param mesh defines the mesh to attach the geometry to
  23615. * @returns the new Geometry
  23616. */
  23617. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23618. /**
  23619. * Creates a new geometry
  23620. * @param id defines the unique ID
  23621. * @param scene defines the hosting scene
  23622. * @param vertexData defines the VertexData used to get geometry data
  23623. * @param updatable defines if geometry must be updatable (false by default)
  23624. * @param mesh defines the mesh that will be associated with the geometry
  23625. */
  23626. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23627. /**
  23628. * Gets the current extend of the geometry
  23629. */
  23630. readonly extend: {
  23631. minimum: Vector3;
  23632. maximum: Vector3;
  23633. };
  23634. /**
  23635. * Gets the hosting scene
  23636. * @returns the hosting Scene
  23637. */
  23638. getScene(): Scene;
  23639. /**
  23640. * Gets the hosting engine
  23641. * @returns the hosting Engine
  23642. */
  23643. getEngine(): Engine;
  23644. /**
  23645. * Defines if the geometry is ready to use
  23646. * @returns true if the geometry is ready to be used
  23647. */
  23648. isReady(): boolean;
  23649. /**
  23650. * Gets a value indicating that the geometry should not be serialized
  23651. */
  23652. readonly doNotSerialize: boolean;
  23653. /** @hidden */
  23654. _rebuild(): void;
  23655. /**
  23656. * Affects all geometry data in one call
  23657. * @param vertexData defines the geometry data
  23658. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23659. */
  23660. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23661. /**
  23662. * Set specific vertex data
  23663. * @param kind defines the data kind (Position, normal, etc...)
  23664. * @param data defines the vertex data to use
  23665. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23666. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23667. */
  23668. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23669. /**
  23670. * Removes a specific vertex data
  23671. * @param kind defines the data kind (Position, normal, etc...)
  23672. */
  23673. removeVerticesData(kind: string): void;
  23674. /**
  23675. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23676. * @param buffer defines the vertex buffer to use
  23677. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23678. */
  23679. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23680. /**
  23681. * Update a specific vertex buffer
  23682. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23683. * It will do nothing if the buffer is not updatable
  23684. * @param kind defines the data kind (Position, normal, etc...)
  23685. * @param data defines the data to use
  23686. * @param offset defines the offset in the target buffer where to store the data
  23687. * @param useBytes set to true if the offset is in bytes
  23688. */
  23689. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23690. /**
  23691. * Update a specific vertex buffer
  23692. * This function will create a new buffer if the current one is not updatable
  23693. * @param kind defines the data kind (Position, normal, etc...)
  23694. * @param data defines the data to use
  23695. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23696. */
  23697. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23698. private _updateBoundingInfo;
  23699. /** @hidden */
  23700. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23701. /**
  23702. * Gets total number of vertices
  23703. * @returns the total number of vertices
  23704. */
  23705. getTotalVertices(): number;
  23706. /**
  23707. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23708. * @param kind defines the data kind (Position, normal, etc...)
  23709. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23710. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23711. * @returns a float array containing vertex data
  23712. */
  23713. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23714. /**
  23715. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23716. * @param kind defines the data kind (Position, normal, etc...)
  23717. * @returns true if the vertex buffer with the specified kind is updatable
  23718. */
  23719. isVertexBufferUpdatable(kind: string): boolean;
  23720. /**
  23721. * Gets a specific vertex buffer
  23722. * @param kind defines the data kind (Position, normal, etc...)
  23723. * @returns a VertexBuffer
  23724. */
  23725. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23726. /**
  23727. * Returns all vertex buffers
  23728. * @return an object holding all vertex buffers indexed by kind
  23729. */
  23730. getVertexBuffers(): Nullable<{
  23731. [key: string]: VertexBuffer;
  23732. }>;
  23733. /**
  23734. * Gets a boolean indicating if specific vertex buffer is present
  23735. * @param kind defines the data kind (Position, normal, etc...)
  23736. * @returns true if data is present
  23737. */
  23738. isVerticesDataPresent(kind: string): boolean;
  23739. /**
  23740. * Gets a list of all attached data kinds (Position, normal, etc...)
  23741. * @returns a list of string containing all kinds
  23742. */
  23743. getVerticesDataKinds(): string[];
  23744. /**
  23745. * Update index buffer
  23746. * @param indices defines the indices to store in the index buffer
  23747. * @param offset defines the offset in the target buffer where to store the data
  23748. * @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)
  23749. */
  23750. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23751. /**
  23752. * Creates a new index buffer
  23753. * @param indices defines the indices to store in the index buffer
  23754. * @param totalVertices defines the total number of vertices (could be null)
  23755. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23756. */
  23757. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23758. /**
  23759. * Return the total number of indices
  23760. * @returns the total number of indices
  23761. */
  23762. getTotalIndices(): number;
  23763. /**
  23764. * Gets the index buffer array
  23765. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23766. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23767. * @returns the index buffer array
  23768. */
  23769. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23770. /**
  23771. * Gets the index buffer
  23772. * @return the index buffer
  23773. */
  23774. getIndexBuffer(): Nullable<DataBuffer>;
  23775. /** @hidden */
  23776. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23777. /**
  23778. * Release the associated resources for a specific mesh
  23779. * @param mesh defines the source mesh
  23780. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23781. */
  23782. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23783. /**
  23784. * Apply current geometry to a given mesh
  23785. * @param mesh defines the mesh to apply geometry to
  23786. */
  23787. applyToMesh(mesh: Mesh): void;
  23788. private _updateExtend;
  23789. private _applyToMesh;
  23790. private notifyUpdate;
  23791. /**
  23792. * Load the geometry if it was flagged as delay loaded
  23793. * @param scene defines the hosting scene
  23794. * @param onLoaded defines a callback called when the geometry is loaded
  23795. */
  23796. load(scene: Scene, onLoaded?: () => void): void;
  23797. private _queueLoad;
  23798. /**
  23799. * Invert the geometry to move from a right handed system to a left handed one.
  23800. */
  23801. toLeftHanded(): void;
  23802. /** @hidden */
  23803. _resetPointsArrayCache(): void;
  23804. /** @hidden */
  23805. _generatePointsArray(): boolean;
  23806. /**
  23807. * Gets a value indicating if the geometry is disposed
  23808. * @returns true if the geometry was disposed
  23809. */
  23810. isDisposed(): boolean;
  23811. private _disposeVertexArrayObjects;
  23812. /**
  23813. * Free all associated resources
  23814. */
  23815. dispose(): void;
  23816. /**
  23817. * Clone the current geometry into a new geometry
  23818. * @param id defines the unique ID of the new geometry
  23819. * @returns a new geometry object
  23820. */
  23821. copy(id: string): Geometry;
  23822. /**
  23823. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23824. * @return a JSON representation of the current geometry data (without the vertices data)
  23825. */
  23826. serialize(): any;
  23827. private toNumberArray;
  23828. /**
  23829. * Serialize all vertices data into a JSON oject
  23830. * @returns a JSON representation of the current geometry data
  23831. */
  23832. serializeVerticeData(): any;
  23833. /**
  23834. * Extracts a clone of a mesh geometry
  23835. * @param mesh defines the source mesh
  23836. * @param id defines the unique ID of the new geometry object
  23837. * @returns the new geometry object
  23838. */
  23839. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23840. /**
  23841. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23842. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23843. * Be aware Math.random() could cause collisions, but:
  23844. * "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"
  23845. * @returns a string containing a new GUID
  23846. */
  23847. static RandomId(): string;
  23848. /** @hidden */
  23849. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23850. private static _CleanMatricesWeights;
  23851. /**
  23852. * Create a new geometry from persisted data (Using .babylon file format)
  23853. * @param parsedVertexData defines the persisted data
  23854. * @param scene defines the hosting scene
  23855. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23856. * @returns the new geometry object
  23857. */
  23858. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23859. }
  23860. }
  23861. declare module "babylonjs/Meshes/mesh.vertexData" {
  23862. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23863. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23864. import { Geometry } from "babylonjs/Meshes/geometry";
  23865. import { Mesh } from "babylonjs/Meshes/mesh";
  23866. /**
  23867. * Define an interface for all classes that will get and set the data on vertices
  23868. */
  23869. export interface IGetSetVerticesData {
  23870. /**
  23871. * Gets a boolean indicating if specific vertex data is present
  23872. * @param kind defines the vertex data kind to use
  23873. * @returns true is data kind is present
  23874. */
  23875. isVerticesDataPresent(kind: string): boolean;
  23876. /**
  23877. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23878. * @param kind defines the data kind (Position, normal, etc...)
  23879. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23880. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23881. * @returns a float array containing vertex data
  23882. */
  23883. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23884. /**
  23885. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23886. * @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.
  23887. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23888. * @returns the indices array or an empty array if the mesh has no geometry
  23889. */
  23890. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23891. /**
  23892. * Set specific vertex data
  23893. * @param kind defines the data kind (Position, normal, etc...)
  23894. * @param data defines the vertex data to use
  23895. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23896. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23897. */
  23898. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23899. /**
  23900. * Update a specific associated vertex buffer
  23901. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23902. * - VertexBuffer.PositionKind
  23903. * - VertexBuffer.UVKind
  23904. * - VertexBuffer.UV2Kind
  23905. * - VertexBuffer.UV3Kind
  23906. * - VertexBuffer.UV4Kind
  23907. * - VertexBuffer.UV5Kind
  23908. * - VertexBuffer.UV6Kind
  23909. * - VertexBuffer.ColorKind
  23910. * - VertexBuffer.MatricesIndicesKind
  23911. * - VertexBuffer.MatricesIndicesExtraKind
  23912. * - VertexBuffer.MatricesWeightsKind
  23913. * - VertexBuffer.MatricesWeightsExtraKind
  23914. * @param data defines the data source
  23915. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23916. * @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)
  23917. */
  23918. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23919. /**
  23920. * Creates a new index buffer
  23921. * @param indices defines the indices to store in the index buffer
  23922. * @param totalVertices defines the total number of vertices (could be null)
  23923. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23924. */
  23925. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23926. }
  23927. /**
  23928. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23929. */
  23930. export class VertexData {
  23931. /**
  23932. * Mesh side orientation : usually the external or front surface
  23933. */
  23934. static readonly FRONTSIDE: number;
  23935. /**
  23936. * Mesh side orientation : usually the internal or back surface
  23937. */
  23938. static readonly BACKSIDE: number;
  23939. /**
  23940. * Mesh side orientation : both internal and external or front and back surfaces
  23941. */
  23942. static readonly DOUBLESIDE: number;
  23943. /**
  23944. * Mesh side orientation : by default, `FRONTSIDE`
  23945. */
  23946. static readonly DEFAULTSIDE: number;
  23947. /**
  23948. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23949. */
  23950. positions: Nullable<FloatArray>;
  23951. /**
  23952. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23953. */
  23954. normals: Nullable<FloatArray>;
  23955. /**
  23956. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23957. */
  23958. tangents: Nullable<FloatArray>;
  23959. /**
  23960. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23961. */
  23962. uvs: Nullable<FloatArray>;
  23963. /**
  23964. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23965. */
  23966. uvs2: Nullable<FloatArray>;
  23967. /**
  23968. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23969. */
  23970. uvs3: Nullable<FloatArray>;
  23971. /**
  23972. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23973. */
  23974. uvs4: Nullable<FloatArray>;
  23975. /**
  23976. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23977. */
  23978. uvs5: Nullable<FloatArray>;
  23979. /**
  23980. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23981. */
  23982. uvs6: Nullable<FloatArray>;
  23983. /**
  23984. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23985. */
  23986. colors: Nullable<FloatArray>;
  23987. /**
  23988. * 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).
  23989. */
  23990. matricesIndices: Nullable<FloatArray>;
  23991. /**
  23992. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23993. */
  23994. matricesWeights: Nullable<FloatArray>;
  23995. /**
  23996. * An array extending the number of possible indices
  23997. */
  23998. matricesIndicesExtra: Nullable<FloatArray>;
  23999. /**
  24000. * An array extending the number of possible weights when the number of indices is extended
  24001. */
  24002. matricesWeightsExtra: Nullable<FloatArray>;
  24003. /**
  24004. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  24005. */
  24006. indices: Nullable<IndicesArray>;
  24007. /**
  24008. * Uses the passed data array to set the set the values for the specified kind of data
  24009. * @param data a linear array of floating numbers
  24010. * @param kind the type of data that is being set, eg positions, colors etc
  24011. */
  24012. set(data: FloatArray, kind: string): void;
  24013. /**
  24014. * Associates the vertexData to the passed Mesh.
  24015. * Sets it as updatable or not (default `false`)
  24016. * @param mesh the mesh the vertexData is applied to
  24017. * @param updatable when used and having the value true allows new data to update the vertexData
  24018. * @returns the VertexData
  24019. */
  24020. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  24021. /**
  24022. * Associates the vertexData to the passed Geometry.
  24023. * Sets it as updatable or not (default `false`)
  24024. * @param geometry the geometry the vertexData is applied to
  24025. * @param updatable when used and having the value true allows new data to update the vertexData
  24026. * @returns VertexData
  24027. */
  24028. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  24029. /**
  24030. * Updates the associated mesh
  24031. * @param mesh the mesh to be updated
  24032. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24033. * @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
  24034. * @returns VertexData
  24035. */
  24036. updateMesh(mesh: Mesh): VertexData;
  24037. /**
  24038. * Updates the associated geometry
  24039. * @param geometry the geometry to be updated
  24040. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24041. * @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
  24042. * @returns VertexData.
  24043. */
  24044. updateGeometry(geometry: Geometry): VertexData;
  24045. private _applyTo;
  24046. private _update;
  24047. /**
  24048. * Transforms each position and each normal of the vertexData according to the passed Matrix
  24049. * @param matrix the transforming matrix
  24050. * @returns the VertexData
  24051. */
  24052. transform(matrix: Matrix): VertexData;
  24053. /**
  24054. * Merges the passed VertexData into the current one
  24055. * @param other the VertexData to be merged into the current one
  24056. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  24057. * @returns the modified VertexData
  24058. */
  24059. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  24060. private _mergeElement;
  24061. private _validate;
  24062. /**
  24063. * Serializes the VertexData
  24064. * @returns a serialized object
  24065. */
  24066. serialize(): any;
  24067. /**
  24068. * Extracts the vertexData from a mesh
  24069. * @param mesh the mesh from which to extract the VertexData
  24070. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  24071. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24072. * @returns the object VertexData associated to the passed mesh
  24073. */
  24074. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24075. /**
  24076. * Extracts the vertexData from the geometry
  24077. * @param geometry the geometry from which to extract the VertexData
  24078. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  24079. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24080. * @returns the object VertexData associated to the passed mesh
  24081. */
  24082. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24083. private static _ExtractFrom;
  24084. /**
  24085. * Creates the VertexData for a Ribbon
  24086. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  24087. * * pathArray array of paths, each of which an array of successive Vector3
  24088. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  24089. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  24090. * * 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
  24091. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24092. * * 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)
  24093. * * 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)
  24094. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  24095. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  24096. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  24097. * @returns the VertexData of the ribbon
  24098. */
  24099. static CreateRibbon(options: {
  24100. pathArray: Vector3[][];
  24101. closeArray?: boolean;
  24102. closePath?: boolean;
  24103. offset?: number;
  24104. sideOrientation?: number;
  24105. frontUVs?: Vector4;
  24106. backUVs?: Vector4;
  24107. invertUV?: boolean;
  24108. uvs?: Vector2[];
  24109. colors?: Color4[];
  24110. }): VertexData;
  24111. /**
  24112. * Creates the VertexData for a box
  24113. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24114. * * size sets the width, height and depth of the box to the value of size, optional default 1
  24115. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  24116. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  24117. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  24118. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24119. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24120. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24121. * * 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)
  24122. * * 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)
  24123. * @returns the VertexData of the box
  24124. */
  24125. static CreateBox(options: {
  24126. size?: number;
  24127. width?: number;
  24128. height?: number;
  24129. depth?: number;
  24130. faceUV?: Vector4[];
  24131. faceColors?: Color4[];
  24132. sideOrientation?: number;
  24133. frontUVs?: Vector4;
  24134. backUVs?: Vector4;
  24135. }): VertexData;
  24136. /**
  24137. * Creates the VertexData for a tiled box
  24138. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24139. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24140. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24141. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24142. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24143. * @returns the VertexData of the box
  24144. */
  24145. static CreateTiledBox(options: {
  24146. pattern?: number;
  24147. width?: number;
  24148. height?: number;
  24149. depth?: number;
  24150. tileSize?: number;
  24151. tileWidth?: number;
  24152. tileHeight?: number;
  24153. alignHorizontal?: number;
  24154. alignVertical?: number;
  24155. faceUV?: Vector4[];
  24156. faceColors?: Color4[];
  24157. sideOrientation?: number;
  24158. }): VertexData;
  24159. /**
  24160. * Creates the VertexData for a tiled plane
  24161. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24162. * * pattern a limited pattern arrangement depending on the number
  24163. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24164. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24165. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24167. * * 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)
  24168. * * 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)
  24169. * @returns the VertexData of the tiled plane
  24170. */
  24171. static CreateTiledPlane(options: {
  24172. pattern?: number;
  24173. tileSize?: number;
  24174. tileWidth?: number;
  24175. tileHeight?: number;
  24176. size?: number;
  24177. width?: number;
  24178. height?: number;
  24179. alignHorizontal?: number;
  24180. alignVertical?: number;
  24181. sideOrientation?: number;
  24182. frontUVs?: Vector4;
  24183. backUVs?: Vector4;
  24184. }): VertexData;
  24185. /**
  24186. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24187. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24188. * * segments sets the number of horizontal strips optional, default 32
  24189. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24190. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24191. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24192. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24193. * * 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
  24194. * * 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
  24195. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24196. * * 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)
  24197. * * 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)
  24198. * @returns the VertexData of the ellipsoid
  24199. */
  24200. static CreateSphere(options: {
  24201. segments?: number;
  24202. diameter?: number;
  24203. diameterX?: number;
  24204. diameterY?: number;
  24205. diameterZ?: number;
  24206. arc?: number;
  24207. slice?: number;
  24208. sideOrientation?: number;
  24209. frontUVs?: Vector4;
  24210. backUVs?: Vector4;
  24211. }): VertexData;
  24212. /**
  24213. * Creates the VertexData for a cylinder, cone or prism
  24214. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24215. * * height sets the height (y direction) of the cylinder, optional, default 2
  24216. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24217. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24218. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24219. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24220. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24221. * * 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
  24222. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24223. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24224. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24225. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24226. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24227. * * 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)
  24228. * * 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)
  24229. * @returns the VertexData of the cylinder, cone or prism
  24230. */
  24231. static CreateCylinder(options: {
  24232. height?: number;
  24233. diameterTop?: number;
  24234. diameterBottom?: number;
  24235. diameter?: number;
  24236. tessellation?: number;
  24237. subdivisions?: number;
  24238. arc?: number;
  24239. faceColors?: Color4[];
  24240. faceUV?: Vector4[];
  24241. hasRings?: boolean;
  24242. enclose?: boolean;
  24243. sideOrientation?: number;
  24244. frontUVs?: Vector4;
  24245. backUVs?: Vector4;
  24246. }): VertexData;
  24247. /**
  24248. * Creates the VertexData for a torus
  24249. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24250. * * diameter the diameter of the torus, optional default 1
  24251. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24252. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24253. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24254. * * 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)
  24255. * * 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)
  24256. * @returns the VertexData of the torus
  24257. */
  24258. static CreateTorus(options: {
  24259. diameter?: number;
  24260. thickness?: number;
  24261. tessellation?: number;
  24262. sideOrientation?: number;
  24263. frontUVs?: Vector4;
  24264. backUVs?: Vector4;
  24265. }): VertexData;
  24266. /**
  24267. * Creates the VertexData of the LineSystem
  24268. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24269. * - lines an array of lines, each line being an array of successive Vector3
  24270. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24271. * @returns the VertexData of the LineSystem
  24272. */
  24273. static CreateLineSystem(options: {
  24274. lines: Vector3[][];
  24275. colors?: Nullable<Color4[][]>;
  24276. }): VertexData;
  24277. /**
  24278. * Create the VertexData for a DashedLines
  24279. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24280. * - points an array successive Vector3
  24281. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24282. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24283. * - dashNb the intended total number of dashes, optional, default 200
  24284. * @returns the VertexData for the DashedLines
  24285. */
  24286. static CreateDashedLines(options: {
  24287. points: Vector3[];
  24288. dashSize?: number;
  24289. gapSize?: number;
  24290. dashNb?: number;
  24291. }): VertexData;
  24292. /**
  24293. * Creates the VertexData for a Ground
  24294. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24295. * - width the width (x direction) of the ground, optional, default 1
  24296. * - height the height (z direction) of the ground, optional, default 1
  24297. * - subdivisions the number of subdivisions per side, optional, default 1
  24298. * @returns the VertexData of the Ground
  24299. */
  24300. static CreateGround(options: {
  24301. width?: number;
  24302. height?: number;
  24303. subdivisions?: number;
  24304. subdivisionsX?: number;
  24305. subdivisionsY?: number;
  24306. }): VertexData;
  24307. /**
  24308. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24309. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24310. * * xmin the ground minimum X coordinate, optional, default -1
  24311. * * zmin the ground minimum Z coordinate, optional, default -1
  24312. * * xmax the ground maximum X coordinate, optional, default 1
  24313. * * zmax the ground maximum Z coordinate, optional, default 1
  24314. * * 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}
  24315. * * 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}
  24316. * @returns the VertexData of the TiledGround
  24317. */
  24318. static CreateTiledGround(options: {
  24319. xmin: number;
  24320. zmin: number;
  24321. xmax: number;
  24322. zmax: number;
  24323. subdivisions?: {
  24324. w: number;
  24325. h: number;
  24326. };
  24327. precision?: {
  24328. w: number;
  24329. h: number;
  24330. };
  24331. }): VertexData;
  24332. /**
  24333. * Creates the VertexData of the Ground designed from a heightmap
  24334. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24335. * * width the width (x direction) of the ground
  24336. * * height the height (z direction) of the ground
  24337. * * subdivisions the number of subdivisions per side
  24338. * * minHeight the minimum altitude on the ground, optional, default 0
  24339. * * maxHeight the maximum altitude on the ground, optional default 1
  24340. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24341. * * buffer the array holding the image color data
  24342. * * bufferWidth the width of image
  24343. * * bufferHeight the height of image
  24344. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24345. * @returns the VertexData of the Ground designed from a heightmap
  24346. */
  24347. static CreateGroundFromHeightMap(options: {
  24348. width: number;
  24349. height: number;
  24350. subdivisions: number;
  24351. minHeight: number;
  24352. maxHeight: number;
  24353. colorFilter: Color3;
  24354. buffer: Uint8Array;
  24355. bufferWidth: number;
  24356. bufferHeight: number;
  24357. alphaFilter: number;
  24358. }): VertexData;
  24359. /**
  24360. * Creates the VertexData for a Plane
  24361. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24362. * * size sets the width and height of the plane to the value of size, optional default 1
  24363. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24364. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24365. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24366. * * 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)
  24367. * * 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)
  24368. * @returns the VertexData of the box
  24369. */
  24370. static CreatePlane(options: {
  24371. size?: number;
  24372. width?: number;
  24373. height?: number;
  24374. sideOrientation?: number;
  24375. frontUVs?: Vector4;
  24376. backUVs?: Vector4;
  24377. }): VertexData;
  24378. /**
  24379. * Creates the VertexData of the Disc or regular Polygon
  24380. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24381. * * radius the radius of the disc, optional default 0.5
  24382. * * tessellation the number of polygon sides, optional, default 64
  24383. * * 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
  24384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24385. * * 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)
  24386. * * 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)
  24387. * @returns the VertexData of the box
  24388. */
  24389. static CreateDisc(options: {
  24390. radius?: number;
  24391. tessellation?: number;
  24392. arc?: number;
  24393. sideOrientation?: number;
  24394. frontUVs?: Vector4;
  24395. backUVs?: Vector4;
  24396. }): VertexData;
  24397. /**
  24398. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24399. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24400. * @param polygon a mesh built from polygonTriangulation.build()
  24401. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24402. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24403. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24404. * @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)
  24405. * @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)
  24406. * @returns the VertexData of the Polygon
  24407. */
  24408. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24409. /**
  24410. * Creates the VertexData of the IcoSphere
  24411. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24412. * * radius the radius of the IcoSphere, optional default 1
  24413. * * radiusX allows stretching in the x direction, optional, default radius
  24414. * * radiusY allows stretching in the y direction, optional, default radius
  24415. * * radiusZ allows stretching in the z direction, optional, default radius
  24416. * * flat when true creates a flat shaded mesh, optional, default true
  24417. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24418. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24419. * * 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)
  24420. * * 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)
  24421. * @returns the VertexData of the IcoSphere
  24422. */
  24423. static CreateIcoSphere(options: {
  24424. radius?: number;
  24425. radiusX?: number;
  24426. radiusY?: number;
  24427. radiusZ?: number;
  24428. flat?: boolean;
  24429. subdivisions?: number;
  24430. sideOrientation?: number;
  24431. frontUVs?: Vector4;
  24432. backUVs?: Vector4;
  24433. }): VertexData;
  24434. /**
  24435. * Creates the VertexData for a Polyhedron
  24436. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24437. * * type provided types are:
  24438. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24439. * * 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)
  24440. * * size the size of the IcoSphere, optional default 1
  24441. * * sizeX allows stretching in the x direction, optional, default size
  24442. * * sizeY allows stretching in the y direction, optional, default size
  24443. * * sizeZ allows stretching in the z direction, optional, default size
  24444. * * 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
  24445. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24446. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24447. * * flat when true creates a flat shaded mesh, optional, default true
  24448. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24449. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24450. * * 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)
  24451. * * 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)
  24452. * @returns the VertexData of the Polyhedron
  24453. */
  24454. static CreatePolyhedron(options: {
  24455. type?: number;
  24456. size?: number;
  24457. sizeX?: number;
  24458. sizeY?: number;
  24459. sizeZ?: number;
  24460. custom?: any;
  24461. faceUV?: Vector4[];
  24462. faceColors?: Color4[];
  24463. flat?: boolean;
  24464. sideOrientation?: number;
  24465. frontUVs?: Vector4;
  24466. backUVs?: Vector4;
  24467. }): VertexData;
  24468. /**
  24469. * Creates the VertexData for a TorusKnot
  24470. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24471. * * radius the radius of the torus knot, optional, default 2
  24472. * * tube the thickness of the tube, optional, default 0.5
  24473. * * radialSegments the number of sides on each tube segments, optional, default 32
  24474. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24475. * * p the number of windings around the z axis, optional, default 2
  24476. * * q the number of windings around the x axis, optional, default 3
  24477. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24478. * * 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)
  24479. * * 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)
  24480. * @returns the VertexData of the Torus Knot
  24481. */
  24482. static CreateTorusKnot(options: {
  24483. radius?: number;
  24484. tube?: number;
  24485. radialSegments?: number;
  24486. tubularSegments?: number;
  24487. p?: number;
  24488. q?: number;
  24489. sideOrientation?: number;
  24490. frontUVs?: Vector4;
  24491. backUVs?: Vector4;
  24492. }): VertexData;
  24493. /**
  24494. * Compute normals for given positions and indices
  24495. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24496. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24497. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24498. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24499. * * facetNormals : optional array of facet normals (vector3)
  24500. * * facetPositions : optional array of facet positions (vector3)
  24501. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24502. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24503. * * bInfo : optional bounding info, required for facetPartitioning computation
  24504. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24505. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24506. * * useRightHandedSystem: optional boolean to for right handed system computation
  24507. * * depthSort : optional boolean to enable the facet depth sort computation
  24508. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24509. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24510. */
  24511. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24512. facetNormals?: any;
  24513. facetPositions?: any;
  24514. facetPartitioning?: any;
  24515. ratio?: number;
  24516. bInfo?: any;
  24517. bbSize?: Vector3;
  24518. subDiv?: any;
  24519. useRightHandedSystem?: boolean;
  24520. depthSort?: boolean;
  24521. distanceTo?: Vector3;
  24522. depthSortedFacets?: any;
  24523. }): void;
  24524. /** @hidden */
  24525. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24526. /**
  24527. * Applies VertexData created from the imported parameters to the geometry
  24528. * @param parsedVertexData the parsed data from an imported file
  24529. * @param geometry the geometry to apply the VertexData to
  24530. */
  24531. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24532. }
  24533. }
  24534. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24535. import { Nullable } from "babylonjs/types";
  24536. import { Scene } from "babylonjs/scene";
  24537. import { Vector4 } from "babylonjs/Maths/math";
  24538. import { Mesh } from "babylonjs/Meshes/mesh";
  24539. /**
  24540. * Class containing static functions to help procedurally build meshes
  24541. */
  24542. export class DiscBuilder {
  24543. /**
  24544. * Creates a plane polygonal mesh. By default, this is a disc
  24545. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24546. * * 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
  24547. * * 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
  24548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24551. * @param name defines the name of the mesh
  24552. * @param options defines the options used to create the mesh
  24553. * @param scene defines the hosting scene
  24554. * @returns the plane polygonal mesh
  24555. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24556. */
  24557. static CreateDisc(name: string, options: {
  24558. radius?: number;
  24559. tessellation?: number;
  24560. arc?: number;
  24561. updatable?: boolean;
  24562. sideOrientation?: number;
  24563. frontUVs?: Vector4;
  24564. backUVs?: Vector4;
  24565. }, scene?: Nullable<Scene>): Mesh;
  24566. }
  24567. }
  24568. declare module "babylonjs/Particles/solidParticleSystem" {
  24569. import { Vector3 } from "babylonjs/Maths/math";
  24570. import { Mesh } from "babylonjs/Meshes/mesh";
  24571. import { Scene, IDisposable } from "babylonjs/scene";
  24572. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24573. /**
  24574. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24575. *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.
  24576. * The SPS is also a particle system. It provides some methods to manage the particles.
  24577. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24578. *
  24579. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24580. */
  24581. export class SolidParticleSystem implements IDisposable {
  24582. /**
  24583. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24584. * Example : var p = SPS.particles[i];
  24585. */
  24586. particles: SolidParticle[];
  24587. /**
  24588. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24589. */
  24590. nbParticles: number;
  24591. /**
  24592. * If the particles must ever face the camera (default false). Useful for planar particles.
  24593. */
  24594. billboard: boolean;
  24595. /**
  24596. * Recompute normals when adding a shape
  24597. */
  24598. recomputeNormals: boolean;
  24599. /**
  24600. * This a counter ofr your own usage. It's not set by any SPS functions.
  24601. */
  24602. counter: number;
  24603. /**
  24604. * The SPS name. This name is also given to the underlying mesh.
  24605. */
  24606. name: string;
  24607. /**
  24608. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24609. */
  24610. mesh: Mesh;
  24611. /**
  24612. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24613. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24614. */
  24615. vars: any;
  24616. /**
  24617. * This array is populated when the SPS is set as 'pickable'.
  24618. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24619. * Each element of this array is an object `{idx: int, faceId: int}`.
  24620. * `idx` is the picked particle index in the `SPS.particles` array
  24621. * `faceId` is the picked face index counted within this particle.
  24622. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24623. */
  24624. pickedParticles: {
  24625. idx: number;
  24626. faceId: number;
  24627. }[];
  24628. /**
  24629. * This array is populated when `enableDepthSort` is set to true.
  24630. * Each element of this array is an instance of the class DepthSortedParticle.
  24631. */
  24632. depthSortedParticles: DepthSortedParticle[];
  24633. /**
  24634. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24635. * @hidden
  24636. */
  24637. _bSphereOnly: boolean;
  24638. /**
  24639. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24640. * @hidden
  24641. */
  24642. _bSphereRadiusFactor: number;
  24643. private _scene;
  24644. private _positions;
  24645. private _indices;
  24646. private _normals;
  24647. private _colors;
  24648. private _uvs;
  24649. private _indices32;
  24650. private _positions32;
  24651. private _normals32;
  24652. private _fixedNormal32;
  24653. private _colors32;
  24654. private _uvs32;
  24655. private _index;
  24656. private _updatable;
  24657. private _pickable;
  24658. private _isVisibilityBoxLocked;
  24659. private _alwaysVisible;
  24660. private _depthSort;
  24661. private _shapeCounter;
  24662. private _copy;
  24663. private _color;
  24664. private _computeParticleColor;
  24665. private _computeParticleTexture;
  24666. private _computeParticleRotation;
  24667. private _computeParticleVertex;
  24668. private _computeBoundingBox;
  24669. private _depthSortParticles;
  24670. private _camera;
  24671. private _mustUnrotateFixedNormals;
  24672. private _particlesIntersect;
  24673. private _needs32Bits;
  24674. /**
  24675. * Creates a SPS (Solid Particle System) object.
  24676. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24677. * @param scene (Scene) is the scene in which the SPS is added.
  24678. * @param options defines the options of the sps e.g.
  24679. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24680. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24681. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24682. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24683. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24684. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24685. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24686. */
  24687. constructor(name: string, scene: Scene, options?: {
  24688. updatable?: boolean;
  24689. isPickable?: boolean;
  24690. enableDepthSort?: boolean;
  24691. particleIntersection?: boolean;
  24692. boundingSphereOnly?: boolean;
  24693. bSphereRadiusFactor?: number;
  24694. });
  24695. /**
  24696. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24697. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24698. * @returns the created mesh
  24699. */
  24700. buildMesh(): Mesh;
  24701. /**
  24702. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24703. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24704. * Thus the particles generated from `digest()` have their property `position` set yet.
  24705. * @param mesh ( Mesh ) is the mesh to be digested
  24706. * @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
  24707. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24708. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24709. * @returns the current SPS
  24710. */
  24711. digest(mesh: Mesh, options?: {
  24712. facetNb?: number;
  24713. number?: number;
  24714. delta?: number;
  24715. }): SolidParticleSystem;
  24716. private _unrotateFixedNormals;
  24717. private _resetCopy;
  24718. private _meshBuilder;
  24719. private _posToShape;
  24720. private _uvsToShapeUV;
  24721. private _addParticle;
  24722. /**
  24723. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24724. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24725. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24726. * @param nb (positive integer) the number of particles to be created from this model
  24727. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24728. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24729. * @returns the number of shapes in the system
  24730. */
  24731. addShape(mesh: Mesh, nb: number, options?: {
  24732. positionFunction?: any;
  24733. vertexFunction?: any;
  24734. }): number;
  24735. private _rebuildParticle;
  24736. /**
  24737. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24738. * @returns the SPS.
  24739. */
  24740. rebuildMesh(): SolidParticleSystem;
  24741. /**
  24742. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24743. * This method calls `updateParticle()` for each particle of the SPS.
  24744. * For an animated SPS, it is usually called within the render loop.
  24745. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24746. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24747. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24748. * @returns the SPS.
  24749. */
  24750. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24751. /**
  24752. * Disposes the SPS.
  24753. */
  24754. dispose(): void;
  24755. /**
  24756. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24757. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24758. * @returns the SPS.
  24759. */
  24760. refreshVisibleSize(): SolidParticleSystem;
  24761. /**
  24762. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24763. * @param size the size (float) of the visibility box
  24764. * note : this doesn't lock the SPS mesh bounding box.
  24765. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24766. */
  24767. setVisibilityBox(size: number): void;
  24768. /**
  24769. * Gets whether the SPS as always visible or not
  24770. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24771. */
  24772. /**
  24773. * Sets the SPS as always visible or not
  24774. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24775. */
  24776. isAlwaysVisible: boolean;
  24777. /**
  24778. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24779. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24780. */
  24781. /**
  24782. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24783. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24784. */
  24785. isVisibilityBoxLocked: boolean;
  24786. /**
  24787. * Tells to `setParticles()` to compute the particle rotations or not.
  24788. * Default value : true. The SPS is faster when it's set to false.
  24789. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24790. */
  24791. /**
  24792. * Gets if `setParticles()` computes the particle rotations or not.
  24793. * Default value : true. The SPS is faster when it's set to false.
  24794. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24795. */
  24796. computeParticleRotation: boolean;
  24797. /**
  24798. * Tells to `setParticles()` to compute the particle colors or not.
  24799. * Default value : true. The SPS is faster when it's set to false.
  24800. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24801. */
  24802. /**
  24803. * Gets if `setParticles()` computes the particle colors or not.
  24804. * Default value : true. The SPS is faster when it's set to false.
  24805. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24806. */
  24807. computeParticleColor: boolean;
  24808. /**
  24809. * Gets if `setParticles()` computes the particle textures or not.
  24810. * Default value : true. The SPS is faster when it's set to false.
  24811. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24812. */
  24813. computeParticleTexture: boolean;
  24814. /**
  24815. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24816. * Default value : false. The SPS is faster when it's set to false.
  24817. * Note : the particle custom vertex positions aren't stored values.
  24818. */
  24819. /**
  24820. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24821. * Default value : false. The SPS is faster when it's set to false.
  24822. * Note : the particle custom vertex positions aren't stored values.
  24823. */
  24824. computeParticleVertex: boolean;
  24825. /**
  24826. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24827. */
  24828. /**
  24829. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24830. */
  24831. computeBoundingBox: boolean;
  24832. /**
  24833. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24834. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24835. * Default : `true`
  24836. */
  24837. /**
  24838. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24839. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24840. * Default : `true`
  24841. */
  24842. depthSortParticles: boolean;
  24843. /**
  24844. * This function does nothing. It may be overwritten to set all the particle first values.
  24845. * The SPS doesn't call this function, you may have to call it by your own.
  24846. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24847. */
  24848. initParticles(): void;
  24849. /**
  24850. * This function does nothing. It may be overwritten to recycle a particle.
  24851. * The SPS doesn't call this function, you may have to call it by your own.
  24852. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24853. * @param particle The particle to recycle
  24854. * @returns the recycled particle
  24855. */
  24856. recycleParticle(particle: SolidParticle): SolidParticle;
  24857. /**
  24858. * Updates a particle : this function should be overwritten by the user.
  24859. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24860. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24861. * @example : just set a particle position or velocity and recycle conditions
  24862. * @param particle The particle to update
  24863. * @returns the updated particle
  24864. */
  24865. updateParticle(particle: SolidParticle): SolidParticle;
  24866. /**
  24867. * Updates a vertex of a particle : it can be overwritten by the user.
  24868. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24869. * @param particle the current particle
  24870. * @param vertex the current index of the current particle
  24871. * @param pt the index of the current vertex in the particle shape
  24872. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24873. * @example : just set a vertex particle position
  24874. * @returns the updated vertex
  24875. */
  24876. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24877. /**
  24878. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24879. * This does nothing and may be overwritten by the user.
  24880. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24881. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24882. * @param update the boolean update value actually passed to setParticles()
  24883. */
  24884. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24885. /**
  24886. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24887. * This will be passed three parameters.
  24888. * This does nothing and may be overwritten by the user.
  24889. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24890. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24891. * @param update the boolean update value actually passed to setParticles()
  24892. */
  24893. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24894. }
  24895. }
  24896. declare module "babylonjs/Particles/solidParticle" {
  24897. import { Nullable } from "babylonjs/types";
  24898. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24899. import { Mesh } from "babylonjs/Meshes/mesh";
  24900. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24901. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24902. /**
  24903. * Represents one particle of a solid particle system.
  24904. */
  24905. export class SolidParticle {
  24906. /**
  24907. * particle global index
  24908. */
  24909. idx: number;
  24910. /**
  24911. * The color of the particle
  24912. */
  24913. color: Nullable<Color4>;
  24914. /**
  24915. * The world space position of the particle.
  24916. */
  24917. position: Vector3;
  24918. /**
  24919. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24920. */
  24921. rotation: Vector3;
  24922. /**
  24923. * The world space rotation quaternion of the particle.
  24924. */
  24925. rotationQuaternion: Nullable<Quaternion>;
  24926. /**
  24927. * The scaling of the particle.
  24928. */
  24929. scaling: Vector3;
  24930. /**
  24931. * The uvs of the particle.
  24932. */
  24933. uvs: Vector4;
  24934. /**
  24935. * The current speed of the particle.
  24936. */
  24937. velocity: Vector3;
  24938. /**
  24939. * The pivot point in the particle local space.
  24940. */
  24941. pivot: Vector3;
  24942. /**
  24943. * Must the particle be translated from its pivot point in its local space ?
  24944. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24945. * Default : false
  24946. */
  24947. translateFromPivot: boolean;
  24948. /**
  24949. * Is the particle active or not ?
  24950. */
  24951. alive: boolean;
  24952. /**
  24953. * Is the particle visible or not ?
  24954. */
  24955. isVisible: boolean;
  24956. /**
  24957. * Index of this particle in the global "positions" array (Internal use)
  24958. * @hidden
  24959. */
  24960. _pos: number;
  24961. /**
  24962. * @hidden Index of this particle in the global "indices" array (Internal use)
  24963. */
  24964. _ind: number;
  24965. /**
  24966. * @hidden ModelShape of this particle (Internal use)
  24967. */
  24968. _model: ModelShape;
  24969. /**
  24970. * ModelShape id of this particle
  24971. */
  24972. shapeId: number;
  24973. /**
  24974. * Index of the particle in its shape id (Internal use)
  24975. */
  24976. idxInShape: number;
  24977. /**
  24978. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24979. */
  24980. _modelBoundingInfo: BoundingInfo;
  24981. /**
  24982. * @hidden Particle BoundingInfo object (Internal use)
  24983. */
  24984. _boundingInfo: BoundingInfo;
  24985. /**
  24986. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24987. */
  24988. _sps: SolidParticleSystem;
  24989. /**
  24990. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24991. */
  24992. _stillInvisible: boolean;
  24993. /**
  24994. * @hidden Last computed particle rotation matrix
  24995. */
  24996. _rotationMatrix: number[];
  24997. /**
  24998. * Parent particle Id, if any.
  24999. * Default null.
  25000. */
  25001. parentId: Nullable<number>;
  25002. /**
  25003. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25004. * The possible values are :
  25005. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25006. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25007. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25008. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25009. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25010. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25011. * */
  25012. cullingStrategy: number;
  25013. /**
  25014. * @hidden Internal global position in the SPS.
  25015. */
  25016. _globalPosition: Vector3;
  25017. /**
  25018. * Creates a Solid Particle object.
  25019. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25020. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25021. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25022. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25023. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25024. * @param shapeId (integer) is the model shape identifier in the SPS.
  25025. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25026. * @param sps defines the sps it is associated to
  25027. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25028. */
  25029. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25030. /**
  25031. * Legacy support, changed scale to scaling
  25032. */
  25033. /**
  25034. * Legacy support, changed scale to scaling
  25035. */
  25036. scale: Vector3;
  25037. /**
  25038. * Legacy support, changed quaternion to rotationQuaternion
  25039. */
  25040. /**
  25041. * Legacy support, changed quaternion to rotationQuaternion
  25042. */
  25043. quaternion: Nullable<Quaternion>;
  25044. /**
  25045. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25046. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25047. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25048. * @returns true if it intersects
  25049. */
  25050. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25051. /**
  25052. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25053. * A particle is in the frustum if its bounding box intersects the frustum
  25054. * @param frustumPlanes defines the frustum to test
  25055. * @returns true if the particle is in the frustum planes
  25056. */
  25057. isInFrustum(frustumPlanes: Plane[]): boolean;
  25058. /**
  25059. * get the rotation matrix of the particle
  25060. * @hidden
  25061. */
  25062. getRotationMatrix(m: Matrix): void;
  25063. }
  25064. /**
  25065. * Represents the shape of the model used by one particle of a solid particle system.
  25066. * SPS internal tool, don't use it manually.
  25067. */
  25068. export class ModelShape {
  25069. /**
  25070. * The shape id
  25071. * @hidden
  25072. */
  25073. shapeID: number;
  25074. /**
  25075. * flat array of model positions (internal use)
  25076. * @hidden
  25077. */
  25078. _shape: Vector3[];
  25079. /**
  25080. * flat array of model UVs (internal use)
  25081. * @hidden
  25082. */
  25083. _shapeUV: number[];
  25084. /**
  25085. * length of the shape in the model indices array (internal use)
  25086. * @hidden
  25087. */
  25088. _indicesLength: number;
  25089. /**
  25090. * Custom position function (internal use)
  25091. * @hidden
  25092. */
  25093. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25094. /**
  25095. * Custom vertex function (internal use)
  25096. * @hidden
  25097. */
  25098. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25099. /**
  25100. * 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.
  25101. * SPS internal tool, don't use it manually.
  25102. * @hidden
  25103. */
  25104. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25105. }
  25106. /**
  25107. * Represents a Depth Sorted Particle in the solid particle system.
  25108. */
  25109. export class DepthSortedParticle {
  25110. /**
  25111. * Index of the particle in the "indices" array
  25112. */
  25113. ind: number;
  25114. /**
  25115. * Length of the particle shape in the "indices" array
  25116. */
  25117. indicesLength: number;
  25118. /**
  25119. * Squared distance from the particle to the camera
  25120. */
  25121. sqDistance: number;
  25122. }
  25123. }
  25124. declare module "babylonjs/Collisions/meshCollisionData" {
  25125. import { Collider } from "babylonjs/Collisions/collider";
  25126. import { Vector3 } from "babylonjs/Maths/math";
  25127. import { Nullable } from "babylonjs/types";
  25128. import { Observer } from "babylonjs/Misc/observable";
  25129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25130. /**
  25131. * @hidden
  25132. */
  25133. export class _MeshCollisionData {
  25134. _checkCollisions: boolean;
  25135. _collisionMask: number;
  25136. _collisionGroup: number;
  25137. _collider: Nullable<Collider>;
  25138. _oldPositionForCollisions: Vector3;
  25139. _diffPositionForCollisions: Vector3;
  25140. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25141. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25142. }
  25143. }
  25144. declare module "babylonjs/Meshes/abstractMesh" {
  25145. import { Observable } from "babylonjs/Misc/observable";
  25146. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25147. import { Camera } from "babylonjs/Cameras/camera";
  25148. import { Scene, IDisposable } from "babylonjs/scene";
  25149. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25150. import { Node } from "babylonjs/node";
  25151. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25152. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25153. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25154. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25155. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25156. import { Material } from "babylonjs/Materials/material";
  25157. import { Light } from "babylonjs/Lights/light";
  25158. import { Skeleton } from "babylonjs/Bones/skeleton";
  25159. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25160. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25161. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25162. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  25163. import { Ray } from "babylonjs/Culling/ray";
  25164. import { Collider } from "babylonjs/Collisions/collider";
  25165. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25166. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25167. /** @hidden */
  25168. class _FacetDataStorage {
  25169. facetPositions: Vector3[];
  25170. facetNormals: Vector3[];
  25171. facetPartitioning: number[][];
  25172. facetNb: number;
  25173. partitioningSubdivisions: number;
  25174. partitioningBBoxRatio: number;
  25175. facetDataEnabled: boolean;
  25176. facetParameters: any;
  25177. bbSize: Vector3;
  25178. subDiv: {
  25179. max: number;
  25180. X: number;
  25181. Y: number;
  25182. Z: number;
  25183. };
  25184. facetDepthSort: boolean;
  25185. facetDepthSortEnabled: boolean;
  25186. depthSortedIndices: IndicesArray;
  25187. depthSortedFacets: {
  25188. ind: number;
  25189. sqDistance: number;
  25190. }[];
  25191. facetDepthSortFunction: (f1: {
  25192. ind: number;
  25193. sqDistance: number;
  25194. }, f2: {
  25195. ind: number;
  25196. sqDistance: number;
  25197. }) => number;
  25198. facetDepthSortFrom: Vector3;
  25199. facetDepthSortOrigin: Vector3;
  25200. invertedMatrix: Matrix;
  25201. }
  25202. /**
  25203. * @hidden
  25204. **/
  25205. class _InternalAbstractMeshDataInfo {
  25206. _hasVertexAlpha: boolean;
  25207. _useVertexColors: boolean;
  25208. _numBoneInfluencers: number;
  25209. _applyFog: boolean;
  25210. _receiveShadows: boolean;
  25211. _facetData: _FacetDataStorage;
  25212. _visibility: number;
  25213. _skeleton: Nullable<Skeleton>;
  25214. _layerMask: number;
  25215. _computeBonesUsingShaders: boolean;
  25216. _isActive: boolean;
  25217. _onlyForInstances: boolean;
  25218. _isActiveIntermediate: boolean;
  25219. _onlyForInstancesIntermediate: boolean;
  25220. }
  25221. /**
  25222. * Class used to store all common mesh properties
  25223. */
  25224. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25225. /** No occlusion */
  25226. static OCCLUSION_TYPE_NONE: number;
  25227. /** Occlusion set to optimisitic */
  25228. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25229. /** Occlusion set to strict */
  25230. static OCCLUSION_TYPE_STRICT: number;
  25231. /** Use an accurante occlusion algorithm */
  25232. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25233. /** Use a conservative occlusion algorithm */
  25234. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25235. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25236. * Test order :
  25237. * Is the bounding sphere outside the frustum ?
  25238. * If not, are the bounding box vertices outside the frustum ?
  25239. * It not, then the cullable object is in the frustum.
  25240. */
  25241. static readonly CULLINGSTRATEGY_STANDARD: number;
  25242. /** Culling strategy : Bounding Sphere Only.
  25243. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25244. * It's also less accurate than the standard because some not visible objects can still be selected.
  25245. * Test : is the bounding sphere outside the frustum ?
  25246. * If not, then the cullable object is in the frustum.
  25247. */
  25248. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25249. /** Culling strategy : Optimistic Inclusion.
  25250. * This in an inclusion test first, then the standard exclusion test.
  25251. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25252. * 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.
  25253. * Anyway, it's as accurate as the standard strategy.
  25254. * Test :
  25255. * Is the cullable object bounding sphere center in the frustum ?
  25256. * If not, apply the default culling strategy.
  25257. */
  25258. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25259. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25260. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25261. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25262. * 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.
  25263. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25264. * Test :
  25265. * Is the cullable object bounding sphere center in the frustum ?
  25266. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25267. */
  25268. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25269. /**
  25270. * No billboard
  25271. */
  25272. static readonly BILLBOARDMODE_NONE: number;
  25273. /** Billboard on X axis */
  25274. static readonly BILLBOARDMODE_X: number;
  25275. /** Billboard on Y axis */
  25276. static readonly BILLBOARDMODE_Y: number;
  25277. /** Billboard on Z axis */
  25278. static readonly BILLBOARDMODE_Z: number;
  25279. /** Billboard on all axes */
  25280. static readonly BILLBOARDMODE_ALL: number;
  25281. /** @hidden */
  25282. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25283. /**
  25284. * The culling strategy to use to check whether the mesh must be rendered or not.
  25285. * This value can be changed at any time and will be used on the next render mesh selection.
  25286. * The possible values are :
  25287. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25288. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25289. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25290. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25291. * Please read each static variable documentation to get details about the culling process.
  25292. * */
  25293. cullingStrategy: number;
  25294. /**
  25295. * Gets the number of facets in the mesh
  25296. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25297. */
  25298. readonly facetNb: number;
  25299. /**
  25300. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25302. */
  25303. partitioningSubdivisions: number;
  25304. /**
  25305. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25306. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25307. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25308. */
  25309. partitioningBBoxRatio: number;
  25310. /**
  25311. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25312. * Works only for updatable meshes.
  25313. * Doesn't work with multi-materials
  25314. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25315. */
  25316. mustDepthSortFacets: boolean;
  25317. /**
  25318. * The location (Vector3) where the facet depth sort must be computed from.
  25319. * By default, the active camera position.
  25320. * Used only when facet depth sort is enabled
  25321. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25322. */
  25323. facetDepthSortFrom: Vector3;
  25324. /**
  25325. * gets a boolean indicating if facetData is enabled
  25326. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25327. */
  25328. readonly isFacetDataEnabled: boolean;
  25329. /** @hidden */
  25330. _updateNonUniformScalingState(value: boolean): boolean;
  25331. /**
  25332. * An event triggered when this mesh collides with another one
  25333. */
  25334. onCollideObservable: Observable<AbstractMesh>;
  25335. /** Set a function to call when this mesh collides with another one */
  25336. onCollide: () => void;
  25337. /**
  25338. * An event triggered when the collision's position changes
  25339. */
  25340. onCollisionPositionChangeObservable: Observable<Vector3>;
  25341. /** Set a function to call when the collision's position changes */
  25342. onCollisionPositionChange: () => void;
  25343. /**
  25344. * An event triggered when material is changed
  25345. */
  25346. onMaterialChangedObservable: Observable<AbstractMesh>;
  25347. /**
  25348. * Gets or sets the orientation for POV movement & rotation
  25349. */
  25350. definedFacingForward: boolean;
  25351. /** @hidden */
  25352. _occlusionQuery: Nullable<WebGLQuery>;
  25353. /** @hidden */
  25354. _renderingGroup: Nullable<RenderingGroup>;
  25355. /**
  25356. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25357. */
  25358. /**
  25359. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25360. */
  25361. visibility: number;
  25362. /** Gets or sets the alpha index used to sort transparent meshes
  25363. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25364. */
  25365. alphaIndex: number;
  25366. /**
  25367. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25368. */
  25369. isVisible: boolean;
  25370. /**
  25371. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25372. */
  25373. isPickable: boolean;
  25374. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25375. showSubMeshesBoundingBox: boolean;
  25376. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25377. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25378. */
  25379. isBlocker: boolean;
  25380. /**
  25381. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25382. */
  25383. enablePointerMoveEvents: boolean;
  25384. /**
  25385. * Specifies the rendering group id for this mesh (0 by default)
  25386. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25387. */
  25388. renderingGroupId: number;
  25389. private _material;
  25390. /** Gets or sets current material */
  25391. material: Nullable<Material>;
  25392. /**
  25393. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25394. * @see http://doc.babylonjs.com/babylon101/shadows
  25395. */
  25396. receiveShadows: boolean;
  25397. /** Defines color to use when rendering outline */
  25398. outlineColor: Color3;
  25399. /** Define width to use when rendering outline */
  25400. outlineWidth: number;
  25401. /** Defines color to use when rendering overlay */
  25402. overlayColor: Color3;
  25403. /** Defines alpha to use when rendering overlay */
  25404. overlayAlpha: number;
  25405. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25406. hasVertexAlpha: boolean;
  25407. /** 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) */
  25408. useVertexColors: boolean;
  25409. /**
  25410. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25411. */
  25412. computeBonesUsingShaders: boolean;
  25413. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25414. numBoneInfluencers: number;
  25415. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25416. applyFog: boolean;
  25417. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25418. useOctreeForRenderingSelection: boolean;
  25419. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25420. useOctreeForPicking: boolean;
  25421. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25422. useOctreeForCollisions: boolean;
  25423. /**
  25424. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25425. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25426. */
  25427. layerMask: number;
  25428. /**
  25429. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25430. */
  25431. alwaysSelectAsActiveMesh: boolean;
  25432. /**
  25433. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25434. */
  25435. doNotSyncBoundingInfo: boolean;
  25436. /**
  25437. * Gets or sets the current action manager
  25438. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25439. */
  25440. actionManager: Nullable<AbstractActionManager>;
  25441. private _meshCollisionData;
  25442. /**
  25443. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25444. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25445. */
  25446. ellipsoid: Vector3;
  25447. /**
  25448. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25449. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25450. */
  25451. ellipsoidOffset: Vector3;
  25452. /**
  25453. * Gets or sets a collision mask used to mask collisions (default is -1).
  25454. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25455. */
  25456. collisionMask: number;
  25457. /**
  25458. * Gets or sets the current collision group mask (-1 by default).
  25459. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25460. */
  25461. collisionGroup: number;
  25462. /**
  25463. * Defines edge width used when edgesRenderer is enabled
  25464. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25465. */
  25466. edgesWidth: number;
  25467. /**
  25468. * Defines edge color used when edgesRenderer is enabled
  25469. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25470. */
  25471. edgesColor: Color4;
  25472. /** @hidden */
  25473. _edgesRenderer: Nullable<IEdgesRenderer>;
  25474. /** @hidden */
  25475. _masterMesh: Nullable<AbstractMesh>;
  25476. /** @hidden */
  25477. _boundingInfo: Nullable<BoundingInfo>;
  25478. /** @hidden */
  25479. _renderId: number;
  25480. /**
  25481. * Gets or sets the list of subMeshes
  25482. * @see http://doc.babylonjs.com/how_to/multi_materials
  25483. */
  25484. subMeshes: SubMesh[];
  25485. /** @hidden */
  25486. _intersectionsInProgress: AbstractMesh[];
  25487. /** @hidden */
  25488. _unIndexed: boolean;
  25489. /** @hidden */
  25490. _lightSources: Light[];
  25491. /** Gets the list of lights affecting that mesh */
  25492. readonly lightSources: Light[];
  25493. /** @hidden */
  25494. readonly _positions: Nullable<Vector3[]>;
  25495. /** @hidden */
  25496. _waitingData: {
  25497. lods: Nullable<any>;
  25498. actions: Nullable<any>;
  25499. freezeWorldMatrix: Nullable<boolean>;
  25500. };
  25501. /** @hidden */
  25502. _bonesTransformMatrices: Nullable<Float32Array>;
  25503. /** @hidden */
  25504. _transformMatrixTexture: Nullable<RawTexture>;
  25505. /**
  25506. * Gets or sets a skeleton to apply skining transformations
  25507. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25508. */
  25509. skeleton: Nullable<Skeleton>;
  25510. /**
  25511. * An event triggered when the mesh is rebuilt.
  25512. */
  25513. onRebuildObservable: Observable<AbstractMesh>;
  25514. /**
  25515. * Creates a new AbstractMesh
  25516. * @param name defines the name of the mesh
  25517. * @param scene defines the hosting scene
  25518. */
  25519. constructor(name: string, scene?: Nullable<Scene>);
  25520. /**
  25521. * Returns the string "AbstractMesh"
  25522. * @returns "AbstractMesh"
  25523. */
  25524. getClassName(): string;
  25525. /**
  25526. * Gets a string representation of the current mesh
  25527. * @param fullDetails defines a boolean indicating if full details must be included
  25528. * @returns a string representation of the current mesh
  25529. */
  25530. toString(fullDetails?: boolean): string;
  25531. /**
  25532. * @hidden
  25533. */
  25534. protected _getEffectiveParent(): Nullable<Node>;
  25535. /** @hidden */
  25536. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25537. /** @hidden */
  25538. _rebuild(): void;
  25539. /** @hidden */
  25540. _resyncLightSources(): void;
  25541. /** @hidden */
  25542. _resyncLighSource(light: Light): void;
  25543. /** @hidden */
  25544. _unBindEffect(): void;
  25545. /** @hidden */
  25546. _removeLightSource(light: Light): void;
  25547. private _markSubMeshesAsDirty;
  25548. /** @hidden */
  25549. _markSubMeshesAsLightDirty(): void;
  25550. /** @hidden */
  25551. _markSubMeshesAsAttributesDirty(): void;
  25552. /** @hidden */
  25553. _markSubMeshesAsMiscDirty(): void;
  25554. /**
  25555. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25556. */
  25557. scaling: Vector3;
  25558. /**
  25559. * Returns true if the mesh is blocked. Implemented by child classes
  25560. */
  25561. readonly isBlocked: boolean;
  25562. /**
  25563. * Returns the mesh itself by default. Implemented by child classes
  25564. * @param camera defines the camera to use to pick the right LOD level
  25565. * @returns the currentAbstractMesh
  25566. */
  25567. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25568. /**
  25569. * Returns 0 by default. Implemented by child classes
  25570. * @returns an integer
  25571. */
  25572. getTotalVertices(): number;
  25573. /**
  25574. * Returns a positive integer : the total number of indices in this mesh geometry.
  25575. * @returns the numner of indices or zero if the mesh has no geometry.
  25576. */
  25577. getTotalIndices(): number;
  25578. /**
  25579. * Returns null by default. Implemented by child classes
  25580. * @returns null
  25581. */
  25582. getIndices(): Nullable<IndicesArray>;
  25583. /**
  25584. * Returns the array of the requested vertex data kind. Implemented by child classes
  25585. * @param kind defines the vertex data kind to use
  25586. * @returns null
  25587. */
  25588. getVerticesData(kind: string): Nullable<FloatArray>;
  25589. /**
  25590. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25591. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25592. * Note that a new underlying VertexBuffer object is created each call.
  25593. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25594. * @param kind defines vertex data kind:
  25595. * * VertexBuffer.PositionKind
  25596. * * VertexBuffer.UVKind
  25597. * * VertexBuffer.UV2Kind
  25598. * * VertexBuffer.UV3Kind
  25599. * * VertexBuffer.UV4Kind
  25600. * * VertexBuffer.UV5Kind
  25601. * * VertexBuffer.UV6Kind
  25602. * * VertexBuffer.ColorKind
  25603. * * VertexBuffer.MatricesIndicesKind
  25604. * * VertexBuffer.MatricesIndicesExtraKind
  25605. * * VertexBuffer.MatricesWeightsKind
  25606. * * VertexBuffer.MatricesWeightsExtraKind
  25607. * @param data defines the data source
  25608. * @param updatable defines if the data must be flagged as updatable (or static)
  25609. * @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
  25610. * @returns the current mesh
  25611. */
  25612. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25613. /**
  25614. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25615. * If the mesh has no geometry, it is simply returned as it is.
  25616. * @param kind defines vertex data kind:
  25617. * * VertexBuffer.PositionKind
  25618. * * VertexBuffer.UVKind
  25619. * * VertexBuffer.UV2Kind
  25620. * * VertexBuffer.UV3Kind
  25621. * * VertexBuffer.UV4Kind
  25622. * * VertexBuffer.UV5Kind
  25623. * * VertexBuffer.UV6Kind
  25624. * * VertexBuffer.ColorKind
  25625. * * VertexBuffer.MatricesIndicesKind
  25626. * * VertexBuffer.MatricesIndicesExtraKind
  25627. * * VertexBuffer.MatricesWeightsKind
  25628. * * VertexBuffer.MatricesWeightsExtraKind
  25629. * @param data defines the data source
  25630. * @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
  25631. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25632. * @returns the current mesh
  25633. */
  25634. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25635. /**
  25636. * Sets the mesh indices,
  25637. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25638. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25639. * @param totalVertices Defines the total number of vertices
  25640. * @returns the current mesh
  25641. */
  25642. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25643. /**
  25644. * Gets a boolean indicating if specific vertex data is present
  25645. * @param kind defines the vertex data kind to use
  25646. * @returns true is data kind is present
  25647. */
  25648. isVerticesDataPresent(kind: string): boolean;
  25649. /**
  25650. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25651. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25652. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25653. * @returns a BoundingInfo
  25654. */
  25655. getBoundingInfo(): BoundingInfo;
  25656. /**
  25657. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25658. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25659. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25660. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25661. * @returns the current mesh
  25662. */
  25663. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25664. /**
  25665. * Overwrite the current bounding info
  25666. * @param boundingInfo defines the new bounding info
  25667. * @returns the current mesh
  25668. */
  25669. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25670. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25671. readonly useBones: boolean;
  25672. /** @hidden */
  25673. _preActivate(): void;
  25674. /** @hidden */
  25675. _preActivateForIntermediateRendering(renderId: number): void;
  25676. /** @hidden */
  25677. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25678. /** @hidden */
  25679. _postActivate(): void;
  25680. /** @hidden */
  25681. _freeze(): void;
  25682. /** @hidden */
  25683. _unFreeze(): void;
  25684. /**
  25685. * Gets the current world matrix
  25686. * @returns a Matrix
  25687. */
  25688. getWorldMatrix(): Matrix;
  25689. /** @hidden */
  25690. _getWorldMatrixDeterminant(): number;
  25691. /**
  25692. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25693. */
  25694. readonly isAnInstance: boolean;
  25695. /**
  25696. * Perform relative position change from the point of view of behind the front of the mesh.
  25697. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25698. * Supports definition of mesh facing forward or backward
  25699. * @param amountRight defines the distance on the right axis
  25700. * @param amountUp defines the distance on the up axis
  25701. * @param amountForward defines the distance on the forward axis
  25702. * @returns the current mesh
  25703. */
  25704. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25705. /**
  25706. * Calculate relative position change from the point of view of behind the front of the mesh.
  25707. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25708. * Supports definition of mesh facing forward or backward
  25709. * @param amountRight defines the distance on the right axis
  25710. * @param amountUp defines the distance on the up axis
  25711. * @param amountForward defines the distance on the forward axis
  25712. * @returns the new displacement vector
  25713. */
  25714. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25715. /**
  25716. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25717. * Supports definition of mesh facing forward or backward
  25718. * @param flipBack defines the flip
  25719. * @param twirlClockwise defines the twirl
  25720. * @param tiltRight defines the tilt
  25721. * @returns the current mesh
  25722. */
  25723. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25724. /**
  25725. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25726. * Supports definition of mesh facing forward or backward.
  25727. * @param flipBack defines the flip
  25728. * @param twirlClockwise defines the twirl
  25729. * @param tiltRight defines the tilt
  25730. * @returns the new rotation vector
  25731. */
  25732. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25733. /**
  25734. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25735. * This means the mesh underlying bounding box and sphere are recomputed.
  25736. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25737. * @returns the current mesh
  25738. */
  25739. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25740. /** @hidden */
  25741. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25742. /** @hidden */
  25743. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25744. /** @hidden */
  25745. _updateBoundingInfo(): AbstractMesh;
  25746. /** @hidden */
  25747. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25748. /** @hidden */
  25749. protected _afterComputeWorldMatrix(): void;
  25750. /** @hidden */
  25751. readonly _effectiveMesh: AbstractMesh;
  25752. /**
  25753. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25754. * A mesh is in the frustum if its bounding box intersects the frustum
  25755. * @param frustumPlanes defines the frustum to test
  25756. * @returns true if the mesh is in the frustum planes
  25757. */
  25758. isInFrustum(frustumPlanes: Plane[]): boolean;
  25759. /**
  25760. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25761. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25762. * @param frustumPlanes defines the frustum to test
  25763. * @returns true if the mesh is completely in the frustum planes
  25764. */
  25765. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25766. /**
  25767. * True if the mesh intersects another mesh or a SolidParticle object
  25768. * @param mesh defines a target mesh or SolidParticle to test
  25769. * @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)
  25770. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25771. * @returns true if there is an intersection
  25772. */
  25773. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25774. /**
  25775. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25776. * @param point defines the point to test
  25777. * @returns true if there is an intersection
  25778. */
  25779. intersectsPoint(point: Vector3): boolean;
  25780. /**
  25781. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25782. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25783. */
  25784. checkCollisions: boolean;
  25785. /**
  25786. * Gets Collider object used to compute collisions (not physics)
  25787. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25788. */
  25789. readonly collider: Nullable<Collider>;
  25790. /**
  25791. * Move the mesh using collision engine
  25792. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25793. * @param displacement defines the requested displacement vector
  25794. * @returns the current mesh
  25795. */
  25796. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25797. private _onCollisionPositionChange;
  25798. /** @hidden */
  25799. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25800. /** @hidden */
  25801. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25802. /** @hidden */
  25803. _checkCollision(collider: Collider): AbstractMesh;
  25804. /** @hidden */
  25805. _generatePointsArray(): boolean;
  25806. /**
  25807. * Checks if the passed Ray intersects with the mesh
  25808. * @param ray defines the ray to use
  25809. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25810. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25811. * @returns the picking info
  25812. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25813. */
  25814. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25815. /**
  25816. * Clones the current mesh
  25817. * @param name defines the mesh name
  25818. * @param newParent defines the new mesh parent
  25819. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25820. * @returns the new mesh
  25821. */
  25822. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25823. /**
  25824. * Disposes all the submeshes of the current meshnp
  25825. * @returns the current mesh
  25826. */
  25827. releaseSubMeshes(): AbstractMesh;
  25828. /**
  25829. * Releases resources associated with this abstract mesh.
  25830. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25831. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25832. */
  25833. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25834. /**
  25835. * Adds the passed mesh as a child to the current mesh
  25836. * @param mesh defines the child mesh
  25837. * @returns the current mesh
  25838. */
  25839. addChild(mesh: AbstractMesh): AbstractMesh;
  25840. /**
  25841. * Removes the passed mesh from the current mesh children list
  25842. * @param mesh defines the child mesh
  25843. * @returns the current mesh
  25844. */
  25845. removeChild(mesh: AbstractMesh): AbstractMesh;
  25846. /** @hidden */
  25847. private _initFacetData;
  25848. /**
  25849. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25850. * This method can be called within the render loop.
  25851. * 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
  25852. * @returns the current mesh
  25853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25854. */
  25855. updateFacetData(): AbstractMesh;
  25856. /**
  25857. * Returns the facetLocalNormals array.
  25858. * The normals are expressed in the mesh local spac
  25859. * @returns an array of Vector3
  25860. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25861. */
  25862. getFacetLocalNormals(): Vector3[];
  25863. /**
  25864. * Returns the facetLocalPositions array.
  25865. * The facet positions are expressed in the mesh local space
  25866. * @returns an array of Vector3
  25867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25868. */
  25869. getFacetLocalPositions(): Vector3[];
  25870. /**
  25871. * Returns the facetLocalPartioning array
  25872. * @returns an array of array of numbers
  25873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25874. */
  25875. getFacetLocalPartitioning(): number[][];
  25876. /**
  25877. * Returns the i-th facet position in the world system.
  25878. * This method allocates a new Vector3 per call
  25879. * @param i defines the facet index
  25880. * @returns a new Vector3
  25881. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25882. */
  25883. getFacetPosition(i: number): Vector3;
  25884. /**
  25885. * Sets the reference Vector3 with the i-th facet position in the world system
  25886. * @param i defines the facet index
  25887. * @param ref defines the target vector
  25888. * @returns the current mesh
  25889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25890. */
  25891. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25892. /**
  25893. * Returns the i-th facet normal in the world system.
  25894. * This method allocates a new Vector3 per call
  25895. * @param i defines the facet index
  25896. * @returns a new Vector3
  25897. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25898. */
  25899. getFacetNormal(i: number): Vector3;
  25900. /**
  25901. * Sets the reference Vector3 with the i-th facet normal in the world system
  25902. * @param i defines the facet index
  25903. * @param ref defines the target vector
  25904. * @returns the current mesh
  25905. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25906. */
  25907. getFacetNormalToRef(i: number, ref: Vector3): this;
  25908. /**
  25909. * 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)
  25910. * @param x defines x coordinate
  25911. * @param y defines y coordinate
  25912. * @param z defines z coordinate
  25913. * @returns the array of facet indexes
  25914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25915. */
  25916. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25917. /**
  25918. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25919. * @param projected sets as the (x,y,z) world projection on the facet
  25920. * @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
  25921. * @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
  25922. * @param x defines x coordinate
  25923. * @param y defines y coordinate
  25924. * @param z defines z coordinate
  25925. * @returns the face index if found (or null instead)
  25926. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25927. */
  25928. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25929. /**
  25930. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25931. * @param projected sets as the (x,y,z) local projection on the facet
  25932. * @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
  25933. * @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
  25934. * @param x defines x coordinate
  25935. * @param y defines y coordinate
  25936. * @param z defines z coordinate
  25937. * @returns the face index if found (or null instead)
  25938. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25939. */
  25940. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25941. /**
  25942. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25943. * @returns the parameters
  25944. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25945. */
  25946. getFacetDataParameters(): any;
  25947. /**
  25948. * Disables the feature FacetData and frees the related memory
  25949. * @returns the current mesh
  25950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25951. */
  25952. disableFacetData(): AbstractMesh;
  25953. /**
  25954. * Updates the AbstractMesh indices array
  25955. * @param indices defines the data source
  25956. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25957. * @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)
  25958. * @returns the current mesh
  25959. */
  25960. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25961. /**
  25962. * Creates new normals data for the mesh
  25963. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25964. * @returns the current mesh
  25965. */
  25966. createNormals(updatable: boolean): AbstractMesh;
  25967. /**
  25968. * Align the mesh with a normal
  25969. * @param normal defines the normal to use
  25970. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25971. * @returns the current mesh
  25972. */
  25973. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25974. /** @hidden */
  25975. _checkOcclusionQuery(): boolean;
  25976. /**
  25977. * Disables the mesh edge rendering mode
  25978. * @returns the currentAbstractMesh
  25979. */
  25980. disableEdgesRendering(): AbstractMesh;
  25981. /**
  25982. * Enables the edge rendering mode on the mesh.
  25983. * This mode makes the mesh edges visible
  25984. * @param epsilon defines the maximal distance between two angles to detect a face
  25985. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25986. * @returns the currentAbstractMesh
  25987. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25988. */
  25989. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25990. }
  25991. }
  25992. declare module "babylonjs/Actions/actionEvent" {
  25993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25994. import { Nullable } from "babylonjs/types";
  25995. import { Sprite } from "babylonjs/Sprites/sprite";
  25996. import { Scene } from "babylonjs/scene";
  25997. import { Vector2 } from "babylonjs/Maths/math";
  25998. /**
  25999. * Interface used to define ActionEvent
  26000. */
  26001. export interface IActionEvent {
  26002. /** The mesh or sprite that triggered the action */
  26003. source: any;
  26004. /** The X mouse cursor position at the time of the event */
  26005. pointerX: number;
  26006. /** The Y mouse cursor position at the time of the event */
  26007. pointerY: number;
  26008. /** The mesh that is currently pointed at (can be null) */
  26009. meshUnderPointer: Nullable<AbstractMesh>;
  26010. /** the original (browser) event that triggered the ActionEvent */
  26011. sourceEvent?: any;
  26012. /** additional data for the event */
  26013. additionalData?: any;
  26014. }
  26015. /**
  26016. * ActionEvent is the event being sent when an action is triggered.
  26017. */
  26018. export class ActionEvent implements IActionEvent {
  26019. /** The mesh or sprite that triggered the action */
  26020. source: any;
  26021. /** The X mouse cursor position at the time of the event */
  26022. pointerX: number;
  26023. /** The Y mouse cursor position at the time of the event */
  26024. pointerY: number;
  26025. /** The mesh that is currently pointed at (can be null) */
  26026. meshUnderPointer: Nullable<AbstractMesh>;
  26027. /** the original (browser) event that triggered the ActionEvent */
  26028. sourceEvent?: any;
  26029. /** additional data for the event */
  26030. additionalData?: any;
  26031. /**
  26032. * Creates a new ActionEvent
  26033. * @param source The mesh or sprite that triggered the action
  26034. * @param pointerX The X mouse cursor position at the time of the event
  26035. * @param pointerY The Y mouse cursor position at the time of the event
  26036. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26037. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26038. * @param additionalData additional data for the event
  26039. */
  26040. constructor(
  26041. /** The mesh or sprite that triggered the action */
  26042. source: any,
  26043. /** The X mouse cursor position at the time of the event */
  26044. pointerX: number,
  26045. /** The Y mouse cursor position at the time of the event */
  26046. pointerY: number,
  26047. /** The mesh that is currently pointed at (can be null) */
  26048. meshUnderPointer: Nullable<AbstractMesh>,
  26049. /** the original (browser) event that triggered the ActionEvent */
  26050. sourceEvent?: any,
  26051. /** additional data for the event */
  26052. additionalData?: any);
  26053. /**
  26054. * Helper function to auto-create an ActionEvent from a source mesh.
  26055. * @param source The source mesh that triggered the event
  26056. * @param evt The original (browser) event
  26057. * @param additionalData additional data for the event
  26058. * @returns the new ActionEvent
  26059. */
  26060. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26061. /**
  26062. * Helper function to auto-create an ActionEvent from a source sprite
  26063. * @param source The source sprite that triggered the event
  26064. * @param scene Scene associated with the sprite
  26065. * @param evt The original (browser) event
  26066. * @param additionalData additional data for the event
  26067. * @returns the new ActionEvent
  26068. */
  26069. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26070. /**
  26071. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26072. * @param scene the scene where the event occurred
  26073. * @param evt The original (browser) event
  26074. * @returns the new ActionEvent
  26075. */
  26076. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26077. /**
  26078. * Helper function to auto-create an ActionEvent from a primitive
  26079. * @param prim defines the target primitive
  26080. * @param pointerPos defines the pointer position
  26081. * @param evt The original (browser) event
  26082. * @param additionalData additional data for the event
  26083. * @returns the new ActionEvent
  26084. */
  26085. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26086. }
  26087. }
  26088. declare module "babylonjs/Actions/abstractActionManager" {
  26089. import { IDisposable } from "babylonjs/scene";
  26090. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  26091. import { IAction } from "babylonjs/Actions/action";
  26092. import { Nullable } from "babylonjs/types";
  26093. /**
  26094. * Abstract class used to decouple action Manager from scene and meshes.
  26095. * Do not instantiate.
  26096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26097. */
  26098. export abstract class AbstractActionManager implements IDisposable {
  26099. /** Gets the list of active triggers */
  26100. static Triggers: {
  26101. [key: string]: number;
  26102. };
  26103. /** Gets the cursor to use when hovering items */
  26104. hoverCursor: string;
  26105. /** Gets the list of actions */
  26106. actions: IAction[];
  26107. /**
  26108. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26109. */
  26110. isRecursive: boolean;
  26111. /**
  26112. * Releases all associated resources
  26113. */
  26114. abstract dispose(): void;
  26115. /**
  26116. * Does this action manager has pointer triggers
  26117. */
  26118. abstract readonly hasPointerTriggers: boolean;
  26119. /**
  26120. * Does this action manager has pick triggers
  26121. */
  26122. abstract readonly hasPickTriggers: boolean;
  26123. /**
  26124. * Process a specific trigger
  26125. * @param trigger defines the trigger to process
  26126. * @param evt defines the event details to be processed
  26127. */
  26128. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26129. /**
  26130. * Does this action manager handles actions of any of the given triggers
  26131. * @param triggers defines the triggers to be tested
  26132. * @return a boolean indicating whether one (or more) of the triggers is handled
  26133. */
  26134. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26135. /**
  26136. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26137. * speed.
  26138. * @param triggerA defines the trigger to be tested
  26139. * @param triggerB defines the trigger to be tested
  26140. * @return a boolean indicating whether one (or more) of the triggers is handled
  26141. */
  26142. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26143. /**
  26144. * Does this action manager handles actions of a given trigger
  26145. * @param trigger defines the trigger to be tested
  26146. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26147. * @return whether the trigger is handled
  26148. */
  26149. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26150. /**
  26151. * Serialize this manager to a JSON object
  26152. * @param name defines the property name to store this manager
  26153. * @returns a JSON representation of this manager
  26154. */
  26155. abstract serialize(name: string): any;
  26156. /**
  26157. * Registers an action to this action manager
  26158. * @param action defines the action to be registered
  26159. * @return the action amended (prepared) after registration
  26160. */
  26161. abstract registerAction(action: IAction): Nullable<IAction>;
  26162. /**
  26163. * Unregisters an action to this action manager
  26164. * @param action defines the action to be unregistered
  26165. * @return a boolean indicating whether the action has been unregistered
  26166. */
  26167. abstract unregisterAction(action: IAction): Boolean;
  26168. /**
  26169. * Does exist one action manager with at least one trigger
  26170. **/
  26171. static readonly HasTriggers: boolean;
  26172. /**
  26173. * Does exist one action manager with at least one pick trigger
  26174. **/
  26175. static readonly HasPickTriggers: boolean;
  26176. /**
  26177. * Does exist one action manager that handles actions of a given trigger
  26178. * @param trigger defines the trigger to be tested
  26179. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26180. **/
  26181. static HasSpecificTrigger(trigger: number): boolean;
  26182. }
  26183. }
  26184. declare module "babylonjs/node" {
  26185. import { Scene } from "babylonjs/scene";
  26186. import { Nullable } from "babylonjs/types";
  26187. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26188. import { Engine } from "babylonjs/Engines/engine";
  26189. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26190. import { Observable } from "babylonjs/Misc/observable";
  26191. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26192. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26193. import { Animatable } from "babylonjs/Animations/animatable";
  26194. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26195. import { Animation } from "babylonjs/Animations/animation";
  26196. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26198. /**
  26199. * Defines how a node can be built from a string name.
  26200. */
  26201. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26202. /**
  26203. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26204. */
  26205. export class Node implements IBehaviorAware<Node> {
  26206. /** @hidden */
  26207. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26208. private static _NodeConstructors;
  26209. /**
  26210. * Add a new node constructor
  26211. * @param type defines the type name of the node to construct
  26212. * @param constructorFunc defines the constructor function
  26213. */
  26214. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26215. /**
  26216. * Returns a node constructor based on type name
  26217. * @param type defines the type name
  26218. * @param name defines the new node name
  26219. * @param scene defines the hosting scene
  26220. * @param options defines optional options to transmit to constructors
  26221. * @returns the new constructor or null
  26222. */
  26223. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26224. /**
  26225. * Gets or sets the name of the node
  26226. */
  26227. name: string;
  26228. /**
  26229. * Gets or sets the id of the node
  26230. */
  26231. id: string;
  26232. /**
  26233. * Gets or sets the unique id of the node
  26234. */
  26235. uniqueId: number;
  26236. /**
  26237. * Gets or sets a string used to store user defined state for the node
  26238. */
  26239. state: string;
  26240. /**
  26241. * Gets or sets an object used to store user defined information for the node
  26242. */
  26243. metadata: any;
  26244. /**
  26245. * For internal use only. Please do not use.
  26246. */
  26247. reservedDataStore: any;
  26248. /**
  26249. * List of inspectable custom properties (used by the Inspector)
  26250. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26251. */
  26252. inspectableCustomProperties: IInspectable[];
  26253. /**
  26254. * Gets or sets a boolean used to define if the node must be serialized
  26255. */
  26256. doNotSerialize: boolean;
  26257. /** @hidden */
  26258. _isDisposed: boolean;
  26259. /**
  26260. * Gets a list of Animations associated with the node
  26261. */
  26262. animations: import("babylonjs/Animations/animation").Animation[];
  26263. protected _ranges: {
  26264. [name: string]: Nullable<AnimationRange>;
  26265. };
  26266. /**
  26267. * Callback raised when the node is ready to be used
  26268. */
  26269. onReady: Nullable<(node: Node) => void>;
  26270. private _isEnabled;
  26271. private _isParentEnabled;
  26272. private _isReady;
  26273. /** @hidden */
  26274. _currentRenderId: number;
  26275. private _parentUpdateId;
  26276. /** @hidden */
  26277. _childUpdateId: number;
  26278. /** @hidden */
  26279. _waitingParentId: Nullable<string>;
  26280. /** @hidden */
  26281. _scene: Scene;
  26282. /** @hidden */
  26283. _cache: any;
  26284. private _parentNode;
  26285. private _children;
  26286. /** @hidden */
  26287. _worldMatrix: Matrix;
  26288. /** @hidden */
  26289. _worldMatrixDeterminant: number;
  26290. /** @hidden */
  26291. _worldMatrixDeterminantIsDirty: boolean;
  26292. /** @hidden */
  26293. private _sceneRootNodesIndex;
  26294. /**
  26295. * Gets a boolean indicating if the node has been disposed
  26296. * @returns true if the node was disposed
  26297. */
  26298. isDisposed(): boolean;
  26299. /**
  26300. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26301. * @see https://doc.babylonjs.com/how_to/parenting
  26302. */
  26303. parent: Nullable<Node>;
  26304. private addToSceneRootNodes;
  26305. private removeFromSceneRootNodes;
  26306. private _animationPropertiesOverride;
  26307. /**
  26308. * Gets or sets the animation properties override
  26309. */
  26310. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26311. /**
  26312. * Gets a string idenfifying the name of the class
  26313. * @returns "Node" string
  26314. */
  26315. getClassName(): string;
  26316. /** @hidden */
  26317. readonly _isNode: boolean;
  26318. /**
  26319. * An event triggered when the mesh is disposed
  26320. */
  26321. onDisposeObservable: Observable<Node>;
  26322. private _onDisposeObserver;
  26323. /**
  26324. * Sets a callback that will be raised when the node will be disposed
  26325. */
  26326. onDispose: () => void;
  26327. /**
  26328. * Creates a new Node
  26329. * @param name the name and id to be given to this node
  26330. * @param scene the scene this node will be added to
  26331. * @param addToRootNodes the node will be added to scene.rootNodes
  26332. */
  26333. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26334. /**
  26335. * Gets the scene of the node
  26336. * @returns a scene
  26337. */
  26338. getScene(): Scene;
  26339. /**
  26340. * Gets the engine of the node
  26341. * @returns a Engine
  26342. */
  26343. getEngine(): Engine;
  26344. private _behaviors;
  26345. /**
  26346. * Attach a behavior to the node
  26347. * @see http://doc.babylonjs.com/features/behaviour
  26348. * @param behavior defines the behavior to attach
  26349. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26350. * @returns the current Node
  26351. */
  26352. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26353. /**
  26354. * Remove an attached behavior
  26355. * @see http://doc.babylonjs.com/features/behaviour
  26356. * @param behavior defines the behavior to attach
  26357. * @returns the current Node
  26358. */
  26359. removeBehavior(behavior: Behavior<Node>): Node;
  26360. /**
  26361. * Gets the list of attached behaviors
  26362. * @see http://doc.babylonjs.com/features/behaviour
  26363. */
  26364. readonly behaviors: Behavior<Node>[];
  26365. /**
  26366. * Gets an attached behavior by name
  26367. * @param name defines the name of the behavior to look for
  26368. * @see http://doc.babylonjs.com/features/behaviour
  26369. * @returns null if behavior was not found else the requested behavior
  26370. */
  26371. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26372. /**
  26373. * Returns the latest update of the World matrix
  26374. * @returns a Matrix
  26375. */
  26376. getWorldMatrix(): Matrix;
  26377. /** @hidden */
  26378. _getWorldMatrixDeterminant(): number;
  26379. /**
  26380. * Returns directly the latest state of the mesh World matrix.
  26381. * A Matrix is returned.
  26382. */
  26383. readonly worldMatrixFromCache: Matrix;
  26384. /** @hidden */
  26385. _initCache(): void;
  26386. /** @hidden */
  26387. updateCache(force?: boolean): void;
  26388. /** @hidden */
  26389. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26390. /** @hidden */
  26391. _updateCache(ignoreParentClass?: boolean): void;
  26392. /** @hidden */
  26393. _isSynchronized(): boolean;
  26394. /** @hidden */
  26395. _markSyncedWithParent(): void;
  26396. /** @hidden */
  26397. isSynchronizedWithParent(): boolean;
  26398. /** @hidden */
  26399. isSynchronized(): boolean;
  26400. /**
  26401. * Is this node ready to be used/rendered
  26402. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26403. * @return true if the node is ready
  26404. */
  26405. isReady(completeCheck?: boolean): boolean;
  26406. /**
  26407. * Is this node enabled?
  26408. * 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
  26409. * @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
  26410. * @return whether this node (and its parent) is enabled
  26411. */
  26412. isEnabled(checkAncestors?: boolean): boolean;
  26413. /** @hidden */
  26414. protected _syncParentEnabledState(): void;
  26415. /**
  26416. * Set the enabled state of this node
  26417. * @param value defines the new enabled state
  26418. */
  26419. setEnabled(value: boolean): void;
  26420. /**
  26421. * Is this node a descendant of the given node?
  26422. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26423. * @param ancestor defines the parent node to inspect
  26424. * @returns a boolean indicating if this node is a descendant of the given node
  26425. */
  26426. isDescendantOf(ancestor: Node): boolean;
  26427. /** @hidden */
  26428. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26429. /**
  26430. * Will return all nodes that have this node as ascendant
  26431. * @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
  26432. * @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
  26433. * @return all children nodes of all types
  26434. */
  26435. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26436. /**
  26437. * Get all child-meshes of this node
  26438. * @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)
  26439. * @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
  26440. * @returns an array of AbstractMesh
  26441. */
  26442. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26443. /**
  26444. * Get all direct children of this node
  26445. * @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
  26446. * @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)
  26447. * @returns an array of Node
  26448. */
  26449. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26450. /** @hidden */
  26451. _setReady(state: boolean): void;
  26452. /**
  26453. * Get an animation by name
  26454. * @param name defines the name of the animation to look for
  26455. * @returns null if not found else the requested animation
  26456. */
  26457. getAnimationByName(name: string): Nullable<Animation>;
  26458. /**
  26459. * Creates an animation range for this node
  26460. * @param name defines the name of the range
  26461. * @param from defines the starting key
  26462. * @param to defines the end key
  26463. */
  26464. createAnimationRange(name: string, from: number, to: number): void;
  26465. /**
  26466. * Delete a specific animation range
  26467. * @param name defines the name of the range to delete
  26468. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26469. */
  26470. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26471. /**
  26472. * Get an animation range by name
  26473. * @param name defines the name of the animation range to look for
  26474. * @returns null if not found else the requested animation range
  26475. */
  26476. getAnimationRange(name: string): Nullable<AnimationRange>;
  26477. /**
  26478. * Gets the list of all animation ranges defined on this node
  26479. * @returns an array
  26480. */
  26481. getAnimationRanges(): Nullable<AnimationRange>[];
  26482. /**
  26483. * Will start the animation sequence
  26484. * @param name defines the range frames for animation sequence
  26485. * @param loop defines if the animation should loop (false by default)
  26486. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26487. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26488. * @returns the object created for this animation. If range does not exist, it will return null
  26489. */
  26490. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26491. /**
  26492. * Serialize animation ranges into a JSON compatible object
  26493. * @returns serialization object
  26494. */
  26495. serializeAnimationRanges(): any;
  26496. /**
  26497. * Computes the world matrix of the node
  26498. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26499. * @returns the world matrix
  26500. */
  26501. computeWorldMatrix(force?: boolean): Matrix;
  26502. /**
  26503. * Releases resources associated with this node.
  26504. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26505. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26506. */
  26507. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26508. /**
  26509. * Parse animation range data from a serialization object and store them into a given node
  26510. * @param node defines where to store the animation ranges
  26511. * @param parsedNode defines the serialization object to read data from
  26512. * @param scene defines the hosting scene
  26513. */
  26514. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26515. /**
  26516. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26517. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26518. * @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
  26519. * @returns the new bounding vectors
  26520. */
  26521. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26522. min: Vector3;
  26523. max: Vector3;
  26524. };
  26525. }
  26526. }
  26527. declare module "babylonjs/Animations/animation" {
  26528. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26529. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26530. import { Nullable } from "babylonjs/types";
  26531. import { Scene } from "babylonjs/scene";
  26532. import { IAnimatable } from "babylonjs/Misc/tools";
  26533. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26534. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26535. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26536. import { Node } from "babylonjs/node";
  26537. import { Animatable } from "babylonjs/Animations/animatable";
  26538. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26539. /**
  26540. * @hidden
  26541. */
  26542. export class _IAnimationState {
  26543. key: number;
  26544. repeatCount: number;
  26545. workValue?: any;
  26546. loopMode?: number;
  26547. offsetValue?: any;
  26548. highLimitValue?: any;
  26549. }
  26550. /**
  26551. * Class used to store any kind of animation
  26552. */
  26553. export class Animation {
  26554. /**Name of the animation */
  26555. name: string;
  26556. /**Property to animate */
  26557. targetProperty: string;
  26558. /**The frames per second of the animation */
  26559. framePerSecond: number;
  26560. /**The data type of the animation */
  26561. dataType: number;
  26562. /**The loop mode of the animation */
  26563. loopMode?: number | undefined;
  26564. /**Specifies if blending should be enabled */
  26565. enableBlending?: boolean | undefined;
  26566. /**
  26567. * Use matrix interpolation instead of using direct key value when animating matrices
  26568. */
  26569. static AllowMatricesInterpolation: boolean;
  26570. /**
  26571. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26572. */
  26573. static AllowMatrixDecomposeForInterpolation: boolean;
  26574. /**
  26575. * Stores the key frames of the animation
  26576. */
  26577. private _keys;
  26578. /**
  26579. * Stores the easing function of the animation
  26580. */
  26581. private _easingFunction;
  26582. /**
  26583. * @hidden Internal use only
  26584. */
  26585. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26586. /**
  26587. * The set of event that will be linked to this animation
  26588. */
  26589. private _events;
  26590. /**
  26591. * Stores an array of target property paths
  26592. */
  26593. targetPropertyPath: string[];
  26594. /**
  26595. * Stores the blending speed of the animation
  26596. */
  26597. blendingSpeed: number;
  26598. /**
  26599. * Stores the animation ranges for the animation
  26600. */
  26601. private _ranges;
  26602. /**
  26603. * @hidden Internal use
  26604. */
  26605. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26606. /**
  26607. * Sets up an animation
  26608. * @param property The property to animate
  26609. * @param animationType The animation type to apply
  26610. * @param framePerSecond The frames per second of the animation
  26611. * @param easingFunction The easing function used in the animation
  26612. * @returns The created animation
  26613. */
  26614. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26615. /**
  26616. * Create and start an animation on a node
  26617. * @param name defines the name of the global animation that will be run on all nodes
  26618. * @param node defines the root node where the animation will take place
  26619. * @param targetProperty defines property to animate
  26620. * @param framePerSecond defines the number of frame per second yo use
  26621. * @param totalFrame defines the number of frames in total
  26622. * @param from defines the initial value
  26623. * @param to defines the final value
  26624. * @param loopMode defines which loop mode you want to use (off by default)
  26625. * @param easingFunction defines the easing function to use (linear by default)
  26626. * @param onAnimationEnd defines the callback to call when animation end
  26627. * @returns the animatable created for this animation
  26628. */
  26629. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26630. /**
  26631. * Create and start an animation on a node and its descendants
  26632. * @param name defines the name of the global animation that will be run on all nodes
  26633. * @param node defines the root node where the animation will take place
  26634. * @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
  26635. * @param targetProperty defines property to animate
  26636. * @param framePerSecond defines the number of frame per second to use
  26637. * @param totalFrame defines the number of frames in total
  26638. * @param from defines the initial value
  26639. * @param to defines the final value
  26640. * @param loopMode defines which loop mode you want to use (off by default)
  26641. * @param easingFunction defines the easing function to use (linear by default)
  26642. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26643. * @returns the list of animatables created for all nodes
  26644. * @example https://www.babylonjs-playground.com/#MH0VLI
  26645. */
  26646. 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[]>;
  26647. /**
  26648. * Creates a new animation, merges it with the existing animations and starts it
  26649. * @param name Name of the animation
  26650. * @param node Node which contains the scene that begins the animations
  26651. * @param targetProperty Specifies which property to animate
  26652. * @param framePerSecond The frames per second of the animation
  26653. * @param totalFrame The total number of frames
  26654. * @param from The frame at the beginning of the animation
  26655. * @param to The frame at the end of the animation
  26656. * @param loopMode Specifies the loop mode of the animation
  26657. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26658. * @param onAnimationEnd Callback to run once the animation is complete
  26659. * @returns Nullable animation
  26660. */
  26661. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26662. /**
  26663. * Transition property of an host to the target Value
  26664. * @param property The property to transition
  26665. * @param targetValue The target Value of the property
  26666. * @param host The object where the property to animate belongs
  26667. * @param scene Scene used to run the animation
  26668. * @param frameRate Framerate (in frame/s) to use
  26669. * @param transition The transition type we want to use
  26670. * @param duration The duration of the animation, in milliseconds
  26671. * @param onAnimationEnd Callback trigger at the end of the animation
  26672. * @returns Nullable animation
  26673. */
  26674. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26675. /**
  26676. * Return the array of runtime animations currently using this animation
  26677. */
  26678. readonly runtimeAnimations: RuntimeAnimation[];
  26679. /**
  26680. * Specifies if any of the runtime animations are currently running
  26681. */
  26682. readonly hasRunningRuntimeAnimations: boolean;
  26683. /**
  26684. * Initializes the animation
  26685. * @param name Name of the animation
  26686. * @param targetProperty Property to animate
  26687. * @param framePerSecond The frames per second of the animation
  26688. * @param dataType The data type of the animation
  26689. * @param loopMode The loop mode of the animation
  26690. * @param enableBlending Specifies if blending should be enabled
  26691. */
  26692. constructor(
  26693. /**Name of the animation */
  26694. name: string,
  26695. /**Property to animate */
  26696. targetProperty: string,
  26697. /**The frames per second of the animation */
  26698. framePerSecond: number,
  26699. /**The data type of the animation */
  26700. dataType: number,
  26701. /**The loop mode of the animation */
  26702. loopMode?: number | undefined,
  26703. /**Specifies if blending should be enabled */
  26704. enableBlending?: boolean | undefined);
  26705. /**
  26706. * Converts the animation to a string
  26707. * @param fullDetails support for multiple levels of logging within scene loading
  26708. * @returns String form of the animation
  26709. */
  26710. toString(fullDetails?: boolean): string;
  26711. /**
  26712. * Add an event to this animation
  26713. * @param event Event to add
  26714. */
  26715. addEvent(event: AnimationEvent): void;
  26716. /**
  26717. * Remove all events found at the given frame
  26718. * @param frame The frame to remove events from
  26719. */
  26720. removeEvents(frame: number): void;
  26721. /**
  26722. * Retrieves all the events from the animation
  26723. * @returns Events from the animation
  26724. */
  26725. getEvents(): AnimationEvent[];
  26726. /**
  26727. * Creates an animation range
  26728. * @param name Name of the animation range
  26729. * @param from Starting frame of the animation range
  26730. * @param to Ending frame of the animation
  26731. */
  26732. createRange(name: string, from: number, to: number): void;
  26733. /**
  26734. * Deletes an animation range by name
  26735. * @param name Name of the animation range to delete
  26736. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26737. */
  26738. deleteRange(name: string, deleteFrames?: boolean): void;
  26739. /**
  26740. * Gets the animation range by name, or null if not defined
  26741. * @param name Name of the animation range
  26742. * @returns Nullable animation range
  26743. */
  26744. getRange(name: string): Nullable<AnimationRange>;
  26745. /**
  26746. * Gets the key frames from the animation
  26747. * @returns The key frames of the animation
  26748. */
  26749. getKeys(): Array<IAnimationKey>;
  26750. /**
  26751. * Gets the highest frame rate of the animation
  26752. * @returns Highest frame rate of the animation
  26753. */
  26754. getHighestFrame(): number;
  26755. /**
  26756. * Gets the easing function of the animation
  26757. * @returns Easing function of the animation
  26758. */
  26759. getEasingFunction(): IEasingFunction;
  26760. /**
  26761. * Sets the easing function of the animation
  26762. * @param easingFunction A custom mathematical formula for animation
  26763. */
  26764. setEasingFunction(easingFunction: EasingFunction): void;
  26765. /**
  26766. * Interpolates a scalar linearly
  26767. * @param startValue Start value of the animation curve
  26768. * @param endValue End value of the animation curve
  26769. * @param gradient Scalar amount to interpolate
  26770. * @returns Interpolated scalar value
  26771. */
  26772. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26773. /**
  26774. * Interpolates a scalar cubically
  26775. * @param startValue Start value of the animation curve
  26776. * @param outTangent End tangent of the animation
  26777. * @param endValue End value of the animation curve
  26778. * @param inTangent Start tangent of the animation curve
  26779. * @param gradient Scalar amount to interpolate
  26780. * @returns Interpolated scalar value
  26781. */
  26782. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26783. /**
  26784. * Interpolates a quaternion using a spherical linear interpolation
  26785. * @param startValue Start value of the animation curve
  26786. * @param endValue End value of the animation curve
  26787. * @param gradient Scalar amount to interpolate
  26788. * @returns Interpolated quaternion value
  26789. */
  26790. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26791. /**
  26792. * Interpolates a quaternion cubically
  26793. * @param startValue Start value of the animation curve
  26794. * @param outTangent End tangent of the animation curve
  26795. * @param endValue End value of the animation curve
  26796. * @param inTangent Start tangent of the animation curve
  26797. * @param gradient Scalar amount to interpolate
  26798. * @returns Interpolated quaternion value
  26799. */
  26800. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26801. /**
  26802. * Interpolates a Vector3 linearl
  26803. * @param startValue Start value of the animation curve
  26804. * @param endValue End value of the animation curve
  26805. * @param gradient Scalar amount to interpolate
  26806. * @returns Interpolated scalar value
  26807. */
  26808. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26809. /**
  26810. * Interpolates a Vector3 cubically
  26811. * @param startValue Start value of the animation curve
  26812. * @param outTangent End tangent of the animation
  26813. * @param endValue End value of the animation curve
  26814. * @param inTangent Start tangent of the animation curve
  26815. * @param gradient Scalar amount to interpolate
  26816. * @returns InterpolatedVector3 value
  26817. */
  26818. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26819. /**
  26820. * Interpolates a Vector2 linearly
  26821. * @param startValue Start value of the animation curve
  26822. * @param endValue End value of the animation curve
  26823. * @param gradient Scalar amount to interpolate
  26824. * @returns Interpolated Vector2 value
  26825. */
  26826. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26827. /**
  26828. * Interpolates a Vector2 cubically
  26829. * @param startValue Start value of the animation curve
  26830. * @param outTangent End tangent of the animation
  26831. * @param endValue End value of the animation curve
  26832. * @param inTangent Start tangent of the animation curve
  26833. * @param gradient Scalar amount to interpolate
  26834. * @returns Interpolated Vector2 value
  26835. */
  26836. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26837. /**
  26838. * Interpolates a size linearly
  26839. * @param startValue Start value of the animation curve
  26840. * @param endValue End value of the animation curve
  26841. * @param gradient Scalar amount to interpolate
  26842. * @returns Interpolated Size value
  26843. */
  26844. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26845. /**
  26846. * Interpolates a Color3 linearly
  26847. * @param startValue Start value of the animation curve
  26848. * @param endValue End value of the animation curve
  26849. * @param gradient Scalar amount to interpolate
  26850. * @returns Interpolated Color3 value
  26851. */
  26852. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26853. /**
  26854. * @hidden Internal use only
  26855. */
  26856. _getKeyValue(value: any): any;
  26857. /**
  26858. * @hidden Internal use only
  26859. */
  26860. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26861. /**
  26862. * Defines the function to use to interpolate matrices
  26863. * @param startValue defines the start matrix
  26864. * @param endValue defines the end matrix
  26865. * @param gradient defines the gradient between both matrices
  26866. * @param result defines an optional target matrix where to store the interpolation
  26867. * @returns the interpolated matrix
  26868. */
  26869. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26870. /**
  26871. * Makes a copy of the animation
  26872. * @returns Cloned animation
  26873. */
  26874. clone(): Animation;
  26875. /**
  26876. * Sets the key frames of the animation
  26877. * @param values The animation key frames to set
  26878. */
  26879. setKeys(values: Array<IAnimationKey>): void;
  26880. /**
  26881. * Serializes the animation to an object
  26882. * @returns Serialized object
  26883. */
  26884. serialize(): any;
  26885. /**
  26886. * Float animation type
  26887. */
  26888. private static _ANIMATIONTYPE_FLOAT;
  26889. /**
  26890. * Vector3 animation type
  26891. */
  26892. private static _ANIMATIONTYPE_VECTOR3;
  26893. /**
  26894. * Quaternion animation type
  26895. */
  26896. private static _ANIMATIONTYPE_QUATERNION;
  26897. /**
  26898. * Matrix animation type
  26899. */
  26900. private static _ANIMATIONTYPE_MATRIX;
  26901. /**
  26902. * Color3 animation type
  26903. */
  26904. private static _ANIMATIONTYPE_COLOR3;
  26905. /**
  26906. * Vector2 animation type
  26907. */
  26908. private static _ANIMATIONTYPE_VECTOR2;
  26909. /**
  26910. * Size animation type
  26911. */
  26912. private static _ANIMATIONTYPE_SIZE;
  26913. /**
  26914. * Relative Loop Mode
  26915. */
  26916. private static _ANIMATIONLOOPMODE_RELATIVE;
  26917. /**
  26918. * Cycle Loop Mode
  26919. */
  26920. private static _ANIMATIONLOOPMODE_CYCLE;
  26921. /**
  26922. * Constant Loop Mode
  26923. */
  26924. private static _ANIMATIONLOOPMODE_CONSTANT;
  26925. /**
  26926. * Get the float animation type
  26927. */
  26928. static readonly ANIMATIONTYPE_FLOAT: number;
  26929. /**
  26930. * Get the Vector3 animation type
  26931. */
  26932. static readonly ANIMATIONTYPE_VECTOR3: number;
  26933. /**
  26934. * Get the Vector2 animation type
  26935. */
  26936. static readonly ANIMATIONTYPE_VECTOR2: number;
  26937. /**
  26938. * Get the Size animation type
  26939. */
  26940. static readonly ANIMATIONTYPE_SIZE: number;
  26941. /**
  26942. * Get the Quaternion animation type
  26943. */
  26944. static readonly ANIMATIONTYPE_QUATERNION: number;
  26945. /**
  26946. * Get the Matrix animation type
  26947. */
  26948. static readonly ANIMATIONTYPE_MATRIX: number;
  26949. /**
  26950. * Get the Color3 animation type
  26951. */
  26952. static readonly ANIMATIONTYPE_COLOR3: number;
  26953. /**
  26954. * Get the Relative Loop Mode
  26955. */
  26956. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26957. /**
  26958. * Get the Cycle Loop Mode
  26959. */
  26960. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26961. /**
  26962. * Get the Constant Loop Mode
  26963. */
  26964. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26965. /** @hidden */
  26966. static _UniversalLerp(left: any, right: any, amount: number): any;
  26967. /**
  26968. * Parses an animation object and creates an animation
  26969. * @param parsedAnimation Parsed animation object
  26970. * @returns Animation object
  26971. */
  26972. static Parse(parsedAnimation: any): Animation;
  26973. /**
  26974. * Appends the serialized animations from the source animations
  26975. * @param source Source containing the animations
  26976. * @param destination Target to store the animations
  26977. */
  26978. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26979. }
  26980. }
  26981. declare module "babylonjs/Materials/Textures/baseTexture" {
  26982. import { Observable } from "babylonjs/Misc/observable";
  26983. import { IAnimatable } from "babylonjs/Misc/tools";
  26984. import { Nullable } from "babylonjs/types";
  26985. import { Scene } from "babylonjs/scene";
  26986. import { Matrix, ISize } from "babylonjs/Maths/math";
  26987. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26988. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26989. /**
  26990. * Base class of all the textures in babylon.
  26991. * It groups all the common properties the materials, post process, lights... might need
  26992. * in order to make a correct use of the texture.
  26993. */
  26994. export class BaseTexture implements IAnimatable {
  26995. /**
  26996. * Default anisotropic filtering level for the application.
  26997. * It is set to 4 as a good tradeoff between perf and quality.
  26998. */
  26999. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27000. /**
  27001. * Gets or sets the unique id of the texture
  27002. */
  27003. uniqueId: number;
  27004. /**
  27005. * Define the name of the texture.
  27006. */
  27007. name: string;
  27008. /**
  27009. * Gets or sets an object used to store user defined information.
  27010. */
  27011. metadata: any;
  27012. /**
  27013. * For internal use only. Please do not use.
  27014. */
  27015. reservedDataStore: any;
  27016. private _hasAlpha;
  27017. /**
  27018. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27019. */
  27020. hasAlpha: boolean;
  27021. /**
  27022. * Defines if the alpha value should be determined via the rgb values.
  27023. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27024. */
  27025. getAlphaFromRGB: boolean;
  27026. /**
  27027. * Intensity or strength of the texture.
  27028. * It is commonly used by materials to fine tune the intensity of the texture
  27029. */
  27030. level: number;
  27031. /**
  27032. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27033. * This is part of the texture as textures usually maps to one uv set.
  27034. */
  27035. coordinatesIndex: number;
  27036. private _coordinatesMode;
  27037. /**
  27038. * How a texture is mapped.
  27039. *
  27040. * | Value | Type | Description |
  27041. * | ----- | ----------------------------------- | ----------- |
  27042. * | 0 | EXPLICIT_MODE | |
  27043. * | 1 | SPHERICAL_MODE | |
  27044. * | 2 | PLANAR_MODE | |
  27045. * | 3 | CUBIC_MODE | |
  27046. * | 4 | PROJECTION_MODE | |
  27047. * | 5 | SKYBOX_MODE | |
  27048. * | 6 | INVCUBIC_MODE | |
  27049. * | 7 | EQUIRECTANGULAR_MODE | |
  27050. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27051. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27052. */
  27053. coordinatesMode: number;
  27054. /**
  27055. * | Value | Type | Description |
  27056. * | ----- | ------------------ | ----------- |
  27057. * | 0 | CLAMP_ADDRESSMODE | |
  27058. * | 1 | WRAP_ADDRESSMODE | |
  27059. * | 2 | MIRROR_ADDRESSMODE | |
  27060. */
  27061. wrapU: number;
  27062. /**
  27063. * | Value | Type | Description |
  27064. * | ----- | ------------------ | ----------- |
  27065. * | 0 | CLAMP_ADDRESSMODE | |
  27066. * | 1 | WRAP_ADDRESSMODE | |
  27067. * | 2 | MIRROR_ADDRESSMODE | |
  27068. */
  27069. wrapV: number;
  27070. /**
  27071. * | Value | Type | Description |
  27072. * | ----- | ------------------ | ----------- |
  27073. * | 0 | CLAMP_ADDRESSMODE | |
  27074. * | 1 | WRAP_ADDRESSMODE | |
  27075. * | 2 | MIRROR_ADDRESSMODE | |
  27076. */
  27077. wrapR: number;
  27078. /**
  27079. * With compliant hardware and browser (supporting anisotropic filtering)
  27080. * this defines the level of anisotropic filtering in the texture.
  27081. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27082. */
  27083. anisotropicFilteringLevel: number;
  27084. /**
  27085. * Define if the texture is a cube texture or if false a 2d texture.
  27086. */
  27087. isCube: boolean;
  27088. /**
  27089. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27090. */
  27091. is3D: boolean;
  27092. /**
  27093. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27094. * HDR texture are usually stored in linear space.
  27095. * This only impacts the PBR and Background materials
  27096. */
  27097. gammaSpace: boolean;
  27098. /**
  27099. * Gets whether or not the texture contains RGBD data.
  27100. */
  27101. readonly isRGBD: boolean;
  27102. /**
  27103. * Is Z inverted in the texture (useful in a cube texture).
  27104. */
  27105. invertZ: boolean;
  27106. /**
  27107. * Are mip maps generated for this texture or not.
  27108. */
  27109. readonly noMipmap: boolean;
  27110. /**
  27111. * @hidden
  27112. */
  27113. lodLevelInAlpha: boolean;
  27114. /**
  27115. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27116. */
  27117. lodGenerationOffset: number;
  27118. /**
  27119. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27120. */
  27121. lodGenerationScale: number;
  27122. /**
  27123. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27124. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27125. * average roughness values.
  27126. */
  27127. linearSpecularLOD: boolean;
  27128. /**
  27129. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27130. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27131. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27132. */
  27133. irradianceTexture: Nullable<BaseTexture>;
  27134. /**
  27135. * Define if the texture is a render target.
  27136. */
  27137. isRenderTarget: boolean;
  27138. /**
  27139. * Define the unique id of the texture in the scene.
  27140. */
  27141. readonly uid: string;
  27142. /**
  27143. * Return a string representation of the texture.
  27144. * @returns the texture as a string
  27145. */
  27146. toString(): string;
  27147. /**
  27148. * Get the class name of the texture.
  27149. * @returns "BaseTexture"
  27150. */
  27151. getClassName(): string;
  27152. /**
  27153. * Define the list of animation attached to the texture.
  27154. */
  27155. animations: import("babylonjs/Animations/animation").Animation[];
  27156. /**
  27157. * An event triggered when the texture is disposed.
  27158. */
  27159. onDisposeObservable: Observable<BaseTexture>;
  27160. private _onDisposeObserver;
  27161. /**
  27162. * Callback triggered when the texture has been disposed.
  27163. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27164. */
  27165. onDispose: () => void;
  27166. /**
  27167. * Define the current state of the loading sequence when in delayed load mode.
  27168. */
  27169. delayLoadState: number;
  27170. private _scene;
  27171. /** @hidden */
  27172. _texture: Nullable<InternalTexture>;
  27173. private _uid;
  27174. /**
  27175. * Define if the texture is preventinga material to render or not.
  27176. * If not and the texture is not ready, the engine will use a default black texture instead.
  27177. */
  27178. readonly isBlocking: boolean;
  27179. /**
  27180. * Instantiates a new BaseTexture.
  27181. * Base class of all the textures in babylon.
  27182. * It groups all the common properties the materials, post process, lights... might need
  27183. * in order to make a correct use of the texture.
  27184. * @param scene Define the scene the texture blongs to
  27185. */
  27186. constructor(scene: Nullable<Scene>);
  27187. /**
  27188. * Get the scene the texture belongs to.
  27189. * @returns the scene or null if undefined
  27190. */
  27191. getScene(): Nullable<Scene>;
  27192. /**
  27193. * Get the texture transform matrix used to offset tile the texture for istance.
  27194. * @returns the transformation matrix
  27195. */
  27196. getTextureMatrix(): Matrix;
  27197. /**
  27198. * Get the texture reflection matrix used to rotate/transform the reflection.
  27199. * @returns the reflection matrix
  27200. */
  27201. getReflectionTextureMatrix(): Matrix;
  27202. /**
  27203. * Get the underlying lower level texture from Babylon.
  27204. * @returns the insternal texture
  27205. */
  27206. getInternalTexture(): Nullable<InternalTexture>;
  27207. /**
  27208. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27209. * @returns true if ready or not blocking
  27210. */
  27211. isReadyOrNotBlocking(): boolean;
  27212. /**
  27213. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27214. * @returns true if fully ready
  27215. */
  27216. isReady(): boolean;
  27217. private _cachedSize;
  27218. /**
  27219. * Get the size of the texture.
  27220. * @returns the texture size.
  27221. */
  27222. getSize(): ISize;
  27223. /**
  27224. * Get the base size of the texture.
  27225. * It can be different from the size if the texture has been resized for POT for instance
  27226. * @returns the base size
  27227. */
  27228. getBaseSize(): ISize;
  27229. /**
  27230. * Update the sampling mode of the texture.
  27231. * Default is Trilinear mode.
  27232. *
  27233. * | Value | Type | Description |
  27234. * | ----- | ------------------ | ----------- |
  27235. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27236. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27237. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27238. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27239. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27240. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27241. * | 7 | NEAREST_LINEAR | |
  27242. * | 8 | NEAREST_NEAREST | |
  27243. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27244. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27245. * | 11 | LINEAR_LINEAR | |
  27246. * | 12 | LINEAR_NEAREST | |
  27247. *
  27248. * > _mag_: magnification filter (close to the viewer)
  27249. * > _min_: minification filter (far from the viewer)
  27250. * > _mip_: filter used between mip map levels
  27251. *@param samplingMode Define the new sampling mode of the texture
  27252. */
  27253. updateSamplingMode(samplingMode: number): void;
  27254. /**
  27255. * Scales the texture if is `canRescale()`
  27256. * @param ratio the resize factor we want to use to rescale
  27257. */
  27258. scale(ratio: number): void;
  27259. /**
  27260. * Get if the texture can rescale.
  27261. */
  27262. readonly canRescale: boolean;
  27263. /** @hidden */
  27264. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27265. /** @hidden */
  27266. _rebuild(): void;
  27267. /**
  27268. * Triggers the load sequence in delayed load mode.
  27269. */
  27270. delayLoad(): void;
  27271. /**
  27272. * Clones the texture.
  27273. * @returns the cloned texture
  27274. */
  27275. clone(): Nullable<BaseTexture>;
  27276. /**
  27277. * Get the texture underlying type (INT, FLOAT...)
  27278. */
  27279. readonly textureType: number;
  27280. /**
  27281. * Get the texture underlying format (RGB, RGBA...)
  27282. */
  27283. readonly textureFormat: number;
  27284. /**
  27285. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27286. * This will returns an RGBA array buffer containing either in values (0-255) or
  27287. * float values (0-1) depending of the underlying buffer type.
  27288. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27289. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27290. * @param buffer defines a user defined buffer to fill with data (can be null)
  27291. * @returns The Array buffer containing the pixels data.
  27292. */
  27293. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27294. /**
  27295. * Release and destroy the underlying lower level texture aka internalTexture.
  27296. */
  27297. releaseInternalTexture(): void;
  27298. /**
  27299. * Get the polynomial representation of the texture data.
  27300. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27301. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27302. */
  27303. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27304. /** @hidden */
  27305. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27306. /** @hidden */
  27307. readonly _lodTextureMid: Nullable<BaseTexture>;
  27308. /** @hidden */
  27309. readonly _lodTextureLow: Nullable<BaseTexture>;
  27310. /**
  27311. * Dispose the texture and release its associated resources.
  27312. */
  27313. dispose(): void;
  27314. /**
  27315. * Serialize the texture into a JSON representation that can be parsed later on.
  27316. * @returns the JSON representation of the texture
  27317. */
  27318. serialize(): any;
  27319. /**
  27320. * Helper function to be called back once a list of texture contains only ready textures.
  27321. * @param textures Define the list of textures to wait for
  27322. * @param callback Define the callback triggered once the entire list will be ready
  27323. */
  27324. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27325. }
  27326. }
  27327. declare module "babylonjs/Materials/uniformBuffer" {
  27328. import { Nullable, FloatArray } from "babylonjs/types";
  27329. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27330. import { Engine } from "babylonjs/Engines/engine";
  27331. import { Effect } from "babylonjs/Materials/effect";
  27332. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27333. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27334. /**
  27335. * Uniform buffer objects.
  27336. *
  27337. * Handles blocks of uniform on the GPU.
  27338. *
  27339. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27340. *
  27341. * For more information, please refer to :
  27342. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27343. */
  27344. export class UniformBuffer {
  27345. private _engine;
  27346. private _buffer;
  27347. private _data;
  27348. private _bufferData;
  27349. private _dynamic?;
  27350. private _uniformLocations;
  27351. private _uniformSizes;
  27352. private _uniformLocationPointer;
  27353. private _needSync;
  27354. private _noUBO;
  27355. private _currentEffect;
  27356. private static _MAX_UNIFORM_SIZE;
  27357. private static _tempBuffer;
  27358. /**
  27359. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27360. * This is dynamic to allow compat with webgl 1 and 2.
  27361. * You will need to pass the name of the uniform as well as the value.
  27362. */
  27363. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27364. /**
  27365. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27366. * This is dynamic to allow compat with webgl 1 and 2.
  27367. * You will need to pass the name of the uniform as well as the value.
  27368. */
  27369. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27370. /**
  27371. * Lambda to Update a single float in a uniform buffer.
  27372. * This is dynamic to allow compat with webgl 1 and 2.
  27373. * You will need to pass the name of the uniform as well as the value.
  27374. */
  27375. updateFloat: (name: string, x: number) => void;
  27376. /**
  27377. * Lambda to Update a vec2 of float in a uniform buffer.
  27378. * This is dynamic to allow compat with webgl 1 and 2.
  27379. * You will need to pass the name of the uniform as well as the value.
  27380. */
  27381. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27382. /**
  27383. * Lambda to Update a vec3 of float in a uniform buffer.
  27384. * This is dynamic to allow compat with webgl 1 and 2.
  27385. * You will need to pass the name of the uniform as well as the value.
  27386. */
  27387. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27388. /**
  27389. * Lambda to Update a vec4 of float in a uniform buffer.
  27390. * This is dynamic to allow compat with webgl 1 and 2.
  27391. * You will need to pass the name of the uniform as well as the value.
  27392. */
  27393. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27394. /**
  27395. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27396. * This is dynamic to allow compat with webgl 1 and 2.
  27397. * You will need to pass the name of the uniform as well as the value.
  27398. */
  27399. updateMatrix: (name: string, mat: Matrix) => void;
  27400. /**
  27401. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27402. * This is dynamic to allow compat with webgl 1 and 2.
  27403. * You will need to pass the name of the uniform as well as the value.
  27404. */
  27405. updateVector3: (name: string, vector: Vector3) => void;
  27406. /**
  27407. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27408. * This is dynamic to allow compat with webgl 1 and 2.
  27409. * You will need to pass the name of the uniform as well as the value.
  27410. */
  27411. updateVector4: (name: string, vector: Vector4) => void;
  27412. /**
  27413. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27414. * This is dynamic to allow compat with webgl 1 and 2.
  27415. * You will need to pass the name of the uniform as well as the value.
  27416. */
  27417. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27418. /**
  27419. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27420. * This is dynamic to allow compat with webgl 1 and 2.
  27421. * You will need to pass the name of the uniform as well as the value.
  27422. */
  27423. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27424. /**
  27425. * Instantiates a new Uniform buffer objects.
  27426. *
  27427. * Handles blocks of uniform on the GPU.
  27428. *
  27429. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27430. *
  27431. * For more information, please refer to :
  27432. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27433. * @param engine Define the engine the buffer is associated with
  27434. * @param data Define the data contained in the buffer
  27435. * @param dynamic Define if the buffer is updatable
  27436. */
  27437. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27438. /**
  27439. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27440. * or just falling back on setUniformXXX calls.
  27441. */
  27442. readonly useUbo: boolean;
  27443. /**
  27444. * Indicates if the WebGL underlying uniform buffer is in sync
  27445. * with the javascript cache data.
  27446. */
  27447. readonly isSync: boolean;
  27448. /**
  27449. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27450. * Also, a dynamic UniformBuffer will disable cache verification and always
  27451. * update the underlying WebGL uniform buffer to the GPU.
  27452. * @returns if Dynamic, otherwise false
  27453. */
  27454. isDynamic(): boolean;
  27455. /**
  27456. * The data cache on JS side.
  27457. * @returns the underlying data as a float array
  27458. */
  27459. getData(): Float32Array;
  27460. /**
  27461. * The underlying WebGL Uniform buffer.
  27462. * @returns the webgl buffer
  27463. */
  27464. getBuffer(): Nullable<DataBuffer>;
  27465. /**
  27466. * std140 layout specifies how to align data within an UBO structure.
  27467. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27468. * for specs.
  27469. */
  27470. private _fillAlignment;
  27471. /**
  27472. * Adds an uniform in the buffer.
  27473. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27474. * for the layout to be correct !
  27475. * @param name Name of the uniform, as used in the uniform block in the shader.
  27476. * @param size Data size, or data directly.
  27477. */
  27478. addUniform(name: string, size: number | number[]): void;
  27479. /**
  27480. * Adds a Matrix 4x4 to the uniform buffer.
  27481. * @param name Name of the uniform, as used in the uniform block in the shader.
  27482. * @param mat A 4x4 matrix.
  27483. */
  27484. addMatrix(name: string, mat: Matrix): void;
  27485. /**
  27486. * Adds a vec2 to the uniform buffer.
  27487. * @param name Name of the uniform, as used in the uniform block in the shader.
  27488. * @param x Define the x component value of the vec2
  27489. * @param y Define the y component value of the vec2
  27490. */
  27491. addFloat2(name: string, x: number, y: number): void;
  27492. /**
  27493. * Adds a vec3 to the uniform buffer.
  27494. * @param name Name of the uniform, as used in the uniform block in the shader.
  27495. * @param x Define the x component value of the vec3
  27496. * @param y Define the y component value of the vec3
  27497. * @param z Define the z component value of the vec3
  27498. */
  27499. addFloat3(name: string, x: number, y: number, z: number): void;
  27500. /**
  27501. * Adds a vec3 to the uniform buffer.
  27502. * @param name Name of the uniform, as used in the uniform block in the shader.
  27503. * @param color Define the vec3 from a Color
  27504. */
  27505. addColor3(name: string, color: Color3): void;
  27506. /**
  27507. * Adds a vec4 to the uniform buffer.
  27508. * @param name Name of the uniform, as used in the uniform block in the shader.
  27509. * @param color Define the rgb components from a Color
  27510. * @param alpha Define the a component of the vec4
  27511. */
  27512. addColor4(name: string, color: Color3, alpha: number): void;
  27513. /**
  27514. * Adds a vec3 to the uniform buffer.
  27515. * @param name Name of the uniform, as used in the uniform block in the shader.
  27516. * @param vector Define the vec3 components from a Vector
  27517. */
  27518. addVector3(name: string, vector: Vector3): void;
  27519. /**
  27520. * Adds a Matrix 3x3 to the uniform buffer.
  27521. * @param name Name of the uniform, as used in the uniform block in the shader.
  27522. */
  27523. addMatrix3x3(name: string): void;
  27524. /**
  27525. * Adds a Matrix 2x2 to the uniform buffer.
  27526. * @param name Name of the uniform, as used in the uniform block in the shader.
  27527. */
  27528. addMatrix2x2(name: string): void;
  27529. /**
  27530. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27531. */
  27532. create(): void;
  27533. /** @hidden */
  27534. _rebuild(): void;
  27535. /**
  27536. * Updates the WebGL Uniform Buffer on the GPU.
  27537. * If the `dynamic` flag is set to true, no cache comparison is done.
  27538. * Otherwise, the buffer will be updated only if the cache differs.
  27539. */
  27540. update(): void;
  27541. /**
  27542. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27543. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27544. * @param data Define the flattened data
  27545. * @param size Define the size of the data.
  27546. */
  27547. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27548. private _updateMatrix3x3ForUniform;
  27549. private _updateMatrix3x3ForEffect;
  27550. private _updateMatrix2x2ForEffect;
  27551. private _updateMatrix2x2ForUniform;
  27552. private _updateFloatForEffect;
  27553. private _updateFloatForUniform;
  27554. private _updateFloat2ForEffect;
  27555. private _updateFloat2ForUniform;
  27556. private _updateFloat3ForEffect;
  27557. private _updateFloat3ForUniform;
  27558. private _updateFloat4ForEffect;
  27559. private _updateFloat4ForUniform;
  27560. private _updateMatrixForEffect;
  27561. private _updateMatrixForUniform;
  27562. private _updateVector3ForEffect;
  27563. private _updateVector3ForUniform;
  27564. private _updateVector4ForEffect;
  27565. private _updateVector4ForUniform;
  27566. private _updateColor3ForEffect;
  27567. private _updateColor3ForUniform;
  27568. private _updateColor4ForEffect;
  27569. private _updateColor4ForUniform;
  27570. /**
  27571. * Sets a sampler uniform on the effect.
  27572. * @param name Define the name of the sampler.
  27573. * @param texture Define the texture to set in the sampler
  27574. */
  27575. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27576. /**
  27577. * Directly updates the value of the uniform in the cache AND on the GPU.
  27578. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27579. * @param data Define the flattened data
  27580. */
  27581. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27582. /**
  27583. * Binds this uniform buffer to an effect.
  27584. * @param effect Define the effect to bind the buffer to
  27585. * @param name Name of the uniform block in the shader.
  27586. */
  27587. bindToEffect(effect: Effect, name: string): void;
  27588. /**
  27589. * Disposes the uniform buffer.
  27590. */
  27591. dispose(): void;
  27592. }
  27593. }
  27594. declare module "babylonjs/Audio/analyser" {
  27595. import { Scene } from "babylonjs/scene";
  27596. /**
  27597. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27599. */
  27600. export class Analyser {
  27601. /**
  27602. * Gets or sets the smoothing
  27603. * @ignorenaming
  27604. */
  27605. SMOOTHING: number;
  27606. /**
  27607. * Gets or sets the FFT table size
  27608. * @ignorenaming
  27609. */
  27610. FFT_SIZE: number;
  27611. /**
  27612. * Gets or sets the bar graph amplitude
  27613. * @ignorenaming
  27614. */
  27615. BARGRAPHAMPLITUDE: number;
  27616. /**
  27617. * Gets or sets the position of the debug canvas
  27618. * @ignorenaming
  27619. */
  27620. DEBUGCANVASPOS: {
  27621. x: number;
  27622. y: number;
  27623. };
  27624. /**
  27625. * Gets or sets the debug canvas size
  27626. * @ignorenaming
  27627. */
  27628. DEBUGCANVASSIZE: {
  27629. width: number;
  27630. height: number;
  27631. };
  27632. private _byteFreqs;
  27633. private _byteTime;
  27634. private _floatFreqs;
  27635. private _webAudioAnalyser;
  27636. private _debugCanvas;
  27637. private _debugCanvasContext;
  27638. private _scene;
  27639. private _registerFunc;
  27640. private _audioEngine;
  27641. /**
  27642. * Creates a new analyser
  27643. * @param scene defines hosting scene
  27644. */
  27645. constructor(scene: Scene);
  27646. /**
  27647. * Get the number of data values you will have to play with for the visualization
  27648. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27649. * @returns a number
  27650. */
  27651. getFrequencyBinCount(): number;
  27652. /**
  27653. * Gets the current frequency data as a byte array
  27654. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27655. * @returns a Uint8Array
  27656. */
  27657. getByteFrequencyData(): Uint8Array;
  27658. /**
  27659. * Gets the current waveform as a byte array
  27660. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27661. * @returns a Uint8Array
  27662. */
  27663. getByteTimeDomainData(): Uint8Array;
  27664. /**
  27665. * Gets the current frequency data as a float array
  27666. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27667. * @returns a Float32Array
  27668. */
  27669. getFloatFrequencyData(): Float32Array;
  27670. /**
  27671. * Renders the debug canvas
  27672. */
  27673. drawDebugCanvas(): void;
  27674. /**
  27675. * Stops rendering the debug canvas and removes it
  27676. */
  27677. stopDebugCanvas(): void;
  27678. /**
  27679. * Connects two audio nodes
  27680. * @param inputAudioNode defines first node to connect
  27681. * @param outputAudioNode defines second node to connect
  27682. */
  27683. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27684. /**
  27685. * Releases all associated resources
  27686. */
  27687. dispose(): void;
  27688. }
  27689. }
  27690. declare module "babylonjs/Audio/audioEngine" {
  27691. import { IDisposable } from "babylonjs/scene";
  27692. import { Analyser } from "babylonjs/Audio/analyser";
  27693. import { Nullable } from "babylonjs/types";
  27694. import { Observable } from "babylonjs/Misc/observable";
  27695. /**
  27696. * This represents an audio engine and it is responsible
  27697. * to play, synchronize and analyse sounds throughout the application.
  27698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27699. */
  27700. export interface IAudioEngine extends IDisposable {
  27701. /**
  27702. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27703. */
  27704. readonly canUseWebAudio: boolean;
  27705. /**
  27706. * Gets the current AudioContext if available.
  27707. */
  27708. readonly audioContext: Nullable<AudioContext>;
  27709. /**
  27710. * The master gain node defines the global audio volume of your audio engine.
  27711. */
  27712. readonly masterGain: GainNode;
  27713. /**
  27714. * Gets whether or not mp3 are supported by your browser.
  27715. */
  27716. readonly isMP3supported: boolean;
  27717. /**
  27718. * Gets whether or not ogg are supported by your browser.
  27719. */
  27720. readonly isOGGsupported: boolean;
  27721. /**
  27722. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27723. * @ignoreNaming
  27724. */
  27725. WarnedWebAudioUnsupported: boolean;
  27726. /**
  27727. * Defines if the audio engine relies on a custom unlocked button.
  27728. * In this case, the embedded button will not be displayed.
  27729. */
  27730. useCustomUnlockedButton: boolean;
  27731. /**
  27732. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27733. */
  27734. readonly unlocked: boolean;
  27735. /**
  27736. * Event raised when audio has been unlocked on the browser.
  27737. */
  27738. onAudioUnlockedObservable: Observable<AudioEngine>;
  27739. /**
  27740. * Event raised when audio has been locked on the browser.
  27741. */
  27742. onAudioLockedObservable: Observable<AudioEngine>;
  27743. /**
  27744. * Flags the audio engine in Locked state.
  27745. * This happens due to new browser policies preventing audio to autoplay.
  27746. */
  27747. lock(): void;
  27748. /**
  27749. * Unlocks the audio engine once a user action has been done on the dom.
  27750. * This is helpful to resume play once browser policies have been satisfied.
  27751. */
  27752. unlock(): void;
  27753. }
  27754. /**
  27755. * This represents the default audio engine used in babylon.
  27756. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27758. */
  27759. export class AudioEngine implements IAudioEngine {
  27760. private _audioContext;
  27761. private _audioContextInitialized;
  27762. private _muteButton;
  27763. private _hostElement;
  27764. /**
  27765. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27766. */
  27767. canUseWebAudio: boolean;
  27768. /**
  27769. * The master gain node defines the global audio volume of your audio engine.
  27770. */
  27771. masterGain: GainNode;
  27772. /**
  27773. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27774. * @ignoreNaming
  27775. */
  27776. WarnedWebAudioUnsupported: boolean;
  27777. /**
  27778. * Gets whether or not mp3 are supported by your browser.
  27779. */
  27780. isMP3supported: boolean;
  27781. /**
  27782. * Gets whether or not ogg are supported by your browser.
  27783. */
  27784. isOGGsupported: boolean;
  27785. /**
  27786. * Gets whether audio has been unlocked on the device.
  27787. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27788. * a user interaction has happened.
  27789. */
  27790. unlocked: boolean;
  27791. /**
  27792. * Defines if the audio engine relies on a custom unlocked button.
  27793. * In this case, the embedded button will not be displayed.
  27794. */
  27795. useCustomUnlockedButton: boolean;
  27796. /**
  27797. * Event raised when audio has been unlocked on the browser.
  27798. */
  27799. onAudioUnlockedObservable: Observable<AudioEngine>;
  27800. /**
  27801. * Event raised when audio has been locked on the browser.
  27802. */
  27803. onAudioLockedObservable: Observable<AudioEngine>;
  27804. /**
  27805. * Gets the current AudioContext if available.
  27806. */
  27807. readonly audioContext: Nullable<AudioContext>;
  27808. private _connectedAnalyser;
  27809. /**
  27810. * Instantiates a new audio engine.
  27811. *
  27812. * There should be only one per page as some browsers restrict the number
  27813. * of audio contexts you can create.
  27814. * @param hostElement defines the host element where to display the mute icon if necessary
  27815. */
  27816. constructor(hostElement?: Nullable<HTMLElement>);
  27817. /**
  27818. * Flags the audio engine in Locked state.
  27819. * This happens due to new browser policies preventing audio to autoplay.
  27820. */
  27821. lock(): void;
  27822. /**
  27823. * Unlocks the audio engine once a user action has been done on the dom.
  27824. * This is helpful to resume play once browser policies have been satisfied.
  27825. */
  27826. unlock(): void;
  27827. private _resumeAudioContext;
  27828. private _initializeAudioContext;
  27829. private _tryToRun;
  27830. private _triggerRunningState;
  27831. private _triggerSuspendedState;
  27832. private _displayMuteButton;
  27833. private _moveButtonToTopLeft;
  27834. private _onResize;
  27835. private _hideMuteButton;
  27836. /**
  27837. * Destroy and release the resources associated with the audio ccontext.
  27838. */
  27839. dispose(): void;
  27840. /**
  27841. * Gets the global volume sets on the master gain.
  27842. * @returns the global volume if set or -1 otherwise
  27843. */
  27844. getGlobalVolume(): number;
  27845. /**
  27846. * Sets the global volume of your experience (sets on the master gain).
  27847. * @param newVolume Defines the new global volume of the application
  27848. */
  27849. setGlobalVolume(newVolume: number): void;
  27850. /**
  27851. * Connect the audio engine to an audio analyser allowing some amazing
  27852. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27854. * @param analyser The analyser to connect to the engine
  27855. */
  27856. connectToAnalyser(analyser: Analyser): void;
  27857. }
  27858. }
  27859. declare module "babylonjs/Loading/loadingScreen" {
  27860. /**
  27861. * Interface used to present a loading screen while loading a scene
  27862. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27863. */
  27864. export interface ILoadingScreen {
  27865. /**
  27866. * Function called to display the loading screen
  27867. */
  27868. displayLoadingUI: () => void;
  27869. /**
  27870. * Function called to hide the loading screen
  27871. */
  27872. hideLoadingUI: () => void;
  27873. /**
  27874. * Gets or sets the color to use for the background
  27875. */
  27876. loadingUIBackgroundColor: string;
  27877. /**
  27878. * Gets or sets the text to display while loading
  27879. */
  27880. loadingUIText: string;
  27881. }
  27882. /**
  27883. * Class used for the default loading screen
  27884. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27885. */
  27886. export class DefaultLoadingScreen implements ILoadingScreen {
  27887. private _renderingCanvas;
  27888. private _loadingText;
  27889. private _loadingDivBackgroundColor;
  27890. private _loadingDiv;
  27891. private _loadingTextDiv;
  27892. /** Gets or sets the logo url to use for the default loading screen */
  27893. static DefaultLogoUrl: string;
  27894. /** Gets or sets the spinner url to use for the default loading screen */
  27895. static DefaultSpinnerUrl: string;
  27896. /**
  27897. * Creates a new default loading screen
  27898. * @param _renderingCanvas defines the canvas used to render the scene
  27899. * @param _loadingText defines the default text to display
  27900. * @param _loadingDivBackgroundColor defines the default background color
  27901. */
  27902. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27903. /**
  27904. * Function called to display the loading screen
  27905. */
  27906. displayLoadingUI(): void;
  27907. /**
  27908. * Function called to hide the loading screen
  27909. */
  27910. hideLoadingUI(): void;
  27911. /**
  27912. * Gets or sets the text to display while loading
  27913. */
  27914. loadingUIText: string;
  27915. /**
  27916. * Gets or sets the color to use for the background
  27917. */
  27918. loadingUIBackgroundColor: string;
  27919. private _resizeLoadingUI;
  27920. }
  27921. }
  27922. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27923. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27924. import { Engine } from "babylonjs/Engines/engine";
  27925. import { Nullable } from "babylonjs/types";
  27926. /** @hidden */
  27927. export class WebGLPipelineContext implements IPipelineContext {
  27928. engine: Engine;
  27929. program: Nullable<WebGLProgram>;
  27930. context?: WebGLRenderingContext;
  27931. vertexShader?: WebGLShader;
  27932. fragmentShader?: WebGLShader;
  27933. isParallelCompiled: boolean;
  27934. onCompiled?: () => void;
  27935. transformFeedback?: WebGLTransformFeedback | null;
  27936. readonly isAsync: boolean;
  27937. readonly isReady: boolean;
  27938. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27939. }
  27940. }
  27941. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27942. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27943. /** @hidden */
  27944. export class WebGLDataBuffer extends DataBuffer {
  27945. private _buffer;
  27946. constructor(resource: WebGLBuffer);
  27947. readonly underlyingResource: any;
  27948. }
  27949. }
  27950. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27951. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27952. /** @hidden */
  27953. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27954. attributeProcessor(attribute: string): string;
  27955. varyingProcessor(varying: string, isFragment: boolean): string;
  27956. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27957. }
  27958. }
  27959. declare module "babylonjs/Materials/Textures/videoTexture" {
  27960. import { Observable } from "babylonjs/Misc/observable";
  27961. import { Nullable } from "babylonjs/types";
  27962. import { Scene } from "babylonjs/scene";
  27963. import { Texture } from "babylonjs/Materials/Textures/texture";
  27964. /**
  27965. * Settings for finer control over video usage
  27966. */
  27967. export interface VideoTextureSettings {
  27968. /**
  27969. * Applies `autoplay` to video, if specified
  27970. */
  27971. autoPlay?: boolean;
  27972. /**
  27973. * Applies `loop` to video, if specified
  27974. */
  27975. loop?: boolean;
  27976. /**
  27977. * Automatically updates internal texture from video at every frame in the render loop
  27978. */
  27979. autoUpdateTexture: boolean;
  27980. /**
  27981. * Image src displayed during the video loading or until the user interacts with the video.
  27982. */
  27983. poster?: string;
  27984. }
  27985. /**
  27986. * If you want to display a video in your scene, this is the special texture for that.
  27987. * This special texture works similar to other textures, with the exception of a few parameters.
  27988. * @see https://doc.babylonjs.com/how_to/video_texture
  27989. */
  27990. export class VideoTexture extends Texture {
  27991. /**
  27992. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27993. */
  27994. readonly autoUpdateTexture: boolean;
  27995. /**
  27996. * The video instance used by the texture internally
  27997. */
  27998. readonly video: HTMLVideoElement;
  27999. private _onUserActionRequestedObservable;
  28000. /**
  28001. * Event triggerd when a dom action is required by the user to play the video.
  28002. * This happens due to recent changes in browser policies preventing video to auto start.
  28003. */
  28004. readonly onUserActionRequestedObservable: Observable<Texture>;
  28005. private _generateMipMaps;
  28006. private _engine;
  28007. private _stillImageCaptured;
  28008. private _displayingPosterTexture;
  28009. private _settings;
  28010. private _createInternalTextureOnEvent;
  28011. /**
  28012. * Creates a video texture.
  28013. * If you want to display a video in your scene, this is the special texture for that.
  28014. * This special texture works similar to other textures, with the exception of a few parameters.
  28015. * @see https://doc.babylonjs.com/how_to/video_texture
  28016. * @param name optional name, will detect from video source, if not defined
  28017. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28018. * @param scene is obviously the current scene.
  28019. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28020. * @param invertY is false by default but can be used to invert video on Y axis
  28021. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28022. * @param settings allows finer control over video usage
  28023. */
  28024. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28025. private _getName;
  28026. private _getVideo;
  28027. private _createInternalTexture;
  28028. private reset;
  28029. /**
  28030. * @hidden Internal method to initiate `update`.
  28031. */
  28032. _rebuild(): void;
  28033. /**
  28034. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28035. */
  28036. update(): void;
  28037. /**
  28038. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28039. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28040. */
  28041. updateTexture(isVisible: boolean): void;
  28042. protected _updateInternalTexture: () => void;
  28043. /**
  28044. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28045. * @param url New url.
  28046. */
  28047. updateURL(url: string): void;
  28048. /**
  28049. * Dispose the texture and release its associated resources.
  28050. */
  28051. dispose(): void;
  28052. /**
  28053. * Creates a video texture straight from a stream.
  28054. * @param scene Define the scene the texture should be created in
  28055. * @param stream Define the stream the texture should be created from
  28056. * @returns The created video texture as a promise
  28057. */
  28058. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28059. /**
  28060. * Creates a video texture straight from your WebCam video feed.
  28061. * @param scene Define the scene the texture should be created in
  28062. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28063. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28064. * @returns The created video texture as a promise
  28065. */
  28066. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28067. minWidth: number;
  28068. maxWidth: number;
  28069. minHeight: number;
  28070. maxHeight: number;
  28071. deviceId: string;
  28072. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28073. /**
  28074. * Creates a video texture straight from your WebCam video feed.
  28075. * @param scene Define the scene the texture should be created in
  28076. * @param onReady Define a callback to triggered once the texture will be ready
  28077. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28078. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28079. */
  28080. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28081. minWidth: number;
  28082. maxWidth: number;
  28083. minHeight: number;
  28084. maxHeight: number;
  28085. deviceId: string;
  28086. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28087. }
  28088. }
  28089. declare module "babylonjs/Engines/engine" {
  28090. import { Observable } from "babylonjs/Misc/observable";
  28091. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  28092. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  28093. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  28094. import { Camera } from "babylonjs/Cameras/camera";
  28095. import { Scene } from "babylonjs/scene";
  28096. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  28097. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28098. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28099. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  28100. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  28101. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28102. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28103. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  28104. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  28105. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  28106. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  28107. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  28108. import { WebRequest } from "babylonjs/Misc/webRequest";
  28109. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  28110. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28111. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28112. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  28113. import { Material } from "babylonjs/Materials/material";
  28114. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28115. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28116. /**
  28117. * Interface for attribute information associated with buffer instanciation
  28118. */
  28119. export class InstancingAttributeInfo {
  28120. /**
  28121. * Index/offset of the attribute in the vertex shader
  28122. */
  28123. index: number;
  28124. /**
  28125. * size of the attribute, 1, 2, 3 or 4
  28126. */
  28127. attributeSize: number;
  28128. /**
  28129. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28130. * default is FLOAT
  28131. */
  28132. attribyteType: number;
  28133. /**
  28134. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28135. */
  28136. normalized: boolean;
  28137. /**
  28138. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28139. */
  28140. offset: number;
  28141. /**
  28142. * Name of the GLSL attribute, for debugging purpose only
  28143. */
  28144. attributeName: string;
  28145. }
  28146. /**
  28147. * Define options used to create a depth texture
  28148. */
  28149. export class DepthTextureCreationOptions {
  28150. /** Specifies whether or not a stencil should be allocated in the texture */
  28151. generateStencil?: boolean;
  28152. /** Specifies whether or not bilinear filtering is enable on the texture */
  28153. bilinearFiltering?: boolean;
  28154. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28155. comparisonFunction?: number;
  28156. /** Specifies if the created texture is a cube texture */
  28157. isCube?: boolean;
  28158. }
  28159. /**
  28160. * Class used to describe the capabilities of the engine relatively to the current browser
  28161. */
  28162. export class EngineCapabilities {
  28163. /** Maximum textures units per fragment shader */
  28164. maxTexturesImageUnits: number;
  28165. /** Maximum texture units per vertex shader */
  28166. maxVertexTextureImageUnits: number;
  28167. /** Maximum textures units in the entire pipeline */
  28168. maxCombinedTexturesImageUnits: number;
  28169. /** Maximum texture size */
  28170. maxTextureSize: number;
  28171. /** Maximum cube texture size */
  28172. maxCubemapTextureSize: number;
  28173. /** Maximum render texture size */
  28174. maxRenderTextureSize: number;
  28175. /** Maximum number of vertex attributes */
  28176. maxVertexAttribs: number;
  28177. /** Maximum number of varyings */
  28178. maxVaryingVectors: number;
  28179. /** Maximum number of uniforms per vertex shader */
  28180. maxVertexUniformVectors: number;
  28181. /** Maximum number of uniforms per fragment shader */
  28182. maxFragmentUniformVectors: number;
  28183. /** Defines if standard derivates (dx/dy) are supported */
  28184. standardDerivatives: boolean;
  28185. /** Defines if s3tc texture compression is supported */
  28186. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28187. /** Defines if pvrtc texture compression is supported */
  28188. pvrtc: any;
  28189. /** Defines if etc1 texture compression is supported */
  28190. etc1: any;
  28191. /** Defines if etc2 texture compression is supported */
  28192. etc2: any;
  28193. /** Defines if astc texture compression is supported */
  28194. astc: any;
  28195. /** Defines if float textures are supported */
  28196. textureFloat: boolean;
  28197. /** Defines if vertex array objects are supported */
  28198. vertexArrayObject: boolean;
  28199. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28200. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28201. /** Gets the maximum level of anisotropy supported */
  28202. maxAnisotropy: number;
  28203. /** Defines if instancing is supported */
  28204. instancedArrays: boolean;
  28205. /** Defines if 32 bits indices are supported */
  28206. uintIndices: boolean;
  28207. /** Defines if high precision shaders are supported */
  28208. highPrecisionShaderSupported: boolean;
  28209. /** Defines if depth reading in the fragment shader is supported */
  28210. fragmentDepthSupported: boolean;
  28211. /** Defines if float texture linear filtering is supported*/
  28212. textureFloatLinearFiltering: boolean;
  28213. /** Defines if rendering to float textures is supported */
  28214. textureFloatRender: boolean;
  28215. /** Defines if half float textures are supported*/
  28216. textureHalfFloat: boolean;
  28217. /** Defines if half float texture linear filtering is supported*/
  28218. textureHalfFloatLinearFiltering: boolean;
  28219. /** Defines if rendering to half float textures is supported */
  28220. textureHalfFloatRender: boolean;
  28221. /** Defines if textureLOD shader command is supported */
  28222. textureLOD: boolean;
  28223. /** Defines if draw buffers extension is supported */
  28224. drawBuffersExtension: boolean;
  28225. /** Defines if depth textures are supported */
  28226. depthTextureExtension: boolean;
  28227. /** Defines if float color buffer are supported */
  28228. colorBufferFloat: boolean;
  28229. /** Gets disjoint timer query extension (null if not supported) */
  28230. timerQuery: EXT_disjoint_timer_query;
  28231. /** Defines if timestamp can be used with timer query */
  28232. canUseTimestampForTimerQuery: boolean;
  28233. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28234. multiview: any;
  28235. /** Function used to let the system compiles shaders in background */
  28236. parallelShaderCompile: {
  28237. COMPLETION_STATUS_KHR: number;
  28238. };
  28239. }
  28240. /** Interface defining initialization parameters for Engine class */
  28241. export interface EngineOptions extends WebGLContextAttributes {
  28242. /**
  28243. * Defines if the engine should no exceed a specified device ratio
  28244. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28245. */
  28246. limitDeviceRatio?: number;
  28247. /**
  28248. * Defines if webvr should be enabled automatically
  28249. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28250. */
  28251. autoEnableWebVR?: boolean;
  28252. /**
  28253. * Defines if webgl2 should be turned off even if supported
  28254. * @see http://doc.babylonjs.com/features/webgl2
  28255. */
  28256. disableWebGL2Support?: boolean;
  28257. /**
  28258. * Defines if webaudio should be initialized as well
  28259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28260. */
  28261. audioEngine?: boolean;
  28262. /**
  28263. * Defines if animations should run using a deterministic lock step
  28264. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28265. */
  28266. deterministicLockstep?: boolean;
  28267. /** Defines the maximum steps to use with deterministic lock step mode */
  28268. lockstepMaxSteps?: number;
  28269. /**
  28270. * Defines that engine should ignore context lost events
  28271. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28272. */
  28273. doNotHandleContextLost?: boolean;
  28274. /**
  28275. * Defines that engine should ignore modifying touch action attribute and style
  28276. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28277. */
  28278. doNotHandleTouchAction?: boolean;
  28279. /**
  28280. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28281. */
  28282. useHighPrecisionFloats?: boolean;
  28283. }
  28284. /**
  28285. * Defines the interface used by display changed events
  28286. */
  28287. export interface IDisplayChangedEventArgs {
  28288. /** Gets the vrDisplay object (if any) */
  28289. vrDisplay: Nullable<any>;
  28290. /** Gets a boolean indicating if webVR is supported */
  28291. vrSupported: boolean;
  28292. }
  28293. /**
  28294. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28295. */
  28296. export class Engine {
  28297. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28298. static ExceptionList: ({
  28299. key: string;
  28300. capture: string;
  28301. captureConstraint: number;
  28302. targets: string[];
  28303. } | {
  28304. key: string;
  28305. capture: null;
  28306. captureConstraint: null;
  28307. targets: string[];
  28308. })[];
  28309. /** Gets the list of created engines */
  28310. static readonly Instances: Engine[];
  28311. /**
  28312. * Gets the latest created engine
  28313. */
  28314. static readonly LastCreatedEngine: Nullable<Engine>;
  28315. /**
  28316. * Gets the latest created scene
  28317. */
  28318. static readonly LastCreatedScene: Nullable<Scene>;
  28319. /**
  28320. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28321. * @param flag defines which part of the materials must be marked as dirty
  28322. * @param predicate defines a predicate used to filter which materials should be affected
  28323. */
  28324. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28325. /** @hidden */
  28326. static _TextureLoaders: IInternalTextureLoader[];
  28327. /** Defines that alpha blending is disabled */
  28328. static readonly ALPHA_DISABLE: number;
  28329. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28330. static readonly ALPHA_ADD: number;
  28331. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28332. static readonly ALPHA_COMBINE: number;
  28333. /** Defines that alpha blending to DEST - SRC * DEST */
  28334. static readonly ALPHA_SUBTRACT: number;
  28335. /** Defines that alpha blending to SRC * DEST */
  28336. static readonly ALPHA_MULTIPLY: number;
  28337. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28338. static readonly ALPHA_MAXIMIZED: number;
  28339. /** Defines that alpha blending to SRC + DEST */
  28340. static readonly ALPHA_ONEONE: number;
  28341. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28342. static readonly ALPHA_PREMULTIPLIED: number;
  28343. /**
  28344. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28345. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28346. */
  28347. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28348. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28349. static readonly ALPHA_INTERPOLATE: number;
  28350. /**
  28351. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28352. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28353. */
  28354. static readonly ALPHA_SCREENMODE: number;
  28355. /** Defines that the ressource is not delayed*/
  28356. static readonly DELAYLOADSTATE_NONE: number;
  28357. /** Defines that the ressource was successfully delay loaded */
  28358. static readonly DELAYLOADSTATE_LOADED: number;
  28359. /** Defines that the ressource is currently delay loading */
  28360. static readonly DELAYLOADSTATE_LOADING: number;
  28361. /** Defines that the ressource is delayed and has not started loading */
  28362. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28363. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28364. static readonly NEVER: number;
  28365. /** 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 */
  28366. static readonly ALWAYS: number;
  28367. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28368. static readonly LESS: number;
  28369. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28370. static readonly EQUAL: number;
  28371. /** 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 */
  28372. static readonly LEQUAL: number;
  28373. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28374. static readonly GREATER: number;
  28375. /** 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 */
  28376. static readonly GEQUAL: number;
  28377. /** 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 */
  28378. static readonly NOTEQUAL: number;
  28379. /** Passed to stencilOperation to specify that stencil value must be kept */
  28380. static readonly KEEP: number;
  28381. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28382. static readonly REPLACE: number;
  28383. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28384. static readonly INCR: number;
  28385. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28386. static readonly DECR: number;
  28387. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28388. static readonly INVERT: number;
  28389. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28390. static readonly INCR_WRAP: number;
  28391. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28392. static readonly DECR_WRAP: number;
  28393. /** Texture is not repeating outside of 0..1 UVs */
  28394. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28395. /** Texture is repeating outside of 0..1 UVs */
  28396. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28397. /** Texture is repeating and mirrored */
  28398. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28399. /** ALPHA */
  28400. static readonly TEXTUREFORMAT_ALPHA: number;
  28401. /** LUMINANCE */
  28402. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28403. /** LUMINANCE_ALPHA */
  28404. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28405. /** RGB */
  28406. static readonly TEXTUREFORMAT_RGB: number;
  28407. /** RGBA */
  28408. static readonly TEXTUREFORMAT_RGBA: number;
  28409. /** RED */
  28410. static readonly TEXTUREFORMAT_RED: number;
  28411. /** RED (2nd reference) */
  28412. static readonly TEXTUREFORMAT_R: number;
  28413. /** RG */
  28414. static readonly TEXTUREFORMAT_RG: number;
  28415. /** RED_INTEGER */
  28416. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28417. /** RED_INTEGER (2nd reference) */
  28418. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28419. /** RG_INTEGER */
  28420. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28421. /** RGB_INTEGER */
  28422. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28423. /** RGBA_INTEGER */
  28424. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28425. /** UNSIGNED_BYTE */
  28426. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28427. /** UNSIGNED_BYTE (2nd reference) */
  28428. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28429. /** FLOAT */
  28430. static readonly TEXTURETYPE_FLOAT: number;
  28431. /** HALF_FLOAT */
  28432. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28433. /** BYTE */
  28434. static readonly TEXTURETYPE_BYTE: number;
  28435. /** SHORT */
  28436. static readonly TEXTURETYPE_SHORT: number;
  28437. /** UNSIGNED_SHORT */
  28438. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28439. /** INT */
  28440. static readonly TEXTURETYPE_INT: number;
  28441. /** UNSIGNED_INT */
  28442. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28443. /** UNSIGNED_SHORT_4_4_4_4 */
  28444. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28445. /** UNSIGNED_SHORT_5_5_5_1 */
  28446. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28447. /** UNSIGNED_SHORT_5_6_5 */
  28448. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28449. /** UNSIGNED_INT_2_10_10_10_REV */
  28450. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28451. /** UNSIGNED_INT_24_8 */
  28452. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28453. /** UNSIGNED_INT_10F_11F_11F_REV */
  28454. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28455. /** UNSIGNED_INT_5_9_9_9_REV */
  28456. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28457. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28458. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28459. /** nearest is mag = nearest and min = nearest and mip = linear */
  28460. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28461. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28462. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28463. /** Trilinear is mag = linear and min = linear and mip = linear */
  28464. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28465. /** nearest is mag = nearest and min = nearest and mip = linear */
  28466. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28467. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28468. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28469. /** Trilinear is mag = linear and min = linear and mip = linear */
  28470. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28471. /** mag = nearest and min = nearest and mip = nearest */
  28472. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28473. /** mag = nearest and min = linear and mip = nearest */
  28474. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28475. /** mag = nearest and min = linear and mip = linear */
  28476. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28477. /** mag = nearest and min = linear and mip = none */
  28478. static readonly TEXTURE_NEAREST_LINEAR: number;
  28479. /** mag = nearest and min = nearest and mip = none */
  28480. static readonly TEXTURE_NEAREST_NEAREST: number;
  28481. /** mag = linear and min = nearest and mip = nearest */
  28482. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28483. /** mag = linear and min = nearest and mip = linear */
  28484. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28485. /** mag = linear and min = linear and mip = none */
  28486. static readonly TEXTURE_LINEAR_LINEAR: number;
  28487. /** mag = linear and min = nearest and mip = none */
  28488. static readonly TEXTURE_LINEAR_NEAREST: number;
  28489. /** Explicit coordinates mode */
  28490. static readonly TEXTURE_EXPLICIT_MODE: number;
  28491. /** Spherical coordinates mode */
  28492. static readonly TEXTURE_SPHERICAL_MODE: number;
  28493. /** Planar coordinates mode */
  28494. static readonly TEXTURE_PLANAR_MODE: number;
  28495. /** Cubic coordinates mode */
  28496. static readonly TEXTURE_CUBIC_MODE: number;
  28497. /** Projection coordinates mode */
  28498. static readonly TEXTURE_PROJECTION_MODE: number;
  28499. /** Skybox coordinates mode */
  28500. static readonly TEXTURE_SKYBOX_MODE: number;
  28501. /** Inverse Cubic coordinates mode */
  28502. static readonly TEXTURE_INVCUBIC_MODE: number;
  28503. /** Equirectangular coordinates mode */
  28504. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28505. /** Equirectangular Fixed coordinates mode */
  28506. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28507. /** Equirectangular Fixed Mirrored coordinates mode */
  28508. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28509. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28510. static readonly SCALEMODE_FLOOR: number;
  28511. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28512. static readonly SCALEMODE_NEAREST: number;
  28513. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28514. static readonly SCALEMODE_CEILING: number;
  28515. /**
  28516. * Returns the current npm package of the sdk
  28517. */
  28518. static readonly NpmPackage: string;
  28519. /**
  28520. * Returns the current version of the framework
  28521. */
  28522. static readonly Version: string;
  28523. /**
  28524. * Returns a string describing the current engine
  28525. */
  28526. readonly description: string;
  28527. /**
  28528. * Gets or sets the epsilon value used by collision engine
  28529. */
  28530. static CollisionsEpsilon: number;
  28531. /**
  28532. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28533. */
  28534. static ShadersRepository: string;
  28535. /**
  28536. * Method called to create the default loading screen.
  28537. * This can be overriden in your own app.
  28538. * @param canvas The rendering canvas element
  28539. * @returns The loading screen
  28540. */
  28541. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28542. /**
  28543. * Method called to create the default rescale post process on each engine.
  28544. */
  28545. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28546. /** @hidden */
  28547. _shaderProcessor: IShaderProcessor;
  28548. /**
  28549. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28550. */
  28551. forcePOTTextures: boolean;
  28552. /**
  28553. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28554. */
  28555. isFullscreen: boolean;
  28556. /**
  28557. * Gets a boolean indicating if the pointer is currently locked
  28558. */
  28559. isPointerLock: boolean;
  28560. /**
  28561. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28562. */
  28563. cullBackFaces: boolean;
  28564. /**
  28565. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28566. */
  28567. renderEvenInBackground: boolean;
  28568. /**
  28569. * Gets or sets a boolean indicating that cache can be kept between frames
  28570. */
  28571. preventCacheWipeBetweenFrames: boolean;
  28572. /**
  28573. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28574. **/
  28575. enableOfflineSupport: boolean;
  28576. /**
  28577. * 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)
  28578. **/
  28579. disableManifestCheck: boolean;
  28580. /**
  28581. * Gets the list of created scenes
  28582. */
  28583. scenes: Scene[];
  28584. /**
  28585. * Event raised when a new scene is created
  28586. */
  28587. onNewSceneAddedObservable: Observable<Scene>;
  28588. /**
  28589. * Gets the list of created postprocesses
  28590. */
  28591. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28592. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28593. validateShaderPrograms: boolean;
  28594. /**
  28595. * Observable event triggered each time the rendering canvas is resized
  28596. */
  28597. onResizeObservable: Observable<Engine>;
  28598. /**
  28599. * Observable event triggered each time the canvas loses focus
  28600. */
  28601. onCanvasBlurObservable: Observable<Engine>;
  28602. /**
  28603. * Observable event triggered each time the canvas gains focus
  28604. */
  28605. onCanvasFocusObservable: Observable<Engine>;
  28606. /**
  28607. * Observable event triggered each time the canvas receives pointerout event
  28608. */
  28609. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28610. /**
  28611. * Observable event triggered before each texture is initialized
  28612. */
  28613. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28614. /**
  28615. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28616. */
  28617. disableUniformBuffers: boolean;
  28618. /** @hidden */
  28619. _uniformBuffers: UniformBuffer[];
  28620. /**
  28621. * Gets a boolean indicating that the engine supports uniform buffers
  28622. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28623. */
  28624. readonly supportsUniformBuffers: boolean;
  28625. /**
  28626. * Observable raised when the engine begins a new frame
  28627. */
  28628. onBeginFrameObservable: Observable<Engine>;
  28629. /**
  28630. * If set, will be used to request the next animation frame for the render loop
  28631. */
  28632. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28633. /**
  28634. * Observable raised when the engine ends the current frame
  28635. */
  28636. onEndFrameObservable: Observable<Engine>;
  28637. /**
  28638. * Observable raised when the engine is about to compile a shader
  28639. */
  28640. onBeforeShaderCompilationObservable: Observable<Engine>;
  28641. /**
  28642. * Observable raised when the engine has jsut compiled a shader
  28643. */
  28644. onAfterShaderCompilationObservable: Observable<Engine>;
  28645. /** @hidden */
  28646. _gl: WebGLRenderingContext;
  28647. private _renderingCanvas;
  28648. private _windowIsBackground;
  28649. private _webGLVersion;
  28650. protected _highPrecisionShadersAllowed: boolean;
  28651. /** @hidden */
  28652. readonly _shouldUseHighPrecisionShader: boolean;
  28653. /**
  28654. * Gets a boolean indicating that only power of 2 textures are supported
  28655. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28656. */
  28657. readonly needPOTTextures: boolean;
  28658. /** @hidden */
  28659. _badOS: boolean;
  28660. /** @hidden */
  28661. _badDesktopOS: boolean;
  28662. /**
  28663. * Gets the audio engine
  28664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28665. * @ignorenaming
  28666. */
  28667. static audioEngine: IAudioEngine;
  28668. /**
  28669. * Default AudioEngine factory responsible of creating the Audio Engine.
  28670. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28671. */
  28672. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28673. /**
  28674. * Default offline support factory responsible of creating a tool used to store data locally.
  28675. * By default, this will create a Database object if the workload has been embedded.
  28676. */
  28677. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28678. private _onFocus;
  28679. private _onBlur;
  28680. private _onCanvasPointerOut;
  28681. private _onCanvasBlur;
  28682. private _onCanvasFocus;
  28683. private _onFullscreenChange;
  28684. private _onPointerLockChange;
  28685. private _hardwareScalingLevel;
  28686. /** @hidden */
  28687. _caps: EngineCapabilities;
  28688. private _pointerLockRequested;
  28689. private _isStencilEnable;
  28690. private _colorWrite;
  28691. private _loadingScreen;
  28692. /** @hidden */
  28693. _drawCalls: PerfCounter;
  28694. private _glVersion;
  28695. private _glRenderer;
  28696. private _glVendor;
  28697. private _videoTextureSupported;
  28698. private _renderingQueueLaunched;
  28699. private _activeRenderLoops;
  28700. private _deterministicLockstep;
  28701. private _lockstepMaxSteps;
  28702. /**
  28703. * Observable signaled when a context lost event is raised
  28704. */
  28705. onContextLostObservable: Observable<Engine>;
  28706. /**
  28707. * Observable signaled when a context restored event is raised
  28708. */
  28709. onContextRestoredObservable: Observable<Engine>;
  28710. private _onContextLost;
  28711. private _onContextRestored;
  28712. private _contextWasLost;
  28713. /** @hidden */
  28714. _doNotHandleContextLost: boolean;
  28715. /**
  28716. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28717. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28718. */
  28719. doNotHandleContextLost: boolean;
  28720. private _performanceMonitor;
  28721. private _fps;
  28722. private _deltaTime;
  28723. /**
  28724. * Turn this value on if you want to pause FPS computation when in background
  28725. */
  28726. disablePerformanceMonitorInBackground: boolean;
  28727. /**
  28728. * Gets the performance monitor attached to this engine
  28729. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28730. */
  28731. readonly performanceMonitor: PerformanceMonitor;
  28732. /**
  28733. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28734. */
  28735. disableVertexArrayObjects: boolean;
  28736. /** @hidden */
  28737. protected _depthCullingState: _DepthCullingState;
  28738. /** @hidden */
  28739. protected _stencilState: _StencilState;
  28740. /** @hidden */
  28741. protected _alphaState: _AlphaState;
  28742. /** @hidden */
  28743. protected _alphaMode: number;
  28744. /** @hidden */
  28745. _internalTexturesCache: InternalTexture[];
  28746. /** @hidden */
  28747. protected _activeChannel: number;
  28748. private _currentTextureChannel;
  28749. /** @hidden */
  28750. protected _boundTexturesCache: {
  28751. [key: string]: Nullable<InternalTexture>;
  28752. };
  28753. /** @hidden */
  28754. protected _currentEffect: Nullable<Effect>;
  28755. /** @hidden */
  28756. protected _currentProgram: Nullable<WebGLProgram>;
  28757. private _compiledEffects;
  28758. private _vertexAttribArraysEnabled;
  28759. /** @hidden */
  28760. protected _cachedViewport: Nullable<Viewport>;
  28761. private _cachedVertexArrayObject;
  28762. /** @hidden */
  28763. protected _cachedVertexBuffers: any;
  28764. /** @hidden */
  28765. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28766. /** @hidden */
  28767. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28768. /** @hidden */
  28769. _currentRenderTarget: Nullable<InternalTexture>;
  28770. private _uintIndicesCurrentlySet;
  28771. private _currentBoundBuffer;
  28772. /** @hidden */
  28773. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28774. private _currentBufferPointers;
  28775. private _currentInstanceLocations;
  28776. private _currentInstanceBuffers;
  28777. private _textureUnits;
  28778. /** @hidden */
  28779. _workingCanvas: Nullable<HTMLCanvasElement>;
  28780. /** @hidden */
  28781. _workingContext: Nullable<CanvasRenderingContext2D>;
  28782. private _rescalePostProcess;
  28783. private _dummyFramebuffer;
  28784. private _externalData;
  28785. /** @hidden */
  28786. _bindedRenderFunction: any;
  28787. private _vaoRecordInProgress;
  28788. private _mustWipeVertexAttributes;
  28789. private _emptyTexture;
  28790. private _emptyCubeTexture;
  28791. private _emptyTexture3D;
  28792. /** @hidden */
  28793. _frameHandler: number;
  28794. private _nextFreeTextureSlots;
  28795. private _maxSimultaneousTextures;
  28796. private _activeRequests;
  28797. private _texturesSupported;
  28798. /** @hidden */
  28799. _textureFormatInUse: Nullable<string>;
  28800. /**
  28801. * Gets the list of texture formats supported
  28802. */
  28803. readonly texturesSupported: Array<string>;
  28804. /**
  28805. * Gets the list of texture formats in use
  28806. */
  28807. readonly textureFormatInUse: Nullable<string>;
  28808. /**
  28809. * Gets the current viewport
  28810. */
  28811. readonly currentViewport: Nullable<Viewport>;
  28812. /**
  28813. * Gets the default empty texture
  28814. */
  28815. readonly emptyTexture: InternalTexture;
  28816. /**
  28817. * Gets the default empty 3D texture
  28818. */
  28819. readonly emptyTexture3D: InternalTexture;
  28820. /**
  28821. * Gets the default empty cube texture
  28822. */
  28823. readonly emptyCubeTexture: InternalTexture;
  28824. /**
  28825. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28826. */
  28827. readonly premultipliedAlpha: boolean;
  28828. /**
  28829. * Creates a new engine
  28830. * @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
  28831. * @param antialias defines enable antialiasing (default: false)
  28832. * @param options defines further options to be sent to the getContext() function
  28833. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28834. */
  28835. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28836. /**
  28837. * Initializes a webVR display and starts listening to display change events
  28838. * The onVRDisplayChangedObservable will be notified upon these changes
  28839. * @returns The onVRDisplayChangedObservable
  28840. */
  28841. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28842. /** @hidden */
  28843. _prepareVRComponent(): void;
  28844. /** @hidden */
  28845. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28846. /** @hidden */
  28847. _submitVRFrame(): void;
  28848. /**
  28849. * Call this function to leave webVR mode
  28850. * Will do nothing if webVR is not supported or if there is no webVR device
  28851. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28852. */
  28853. disableVR(): void;
  28854. /**
  28855. * Gets a boolean indicating that the system is in VR mode and is presenting
  28856. * @returns true if VR mode is engaged
  28857. */
  28858. isVRPresenting(): boolean;
  28859. /** @hidden */
  28860. _requestVRFrame(): void;
  28861. private _disableTouchAction;
  28862. private _rebuildInternalTextures;
  28863. private _rebuildEffects;
  28864. /**
  28865. * Gets a boolean indicating if all created effects are ready
  28866. * @returns true if all effects are ready
  28867. */
  28868. areAllEffectsReady(): boolean;
  28869. private _rebuildBuffers;
  28870. private _initGLContext;
  28871. /**
  28872. * Gets version of the current webGL context
  28873. */
  28874. readonly webGLVersion: number;
  28875. /**
  28876. * Gets a string idenfifying the name of the class
  28877. * @returns "Engine" string
  28878. */
  28879. getClassName(): string;
  28880. /**
  28881. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28882. */
  28883. readonly isStencilEnable: boolean;
  28884. /** @hidden */
  28885. _prepareWorkingCanvas(): void;
  28886. /**
  28887. * Reset the texture cache to empty state
  28888. */
  28889. resetTextureCache(): void;
  28890. /**
  28891. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28892. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28893. * @returns true if engine is in deterministic lock step mode
  28894. */
  28895. isDeterministicLockStep(): boolean;
  28896. /**
  28897. * Gets the max steps when engine is running in deterministic lock step
  28898. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28899. * @returns the max steps
  28900. */
  28901. getLockstepMaxSteps(): number;
  28902. /**
  28903. * Gets an object containing information about the current webGL context
  28904. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28905. */
  28906. getGlInfo(): {
  28907. vendor: string;
  28908. renderer: string;
  28909. version: string;
  28910. };
  28911. /**
  28912. * Gets current aspect ratio
  28913. * @param camera defines the camera to use to get the aspect ratio
  28914. * @param useScreen defines if screen size must be used (or the current render target if any)
  28915. * @returns a number defining the aspect ratio
  28916. */
  28917. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28918. /**
  28919. * Gets current screen aspect ratio
  28920. * @returns a number defining the aspect ratio
  28921. */
  28922. getScreenAspectRatio(): number;
  28923. /**
  28924. * Gets the current render width
  28925. * @param useScreen defines if screen size must be used (or the current render target if any)
  28926. * @returns a number defining the current render width
  28927. */
  28928. getRenderWidth(useScreen?: boolean): number;
  28929. /**
  28930. * Gets the current render height
  28931. * @param useScreen defines if screen size must be used (or the current render target if any)
  28932. * @returns a number defining the current render height
  28933. */
  28934. getRenderHeight(useScreen?: boolean): number;
  28935. /**
  28936. * Gets the HTML canvas attached with the current webGL context
  28937. * @returns a HTML canvas
  28938. */
  28939. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28940. /**
  28941. * Gets the client rect of the HTML canvas attached with the current webGL context
  28942. * @returns a client rectanglee
  28943. */
  28944. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28945. /**
  28946. * Defines the hardware scaling level.
  28947. * By default the hardware scaling level is computed from the window device ratio.
  28948. * 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.
  28949. * @param level defines the level to use
  28950. */
  28951. setHardwareScalingLevel(level: number): void;
  28952. /**
  28953. * Gets the current hardware scaling level.
  28954. * By default the hardware scaling level is computed from the window device ratio.
  28955. * 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.
  28956. * @returns a number indicating the current hardware scaling level
  28957. */
  28958. getHardwareScalingLevel(): number;
  28959. /**
  28960. * Gets the list of loaded textures
  28961. * @returns an array containing all loaded textures
  28962. */
  28963. getLoadedTexturesCache(): InternalTexture[];
  28964. /**
  28965. * Gets the object containing all engine capabilities
  28966. * @returns the EngineCapabilities object
  28967. */
  28968. getCaps(): EngineCapabilities;
  28969. /**
  28970. * Gets the current depth function
  28971. * @returns a number defining the depth function
  28972. */
  28973. getDepthFunction(): Nullable<number>;
  28974. /**
  28975. * Sets the current depth function
  28976. * @param depthFunc defines the function to use
  28977. */
  28978. setDepthFunction(depthFunc: number): void;
  28979. /**
  28980. * Sets the current depth function to GREATER
  28981. */
  28982. setDepthFunctionToGreater(): void;
  28983. /**
  28984. * Sets the current depth function to GEQUAL
  28985. */
  28986. setDepthFunctionToGreaterOrEqual(): void;
  28987. /**
  28988. * Sets the current depth function to LESS
  28989. */
  28990. setDepthFunctionToLess(): void;
  28991. private _cachedStencilBuffer;
  28992. private _cachedStencilFunction;
  28993. private _cachedStencilMask;
  28994. private _cachedStencilOperationPass;
  28995. private _cachedStencilOperationFail;
  28996. private _cachedStencilOperationDepthFail;
  28997. private _cachedStencilReference;
  28998. /**
  28999. * Caches the the state of the stencil buffer
  29000. */
  29001. cacheStencilState(): void;
  29002. /**
  29003. * Restores the state of the stencil buffer
  29004. */
  29005. restoreStencilState(): void;
  29006. /**
  29007. * Sets the current depth function to LEQUAL
  29008. */
  29009. setDepthFunctionToLessOrEqual(): void;
  29010. /**
  29011. * Gets a boolean indicating if stencil buffer is enabled
  29012. * @returns the current stencil buffer state
  29013. */
  29014. getStencilBuffer(): boolean;
  29015. /**
  29016. * Enable or disable the stencil buffer
  29017. * @param enable defines if the stencil buffer must be enabled or disabled
  29018. */
  29019. setStencilBuffer(enable: boolean): void;
  29020. /**
  29021. * Gets the current stencil mask
  29022. * @returns a number defining the new stencil mask to use
  29023. */
  29024. getStencilMask(): number;
  29025. /**
  29026. * Sets the current stencil mask
  29027. * @param mask defines the new stencil mask to use
  29028. */
  29029. setStencilMask(mask: number): void;
  29030. /**
  29031. * Gets the current stencil function
  29032. * @returns a number defining the stencil function to use
  29033. */
  29034. getStencilFunction(): number;
  29035. /**
  29036. * Gets the current stencil reference value
  29037. * @returns a number defining the stencil reference value to use
  29038. */
  29039. getStencilFunctionReference(): number;
  29040. /**
  29041. * Gets the current stencil mask
  29042. * @returns a number defining the stencil mask to use
  29043. */
  29044. getStencilFunctionMask(): number;
  29045. /**
  29046. * Sets the current stencil function
  29047. * @param stencilFunc defines the new stencil function to use
  29048. */
  29049. setStencilFunction(stencilFunc: number): void;
  29050. /**
  29051. * Sets the current stencil reference
  29052. * @param reference defines the new stencil reference to use
  29053. */
  29054. setStencilFunctionReference(reference: number): void;
  29055. /**
  29056. * Sets the current stencil mask
  29057. * @param mask defines the new stencil mask to use
  29058. */
  29059. setStencilFunctionMask(mask: number): void;
  29060. /**
  29061. * Gets the current stencil operation when stencil fails
  29062. * @returns a number defining stencil operation to use when stencil fails
  29063. */
  29064. getStencilOperationFail(): number;
  29065. /**
  29066. * Gets the current stencil operation when depth fails
  29067. * @returns a number defining stencil operation to use when depth fails
  29068. */
  29069. getStencilOperationDepthFail(): number;
  29070. /**
  29071. * Gets the current stencil operation when stencil passes
  29072. * @returns a number defining stencil operation to use when stencil passes
  29073. */
  29074. getStencilOperationPass(): number;
  29075. /**
  29076. * Sets the stencil operation to use when stencil fails
  29077. * @param operation defines the stencil operation to use when stencil fails
  29078. */
  29079. setStencilOperationFail(operation: number): void;
  29080. /**
  29081. * Sets the stencil operation to use when depth fails
  29082. * @param operation defines the stencil operation to use when depth fails
  29083. */
  29084. setStencilOperationDepthFail(operation: number): void;
  29085. /**
  29086. * Sets the stencil operation to use when stencil passes
  29087. * @param operation defines the stencil operation to use when stencil passes
  29088. */
  29089. setStencilOperationPass(operation: number): void;
  29090. /**
  29091. * Sets a boolean indicating if the dithering state is enabled or disabled
  29092. * @param value defines the dithering state
  29093. */
  29094. setDitheringState(value: boolean): void;
  29095. /**
  29096. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29097. * @param value defines the rasterizer state
  29098. */
  29099. setRasterizerState(value: boolean): void;
  29100. /**
  29101. * stop executing a render loop function and remove it from the execution array
  29102. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29103. */
  29104. stopRenderLoop(renderFunction?: () => void): void;
  29105. /** @hidden */
  29106. _renderLoop(): void;
  29107. /**
  29108. * Register and execute a render loop. The engine can have more than one render function
  29109. * @param renderFunction defines the function to continuously execute
  29110. */
  29111. runRenderLoop(renderFunction: () => void): void;
  29112. /**
  29113. * Toggle full screen mode
  29114. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29115. */
  29116. switchFullscreen(requestPointerLock: boolean): void;
  29117. /**
  29118. * Enters full screen mode
  29119. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29120. */
  29121. enterFullscreen(requestPointerLock: boolean): void;
  29122. /**
  29123. * Exits full screen mode
  29124. */
  29125. exitFullscreen(): void;
  29126. /**
  29127. * Enters Pointerlock mode
  29128. */
  29129. enterPointerlock(): void;
  29130. /**
  29131. * Exits Pointerlock mode
  29132. */
  29133. exitPointerlock(): void;
  29134. /**
  29135. * Clear the current render buffer or the current render target (if any is set up)
  29136. * @param color defines the color to use
  29137. * @param backBuffer defines if the back buffer must be cleared
  29138. * @param depth defines if the depth buffer must be cleared
  29139. * @param stencil defines if the stencil buffer must be cleared
  29140. */
  29141. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29142. /**
  29143. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29144. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29145. * @param y defines the y-coordinate of the corner of the clear rectangle
  29146. * @param width defines the width of the clear rectangle
  29147. * @param height defines the height of the clear rectangle
  29148. * @param clearColor defines the clear color
  29149. */
  29150. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  29151. /**
  29152. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29153. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29154. * @param y defines the y-coordinate of the corner of the clear rectangle
  29155. * @param width defines the width of the clear rectangle
  29156. * @param height defines the height of the clear rectangle
  29157. */
  29158. enableScissor(x: number, y: number, width: number, height: number): void;
  29159. /**
  29160. * Disable previously set scissor test rectangle
  29161. */
  29162. disableScissor(): void;
  29163. private _viewportCached;
  29164. /** @hidden */
  29165. _viewport(x: number, y: number, width: number, height: number): void;
  29166. /**
  29167. * Set the WebGL's viewport
  29168. * @param viewport defines the viewport element to be used
  29169. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29170. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29171. */
  29172. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29173. /**
  29174. * Directly set the WebGL Viewport
  29175. * @param x defines the x coordinate of the viewport (in screen space)
  29176. * @param y defines the y coordinate of the viewport (in screen space)
  29177. * @param width defines the width of the viewport (in screen space)
  29178. * @param height defines the height of the viewport (in screen space)
  29179. * @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
  29180. */
  29181. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29182. /**
  29183. * Begin a new frame
  29184. */
  29185. beginFrame(): void;
  29186. /**
  29187. * Enf the current frame
  29188. */
  29189. endFrame(): void;
  29190. /**
  29191. * Resize the view according to the canvas' size
  29192. */
  29193. resize(): void;
  29194. /**
  29195. * Force a specific size of the canvas
  29196. * @param width defines the new canvas' width
  29197. * @param height defines the new canvas' height
  29198. */
  29199. setSize(width: number, height: number): void;
  29200. /**
  29201. * Binds the frame buffer to the specified texture.
  29202. * @param texture The texture to render to or null for the default canvas
  29203. * @param faceIndex The face of the texture to render to in case of cube texture
  29204. * @param requiredWidth The width of the target to render to
  29205. * @param requiredHeight The height of the target to render to
  29206. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29207. * @param depthStencilTexture The depth stencil texture to use to render
  29208. * @param lodLevel defines le lod level to bind to the frame buffer
  29209. */
  29210. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29211. /** @hidden */
  29212. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29213. /**
  29214. * Unbind the current render target texture from the webGL context
  29215. * @param texture defines the render target texture to unbind
  29216. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29217. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29218. */
  29219. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29220. /**
  29221. * Force the mipmap generation for the given render target texture
  29222. * @param texture defines the render target texture to use
  29223. */
  29224. generateMipMapsForCubemap(texture: InternalTexture): void;
  29225. /**
  29226. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29227. */
  29228. flushFramebuffer(): void;
  29229. /**
  29230. * Unbind the current render target and bind the default framebuffer
  29231. */
  29232. restoreDefaultFramebuffer(): void;
  29233. /**
  29234. * Create an uniform buffer
  29235. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29236. * @param elements defines the content of the uniform buffer
  29237. * @returns the webGL uniform buffer
  29238. */
  29239. createUniformBuffer(elements: FloatArray): DataBuffer;
  29240. /**
  29241. * Create a dynamic uniform buffer
  29242. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29243. * @param elements defines the content of the uniform buffer
  29244. * @returns the webGL uniform buffer
  29245. */
  29246. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29247. /**
  29248. * Update an existing uniform buffer
  29249. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29250. * @param uniformBuffer defines the target uniform buffer
  29251. * @param elements defines the content to update
  29252. * @param offset defines the offset in the uniform buffer where update should start
  29253. * @param count defines the size of the data to update
  29254. */
  29255. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29256. private _resetVertexBufferBinding;
  29257. /**
  29258. * Creates a vertex buffer
  29259. * @param data the data for the vertex buffer
  29260. * @returns the new WebGL static buffer
  29261. */
  29262. createVertexBuffer(data: DataArray): DataBuffer;
  29263. /**
  29264. * Creates a dynamic vertex buffer
  29265. * @param data the data for the dynamic vertex buffer
  29266. * @returns the new WebGL dynamic buffer
  29267. */
  29268. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29269. /**
  29270. * Update a dynamic index buffer
  29271. * @param indexBuffer defines the target index buffer
  29272. * @param indices defines the data to update
  29273. * @param offset defines the offset in the target index buffer where update should start
  29274. */
  29275. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29276. /**
  29277. * Updates a dynamic vertex buffer.
  29278. * @param vertexBuffer the vertex buffer to update
  29279. * @param data the data used to update the vertex buffer
  29280. * @param byteOffset the byte offset of the data
  29281. * @param byteLength the byte length of the data
  29282. */
  29283. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29284. private _resetIndexBufferBinding;
  29285. /**
  29286. * Creates a new index buffer
  29287. * @param indices defines the content of the index buffer
  29288. * @param updatable defines if the index buffer must be updatable
  29289. * @returns a new webGL buffer
  29290. */
  29291. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29292. /**
  29293. * Bind a webGL buffer to the webGL context
  29294. * @param buffer defines the buffer to bind
  29295. */
  29296. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29297. /**
  29298. * Bind an uniform buffer to the current webGL context
  29299. * @param buffer defines the buffer to bind
  29300. */
  29301. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29302. /**
  29303. * Bind a buffer to the current webGL context at a given location
  29304. * @param buffer defines the buffer to bind
  29305. * @param location defines the index where to bind the buffer
  29306. */
  29307. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29308. /**
  29309. * Bind a specific block at a given index in a specific shader program
  29310. * @param pipelineContext defines the pipeline context to use
  29311. * @param blockName defines the block name
  29312. * @param index defines the index where to bind the block
  29313. */
  29314. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29315. private bindIndexBuffer;
  29316. private bindBuffer;
  29317. /**
  29318. * update the bound buffer with the given data
  29319. * @param data defines the data to update
  29320. */
  29321. updateArrayBuffer(data: Float32Array): void;
  29322. private _vertexAttribPointer;
  29323. private _bindIndexBufferWithCache;
  29324. private _bindVertexBuffersAttributes;
  29325. /**
  29326. * Records a vertex array object
  29327. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29328. * @param vertexBuffers defines the list of vertex buffers to store
  29329. * @param indexBuffer defines the index buffer to store
  29330. * @param effect defines the effect to store
  29331. * @returns the new vertex array object
  29332. */
  29333. recordVertexArrayObject(vertexBuffers: {
  29334. [key: string]: VertexBuffer;
  29335. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29336. /**
  29337. * Bind a specific vertex array object
  29338. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29339. * @param vertexArrayObject defines the vertex array object to bind
  29340. * @param indexBuffer defines the index buffer to bind
  29341. */
  29342. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29343. /**
  29344. * Bind webGl buffers directly to the webGL context
  29345. * @param vertexBuffer defines the vertex buffer to bind
  29346. * @param indexBuffer defines the index buffer to bind
  29347. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29348. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29349. * @param effect defines the effect associated with the vertex buffer
  29350. */
  29351. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29352. private _unbindVertexArrayObject;
  29353. /**
  29354. * Bind a list of vertex buffers to the webGL context
  29355. * @param vertexBuffers defines the list of vertex buffers to bind
  29356. * @param indexBuffer defines the index buffer to bind
  29357. * @param effect defines the effect associated with the vertex buffers
  29358. */
  29359. bindBuffers(vertexBuffers: {
  29360. [key: string]: Nullable<VertexBuffer>;
  29361. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29362. /**
  29363. * Unbind all instance attributes
  29364. */
  29365. unbindInstanceAttributes(): void;
  29366. /**
  29367. * Release and free the memory of a vertex array object
  29368. * @param vao defines the vertex array object to delete
  29369. */
  29370. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29371. /** @hidden */
  29372. _releaseBuffer(buffer: DataBuffer): boolean;
  29373. /**
  29374. * Creates a webGL buffer to use with instanciation
  29375. * @param capacity defines the size of the buffer
  29376. * @returns the webGL buffer
  29377. */
  29378. createInstancesBuffer(capacity: number): DataBuffer;
  29379. /**
  29380. * Delete a webGL buffer used with instanciation
  29381. * @param buffer defines the webGL buffer to delete
  29382. */
  29383. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29384. /**
  29385. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29386. * @param instancesBuffer defines the webGL buffer to update and bind
  29387. * @param data defines the data to store in the buffer
  29388. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29389. */
  29390. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29391. /**
  29392. * Apply all cached states (depth, culling, stencil and alpha)
  29393. */
  29394. applyStates(): void;
  29395. /**
  29396. * Send a draw order
  29397. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29398. * @param indexStart defines the starting index
  29399. * @param indexCount defines the number of index to draw
  29400. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29401. */
  29402. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29403. /**
  29404. * Draw a list of points
  29405. * @param verticesStart defines the index of first vertex to draw
  29406. * @param verticesCount defines the count of vertices to draw
  29407. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29408. */
  29409. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29410. /**
  29411. * Draw a list of unindexed primitives
  29412. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29413. * @param verticesStart defines the index of first vertex to draw
  29414. * @param verticesCount defines the count of vertices to draw
  29415. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29416. */
  29417. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29418. /**
  29419. * Draw a list of indexed primitives
  29420. * @param fillMode defines the primitive to use
  29421. * @param indexStart defines the starting index
  29422. * @param indexCount defines the number of index to draw
  29423. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29424. */
  29425. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29426. /**
  29427. * Draw a list of unindexed primitives
  29428. * @param fillMode defines the primitive to use
  29429. * @param verticesStart defines the index of first vertex to draw
  29430. * @param verticesCount defines the count of vertices to draw
  29431. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29432. */
  29433. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29434. private _drawMode;
  29435. /** @hidden */
  29436. _releaseEffect(effect: Effect): void;
  29437. /** @hidden */
  29438. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29439. /**
  29440. * Create a new effect (used to store vertex/fragment shaders)
  29441. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29442. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29443. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29444. * @param samplers defines an array of string used to represent textures
  29445. * @param defines defines the string containing the defines to use to compile the shaders
  29446. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29447. * @param onCompiled defines a function to call when the effect creation is successful
  29448. * @param onError defines a function to call when the effect creation has failed
  29449. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29450. * @returns the new Effect
  29451. */
  29452. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29453. private _compileShader;
  29454. private _compileRawShader;
  29455. /**
  29456. * Directly creates a webGL program
  29457. * @param pipelineContext defines the pipeline context to attach to
  29458. * @param vertexCode defines the vertex shader code to use
  29459. * @param fragmentCode defines the fragment shader code to use
  29460. * @param context defines the webGL context to use (if not set, the current one will be used)
  29461. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29462. * @returns the new webGL program
  29463. */
  29464. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29465. /**
  29466. * Creates a webGL program
  29467. * @param pipelineContext defines the pipeline context to attach to
  29468. * @param vertexCode defines the vertex shader code to use
  29469. * @param fragmentCode defines the fragment shader code to use
  29470. * @param defines defines the string containing the defines to use to compile the shaders
  29471. * @param context defines the webGL context to use (if not set, the current one will be used)
  29472. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29473. * @returns the new webGL program
  29474. */
  29475. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29476. /**
  29477. * Creates a new pipeline context
  29478. * @returns the new pipeline
  29479. */
  29480. createPipelineContext(): WebGLPipelineContext;
  29481. private _createShaderProgram;
  29482. private _finalizePipelineContext;
  29483. /** @hidden */
  29484. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29485. /** @hidden */
  29486. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29487. /** @hidden */
  29488. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29489. /**
  29490. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29491. * @param pipelineContext defines the pipeline context to use
  29492. * @param uniformsNames defines the list of uniform names
  29493. * @returns an array of webGL uniform locations
  29494. */
  29495. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29496. /**
  29497. * Gets the lsit of active attributes for a given webGL program
  29498. * @param pipelineContext defines the pipeline context to use
  29499. * @param attributesNames defines the list of attribute names to get
  29500. * @returns an array of indices indicating the offset of each attribute
  29501. */
  29502. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29503. /**
  29504. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29505. * @param effect defines the effect to activate
  29506. */
  29507. enableEffect(effect: Nullable<Effect>): void;
  29508. /**
  29509. * Set the value of an uniform to an array of int32
  29510. * @param uniform defines the webGL uniform location where to store the value
  29511. * @param array defines the array of int32 to store
  29512. */
  29513. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29514. /**
  29515. * Set the value of an uniform to an array of int32 (stored as vec2)
  29516. * @param uniform defines the webGL uniform location where to store the value
  29517. * @param array defines the array of int32 to store
  29518. */
  29519. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29520. /**
  29521. * Set the value of an uniform to an array of int32 (stored as vec3)
  29522. * @param uniform defines the webGL uniform location where to store the value
  29523. * @param array defines the array of int32 to store
  29524. */
  29525. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29526. /**
  29527. * Set the value of an uniform to an array of int32 (stored as vec4)
  29528. * @param uniform defines the webGL uniform location where to store the value
  29529. * @param array defines the array of int32 to store
  29530. */
  29531. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29532. /**
  29533. * Set the value of an uniform to an array of float32
  29534. * @param uniform defines the webGL uniform location where to store the value
  29535. * @param array defines the array of float32 to store
  29536. */
  29537. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29538. /**
  29539. * Set the value of an uniform to an array of float32 (stored as vec2)
  29540. * @param uniform defines the webGL uniform location where to store the value
  29541. * @param array defines the array of float32 to store
  29542. */
  29543. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29544. /**
  29545. * Set the value of an uniform to an array of float32 (stored as vec3)
  29546. * @param uniform defines the webGL uniform location where to store the value
  29547. * @param array defines the array of float32 to store
  29548. */
  29549. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29550. /**
  29551. * Set the value of an uniform to an array of float32 (stored as vec4)
  29552. * @param uniform defines the webGL uniform location where to store the value
  29553. * @param array defines the array of float32 to store
  29554. */
  29555. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29556. /**
  29557. * Set the value of an uniform to an array of number
  29558. * @param uniform defines the webGL uniform location where to store the value
  29559. * @param array defines the array of number to store
  29560. */
  29561. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29562. /**
  29563. * Set the value of an uniform to an array of number (stored as vec2)
  29564. * @param uniform defines the webGL uniform location where to store the value
  29565. * @param array defines the array of number to store
  29566. */
  29567. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29568. /**
  29569. * Set the value of an uniform to an array of number (stored as vec3)
  29570. * @param uniform defines the webGL uniform location where to store the value
  29571. * @param array defines the array of number to store
  29572. */
  29573. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29574. /**
  29575. * Set the value of an uniform to an array of number (stored as vec4)
  29576. * @param uniform defines the webGL uniform location where to store the value
  29577. * @param array defines the array of number to store
  29578. */
  29579. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29580. /**
  29581. * Set the value of an uniform to an array of float32 (stored as matrices)
  29582. * @param uniform defines the webGL uniform location where to store the value
  29583. * @param matrices defines the array of float32 to store
  29584. */
  29585. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29586. /**
  29587. * Set the value of an uniform to a matrix
  29588. * @param uniform defines the webGL uniform location where to store the value
  29589. * @param matrix defines the matrix to store
  29590. */
  29591. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29592. /**
  29593. * Set the value of an uniform to a matrix (3x3)
  29594. * @param uniform defines the webGL uniform location where to store the value
  29595. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29596. */
  29597. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29598. /**
  29599. * Set the value of an uniform to a matrix (2x2)
  29600. * @param uniform defines the webGL uniform location where to store the value
  29601. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29602. */
  29603. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29604. /**
  29605. * Set the value of an uniform to a number (int)
  29606. * @param uniform defines the webGL uniform location where to store the value
  29607. * @param value defines the int number to store
  29608. */
  29609. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29610. /**
  29611. * Set the value of an uniform to a number (float)
  29612. * @param uniform defines the webGL uniform location where to store the value
  29613. * @param value defines the float number to store
  29614. */
  29615. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29616. /**
  29617. * Set the value of an uniform to a vec2
  29618. * @param uniform defines the webGL uniform location where to store the value
  29619. * @param x defines the 1st component of the value
  29620. * @param y defines the 2nd component of the value
  29621. */
  29622. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29623. /**
  29624. * Set the value of an uniform to a vec3
  29625. * @param uniform defines the webGL uniform location where to store the value
  29626. * @param x defines the 1st component of the value
  29627. * @param y defines the 2nd component of the value
  29628. * @param z defines the 3rd component of the value
  29629. */
  29630. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29631. /**
  29632. * Set the value of an uniform to a boolean
  29633. * @param uniform defines the webGL uniform location where to store the value
  29634. * @param bool defines the boolean to store
  29635. */
  29636. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29637. /**
  29638. * Set the value of an uniform to a vec4
  29639. * @param uniform defines the webGL uniform location where to store the value
  29640. * @param x defines the 1st component of the value
  29641. * @param y defines the 2nd component of the value
  29642. * @param z defines the 3rd component of the value
  29643. * @param w defines the 4th component of the value
  29644. */
  29645. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29646. /**
  29647. * Set the value of an uniform to a Color3
  29648. * @param uniform defines the webGL uniform location where to store the value
  29649. * @param color3 defines the color to store
  29650. */
  29651. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29652. /**
  29653. * Set the value of an uniform to a Color3 and an alpha value
  29654. * @param uniform defines the webGL uniform location where to store the value
  29655. * @param color3 defines the color to store
  29656. * @param alpha defines the alpha component to store
  29657. */
  29658. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29659. /**
  29660. * Sets a Color4 on a uniform variable
  29661. * @param uniform defines the uniform location
  29662. * @param color4 defines the value to be set
  29663. */
  29664. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29665. /**
  29666. * Set various states to the webGL context
  29667. * @param culling defines backface culling state
  29668. * @param zOffset defines the value to apply to zOffset (0 by default)
  29669. * @param force defines if states must be applied even if cache is up to date
  29670. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29671. */
  29672. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29673. /**
  29674. * Set the z offset to apply to current rendering
  29675. * @param value defines the offset to apply
  29676. */
  29677. setZOffset(value: number): void;
  29678. /**
  29679. * Gets the current value of the zOffset
  29680. * @returns the current zOffset state
  29681. */
  29682. getZOffset(): number;
  29683. /**
  29684. * Enable or disable depth buffering
  29685. * @param enable defines the state to set
  29686. */
  29687. setDepthBuffer(enable: boolean): void;
  29688. /**
  29689. * Gets a boolean indicating if depth writing is enabled
  29690. * @returns the current depth writing state
  29691. */
  29692. getDepthWrite(): boolean;
  29693. /**
  29694. * Enable or disable depth writing
  29695. * @param enable defines the state to set
  29696. */
  29697. setDepthWrite(enable: boolean): void;
  29698. /**
  29699. * Enable or disable color writing
  29700. * @param enable defines the state to set
  29701. */
  29702. setColorWrite(enable: boolean): void;
  29703. /**
  29704. * Gets a boolean indicating if color writing is enabled
  29705. * @returns the current color writing state
  29706. */
  29707. getColorWrite(): boolean;
  29708. /**
  29709. * Sets alpha constants used by some alpha blending modes
  29710. * @param r defines the red component
  29711. * @param g defines the green component
  29712. * @param b defines the blue component
  29713. * @param a defines the alpha component
  29714. */
  29715. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29716. /**
  29717. * Sets the current alpha mode
  29718. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29719. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29720. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29721. */
  29722. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29723. /**
  29724. * Gets the current alpha mode
  29725. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29726. * @returns the current alpha mode
  29727. */
  29728. getAlphaMode(): number;
  29729. /**
  29730. * Clears the list of texture accessible through engine.
  29731. * This can help preventing texture load conflict due to name collision.
  29732. */
  29733. clearInternalTexturesCache(): void;
  29734. /**
  29735. * Force the entire cache to be cleared
  29736. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29737. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29738. */
  29739. wipeCaches(bruteForce?: boolean): void;
  29740. /**
  29741. * Set the compressed texture format to use, based on the formats you have, and the formats
  29742. * supported by the hardware / browser.
  29743. *
  29744. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29745. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29746. * to API arguments needed to compressed textures. This puts the burden on the container
  29747. * generator to house the arcane code for determining these for current & future formats.
  29748. *
  29749. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29750. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29751. *
  29752. * Note: The result of this call is not taken into account when a texture is base64.
  29753. *
  29754. * @param formatsAvailable defines the list of those format families you have created
  29755. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29756. *
  29757. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29758. * @returns The extension selected.
  29759. */
  29760. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29761. /** @hidden */
  29762. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29763. min: number;
  29764. mag: number;
  29765. };
  29766. /** @hidden */
  29767. _createTexture(): WebGLTexture;
  29768. /**
  29769. * Usually called from Texture.ts.
  29770. * Passed information to create a WebGLTexture
  29771. * @param urlArg defines a value which contains one of the following:
  29772. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29773. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29774. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29775. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29776. * @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)
  29777. * @param scene needed for loading to the correct scene
  29778. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29779. * @param onLoad optional callback to be called upon successful completion
  29780. * @param onError optional callback to be called upon failure
  29781. * @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
  29782. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29783. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29784. * @param forcedExtension defines the extension to use to pick the right loader
  29785. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29786. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29787. */
  29788. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29789. /**
  29790. * @hidden
  29791. * Rescales a texture
  29792. * @param source input texutre
  29793. * @param destination destination texture
  29794. * @param scene scene to use to render the resize
  29795. * @param internalFormat format to use when resizing
  29796. * @param onComplete callback to be called when resize has completed
  29797. */
  29798. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29799. private _unpackFlipYCached;
  29800. /**
  29801. * In case you are sharing the context with other applications, it might
  29802. * be interested to not cache the unpack flip y state to ensure a consistent
  29803. * value would be set.
  29804. */
  29805. enableUnpackFlipYCached: boolean;
  29806. /** @hidden */
  29807. _unpackFlipY(value: boolean): void;
  29808. /** @hidden */
  29809. _getUnpackAlignement(): number;
  29810. /**
  29811. * Creates a dynamic texture
  29812. * @param width defines the width of the texture
  29813. * @param height defines the height of the texture
  29814. * @param generateMipMaps defines if the engine should generate the mip levels
  29815. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29816. * @returns the dynamic texture inside an InternalTexture
  29817. */
  29818. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29819. /**
  29820. * Update the sampling mode of a given texture
  29821. * @param samplingMode defines the required sampling mode
  29822. * @param texture defines the texture to update
  29823. */
  29824. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29825. /**
  29826. * Update the content of a dynamic texture
  29827. * @param texture defines the texture to update
  29828. * @param canvas defines the canvas containing the source
  29829. * @param invertY defines if data must be stored with Y axis inverted
  29830. * @param premulAlpha defines if alpha is stored as premultiplied
  29831. * @param format defines the format of the data
  29832. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29833. */
  29834. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29835. /**
  29836. * Update a video texture
  29837. * @param texture defines the texture to update
  29838. * @param video defines the video element to use
  29839. * @param invertY defines if data must be stored with Y axis inverted
  29840. */
  29841. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29842. /**
  29843. * Updates a depth texture Comparison Mode and Function.
  29844. * If the comparison Function is equal to 0, the mode will be set to none.
  29845. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29846. * @param texture The texture to set the comparison function for
  29847. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29848. */
  29849. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29850. /** @hidden */
  29851. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29852. width: number;
  29853. height: number;
  29854. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29855. /**
  29856. * Creates a depth stencil texture.
  29857. * This is only available in WebGL 2 or with the depth texture extension available.
  29858. * @param size The size of face edge in the texture.
  29859. * @param options The options defining the texture.
  29860. * @returns The texture
  29861. */
  29862. createDepthStencilTexture(size: number | {
  29863. width: number;
  29864. height: number;
  29865. }, options: DepthTextureCreationOptions): InternalTexture;
  29866. /**
  29867. * Creates a depth stencil texture.
  29868. * This is only available in WebGL 2 or with the depth texture extension available.
  29869. * @param size The size of face edge in the texture.
  29870. * @param options The options defining the texture.
  29871. * @returns The texture
  29872. */
  29873. private _createDepthStencilTexture;
  29874. /**
  29875. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29876. * @param renderTarget The render target to set the frame buffer for
  29877. */
  29878. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29879. /**
  29880. * Creates a new render target texture
  29881. * @param size defines the size of the texture
  29882. * @param options defines the options used to create the texture
  29883. * @returns a new render target texture stored in an InternalTexture
  29884. */
  29885. createRenderTargetTexture(size: number | {
  29886. width: number;
  29887. height: number;
  29888. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29889. /** @hidden */
  29890. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29891. /**
  29892. * Updates the sample count of a render target texture
  29893. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29894. * @param texture defines the texture to update
  29895. * @param samples defines the sample count to set
  29896. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29897. */
  29898. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29899. /** @hidden */
  29900. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29901. /** @hidden */
  29902. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29903. /** @hidden */
  29904. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29905. /** @hidden */
  29906. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29907. /**
  29908. * @hidden
  29909. */
  29910. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29911. private _prepareWebGLTextureContinuation;
  29912. private _prepareWebGLTexture;
  29913. /** @hidden */
  29914. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29915. /** @hidden */
  29916. _releaseFramebufferObjects(texture: InternalTexture): void;
  29917. /** @hidden */
  29918. _releaseTexture(texture: InternalTexture): void;
  29919. private setProgram;
  29920. private _boundUniforms;
  29921. /**
  29922. * Binds an effect to the webGL context
  29923. * @param effect defines the effect to bind
  29924. */
  29925. bindSamplers(effect: Effect): void;
  29926. private _activateCurrentTexture;
  29927. /** @hidden */
  29928. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29929. /** @hidden */
  29930. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29931. /**
  29932. * Sets a texture to the webGL context from a postprocess
  29933. * @param channel defines the channel to use
  29934. * @param postProcess defines the source postprocess
  29935. */
  29936. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29937. /**
  29938. * Binds the output of the passed in post process to the texture channel specified
  29939. * @param channel The channel the texture should be bound to
  29940. * @param postProcess The post process which's output should be bound
  29941. */
  29942. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29943. /**
  29944. * Unbind all textures from the webGL context
  29945. */
  29946. unbindAllTextures(): void;
  29947. /**
  29948. * Sets a texture to the according uniform.
  29949. * @param channel The texture channel
  29950. * @param uniform The uniform to set
  29951. * @param texture The texture to apply
  29952. */
  29953. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29954. /**
  29955. * Sets a depth stencil texture from a render target to the according uniform.
  29956. * @param channel The texture channel
  29957. * @param uniform The uniform to set
  29958. * @param texture The render target texture containing the depth stencil texture to apply
  29959. */
  29960. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29961. private _bindSamplerUniformToChannel;
  29962. private _getTextureWrapMode;
  29963. private _setTexture;
  29964. /**
  29965. * Sets an array of texture to the webGL context
  29966. * @param channel defines the channel where the texture array must be set
  29967. * @param uniform defines the associated uniform location
  29968. * @param textures defines the array of textures to bind
  29969. */
  29970. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29971. /** @hidden */
  29972. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29973. private _setTextureParameterFloat;
  29974. private _setTextureParameterInteger;
  29975. /**
  29976. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29977. * @param x defines the x coordinate of the rectangle where pixels must be read
  29978. * @param y defines the y coordinate of the rectangle where pixels must be read
  29979. * @param width defines the width of the rectangle where pixels must be read
  29980. * @param height defines the height of the rectangle where pixels must be read
  29981. * @returns a Uint8Array containing RGBA colors
  29982. */
  29983. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29984. /**
  29985. * Add an externaly attached data from its key.
  29986. * This method call will fail and return false, if such key already exists.
  29987. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29988. * @param key the unique key that identifies the data
  29989. * @param data the data object to associate to the key for this Engine instance
  29990. * @return true if no such key were already present and the data was added successfully, false otherwise
  29991. */
  29992. addExternalData<T>(key: string, data: T): boolean;
  29993. /**
  29994. * Get an externaly attached data from its key
  29995. * @param key the unique key that identifies the data
  29996. * @return the associated data, if present (can be null), or undefined if not present
  29997. */
  29998. getExternalData<T>(key: string): T;
  29999. /**
  30000. * Get an externaly attached data from its key, create it using a factory if it's not already present
  30001. * @param key the unique key that identifies the data
  30002. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  30003. * @return the associated data, can be null if the factory returned null.
  30004. */
  30005. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  30006. /**
  30007. * Remove an externaly attached data from the Engine instance
  30008. * @param key the unique key that identifies the data
  30009. * @return true if the data was successfully removed, false if it doesn't exist
  30010. */
  30011. removeExternalData(key: string): boolean;
  30012. /**
  30013. * Unbind all vertex attributes from the webGL context
  30014. */
  30015. unbindAllAttributes(): void;
  30016. /**
  30017. * 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
  30018. */
  30019. releaseEffects(): void;
  30020. /**
  30021. * Dispose and release all associated resources
  30022. */
  30023. dispose(): void;
  30024. /**
  30025. * Display the loading screen
  30026. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30027. */
  30028. displayLoadingUI(): void;
  30029. /**
  30030. * Hide the loading screen
  30031. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30032. */
  30033. hideLoadingUI(): void;
  30034. /**
  30035. * Gets the current loading screen object
  30036. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30037. */
  30038. /**
  30039. * Sets the current loading screen object
  30040. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30041. */
  30042. loadingScreen: ILoadingScreen;
  30043. /**
  30044. * Sets the current loading screen text
  30045. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30046. */
  30047. loadingUIText: string;
  30048. /**
  30049. * Sets the current loading screen background color
  30050. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30051. */
  30052. loadingUIBackgroundColor: string;
  30053. /**
  30054. * Attach a new callback raised when context lost event is fired
  30055. * @param callback defines the callback to call
  30056. */
  30057. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30058. /**
  30059. * Attach a new callback raised when context restored event is fired
  30060. * @param callback defines the callback to call
  30061. */
  30062. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30063. /**
  30064. * Gets the source code of the vertex shader associated with a specific webGL program
  30065. * @param program defines the program to use
  30066. * @returns a string containing the source code of the vertex shader associated with the program
  30067. */
  30068. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30069. /**
  30070. * Gets the source code of the fragment shader associated with a specific webGL program
  30071. * @param program defines the program to use
  30072. * @returns a string containing the source code of the fragment shader associated with the program
  30073. */
  30074. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30075. /**
  30076. * Get the current error code of the webGL context
  30077. * @returns the error code
  30078. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30079. */
  30080. getError(): number;
  30081. /**
  30082. * Gets the current framerate
  30083. * @returns a number representing the framerate
  30084. */
  30085. getFps(): number;
  30086. /**
  30087. * Gets the time spent between current and previous frame
  30088. * @returns a number representing the delta time in ms
  30089. */
  30090. getDeltaTime(): number;
  30091. private _measureFps;
  30092. /** @hidden */
  30093. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30094. private _canRenderToFloatFramebuffer;
  30095. private _canRenderToHalfFloatFramebuffer;
  30096. private _canRenderToFramebuffer;
  30097. /** @hidden */
  30098. _getWebGLTextureType(type: number): number;
  30099. /** @hidden */
  30100. _getInternalFormat(format: number): number;
  30101. /** @hidden */
  30102. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30103. /** @hidden */
  30104. _getRGBAMultiSampleBufferFormat(type: number): number;
  30105. /** @hidden */
  30106. _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;
  30107. /** @hidden */
  30108. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30109. /**
  30110. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30111. * @returns true if the engine can be created
  30112. * @ignorenaming
  30113. */
  30114. static isSupported(): boolean;
  30115. }
  30116. }
  30117. declare module "babylonjs/Materials/effect" {
  30118. import { Observable } from "babylonjs/Misc/observable";
  30119. import { Nullable } from "babylonjs/types";
  30120. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  30121. import { IDisposable } from "babylonjs/scene";
  30122. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30123. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30124. import { Engine } from "babylonjs/Engines/engine";
  30125. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30126. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30127. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30128. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30130. /**
  30131. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  30132. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  30133. */
  30134. export class EffectFallbacks {
  30135. private _defines;
  30136. private _currentRank;
  30137. private _maxRank;
  30138. private _mesh;
  30139. /**
  30140. * Removes the fallback from the bound mesh.
  30141. */
  30142. unBindMesh(): void;
  30143. /**
  30144. * Adds a fallback on the specified property.
  30145. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30146. * @param define The name of the define in the shader
  30147. */
  30148. addFallback(rank: number, define: string): void;
  30149. /**
  30150. * Sets the mesh to use CPU skinning when needing to fallback.
  30151. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30152. * @param mesh The mesh to use the fallbacks.
  30153. */
  30154. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30155. /**
  30156. * Checks to see if more fallbacks are still availible.
  30157. */
  30158. readonly isMoreFallbacks: boolean;
  30159. /**
  30160. * Removes the defines that should be removed when falling back.
  30161. * @param currentDefines defines the current define statements for the shader.
  30162. * @param effect defines the current effect we try to compile
  30163. * @returns The resulting defines with defines of the current rank removed.
  30164. */
  30165. reduce(currentDefines: string, effect: Effect): string;
  30166. }
  30167. /**
  30168. * Options to be used when creating an effect.
  30169. */
  30170. export class EffectCreationOptions {
  30171. /**
  30172. * Atrributes that will be used in the shader.
  30173. */
  30174. attributes: string[];
  30175. /**
  30176. * Uniform varible names that will be set in the shader.
  30177. */
  30178. uniformsNames: string[];
  30179. /**
  30180. * Uniform buffer varible names that will be set in the shader.
  30181. */
  30182. uniformBuffersNames: string[];
  30183. /**
  30184. * Sampler texture variable names that will be set in the shader.
  30185. */
  30186. samplers: string[];
  30187. /**
  30188. * Define statements that will be set in the shader.
  30189. */
  30190. defines: any;
  30191. /**
  30192. * Possible fallbacks for this effect to improve performance when needed.
  30193. */
  30194. fallbacks: Nullable<EffectFallbacks>;
  30195. /**
  30196. * Callback that will be called when the shader is compiled.
  30197. */
  30198. onCompiled: Nullable<(effect: Effect) => void>;
  30199. /**
  30200. * Callback that will be called if an error occurs during shader compilation.
  30201. */
  30202. onError: Nullable<(effect: Effect, errors: string) => void>;
  30203. /**
  30204. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30205. */
  30206. indexParameters: any;
  30207. /**
  30208. * Max number of lights that can be used in the shader.
  30209. */
  30210. maxSimultaneousLights: number;
  30211. /**
  30212. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30213. */
  30214. transformFeedbackVaryings: Nullable<string[]>;
  30215. }
  30216. /**
  30217. * Effect containing vertex and fragment shader that can be executed on an object.
  30218. */
  30219. export class Effect implements IDisposable {
  30220. /**
  30221. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30222. */
  30223. static ShadersRepository: string;
  30224. /**
  30225. * Name of the effect.
  30226. */
  30227. name: any;
  30228. /**
  30229. * String container all the define statements that should be set on the shader.
  30230. */
  30231. defines: string;
  30232. /**
  30233. * Callback that will be called when the shader is compiled.
  30234. */
  30235. onCompiled: Nullable<(effect: Effect) => void>;
  30236. /**
  30237. * Callback that will be called if an error occurs during shader compilation.
  30238. */
  30239. onError: Nullable<(effect: Effect, errors: string) => void>;
  30240. /**
  30241. * Callback that will be called when effect is bound.
  30242. */
  30243. onBind: Nullable<(effect: Effect) => void>;
  30244. /**
  30245. * Unique ID of the effect.
  30246. */
  30247. uniqueId: number;
  30248. /**
  30249. * Observable that will be called when the shader is compiled.
  30250. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30251. */
  30252. onCompileObservable: Observable<Effect>;
  30253. /**
  30254. * Observable that will be called if an error occurs during shader compilation.
  30255. */
  30256. onErrorObservable: Observable<Effect>;
  30257. /** @hidden */
  30258. _onBindObservable: Nullable<Observable<Effect>>;
  30259. /**
  30260. * Observable that will be called when effect is bound.
  30261. */
  30262. readonly onBindObservable: Observable<Effect>;
  30263. /** @hidden */
  30264. _bonesComputationForcedToCPU: boolean;
  30265. private static _uniqueIdSeed;
  30266. private _engine;
  30267. private _uniformBuffersNames;
  30268. private _uniformsNames;
  30269. private _samplerList;
  30270. private _samplers;
  30271. private _isReady;
  30272. private _compilationError;
  30273. private _attributesNames;
  30274. private _attributes;
  30275. private _uniforms;
  30276. /**
  30277. * Key for the effect.
  30278. * @hidden
  30279. */
  30280. _key: string;
  30281. private _indexParameters;
  30282. private _fallbacks;
  30283. private _vertexSourceCode;
  30284. private _fragmentSourceCode;
  30285. private _vertexSourceCodeOverride;
  30286. private _fragmentSourceCodeOverride;
  30287. private _transformFeedbackVaryings;
  30288. /**
  30289. * Compiled shader to webGL program.
  30290. * @hidden
  30291. */
  30292. _pipelineContext: Nullable<IPipelineContext>;
  30293. private _valueCache;
  30294. private static _baseCache;
  30295. /**
  30296. * Instantiates an effect.
  30297. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30298. * @param baseName Name of the effect.
  30299. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30300. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30301. * @param samplers List of sampler variables that will be passed to the shader.
  30302. * @param engine Engine to be used to render the effect
  30303. * @param defines Define statements to be added to the shader.
  30304. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30305. * @param onCompiled Callback that will be called when the shader is compiled.
  30306. * @param onError Callback that will be called if an error occurs during shader compilation.
  30307. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30308. */
  30309. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  30310. private _useFinalCode;
  30311. /**
  30312. * Unique key for this effect
  30313. */
  30314. readonly key: string;
  30315. /**
  30316. * If the effect has been compiled and prepared.
  30317. * @returns if the effect is compiled and prepared.
  30318. */
  30319. isReady(): boolean;
  30320. /**
  30321. * The engine the effect was initialized with.
  30322. * @returns the engine.
  30323. */
  30324. getEngine(): Engine;
  30325. /**
  30326. * The pipeline context for this effect
  30327. * @returns the associated pipeline context
  30328. */
  30329. getPipelineContext(): Nullable<IPipelineContext>;
  30330. /**
  30331. * The set of names of attribute variables for the shader.
  30332. * @returns An array of attribute names.
  30333. */
  30334. getAttributesNames(): string[];
  30335. /**
  30336. * Returns the attribute at the given index.
  30337. * @param index The index of the attribute.
  30338. * @returns The location of the attribute.
  30339. */
  30340. getAttributeLocation(index: number): number;
  30341. /**
  30342. * Returns the attribute based on the name of the variable.
  30343. * @param name of the attribute to look up.
  30344. * @returns the attribute location.
  30345. */
  30346. getAttributeLocationByName(name: string): number;
  30347. /**
  30348. * The number of attributes.
  30349. * @returns the numnber of attributes.
  30350. */
  30351. getAttributesCount(): number;
  30352. /**
  30353. * Gets the index of a uniform variable.
  30354. * @param uniformName of the uniform to look up.
  30355. * @returns the index.
  30356. */
  30357. getUniformIndex(uniformName: string): number;
  30358. /**
  30359. * Returns the attribute based on the name of the variable.
  30360. * @param uniformName of the uniform to look up.
  30361. * @returns the location of the uniform.
  30362. */
  30363. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30364. /**
  30365. * Returns an array of sampler variable names
  30366. * @returns The array of sampler variable neames.
  30367. */
  30368. getSamplers(): string[];
  30369. /**
  30370. * The error from the last compilation.
  30371. * @returns the error string.
  30372. */
  30373. getCompilationError(): string;
  30374. /**
  30375. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30376. * @param func The callback to be used.
  30377. */
  30378. executeWhenCompiled(func: (effect: Effect) => void): void;
  30379. private _checkIsReady;
  30380. /** @hidden */
  30381. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30382. /** @hidden */
  30383. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30384. /** @hidden */
  30385. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30386. /**
  30387. * Recompiles the webGL program
  30388. * @param vertexSourceCode The source code for the vertex shader.
  30389. * @param fragmentSourceCode The source code for the fragment shader.
  30390. * @param onCompiled Callback called when completed.
  30391. * @param onError Callback called on error.
  30392. * @hidden
  30393. */
  30394. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30395. /**
  30396. * Prepares the effect
  30397. * @hidden
  30398. */
  30399. _prepareEffect(): void;
  30400. /**
  30401. * Checks if the effect is supported. (Must be called after compilation)
  30402. */
  30403. readonly isSupported: boolean;
  30404. /**
  30405. * Binds a texture to the engine to be used as output of the shader.
  30406. * @param channel Name of the output variable.
  30407. * @param texture Texture to bind.
  30408. * @hidden
  30409. */
  30410. _bindTexture(channel: string, texture: InternalTexture): void;
  30411. /**
  30412. * Sets a texture on the engine to be used in the shader.
  30413. * @param channel Name of the sampler variable.
  30414. * @param texture Texture to set.
  30415. */
  30416. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30417. /**
  30418. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30419. * @param channel Name of the sampler variable.
  30420. * @param texture Texture to set.
  30421. */
  30422. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30423. /**
  30424. * Sets an array of textures on the engine to be used in the shader.
  30425. * @param channel Name of the variable.
  30426. * @param textures Textures to set.
  30427. */
  30428. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30429. /**
  30430. * 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)
  30431. * @param channel Name of the sampler variable.
  30432. * @param postProcess Post process to get the input texture from.
  30433. */
  30434. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30435. /**
  30436. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30437. * 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)
  30438. * @param channel Name of the sampler variable.
  30439. * @param postProcess Post process to get the output texture from.
  30440. */
  30441. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30442. /** @hidden */
  30443. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30444. /** @hidden */
  30445. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30446. /** @hidden */
  30447. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30448. /** @hidden */
  30449. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30450. /**
  30451. * Binds a buffer to a uniform.
  30452. * @param buffer Buffer to bind.
  30453. * @param name Name of the uniform variable to bind to.
  30454. */
  30455. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30456. /**
  30457. * Binds block to a uniform.
  30458. * @param blockName Name of the block to bind.
  30459. * @param index Index to bind.
  30460. */
  30461. bindUniformBlock(blockName: string, index: number): void;
  30462. /**
  30463. * Sets an interger value on a uniform variable.
  30464. * @param uniformName Name of the variable.
  30465. * @param value Value to be set.
  30466. * @returns this effect.
  30467. */
  30468. setInt(uniformName: string, value: number): Effect;
  30469. /**
  30470. * Sets an int array on a uniform variable.
  30471. * @param uniformName Name of the variable.
  30472. * @param array array to be set.
  30473. * @returns this effect.
  30474. */
  30475. setIntArray(uniformName: string, array: Int32Array): Effect;
  30476. /**
  30477. * 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)
  30478. * @param uniformName Name of the variable.
  30479. * @param array array to be set.
  30480. * @returns this effect.
  30481. */
  30482. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30483. /**
  30484. * 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)
  30485. * @param uniformName Name of the variable.
  30486. * @param array array to be set.
  30487. * @returns this effect.
  30488. */
  30489. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30490. /**
  30491. * 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)
  30492. * @param uniformName Name of the variable.
  30493. * @param array array to be set.
  30494. * @returns this effect.
  30495. */
  30496. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30497. /**
  30498. * Sets an float array on a uniform variable.
  30499. * @param uniformName Name of the variable.
  30500. * @param array array to be set.
  30501. * @returns this effect.
  30502. */
  30503. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30504. /**
  30505. * 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)
  30506. * @param uniformName Name of the variable.
  30507. * @param array array to be set.
  30508. * @returns this effect.
  30509. */
  30510. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30511. /**
  30512. * 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)
  30513. * @param uniformName Name of the variable.
  30514. * @param array array to be set.
  30515. * @returns this effect.
  30516. */
  30517. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30518. /**
  30519. * 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)
  30520. * @param uniformName Name of the variable.
  30521. * @param array array to be set.
  30522. * @returns this effect.
  30523. */
  30524. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30525. /**
  30526. * Sets an array on a uniform variable.
  30527. * @param uniformName Name of the variable.
  30528. * @param array array to be set.
  30529. * @returns this effect.
  30530. */
  30531. setArray(uniformName: string, array: number[]): Effect;
  30532. /**
  30533. * 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)
  30534. * @param uniformName Name of the variable.
  30535. * @param array array to be set.
  30536. * @returns this effect.
  30537. */
  30538. setArray2(uniformName: string, array: number[]): Effect;
  30539. /**
  30540. * 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)
  30541. * @param uniformName Name of the variable.
  30542. * @param array array to be set.
  30543. * @returns this effect.
  30544. */
  30545. setArray3(uniformName: string, array: number[]): Effect;
  30546. /**
  30547. * 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)
  30548. * @param uniformName Name of the variable.
  30549. * @param array array to be set.
  30550. * @returns this effect.
  30551. */
  30552. setArray4(uniformName: string, array: number[]): Effect;
  30553. /**
  30554. * Sets matrices on a uniform variable.
  30555. * @param uniformName Name of the variable.
  30556. * @param matrices matrices to be set.
  30557. * @returns this effect.
  30558. */
  30559. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30560. /**
  30561. * Sets matrix on a uniform variable.
  30562. * @param uniformName Name of the variable.
  30563. * @param matrix matrix to be set.
  30564. * @returns this effect.
  30565. */
  30566. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30567. /**
  30568. * 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)
  30569. * @param uniformName Name of the variable.
  30570. * @param matrix matrix to be set.
  30571. * @returns this effect.
  30572. */
  30573. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30574. /**
  30575. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30576. * @param uniformName Name of the variable.
  30577. * @param matrix matrix to be set.
  30578. * @returns this effect.
  30579. */
  30580. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30581. /**
  30582. * Sets a float on a uniform variable.
  30583. * @param uniformName Name of the variable.
  30584. * @param value value to be set.
  30585. * @returns this effect.
  30586. */
  30587. setFloat(uniformName: string, value: number): Effect;
  30588. /**
  30589. * Sets a boolean on a uniform variable.
  30590. * @param uniformName Name of the variable.
  30591. * @param bool value to be set.
  30592. * @returns this effect.
  30593. */
  30594. setBool(uniformName: string, bool: boolean): Effect;
  30595. /**
  30596. * Sets a Vector2 on a uniform variable.
  30597. * @param uniformName Name of the variable.
  30598. * @param vector2 vector2 to be set.
  30599. * @returns this effect.
  30600. */
  30601. setVector2(uniformName: string, vector2: Vector2): Effect;
  30602. /**
  30603. * Sets a float2 on a uniform variable.
  30604. * @param uniformName Name of the variable.
  30605. * @param x First float in float2.
  30606. * @param y Second float in float2.
  30607. * @returns this effect.
  30608. */
  30609. setFloat2(uniformName: string, x: number, y: number): Effect;
  30610. /**
  30611. * Sets a Vector3 on a uniform variable.
  30612. * @param uniformName Name of the variable.
  30613. * @param vector3 Value to be set.
  30614. * @returns this effect.
  30615. */
  30616. setVector3(uniformName: string, vector3: Vector3): Effect;
  30617. /**
  30618. * Sets a float3 on a uniform variable.
  30619. * @param uniformName Name of the variable.
  30620. * @param x First float in float3.
  30621. * @param y Second float in float3.
  30622. * @param z Third float in float3.
  30623. * @returns this effect.
  30624. */
  30625. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30626. /**
  30627. * Sets a Vector4 on a uniform variable.
  30628. * @param uniformName Name of the variable.
  30629. * @param vector4 Value to be set.
  30630. * @returns this effect.
  30631. */
  30632. setVector4(uniformName: string, vector4: Vector4): Effect;
  30633. /**
  30634. * Sets a float4 on a uniform variable.
  30635. * @param uniformName Name of the variable.
  30636. * @param x First float in float4.
  30637. * @param y Second float in float4.
  30638. * @param z Third float in float4.
  30639. * @param w Fourth float in float4.
  30640. * @returns this effect.
  30641. */
  30642. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30643. /**
  30644. * Sets a Color3 on a uniform variable.
  30645. * @param uniformName Name of the variable.
  30646. * @param color3 Value to be set.
  30647. * @returns this effect.
  30648. */
  30649. setColor3(uniformName: string, color3: Color3): Effect;
  30650. /**
  30651. * Sets a Color4 on a uniform variable.
  30652. * @param uniformName Name of the variable.
  30653. * @param color3 Value to be set.
  30654. * @param alpha Alpha value to be set.
  30655. * @returns this effect.
  30656. */
  30657. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30658. /**
  30659. * Sets a Color4 on a uniform variable
  30660. * @param uniformName defines the name of the variable
  30661. * @param color4 defines the value to be set
  30662. * @returns this effect.
  30663. */
  30664. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30665. /** Release all associated resources */
  30666. dispose(): void;
  30667. /**
  30668. * This function will add a new shader to the shader store
  30669. * @param name the name of the shader
  30670. * @param pixelShader optional pixel shader content
  30671. * @param vertexShader optional vertex shader content
  30672. */
  30673. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30674. /**
  30675. * Store of each shader (The can be looked up using effect.key)
  30676. */
  30677. static ShadersStore: {
  30678. [key: string]: string;
  30679. };
  30680. /**
  30681. * Store of each included file for a shader (The can be looked up using effect.key)
  30682. */
  30683. static IncludesShadersStore: {
  30684. [key: string]: string;
  30685. };
  30686. /**
  30687. * Resets the cache of effects.
  30688. */
  30689. static ResetCache(): void;
  30690. }
  30691. }
  30692. declare module "babylonjs/Materials/colorCurves" {
  30693. import { Effect } from "babylonjs/Materials/effect";
  30694. /**
  30695. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30696. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30697. * 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;
  30698. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30699. */
  30700. export class ColorCurves {
  30701. private _dirty;
  30702. private _tempColor;
  30703. private _globalCurve;
  30704. private _highlightsCurve;
  30705. private _midtonesCurve;
  30706. private _shadowsCurve;
  30707. private _positiveCurve;
  30708. private _negativeCurve;
  30709. private _globalHue;
  30710. private _globalDensity;
  30711. private _globalSaturation;
  30712. private _globalExposure;
  30713. /**
  30714. * Gets the global Hue value.
  30715. * 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).
  30716. */
  30717. /**
  30718. * Sets the global Hue value.
  30719. * 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).
  30720. */
  30721. globalHue: number;
  30722. /**
  30723. * Gets the global Density value.
  30724. * 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.
  30725. * Values less than zero provide a filter of opposite hue.
  30726. */
  30727. /**
  30728. * Sets the global Density value.
  30729. * 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.
  30730. * Values less than zero provide a filter of opposite hue.
  30731. */
  30732. globalDensity: number;
  30733. /**
  30734. * Gets the global Saturation value.
  30735. * 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.
  30736. */
  30737. /**
  30738. * Sets the global Saturation value.
  30739. * 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.
  30740. */
  30741. globalSaturation: number;
  30742. /**
  30743. * Gets the global Exposure value.
  30744. * 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.
  30745. */
  30746. /**
  30747. * Sets the global Exposure value.
  30748. * 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.
  30749. */
  30750. globalExposure: number;
  30751. private _highlightsHue;
  30752. private _highlightsDensity;
  30753. private _highlightsSaturation;
  30754. private _highlightsExposure;
  30755. /**
  30756. * Gets the highlights Hue value.
  30757. * 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).
  30758. */
  30759. /**
  30760. * Sets the highlights Hue value.
  30761. * 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).
  30762. */
  30763. highlightsHue: number;
  30764. /**
  30765. * Gets the highlights Density value.
  30766. * 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.
  30767. * Values less than zero provide a filter of opposite hue.
  30768. */
  30769. /**
  30770. * Sets the highlights Density value.
  30771. * 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.
  30772. * Values less than zero provide a filter of opposite hue.
  30773. */
  30774. highlightsDensity: number;
  30775. /**
  30776. * Gets the highlights Saturation value.
  30777. * 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.
  30778. */
  30779. /**
  30780. * Sets the highlights Saturation value.
  30781. * 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.
  30782. */
  30783. highlightsSaturation: number;
  30784. /**
  30785. * Gets the highlights Exposure value.
  30786. * 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.
  30787. */
  30788. /**
  30789. * Sets the highlights Exposure value.
  30790. * 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.
  30791. */
  30792. highlightsExposure: number;
  30793. private _midtonesHue;
  30794. private _midtonesDensity;
  30795. private _midtonesSaturation;
  30796. private _midtonesExposure;
  30797. /**
  30798. * Gets the midtones Hue value.
  30799. * 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).
  30800. */
  30801. /**
  30802. * Sets the midtones Hue value.
  30803. * 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).
  30804. */
  30805. midtonesHue: number;
  30806. /**
  30807. * Gets the midtones Density value.
  30808. * 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.
  30809. * Values less than zero provide a filter of opposite hue.
  30810. */
  30811. /**
  30812. * Sets the midtones Density value.
  30813. * 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.
  30814. * Values less than zero provide a filter of opposite hue.
  30815. */
  30816. midtonesDensity: number;
  30817. /**
  30818. * Gets the midtones Saturation value.
  30819. * 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.
  30820. */
  30821. /**
  30822. * Sets the midtones Saturation value.
  30823. * 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.
  30824. */
  30825. midtonesSaturation: number;
  30826. /**
  30827. * Gets the midtones Exposure value.
  30828. * 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.
  30829. */
  30830. /**
  30831. * Sets the midtones Exposure value.
  30832. * 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.
  30833. */
  30834. midtonesExposure: number;
  30835. private _shadowsHue;
  30836. private _shadowsDensity;
  30837. private _shadowsSaturation;
  30838. private _shadowsExposure;
  30839. /**
  30840. * Gets the shadows Hue value.
  30841. * 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).
  30842. */
  30843. /**
  30844. * Sets the shadows Hue value.
  30845. * 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).
  30846. */
  30847. shadowsHue: number;
  30848. /**
  30849. * Gets the shadows Density value.
  30850. * 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.
  30851. * Values less than zero provide a filter of opposite hue.
  30852. */
  30853. /**
  30854. * Sets the shadows Density value.
  30855. * 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.
  30856. * Values less than zero provide a filter of opposite hue.
  30857. */
  30858. shadowsDensity: number;
  30859. /**
  30860. * Gets the shadows Saturation value.
  30861. * 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.
  30862. */
  30863. /**
  30864. * Sets the shadows Saturation value.
  30865. * 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.
  30866. */
  30867. shadowsSaturation: number;
  30868. /**
  30869. * Gets the shadows Exposure value.
  30870. * 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.
  30871. */
  30872. /**
  30873. * Sets the shadows Exposure value.
  30874. * 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.
  30875. */
  30876. shadowsExposure: number;
  30877. /**
  30878. * Returns the class name
  30879. * @returns The class name
  30880. */
  30881. getClassName(): string;
  30882. /**
  30883. * Binds the color curves to the shader.
  30884. * @param colorCurves The color curve to bind
  30885. * @param effect The effect to bind to
  30886. * @param positiveUniform The positive uniform shader parameter
  30887. * @param neutralUniform The neutral uniform shader parameter
  30888. * @param negativeUniform The negative uniform shader parameter
  30889. */
  30890. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30891. /**
  30892. * Prepare the list of uniforms associated with the ColorCurves effects.
  30893. * @param uniformsList The list of uniforms used in the effect
  30894. */
  30895. static PrepareUniforms(uniformsList: string[]): void;
  30896. /**
  30897. * Returns color grading data based on a hue, density, saturation and exposure value.
  30898. * @param filterHue The hue of the color filter.
  30899. * @param filterDensity The density of the color filter.
  30900. * @param saturation The saturation.
  30901. * @param exposure The exposure.
  30902. * @param result The result data container.
  30903. */
  30904. private getColorGradingDataToRef;
  30905. /**
  30906. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30907. * @param value The input slider value in range [-100,100].
  30908. * @returns Adjusted value.
  30909. */
  30910. private static applyColorGradingSliderNonlinear;
  30911. /**
  30912. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30913. * @param hue The hue (H) input.
  30914. * @param saturation The saturation (S) input.
  30915. * @param brightness The brightness (B) input.
  30916. * @result An RGBA color represented as Vector4.
  30917. */
  30918. private static fromHSBToRef;
  30919. /**
  30920. * Returns a value clamped between min and max
  30921. * @param value The value to clamp
  30922. * @param min The minimum of value
  30923. * @param max The maximum of value
  30924. * @returns The clamped value.
  30925. */
  30926. private static clamp;
  30927. /**
  30928. * Clones the current color curve instance.
  30929. * @return The cloned curves
  30930. */
  30931. clone(): ColorCurves;
  30932. /**
  30933. * Serializes the current color curve instance to a json representation.
  30934. * @return a JSON representation
  30935. */
  30936. serialize(): any;
  30937. /**
  30938. * Parses the color curve from a json representation.
  30939. * @param source the JSON source to parse
  30940. * @return The parsed curves
  30941. */
  30942. static Parse(source: any): ColorCurves;
  30943. }
  30944. }
  30945. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30946. import { Observable } from "babylonjs/Misc/observable";
  30947. import { Nullable } from "babylonjs/types";
  30948. import { Color4 } from "babylonjs/Maths/math";
  30949. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30950. import { Effect } from "babylonjs/Materials/effect";
  30951. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30952. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30953. /**
  30954. * Interface to follow in your material defines to integrate easily the
  30955. * Image proccessing functions.
  30956. * @hidden
  30957. */
  30958. export interface IImageProcessingConfigurationDefines {
  30959. IMAGEPROCESSING: boolean;
  30960. VIGNETTE: boolean;
  30961. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30962. VIGNETTEBLENDMODEOPAQUE: boolean;
  30963. TONEMAPPING: boolean;
  30964. TONEMAPPING_ACES: boolean;
  30965. CONTRAST: boolean;
  30966. EXPOSURE: boolean;
  30967. COLORCURVES: boolean;
  30968. COLORGRADING: boolean;
  30969. COLORGRADING3D: boolean;
  30970. SAMPLER3DGREENDEPTH: boolean;
  30971. SAMPLER3DBGRMAP: boolean;
  30972. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30973. }
  30974. /**
  30975. * @hidden
  30976. */
  30977. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30978. IMAGEPROCESSING: boolean;
  30979. VIGNETTE: boolean;
  30980. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30981. VIGNETTEBLENDMODEOPAQUE: boolean;
  30982. TONEMAPPING: boolean;
  30983. TONEMAPPING_ACES: boolean;
  30984. CONTRAST: boolean;
  30985. COLORCURVES: boolean;
  30986. COLORGRADING: boolean;
  30987. COLORGRADING3D: boolean;
  30988. SAMPLER3DGREENDEPTH: boolean;
  30989. SAMPLER3DBGRMAP: boolean;
  30990. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30991. EXPOSURE: boolean;
  30992. constructor();
  30993. }
  30994. /**
  30995. * This groups together the common properties used for image processing either in direct forward pass
  30996. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30997. * or not.
  30998. */
  30999. export class ImageProcessingConfiguration {
  31000. /**
  31001. * Default tone mapping applied in BabylonJS.
  31002. */
  31003. static readonly TONEMAPPING_STANDARD: number;
  31004. /**
  31005. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  31006. * to other engines rendering to increase portability.
  31007. */
  31008. static readonly TONEMAPPING_ACES: number;
  31009. /**
  31010. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  31011. */
  31012. colorCurves: Nullable<ColorCurves>;
  31013. private _colorCurvesEnabled;
  31014. /**
  31015. * Gets wether the color curves effect is enabled.
  31016. */
  31017. /**
  31018. * Sets wether the color curves effect is enabled.
  31019. */
  31020. colorCurvesEnabled: boolean;
  31021. private _colorGradingTexture;
  31022. /**
  31023. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  31024. */
  31025. /**
  31026. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  31027. */
  31028. colorGradingTexture: Nullable<BaseTexture>;
  31029. private _colorGradingEnabled;
  31030. /**
  31031. * Gets wether the color grading effect is enabled.
  31032. */
  31033. /**
  31034. * Sets wether the color grading effect is enabled.
  31035. */
  31036. colorGradingEnabled: boolean;
  31037. private _colorGradingWithGreenDepth;
  31038. /**
  31039. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  31040. */
  31041. /**
  31042. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  31043. */
  31044. colorGradingWithGreenDepth: boolean;
  31045. private _colorGradingBGR;
  31046. /**
  31047. * Gets wether the color grading texture contains BGR values.
  31048. */
  31049. /**
  31050. * Sets wether the color grading texture contains BGR values.
  31051. */
  31052. colorGradingBGR: boolean;
  31053. /** @hidden */
  31054. _exposure: number;
  31055. /**
  31056. * Gets the Exposure used in the effect.
  31057. */
  31058. /**
  31059. * Sets the Exposure used in the effect.
  31060. */
  31061. exposure: number;
  31062. private _toneMappingEnabled;
  31063. /**
  31064. * Gets wether the tone mapping effect is enabled.
  31065. */
  31066. /**
  31067. * Sets wether the tone mapping effect is enabled.
  31068. */
  31069. toneMappingEnabled: boolean;
  31070. private _toneMappingType;
  31071. /**
  31072. * Gets the type of tone mapping effect.
  31073. */
  31074. /**
  31075. * Sets the type of tone mapping effect used in BabylonJS.
  31076. */
  31077. toneMappingType: number;
  31078. protected _contrast: number;
  31079. /**
  31080. * Gets the contrast used in the effect.
  31081. */
  31082. /**
  31083. * Sets the contrast used in the effect.
  31084. */
  31085. contrast: number;
  31086. /**
  31087. * Vignette stretch size.
  31088. */
  31089. vignetteStretch: number;
  31090. /**
  31091. * Vignette centre X Offset.
  31092. */
  31093. vignetteCentreX: number;
  31094. /**
  31095. * Vignette centre Y Offset.
  31096. */
  31097. vignetteCentreY: number;
  31098. /**
  31099. * Vignette weight or intensity of the vignette effect.
  31100. */
  31101. vignetteWeight: number;
  31102. /**
  31103. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  31104. * if vignetteEnabled is set to true.
  31105. */
  31106. vignetteColor: Color4;
  31107. /**
  31108. * Camera field of view used by the Vignette effect.
  31109. */
  31110. vignetteCameraFov: number;
  31111. private _vignetteBlendMode;
  31112. /**
  31113. * Gets the vignette blend mode allowing different kind of effect.
  31114. */
  31115. /**
  31116. * Sets the vignette blend mode allowing different kind of effect.
  31117. */
  31118. vignetteBlendMode: number;
  31119. private _vignetteEnabled;
  31120. /**
  31121. * Gets wether the vignette effect is enabled.
  31122. */
  31123. /**
  31124. * Sets wether the vignette effect is enabled.
  31125. */
  31126. vignetteEnabled: boolean;
  31127. private _applyByPostProcess;
  31128. /**
  31129. * Gets wether the image processing is applied through a post process or not.
  31130. */
  31131. /**
  31132. * Sets wether the image processing is applied through a post process or not.
  31133. */
  31134. applyByPostProcess: boolean;
  31135. private _isEnabled;
  31136. /**
  31137. * Gets wether the image processing is enabled or not.
  31138. */
  31139. /**
  31140. * Sets wether the image processing is enabled or not.
  31141. */
  31142. isEnabled: boolean;
  31143. /**
  31144. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  31145. */
  31146. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  31147. /**
  31148. * Method called each time the image processing information changes requires to recompile the effect.
  31149. */
  31150. protected _updateParameters(): void;
  31151. /**
  31152. * Gets the current class name.
  31153. * @return "ImageProcessingConfiguration"
  31154. */
  31155. getClassName(): string;
  31156. /**
  31157. * Prepare the list of uniforms associated with the Image Processing effects.
  31158. * @param uniforms The list of uniforms used in the effect
  31159. * @param defines the list of defines currently in use
  31160. */
  31161. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31162. /**
  31163. * Prepare the list of samplers associated with the Image Processing effects.
  31164. * @param samplersList The list of uniforms used in the effect
  31165. * @param defines the list of defines currently in use
  31166. */
  31167. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31168. /**
  31169. * Prepare the list of defines associated to the shader.
  31170. * @param defines the list of defines to complete
  31171. * @param forPostProcess Define if we are currently in post process mode or not
  31172. */
  31173. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31174. /**
  31175. * Returns true if all the image processing information are ready.
  31176. * @returns True if ready, otherwise, false
  31177. */
  31178. isReady(): boolean;
  31179. /**
  31180. * Binds the image processing to the shader.
  31181. * @param effect The effect to bind to
  31182. * @param aspectRatio Define the current aspect ratio of the effect
  31183. */
  31184. bind(effect: Effect, aspectRatio?: number): void;
  31185. /**
  31186. * Clones the current image processing instance.
  31187. * @return The cloned image processing
  31188. */
  31189. clone(): ImageProcessingConfiguration;
  31190. /**
  31191. * Serializes the current image processing instance to a json representation.
  31192. * @return a JSON representation
  31193. */
  31194. serialize(): any;
  31195. /**
  31196. * Parses the image processing from a json representation.
  31197. * @param source the JSON source to parse
  31198. * @return The parsed image processing
  31199. */
  31200. static Parse(source: any): ImageProcessingConfiguration;
  31201. private static _VIGNETTEMODE_MULTIPLY;
  31202. private static _VIGNETTEMODE_OPAQUE;
  31203. /**
  31204. * Used to apply the vignette as a mix with the pixel color.
  31205. */
  31206. static readonly VIGNETTEMODE_MULTIPLY: number;
  31207. /**
  31208. * Used to apply the vignette as a replacement of the pixel color.
  31209. */
  31210. static readonly VIGNETTEMODE_OPAQUE: number;
  31211. }
  31212. }
  31213. declare module "babylonjs/Materials/fresnelParameters" {
  31214. import { Color3 } from "babylonjs/Maths/math";
  31215. /**
  31216. * This represents all the required information to add a fresnel effect on a material:
  31217. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31218. */
  31219. export class FresnelParameters {
  31220. private _isEnabled;
  31221. /**
  31222. * Define if the fresnel effect is enable or not.
  31223. */
  31224. isEnabled: boolean;
  31225. /**
  31226. * Define the color used on edges (grazing angle)
  31227. */
  31228. leftColor: Color3;
  31229. /**
  31230. * Define the color used on center
  31231. */
  31232. rightColor: Color3;
  31233. /**
  31234. * Define bias applied to computed fresnel term
  31235. */
  31236. bias: number;
  31237. /**
  31238. * Defined the power exponent applied to fresnel term
  31239. */
  31240. power: number;
  31241. /**
  31242. * Clones the current fresnel and its valuues
  31243. * @returns a clone fresnel configuration
  31244. */
  31245. clone(): FresnelParameters;
  31246. /**
  31247. * Serializes the current fresnel parameters to a JSON representation.
  31248. * @return the JSON serialization
  31249. */
  31250. serialize(): any;
  31251. /**
  31252. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31253. * @param parsedFresnelParameters Define the JSON representation
  31254. * @returns the parsed parameters
  31255. */
  31256. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31257. }
  31258. }
  31259. declare module "babylonjs/Misc/decorators" {
  31260. import { Nullable } from "babylonjs/types";
  31261. import { Scene } from "babylonjs/scene";
  31262. import { IAnimatable } from "babylonjs/Misc/tools";
  31263. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31264. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31265. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31266. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31267. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31268. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31269. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31270. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31271. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31272. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31273. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31274. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31275. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31276. /**
  31277. * Decorator used to define property that can be serialized as reference to a camera
  31278. * @param sourceName defines the name of the property to decorate
  31279. */
  31280. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31281. /**
  31282. * Class used to help serialization objects
  31283. */
  31284. export class SerializationHelper {
  31285. /** @hidden */
  31286. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31287. /** @hidden */
  31288. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31289. /** @hidden */
  31290. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31291. /** @hidden */
  31292. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31293. /**
  31294. * Appends the serialized animations from the source animations
  31295. * @param source Source containing the animations
  31296. * @param destination Target to store the animations
  31297. */
  31298. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31299. /**
  31300. * Static function used to serialized a specific entity
  31301. * @param entity defines the entity to serialize
  31302. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31303. * @returns a JSON compatible object representing the serialization of the entity
  31304. */
  31305. static Serialize<T>(entity: T, serializationObject?: any): any;
  31306. /**
  31307. * Creates a new entity from a serialization data object
  31308. * @param creationFunction defines a function used to instanciated the new entity
  31309. * @param source defines the source serialization data
  31310. * @param scene defines the hosting scene
  31311. * @param rootUrl defines the root url for resources
  31312. * @returns a new entity
  31313. */
  31314. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31315. /**
  31316. * Clones an object
  31317. * @param creationFunction defines the function used to instanciate the new object
  31318. * @param source defines the source object
  31319. * @returns the cloned object
  31320. */
  31321. static Clone<T>(creationFunction: () => T, source: T): T;
  31322. /**
  31323. * Instanciates a new object based on a source one (some data will be shared between both object)
  31324. * @param creationFunction defines the function used to instanciate the new object
  31325. * @param source defines the source object
  31326. * @returns the new object
  31327. */
  31328. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31329. }
  31330. }
  31331. declare module "babylonjs/Cameras/camera" {
  31332. import { SmartArray } from "babylonjs/Misc/smartArray";
  31333. import { Observable } from "babylonjs/Misc/observable";
  31334. import { Nullable } from "babylonjs/types";
  31335. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31336. import { Scene } from "babylonjs/scene";
  31337. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31338. import { Node } from "babylonjs/node";
  31339. import { Mesh } from "babylonjs/Meshes/mesh";
  31340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31341. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31342. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31343. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31344. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31345. import { Ray } from "babylonjs/Culling/ray";
  31346. /**
  31347. * This is the base class of all the camera used in the application.
  31348. * @see http://doc.babylonjs.com/features/cameras
  31349. */
  31350. export class Camera extends Node {
  31351. /** @hidden */
  31352. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31353. /**
  31354. * This is the default projection mode used by the cameras.
  31355. * It helps recreating a feeling of perspective and better appreciate depth.
  31356. * This is the best way to simulate real life cameras.
  31357. */
  31358. static readonly PERSPECTIVE_CAMERA: number;
  31359. /**
  31360. * This helps creating camera with an orthographic mode.
  31361. * 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.
  31362. */
  31363. static readonly ORTHOGRAPHIC_CAMERA: number;
  31364. /**
  31365. * This is the default FOV mode for perspective cameras.
  31366. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31367. */
  31368. static readonly FOVMODE_VERTICAL_FIXED: number;
  31369. /**
  31370. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31371. */
  31372. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31373. /**
  31374. * This specifies ther is no need for a camera rig.
  31375. * Basically only one eye is rendered corresponding to the camera.
  31376. */
  31377. static readonly RIG_MODE_NONE: number;
  31378. /**
  31379. * Simulates a camera Rig with one blue eye and one red eye.
  31380. * This can be use with 3d blue and red glasses.
  31381. */
  31382. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31383. /**
  31384. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31385. */
  31386. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31387. /**
  31388. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31389. */
  31390. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31391. /**
  31392. * Defines that both eyes of the camera will be rendered over under each other.
  31393. */
  31394. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31395. /**
  31396. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31397. */
  31398. static readonly RIG_MODE_VR: number;
  31399. /**
  31400. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31401. */
  31402. static readonly RIG_MODE_WEBVR: number;
  31403. /**
  31404. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31405. */
  31406. static readonly RIG_MODE_CUSTOM: number;
  31407. /**
  31408. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31409. */
  31410. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31411. /**
  31412. * Define the input manager associated with the camera.
  31413. */
  31414. inputs: CameraInputsManager<Camera>;
  31415. /** @hidden */
  31416. _position: Vector3;
  31417. /**
  31418. * Define the current local position of the camera in the scene
  31419. */
  31420. position: Vector3;
  31421. /**
  31422. * The vector the camera should consider as up.
  31423. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31424. */
  31425. upVector: Vector3;
  31426. /**
  31427. * Define the current limit on the left side for an orthographic camera
  31428. * In scene unit
  31429. */
  31430. orthoLeft: Nullable<number>;
  31431. /**
  31432. * Define the current limit on the right side for an orthographic camera
  31433. * In scene unit
  31434. */
  31435. orthoRight: Nullable<number>;
  31436. /**
  31437. * Define the current limit on the bottom side for an orthographic camera
  31438. * In scene unit
  31439. */
  31440. orthoBottom: Nullable<number>;
  31441. /**
  31442. * Define the current limit on the top side for an orthographic camera
  31443. * In scene unit
  31444. */
  31445. orthoTop: Nullable<number>;
  31446. /**
  31447. * Field Of View is set in Radians. (default is 0.8)
  31448. */
  31449. fov: number;
  31450. /**
  31451. * Define the minimum distance the camera can see from.
  31452. * This is important to note that the depth buffer are not infinite and the closer it starts
  31453. * the more your scene might encounter depth fighting issue.
  31454. */
  31455. minZ: number;
  31456. /**
  31457. * Define the maximum distance the camera can see to.
  31458. * This is important to note that the depth buffer are not infinite and the further it end
  31459. * the more your scene might encounter depth fighting issue.
  31460. */
  31461. maxZ: number;
  31462. /**
  31463. * Define the default inertia of the camera.
  31464. * This helps giving a smooth feeling to the camera movement.
  31465. */
  31466. inertia: number;
  31467. /**
  31468. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  31469. */
  31470. mode: number;
  31471. /**
  31472. * Define wether the camera is intermediate.
  31473. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31474. */
  31475. isIntermediate: boolean;
  31476. /**
  31477. * Define the viewport of the camera.
  31478. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31479. */
  31480. viewport: Viewport;
  31481. /**
  31482. * Restricts the camera to viewing objects with the same layerMask.
  31483. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31484. */
  31485. layerMask: number;
  31486. /**
  31487. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31488. */
  31489. fovMode: number;
  31490. /**
  31491. * Rig mode of the camera.
  31492. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31493. * This is normally controlled byt the camera themselves as internal use.
  31494. */
  31495. cameraRigMode: number;
  31496. /**
  31497. * Defines the distance between both "eyes" in case of a RIG
  31498. */
  31499. interaxialDistance: number;
  31500. /**
  31501. * Defines if stereoscopic rendering is done side by side or over under.
  31502. */
  31503. isStereoscopicSideBySide: boolean;
  31504. /**
  31505. * 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
  31506. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31507. * else in the scene.
  31508. */
  31509. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31510. /**
  31511. * When set, the camera will render to this render target instead of the default canvas
  31512. */
  31513. outputRenderTarget: Nullable<RenderTargetTexture>;
  31514. /**
  31515. * Observable triggered when the camera view matrix has changed.
  31516. */
  31517. onViewMatrixChangedObservable: Observable<Camera>;
  31518. /**
  31519. * Observable triggered when the camera Projection matrix has changed.
  31520. */
  31521. onProjectionMatrixChangedObservable: Observable<Camera>;
  31522. /**
  31523. * Observable triggered when the inputs have been processed.
  31524. */
  31525. onAfterCheckInputsObservable: Observable<Camera>;
  31526. /**
  31527. * Observable triggered when reset has been called and applied to the camera.
  31528. */
  31529. onRestoreStateObservable: Observable<Camera>;
  31530. /** @hidden */
  31531. _cameraRigParams: any;
  31532. /** @hidden */
  31533. _rigCameras: Camera[];
  31534. /** @hidden */
  31535. _rigPostProcess: Nullable<PostProcess>;
  31536. protected _webvrViewMatrix: Matrix;
  31537. /** @hidden */
  31538. _skipRendering: boolean;
  31539. /** @hidden */
  31540. _projectionMatrix: Matrix;
  31541. /** @hidden */
  31542. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31543. /** @hidden */
  31544. _activeMeshes: SmartArray<AbstractMesh>;
  31545. protected _globalPosition: Vector3;
  31546. /** @hidden */
  31547. _computedViewMatrix: Matrix;
  31548. private _doNotComputeProjectionMatrix;
  31549. private _transformMatrix;
  31550. private _frustumPlanes;
  31551. private _refreshFrustumPlanes;
  31552. private _storedFov;
  31553. private _stateStored;
  31554. /**
  31555. * Instantiates a new camera object.
  31556. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31557. * @see http://doc.babylonjs.com/features/cameras
  31558. * @param name Defines the name of the camera in the scene
  31559. * @param position Defines the position of the camera
  31560. * @param scene Defines the scene the camera belongs too
  31561. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31562. */
  31563. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31564. /**
  31565. * Store current camera state (fov, position, etc..)
  31566. * @returns the camera
  31567. */
  31568. storeState(): Camera;
  31569. /**
  31570. * Restores the camera state values if it has been stored. You must call storeState() first
  31571. */
  31572. protected _restoreStateValues(): boolean;
  31573. /**
  31574. * Restored camera state. You must call storeState() first.
  31575. * @returns true if restored and false otherwise
  31576. */
  31577. restoreState(): boolean;
  31578. /**
  31579. * Gets the class name of the camera.
  31580. * @returns the class name
  31581. */
  31582. getClassName(): string;
  31583. /** @hidden */
  31584. readonly _isCamera: boolean;
  31585. /**
  31586. * Gets a string representation of the camera useful for debug purpose.
  31587. * @param fullDetails Defines that a more verboe level of logging is required
  31588. * @returns the string representation
  31589. */
  31590. toString(fullDetails?: boolean): string;
  31591. /**
  31592. * Gets the current world space position of the camera.
  31593. */
  31594. readonly globalPosition: Vector3;
  31595. /**
  31596. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31597. * @returns the active meshe list
  31598. */
  31599. getActiveMeshes(): SmartArray<AbstractMesh>;
  31600. /**
  31601. * Check wether a mesh is part of the current active mesh list of the camera
  31602. * @param mesh Defines the mesh to check
  31603. * @returns true if active, false otherwise
  31604. */
  31605. isActiveMesh(mesh: Mesh): boolean;
  31606. /**
  31607. * Is this camera ready to be used/rendered
  31608. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31609. * @return true if the camera is ready
  31610. */
  31611. isReady(completeCheck?: boolean): boolean;
  31612. /** @hidden */
  31613. _initCache(): void;
  31614. /** @hidden */
  31615. _updateCache(ignoreParentClass?: boolean): void;
  31616. /** @hidden */
  31617. _isSynchronized(): boolean;
  31618. /** @hidden */
  31619. _isSynchronizedViewMatrix(): boolean;
  31620. /** @hidden */
  31621. _isSynchronizedProjectionMatrix(): boolean;
  31622. /**
  31623. * Attach the input controls to a specific dom element to get the input from.
  31624. * @param element Defines the element the controls should be listened from
  31625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31626. */
  31627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31628. /**
  31629. * Detach the current controls from the specified dom element.
  31630. * @param element Defines the element to stop listening the inputs from
  31631. */
  31632. detachControl(element: HTMLElement): void;
  31633. /**
  31634. * Update the camera state according to the different inputs gathered during the frame.
  31635. */
  31636. update(): void;
  31637. /** @hidden */
  31638. _checkInputs(): void;
  31639. /** @hidden */
  31640. readonly rigCameras: Camera[];
  31641. /**
  31642. * Gets the post process used by the rig cameras
  31643. */
  31644. readonly rigPostProcess: Nullable<PostProcess>;
  31645. /**
  31646. * Internal, gets the first post proces.
  31647. * @returns the first post process to be run on this camera.
  31648. */
  31649. _getFirstPostProcess(): Nullable<PostProcess>;
  31650. private _cascadePostProcessesToRigCams;
  31651. /**
  31652. * Attach a post process to the camera.
  31653. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31654. * @param postProcess The post process to attach to the camera
  31655. * @param insertAt The position of the post process in case several of them are in use in the scene
  31656. * @returns the position the post process has been inserted at
  31657. */
  31658. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31659. /**
  31660. * Detach a post process to the camera.
  31661. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31662. * @param postProcess The post process to detach from the camera
  31663. */
  31664. detachPostProcess(postProcess: PostProcess): void;
  31665. /**
  31666. * Gets the current world matrix of the camera
  31667. */
  31668. getWorldMatrix(): Matrix;
  31669. /** @hidden */
  31670. _getViewMatrix(): Matrix;
  31671. /**
  31672. * Gets the current view matrix of the camera.
  31673. * @param force forces the camera to recompute the matrix without looking at the cached state
  31674. * @returns the view matrix
  31675. */
  31676. getViewMatrix(force?: boolean): Matrix;
  31677. /**
  31678. * Freeze the projection matrix.
  31679. * It will prevent the cache check of the camera projection compute and can speed up perf
  31680. * if no parameter of the camera are meant to change
  31681. * @param projection Defines manually a projection if necessary
  31682. */
  31683. freezeProjectionMatrix(projection?: Matrix): void;
  31684. /**
  31685. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31686. */
  31687. unfreezeProjectionMatrix(): void;
  31688. /**
  31689. * Gets the current projection matrix of the camera.
  31690. * @param force forces the camera to recompute the matrix without looking at the cached state
  31691. * @returns the projection matrix
  31692. */
  31693. getProjectionMatrix(force?: boolean): Matrix;
  31694. /**
  31695. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31696. * @returns a Matrix
  31697. */
  31698. getTransformationMatrix(): Matrix;
  31699. private _updateFrustumPlanes;
  31700. /**
  31701. * Checks if a cullable object (mesh...) is in the camera frustum
  31702. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31703. * @param target The object to check
  31704. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31705. * @returns true if the object is in frustum otherwise false
  31706. */
  31707. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31708. /**
  31709. * Checks if a cullable object (mesh...) is in the camera frustum
  31710. * Unlike isInFrustum this cheks the full bounding box
  31711. * @param target The object to check
  31712. * @returns true if the object is in frustum otherwise false
  31713. */
  31714. isCompletelyInFrustum(target: ICullable): boolean;
  31715. /**
  31716. * Gets a ray in the forward direction from the camera.
  31717. * @param length Defines the length of the ray to create
  31718. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31719. * @param origin Defines the start point of the ray which defaults to the camera position
  31720. * @returns the forward ray
  31721. */
  31722. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31723. /**
  31724. * Releases resources associated with this node.
  31725. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31726. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31727. */
  31728. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31729. /** @hidden */
  31730. _isLeftCamera: boolean;
  31731. /**
  31732. * Gets the left camera of a rig setup in case of Rigged Camera
  31733. */
  31734. readonly isLeftCamera: boolean;
  31735. /** @hidden */
  31736. _isRightCamera: boolean;
  31737. /**
  31738. * Gets the right camera of a rig setup in case of Rigged Camera
  31739. */
  31740. readonly isRightCamera: boolean;
  31741. /**
  31742. * Gets the left camera of a rig setup in case of Rigged Camera
  31743. */
  31744. readonly leftCamera: Nullable<FreeCamera>;
  31745. /**
  31746. * Gets the right camera of a rig setup in case of Rigged Camera
  31747. */
  31748. readonly rightCamera: Nullable<FreeCamera>;
  31749. /**
  31750. * Gets the left camera target of a rig setup in case of Rigged Camera
  31751. * @returns the target position
  31752. */
  31753. getLeftTarget(): Nullable<Vector3>;
  31754. /**
  31755. * Gets the right camera target of a rig setup in case of Rigged Camera
  31756. * @returns the target position
  31757. */
  31758. getRightTarget(): Nullable<Vector3>;
  31759. /**
  31760. * @hidden
  31761. */
  31762. setCameraRigMode(mode: number, rigParams: any): void;
  31763. /** @hidden */
  31764. static _setStereoscopicRigMode(camera: Camera): void;
  31765. /** @hidden */
  31766. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31767. /** @hidden */
  31768. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31769. /** @hidden */
  31770. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31771. /** @hidden */
  31772. _getVRProjectionMatrix(): Matrix;
  31773. protected _updateCameraRotationMatrix(): void;
  31774. protected _updateWebVRCameraRotationMatrix(): void;
  31775. /**
  31776. * This function MUST be overwritten by the different WebVR cameras available.
  31777. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31778. * @hidden
  31779. */
  31780. _getWebVRProjectionMatrix(): Matrix;
  31781. /**
  31782. * This function MUST be overwritten by the different WebVR cameras available.
  31783. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31784. * @hidden
  31785. */
  31786. _getWebVRViewMatrix(): Matrix;
  31787. /** @hidden */
  31788. setCameraRigParameter(name: string, value: any): void;
  31789. /**
  31790. * needs to be overridden by children so sub has required properties to be copied
  31791. * @hidden
  31792. */
  31793. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31794. /**
  31795. * May need to be overridden by children
  31796. * @hidden
  31797. */
  31798. _updateRigCameras(): void;
  31799. /** @hidden */
  31800. _setupInputs(): void;
  31801. /**
  31802. * Serialiaze the camera setup to a json represention
  31803. * @returns the JSON representation
  31804. */
  31805. serialize(): any;
  31806. /**
  31807. * Clones the current camera.
  31808. * @param name The cloned camera name
  31809. * @returns the cloned camera
  31810. */
  31811. clone(name: string): Camera;
  31812. /**
  31813. * Gets the direction of the camera relative to a given local axis.
  31814. * @param localAxis Defines the reference axis to provide a relative direction.
  31815. * @return the direction
  31816. */
  31817. getDirection(localAxis: Vector3): Vector3;
  31818. /**
  31819. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31820. * @param localAxis Defines the reference axis to provide a relative direction.
  31821. * @param result Defines the vector to store the result in
  31822. */
  31823. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31824. /**
  31825. * Gets a camera constructor for a given camera type
  31826. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31827. * @param name The name of the camera the result will be able to instantiate
  31828. * @param scene The scene the result will construct the camera in
  31829. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31830. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31831. * @returns a factory method to construc the camera
  31832. */
  31833. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31834. /**
  31835. * Compute the world matrix of the camera.
  31836. * @returns the camera workd matrix
  31837. */
  31838. computeWorldMatrix(): Matrix;
  31839. /**
  31840. * Parse a JSON and creates the camera from the parsed information
  31841. * @param parsedCamera The JSON to parse
  31842. * @param scene The scene to instantiate the camera in
  31843. * @returns the newly constructed camera
  31844. */
  31845. static Parse(parsedCamera: any, scene: Scene): Camera;
  31846. }
  31847. }
  31848. declare module "babylonjs/Misc/tools" {
  31849. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31850. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31851. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31852. import { Observable } from "babylonjs/Misc/observable";
  31853. import { DomManagement } from "babylonjs/Misc/domManagement";
  31854. import { WebRequest } from "babylonjs/Misc/webRequest";
  31855. import { Camera } from "babylonjs/Cameras/camera";
  31856. import { Engine } from "babylonjs/Engines/engine";
  31857. import { Animation } from "babylonjs/Animations/animation";
  31858. /**
  31859. * Interface for any object that can request an animation frame
  31860. */
  31861. export interface ICustomAnimationFrameRequester {
  31862. /**
  31863. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31864. */
  31865. renderFunction?: Function;
  31866. /**
  31867. * Called to request the next frame to render to
  31868. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31869. */
  31870. requestAnimationFrame: Function;
  31871. /**
  31872. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31873. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31874. */
  31875. requestID?: number;
  31876. }
  31877. /**
  31878. * Interface containing an array of animations
  31879. */
  31880. export interface IAnimatable {
  31881. /**
  31882. * Array of animations
  31883. */
  31884. animations: Nullable<Array<Animation>>;
  31885. }
  31886. /** Interface used by value gradients (color, factor, ...) */
  31887. export interface IValueGradient {
  31888. /**
  31889. * Gets or sets the gradient value (between 0 and 1)
  31890. */
  31891. gradient: number;
  31892. }
  31893. /** Class used to store color4 gradient */
  31894. export class ColorGradient implements IValueGradient {
  31895. /**
  31896. * Gets or sets the gradient value (between 0 and 1)
  31897. */
  31898. gradient: number;
  31899. /**
  31900. * Gets or sets first associated color
  31901. */
  31902. color1: Color4;
  31903. /**
  31904. * Gets or sets second associated color
  31905. */
  31906. color2?: Color4;
  31907. /**
  31908. * Will get a color picked randomly between color1 and color2.
  31909. * If color2 is undefined then color1 will be used
  31910. * @param result defines the target Color4 to store the result in
  31911. */
  31912. getColorToRef(result: Color4): void;
  31913. }
  31914. /** Class used to store color 3 gradient */
  31915. export class Color3Gradient implements IValueGradient {
  31916. /**
  31917. * Gets or sets the gradient value (between 0 and 1)
  31918. */
  31919. gradient: number;
  31920. /**
  31921. * Gets or sets the associated color
  31922. */
  31923. color: Color3;
  31924. }
  31925. /** Class used to store factor gradient */
  31926. export class FactorGradient implements IValueGradient {
  31927. /**
  31928. * Gets or sets the gradient value (between 0 and 1)
  31929. */
  31930. gradient: number;
  31931. /**
  31932. * Gets or sets first associated factor
  31933. */
  31934. factor1: number;
  31935. /**
  31936. * Gets or sets second associated factor
  31937. */
  31938. factor2?: number;
  31939. /**
  31940. * Will get a number picked randomly between factor1 and factor2.
  31941. * If factor2 is undefined then factor1 will be used
  31942. * @returns the picked number
  31943. */
  31944. getFactor(): number;
  31945. }
  31946. /**
  31947. * @ignore
  31948. * Application error to support additional information when loading a file
  31949. */
  31950. export class LoadFileError extends Error {
  31951. /** defines the optional web request */
  31952. request?: WebRequest | undefined;
  31953. private static _setPrototypeOf;
  31954. /**
  31955. * Creates a new LoadFileError
  31956. * @param message defines the message of the error
  31957. * @param request defines the optional web request
  31958. */
  31959. constructor(message: string,
  31960. /** defines the optional web request */
  31961. request?: WebRequest | undefined);
  31962. }
  31963. /**
  31964. * Class used to define a retry strategy when error happens while loading assets
  31965. */
  31966. export class RetryStrategy {
  31967. /**
  31968. * Function used to defines an exponential back off strategy
  31969. * @param maxRetries defines the maximum number of retries (3 by default)
  31970. * @param baseInterval defines the interval between retries
  31971. * @returns the strategy function to use
  31972. */
  31973. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31974. }
  31975. /**
  31976. * File request interface
  31977. */
  31978. export interface IFileRequest {
  31979. /**
  31980. * Raised when the request is complete (success or error).
  31981. */
  31982. onCompleteObservable: Observable<IFileRequest>;
  31983. /**
  31984. * Aborts the request for a file.
  31985. */
  31986. abort: () => void;
  31987. }
  31988. /**
  31989. * Class containing a set of static utilities functions
  31990. */
  31991. export class Tools {
  31992. /**
  31993. * Gets or sets the base URL to use to load assets
  31994. */
  31995. static BaseUrl: string;
  31996. /**
  31997. * Enable/Disable Custom HTTP Request Headers globally.
  31998. * default = false
  31999. * @see CustomRequestHeaders
  32000. */
  32001. static UseCustomRequestHeaders: boolean;
  32002. /**
  32003. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32004. * i.e. when loading files, where the server/service expects an Authorization header
  32005. */
  32006. static CustomRequestHeaders: {
  32007. [key: string]: string;
  32008. };
  32009. /**
  32010. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32011. */
  32012. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32013. /**
  32014. * Default behaviour for cors in the application.
  32015. * It can be a string if the expected behavior is identical in the entire app.
  32016. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32017. */
  32018. static CorsBehavior: string | ((url: string | string[]) => string);
  32019. /**
  32020. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32021. * @ignorenaming
  32022. */
  32023. static UseFallbackTexture: boolean;
  32024. /**
  32025. * Use this object to register external classes like custom textures or material
  32026. * to allow the laoders to instantiate them
  32027. */
  32028. static RegisteredExternalClasses: {
  32029. [key: string]: Object;
  32030. };
  32031. /**
  32032. * Texture content used if a texture cannot loaded
  32033. * @ignorenaming
  32034. */
  32035. static fallbackTexture: string;
  32036. /**
  32037. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32038. * @param u defines the coordinate on X axis
  32039. * @param v defines the coordinate on Y axis
  32040. * @param width defines the width of the source data
  32041. * @param height defines the height of the source data
  32042. * @param pixels defines the source byte array
  32043. * @param color defines the output color
  32044. */
  32045. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  32046. /**
  32047. * Interpolates between a and b via alpha
  32048. * @param a The lower value (returned when alpha = 0)
  32049. * @param b The upper value (returned when alpha = 1)
  32050. * @param alpha The interpolation-factor
  32051. * @return The mixed value
  32052. */
  32053. static Mix(a: number, b: number, alpha: number): number;
  32054. /**
  32055. * Tries to instantiate a new object from a given class name
  32056. * @param className defines the class name to instantiate
  32057. * @returns the new object or null if the system was not able to do the instantiation
  32058. */
  32059. static Instantiate(className: string): any;
  32060. /**
  32061. * Provides a slice function that will work even on IE
  32062. * @param data defines the array to slice
  32063. * @param start defines the start of the data (optional)
  32064. * @param end defines the end of the data (optional)
  32065. * @returns the new sliced array
  32066. */
  32067. static Slice<T>(data: T, start?: number, end?: number): T;
  32068. /**
  32069. * Polyfill for setImmediate
  32070. * @param action defines the action to execute after the current execution block
  32071. */
  32072. static SetImmediate(action: () => void): void;
  32073. /**
  32074. * Function indicating if a number is an exponent of 2
  32075. * @param value defines the value to test
  32076. * @returns true if the value is an exponent of 2
  32077. */
  32078. static IsExponentOfTwo(value: number): boolean;
  32079. private static _tmpFloatArray;
  32080. /**
  32081. * Returns the nearest 32-bit single precision float representation of a Number
  32082. * @param value A Number. If the parameter is of a different type, it will get converted
  32083. * to a number or to NaN if it cannot be converted
  32084. * @returns number
  32085. */
  32086. static FloatRound(value: number): number;
  32087. /**
  32088. * Find the next highest power of two.
  32089. * @param x Number to start search from.
  32090. * @return Next highest power of two.
  32091. */
  32092. static CeilingPOT(x: number): number;
  32093. /**
  32094. * Find the next lowest power of two.
  32095. * @param x Number to start search from.
  32096. * @return Next lowest power of two.
  32097. */
  32098. static FloorPOT(x: number): number;
  32099. /**
  32100. * Find the nearest power of two.
  32101. * @param x Number to start search from.
  32102. * @return Next nearest power of two.
  32103. */
  32104. static NearestPOT(x: number): number;
  32105. /**
  32106. * Get the closest exponent of two
  32107. * @param value defines the value to approximate
  32108. * @param max defines the maximum value to return
  32109. * @param mode defines how to define the closest value
  32110. * @returns closest exponent of two of the given value
  32111. */
  32112. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32113. /**
  32114. * Extracts the filename from a path
  32115. * @param path defines the path to use
  32116. * @returns the filename
  32117. */
  32118. static GetFilename(path: string): string;
  32119. /**
  32120. * Extracts the "folder" part of a path (everything before the filename).
  32121. * @param uri The URI to extract the info from
  32122. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32123. * @returns The "folder" part of the path
  32124. */
  32125. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32126. /**
  32127. * Extracts text content from a DOM element hierarchy
  32128. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32129. */
  32130. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32131. /**
  32132. * Convert an angle in radians to degrees
  32133. * @param angle defines the angle to convert
  32134. * @returns the angle in degrees
  32135. */
  32136. static ToDegrees(angle: number): number;
  32137. /**
  32138. * Convert an angle in degrees to radians
  32139. * @param angle defines the angle to convert
  32140. * @returns the angle in radians
  32141. */
  32142. static ToRadians(angle: number): number;
  32143. /**
  32144. * Encode a buffer to a base64 string
  32145. * @param buffer defines the buffer to encode
  32146. * @returns the encoded string
  32147. */
  32148. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32149. /**
  32150. * Extracts minimum and maximum values from a list of indexed positions
  32151. * @param positions defines the positions to use
  32152. * @param indices defines the indices to the positions
  32153. * @param indexStart defines the start index
  32154. * @param indexCount defines the end index
  32155. * @param bias defines bias value to add to the result
  32156. * @return minimum and maximum values
  32157. */
  32158. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32159. minimum: Vector3;
  32160. maximum: Vector3;
  32161. };
  32162. /**
  32163. * Extracts minimum and maximum values from a list of positions
  32164. * @param positions defines the positions to use
  32165. * @param start defines the start index in the positions array
  32166. * @param count defines the number of positions to handle
  32167. * @param bias defines bias value to add to the result
  32168. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32169. * @return minimum and maximum values
  32170. */
  32171. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32172. minimum: Vector3;
  32173. maximum: Vector3;
  32174. };
  32175. /**
  32176. * Returns an array if obj is not an array
  32177. * @param obj defines the object to evaluate as an array
  32178. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32179. * @returns either obj directly if obj is an array or a new array containing obj
  32180. */
  32181. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32182. /**
  32183. * Gets the pointer prefix to use
  32184. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32185. */
  32186. static GetPointerPrefix(): string;
  32187. /**
  32188. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32189. * @param func - the function to be called
  32190. * @param requester - the object that will request the next frame. Falls back to window.
  32191. * @returns frame number
  32192. */
  32193. static QueueNewFrame(func: () => void, requester?: any): number;
  32194. /**
  32195. * Ask the browser to promote the current element to fullscreen rendering mode
  32196. * @param element defines the DOM element to promote
  32197. */
  32198. static RequestFullscreen(element: HTMLElement): void;
  32199. /**
  32200. * Asks the browser to exit fullscreen mode
  32201. */
  32202. static ExitFullscreen(): void;
  32203. /**
  32204. * Ask the browser to promote the current element to pointerlock mode
  32205. * @param element defines the DOM element to promote
  32206. */
  32207. static RequestPointerlock(element: HTMLElement): void;
  32208. /**
  32209. * Asks the browser to exit pointerlock mode
  32210. */
  32211. static ExitPointerlock(): void;
  32212. /**
  32213. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32214. * @param url define the url we are trying
  32215. * @param element define the dom element where to configure the cors policy
  32216. */
  32217. static SetCorsBehavior(url: string | string[], element: {
  32218. crossOrigin: string | null;
  32219. }): void;
  32220. /**
  32221. * Removes unwanted characters from an url
  32222. * @param url defines the url to clean
  32223. * @returns the cleaned url
  32224. */
  32225. static CleanUrl(url: string): string;
  32226. /**
  32227. * Gets or sets a function used to pre-process url before using them to load assets
  32228. */
  32229. static PreprocessUrl: (url: string) => string;
  32230. /**
  32231. * Loads an image as an HTMLImageElement.
  32232. * @param input url string, ArrayBuffer, or Blob to load
  32233. * @param onLoad callback called when the image successfully loads
  32234. * @param onError callback called when the image fails to load
  32235. * @param offlineProvider offline provider for caching
  32236. * @returns the HTMLImageElement of the loaded image
  32237. */
  32238. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32239. /**
  32240. * Loads a file
  32241. * @param url url string, ArrayBuffer, or Blob to load
  32242. * @param onSuccess callback called when the file successfully loads
  32243. * @param onProgress callback called while file is loading (if the server supports this mode)
  32244. * @param offlineProvider defines the offline provider for caching
  32245. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32246. * @param onError callback called when the file fails to load
  32247. * @returns a file request object
  32248. */
  32249. 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;
  32250. /**
  32251. * Loads a file from a url
  32252. * @param url the file url to load
  32253. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32254. */
  32255. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32256. /**
  32257. * Load a script (identified by an url). When the url returns, the
  32258. * content of this file is added into a new script element, attached to the DOM (body element)
  32259. * @param scriptUrl defines the url of the script to laod
  32260. * @param onSuccess defines the callback called when the script is loaded
  32261. * @param onError defines the callback to call if an error occurs
  32262. * @param scriptId defines the id of the script element
  32263. */
  32264. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32265. /**
  32266. * Load an asynchronous script (identified by an url). When the url returns, the
  32267. * content of this file is added into a new script element, attached to the DOM (body element)
  32268. * @param scriptUrl defines the url of the script to laod
  32269. * @param scriptId defines the id of the script element
  32270. * @returns a promise request object
  32271. */
  32272. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32273. /**
  32274. * Loads a file from a blob
  32275. * @param fileToLoad defines the blob to use
  32276. * @param callback defines the callback to call when data is loaded
  32277. * @param progressCallback defines the callback to call during loading process
  32278. * @returns a file request object
  32279. */
  32280. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32281. /**
  32282. * Loads a file
  32283. * @param fileToLoad defines the file to load
  32284. * @param callback defines the callback to call when data is loaded
  32285. * @param progressCallBack defines the callback to call during loading process
  32286. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32287. * @returns a file request object
  32288. */
  32289. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32290. /**
  32291. * Creates a data url from a given string content
  32292. * @param content defines the content to convert
  32293. * @returns the new data url link
  32294. */
  32295. static FileAsURL(content: string): string;
  32296. /**
  32297. * Format the given number to a specific decimal format
  32298. * @param value defines the number to format
  32299. * @param decimals defines the number of decimals to use
  32300. * @returns the formatted string
  32301. */
  32302. static Format(value: number, decimals?: number): string;
  32303. /**
  32304. * Checks if a given vector is inside a specific range
  32305. * @param v defines the vector to test
  32306. * @param min defines the minimum range
  32307. * @param max defines the maximum range
  32308. */
  32309. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32310. /**
  32311. * Tries to copy an object by duplicating every property
  32312. * @param source defines the source object
  32313. * @param destination defines the target object
  32314. * @param doNotCopyList defines a list of properties to avoid
  32315. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32316. */
  32317. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32318. /**
  32319. * Gets a boolean indicating if the given object has no own property
  32320. * @param obj defines the object to test
  32321. * @returns true if object has no own property
  32322. */
  32323. static IsEmpty(obj: any): boolean;
  32324. /**
  32325. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32326. * @param str Source string
  32327. * @param suffix Suffix to search for in the source string
  32328. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32329. */
  32330. static EndsWith(str: string, suffix: string): boolean;
  32331. /**
  32332. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  32333. * @param str Source string
  32334. * @param suffix Suffix to search for in the source string
  32335. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32336. */
  32337. static StartsWith(str: string, suffix: string): boolean;
  32338. /**
  32339. * Function used to register events at window level
  32340. * @param events defines the events to register
  32341. */
  32342. static RegisterTopRootEvents(events: {
  32343. name: string;
  32344. handler: Nullable<(e: FocusEvent) => any>;
  32345. }[]): void;
  32346. /**
  32347. * Function used to unregister events from window level
  32348. * @param events defines the events to unregister
  32349. */
  32350. static UnregisterTopRootEvents(events: {
  32351. name: string;
  32352. handler: Nullable<(e: FocusEvent) => any>;
  32353. }[]): void;
  32354. /**
  32355. * @ignore
  32356. */
  32357. static _ScreenshotCanvas: HTMLCanvasElement;
  32358. /**
  32359. * Dumps the current bound framebuffer
  32360. * @param width defines the rendering width
  32361. * @param height defines the rendering height
  32362. * @param engine defines the hosting engine
  32363. * @param successCallback defines the callback triggered once the data are available
  32364. * @param mimeType defines the mime type of the result
  32365. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32366. */
  32367. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32368. /**
  32369. * Converts the canvas data to blob.
  32370. * This acts as a polyfill for browsers not supporting the to blob function.
  32371. * @param canvas Defines the canvas to extract the data from
  32372. * @param successCallback Defines the callback triggered once the data are available
  32373. * @param mimeType Defines the mime type of the result
  32374. */
  32375. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32376. /**
  32377. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32378. * @param successCallback defines the callback triggered once the data are available
  32379. * @param mimeType defines the mime type of the result
  32380. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32381. */
  32382. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32383. /**
  32384. * Downloads a blob in the browser
  32385. * @param blob defines the blob to download
  32386. * @param fileName defines the name of the downloaded file
  32387. */
  32388. static Download(blob: Blob, fileName: string): void;
  32389. /**
  32390. * Captures a screenshot of the current rendering
  32391. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32392. * @param engine defines the rendering engine
  32393. * @param camera defines the source camera
  32394. * @param size This parameter can be set to a single number or to an object with the
  32395. * following (optional) properties: precision, width, height. If a single number is passed,
  32396. * it will be used for both width and height. If an object is passed, the screenshot size
  32397. * will be derived from the parameters. The precision property is a multiplier allowing
  32398. * rendering at a higher or lower resolution
  32399. * @param successCallback defines the callback receives a single parameter which contains the
  32400. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32401. * src parameter of an <img> to display it
  32402. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32403. * Check your browser for supported MIME types
  32404. */
  32405. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32406. /**
  32407. * Generates an image screenshot from the specified camera.
  32408. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32409. * @param engine The engine to use for rendering
  32410. * @param camera The camera to use for rendering
  32411. * @param size This parameter can be set to a single number or to an object with the
  32412. * following (optional) properties: precision, width, height. If a single number is passed,
  32413. * it will be used for both width and height. If an object is passed, the screenshot size
  32414. * will be derived from the parameters. The precision property is a multiplier allowing
  32415. * rendering at a higher or lower resolution
  32416. * @param successCallback The callback receives a single parameter which contains the
  32417. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32418. * src parameter of an <img> to display it
  32419. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32420. * Check your browser for supported MIME types
  32421. * @param samples Texture samples (default: 1)
  32422. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32423. * @param fileName A name for for the downloaded file.
  32424. */
  32425. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32426. /**
  32427. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32428. * Be aware Math.random() could cause collisions, but:
  32429. * "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"
  32430. * @returns a pseudo random id
  32431. */
  32432. static RandomId(): string;
  32433. /**
  32434. * Test if the given uri is a base64 string
  32435. * @param uri The uri to test
  32436. * @return True if the uri is a base64 string or false otherwise
  32437. */
  32438. static IsBase64(uri: string): boolean;
  32439. /**
  32440. * Decode the given base64 uri.
  32441. * @param uri The uri to decode
  32442. * @return The decoded base64 data.
  32443. */
  32444. static DecodeBase64(uri: string): ArrayBuffer;
  32445. /**
  32446. * Gets the absolute url.
  32447. * @param url the input url
  32448. * @return the absolute url
  32449. */
  32450. static GetAbsoluteUrl(url: string): string;
  32451. /**
  32452. * No log
  32453. */
  32454. static readonly NoneLogLevel: number;
  32455. /**
  32456. * Only message logs
  32457. */
  32458. static readonly MessageLogLevel: number;
  32459. /**
  32460. * Only warning logs
  32461. */
  32462. static readonly WarningLogLevel: number;
  32463. /**
  32464. * Only error logs
  32465. */
  32466. static readonly ErrorLogLevel: number;
  32467. /**
  32468. * All logs
  32469. */
  32470. static readonly AllLogLevel: number;
  32471. /**
  32472. * Gets a value indicating the number of loading errors
  32473. * @ignorenaming
  32474. */
  32475. static readonly errorsCount: number;
  32476. /**
  32477. * Callback called when a new log is added
  32478. */
  32479. static OnNewCacheEntry: (entry: string) => void;
  32480. /**
  32481. * Log a message to the console
  32482. * @param message defines the message to log
  32483. */
  32484. static Log(message: string): void;
  32485. /**
  32486. * Write a warning message to the console
  32487. * @param message defines the message to log
  32488. */
  32489. static Warn(message: string): void;
  32490. /**
  32491. * Write an error message to the console
  32492. * @param message defines the message to log
  32493. */
  32494. static Error(message: string): void;
  32495. /**
  32496. * Gets current log cache (list of logs)
  32497. */
  32498. static readonly LogCache: string;
  32499. /**
  32500. * Clears the log cache
  32501. */
  32502. static ClearLogCache(): void;
  32503. /**
  32504. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32505. */
  32506. static LogLevels: number;
  32507. /**
  32508. * Checks if the loaded document was accessed via `file:`-Protocol.
  32509. * @returns boolean
  32510. */
  32511. static IsFileURL(): boolean;
  32512. /**
  32513. * Checks if the window object exists
  32514. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32515. */
  32516. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32517. /**
  32518. * No performance log
  32519. */
  32520. static readonly PerformanceNoneLogLevel: number;
  32521. /**
  32522. * Use user marks to log performance
  32523. */
  32524. static readonly PerformanceUserMarkLogLevel: number;
  32525. /**
  32526. * Log performance to the console
  32527. */
  32528. static readonly PerformanceConsoleLogLevel: number;
  32529. private static _performance;
  32530. /**
  32531. * Sets the current performance log level
  32532. */
  32533. static PerformanceLogLevel: number;
  32534. private static _StartPerformanceCounterDisabled;
  32535. private static _EndPerformanceCounterDisabled;
  32536. private static _StartUserMark;
  32537. private static _EndUserMark;
  32538. private static _StartPerformanceConsole;
  32539. private static _EndPerformanceConsole;
  32540. /**
  32541. * Starts a performance counter
  32542. */
  32543. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32544. /**
  32545. * Ends a specific performance coutner
  32546. */
  32547. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32548. /**
  32549. * Gets either window.performance.now() if supported or Date.now() else
  32550. */
  32551. static readonly Now: number;
  32552. /**
  32553. * This method will return the name of the class used to create the instance of the given object.
  32554. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32555. * @param object the object to get the class name from
  32556. * @param isType defines if the object is actually a type
  32557. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32558. */
  32559. static GetClassName(object: any, isType?: boolean): string;
  32560. /**
  32561. * Gets the first element of an array satisfying a given predicate
  32562. * @param array defines the array to browse
  32563. * @param predicate defines the predicate to use
  32564. * @returns null if not found or the element
  32565. */
  32566. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32567. /**
  32568. * This method will return the name of the full name of the class, including its owning module (if any).
  32569. * 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).
  32570. * @param object the object to get the class name from
  32571. * @param isType defines if the object is actually a type
  32572. * @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.
  32573. * @ignorenaming
  32574. */
  32575. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32576. /**
  32577. * Returns a promise that resolves after the given amount of time.
  32578. * @param delay Number of milliseconds to delay
  32579. * @returns Promise that resolves after the given amount of time
  32580. */
  32581. static DelayAsync(delay: number): Promise<void>;
  32582. /**
  32583. * Gets the current gradient from an array of IValueGradient
  32584. * @param ratio defines the current ratio to get
  32585. * @param gradients defines the array of IValueGradient
  32586. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32587. */
  32588. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32589. }
  32590. /**
  32591. * This class is used to track a performance counter which is number based.
  32592. * The user has access to many properties which give statistics of different nature.
  32593. *
  32594. * The implementer can track two kinds of Performance Counter: time and count.
  32595. * 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.
  32596. * 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.
  32597. */
  32598. export class PerfCounter {
  32599. /**
  32600. * Gets or sets a global boolean to turn on and off all the counters
  32601. */
  32602. static Enabled: boolean;
  32603. /**
  32604. * Returns the smallest value ever
  32605. */
  32606. readonly min: number;
  32607. /**
  32608. * Returns the biggest value ever
  32609. */
  32610. readonly max: number;
  32611. /**
  32612. * Returns the average value since the performance counter is running
  32613. */
  32614. readonly average: number;
  32615. /**
  32616. * Returns the average value of the last second the counter was monitored
  32617. */
  32618. readonly lastSecAverage: number;
  32619. /**
  32620. * Returns the current value
  32621. */
  32622. readonly current: number;
  32623. /**
  32624. * Gets the accumulated total
  32625. */
  32626. readonly total: number;
  32627. /**
  32628. * Gets the total value count
  32629. */
  32630. readonly count: number;
  32631. /**
  32632. * Creates a new counter
  32633. */
  32634. constructor();
  32635. /**
  32636. * Call this method to start monitoring a new frame.
  32637. * 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.
  32638. */
  32639. fetchNewFrame(): void;
  32640. /**
  32641. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32642. * @param newCount the count value to add to the monitored count
  32643. * @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.
  32644. */
  32645. addCount(newCount: number, fetchResult: boolean): void;
  32646. /**
  32647. * Start monitoring this performance counter
  32648. */
  32649. beginMonitoring(): void;
  32650. /**
  32651. * Compute the time lapsed since the previous beginMonitoring() call.
  32652. * @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
  32653. */
  32654. endMonitoring(newFrame?: boolean): void;
  32655. private _fetchResult;
  32656. private _startMonitoringTime;
  32657. private _min;
  32658. private _max;
  32659. private _average;
  32660. private _current;
  32661. private _totalValueCount;
  32662. private _totalAccumulated;
  32663. private _lastSecAverage;
  32664. private _lastSecAccumulated;
  32665. private _lastSecTime;
  32666. private _lastSecValueCount;
  32667. }
  32668. /**
  32669. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32670. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32671. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32672. * @param name The name of the class, case should be preserved
  32673. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32674. */
  32675. export function className(name: string, module?: string): (target: Object) => void;
  32676. /**
  32677. * An implementation of a loop for asynchronous functions.
  32678. */
  32679. export class AsyncLoop {
  32680. /**
  32681. * Defines the number of iterations for the loop
  32682. */
  32683. iterations: number;
  32684. /**
  32685. * Defines the current index of the loop.
  32686. */
  32687. index: number;
  32688. private _done;
  32689. private _fn;
  32690. private _successCallback;
  32691. /**
  32692. * Constructor.
  32693. * @param iterations the number of iterations.
  32694. * @param func the function to run each iteration
  32695. * @param successCallback the callback that will be called upon succesful execution
  32696. * @param offset starting offset.
  32697. */
  32698. constructor(
  32699. /**
  32700. * Defines the number of iterations for the loop
  32701. */
  32702. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32703. /**
  32704. * Execute the next iteration. Must be called after the last iteration was finished.
  32705. */
  32706. executeNext(): void;
  32707. /**
  32708. * Break the loop and run the success callback.
  32709. */
  32710. breakLoop(): void;
  32711. /**
  32712. * Create and run an async loop.
  32713. * @param iterations the number of iterations.
  32714. * @param fn the function to run each iteration
  32715. * @param successCallback the callback that will be called upon succesful execution
  32716. * @param offset starting offset.
  32717. * @returns the created async loop object
  32718. */
  32719. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32720. /**
  32721. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32722. * @param iterations total number of iterations
  32723. * @param syncedIterations number of synchronous iterations in each async iteration.
  32724. * @param fn the function to call each iteration.
  32725. * @param callback a success call back that will be called when iterating stops.
  32726. * @param breakFunction a break condition (optional)
  32727. * @param timeout timeout settings for the setTimeout function. default - 0.
  32728. * @returns the created async loop object
  32729. */
  32730. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32731. }
  32732. }
  32733. declare module "babylonjs/Collisions/collisionCoordinator" {
  32734. import { Nullable } from "babylonjs/types";
  32735. import { Scene } from "babylonjs/scene";
  32736. import { Vector3 } from "babylonjs/Maths/math";
  32737. import { Collider } from "babylonjs/Collisions/collider";
  32738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32739. /** @hidden */
  32740. export interface ICollisionCoordinator {
  32741. createCollider(): Collider;
  32742. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32743. init(scene: Scene): void;
  32744. }
  32745. /** @hidden */
  32746. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32747. private _scene;
  32748. private _scaledPosition;
  32749. private _scaledVelocity;
  32750. private _finalPosition;
  32751. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32752. createCollider(): Collider;
  32753. init(scene: Scene): void;
  32754. private _collideWithWorld;
  32755. }
  32756. }
  32757. declare module "babylonjs/Inputs/scene.inputManager" {
  32758. import { Nullable } from "babylonjs/types";
  32759. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32760. import { Vector2 } from "babylonjs/Maths/math";
  32761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32762. import { Scene } from "babylonjs/scene";
  32763. /**
  32764. * Class used to manage all inputs for the scene.
  32765. */
  32766. export class InputManager {
  32767. /** The distance in pixel that you have to move to prevent some events */
  32768. static DragMovementThreshold: number;
  32769. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32770. static LongPressDelay: number;
  32771. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32772. static DoubleClickDelay: number;
  32773. /** If you need to check double click without raising a single click at first click, enable this flag */
  32774. static ExclusiveDoubleClickMode: boolean;
  32775. private _wheelEventName;
  32776. private _onPointerMove;
  32777. private _onPointerDown;
  32778. private _onPointerUp;
  32779. private _initClickEvent;
  32780. private _initActionManager;
  32781. private _delayedSimpleClick;
  32782. private _delayedSimpleClickTimeout;
  32783. private _previousDelayedSimpleClickTimeout;
  32784. private _meshPickProceed;
  32785. private _previousButtonPressed;
  32786. private _currentPickResult;
  32787. private _previousPickResult;
  32788. private _totalPointersPressed;
  32789. private _doubleClickOccured;
  32790. private _pointerOverMesh;
  32791. private _pickedDownMesh;
  32792. private _pickedUpMesh;
  32793. private _pointerX;
  32794. private _pointerY;
  32795. private _unTranslatedPointerX;
  32796. private _unTranslatedPointerY;
  32797. private _startingPointerPosition;
  32798. private _previousStartingPointerPosition;
  32799. private _startingPointerTime;
  32800. private _previousStartingPointerTime;
  32801. private _pointerCaptures;
  32802. private _onKeyDown;
  32803. private _onKeyUp;
  32804. private _onCanvasFocusObserver;
  32805. private _onCanvasBlurObserver;
  32806. private _scene;
  32807. /**
  32808. * Creates a new InputManager
  32809. * @param scene defines the hosting scene
  32810. */
  32811. constructor(scene: Scene);
  32812. /**
  32813. * Gets the mesh that is currently under the pointer
  32814. */
  32815. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32816. /**
  32817. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32818. */
  32819. readonly unTranslatedPointer: Vector2;
  32820. /**
  32821. * Gets or sets the current on-screen X position of the pointer
  32822. */
  32823. pointerX: number;
  32824. /**
  32825. * Gets or sets the current on-screen Y position of the pointer
  32826. */
  32827. pointerY: number;
  32828. private _updatePointerPosition;
  32829. private _processPointerMove;
  32830. private _setRayOnPointerInfo;
  32831. private _checkPrePointerObservable;
  32832. /**
  32833. * Use this method to simulate a pointer move on a mesh
  32834. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32835. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32836. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32837. */
  32838. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32839. /**
  32840. * Use this method to simulate a pointer down on a mesh
  32841. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32842. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32843. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32844. */
  32845. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32846. private _processPointerDown;
  32847. /** @hidden */
  32848. _isPointerSwiping(): boolean;
  32849. /**
  32850. * Use this method to simulate a pointer up on a mesh
  32851. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32852. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32853. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32854. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32855. */
  32856. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32857. private _processPointerUp;
  32858. /**
  32859. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32860. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32861. * @returns true if the pointer was captured
  32862. */
  32863. isPointerCaptured(pointerId?: number): boolean;
  32864. /**
  32865. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32866. * @param attachUp defines if you want to attach events to pointerup
  32867. * @param attachDown defines if you want to attach events to pointerdown
  32868. * @param attachMove defines if you want to attach events to pointermove
  32869. */
  32870. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32871. /**
  32872. * Detaches all event handlers
  32873. */
  32874. detachControl(): void;
  32875. /**
  32876. * Force the value of meshUnderPointer
  32877. * @param mesh defines the mesh to use
  32878. */
  32879. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32880. /**
  32881. * Gets the mesh under the pointer
  32882. * @returns a Mesh or null if no mesh is under the pointer
  32883. */
  32884. getPointerOverMesh(): Nullable<AbstractMesh>;
  32885. }
  32886. }
  32887. declare module "babylonjs/Animations/animationGroup" {
  32888. import { Animatable } from "babylonjs/Animations/animatable";
  32889. import { Animation } from "babylonjs/Animations/animation";
  32890. import { Scene, IDisposable } from "babylonjs/scene";
  32891. import { Observable } from "babylonjs/Misc/observable";
  32892. import { Nullable } from "babylonjs/types";
  32893. import "babylonjs/Animations/animatable";
  32894. /**
  32895. * This class defines the direct association between an animation and a target
  32896. */
  32897. export class TargetedAnimation {
  32898. /**
  32899. * Animation to perform
  32900. */
  32901. animation: Animation;
  32902. /**
  32903. * Target to animate
  32904. */
  32905. target: any;
  32906. /**
  32907. * Serialize the object
  32908. * @returns the JSON object representing the current entity
  32909. */
  32910. serialize(): any;
  32911. }
  32912. /**
  32913. * Use this class to create coordinated animations on multiple targets
  32914. */
  32915. export class AnimationGroup implements IDisposable {
  32916. /** The name of the animation group */
  32917. name: string;
  32918. private _scene;
  32919. private _targetedAnimations;
  32920. private _animatables;
  32921. private _from;
  32922. private _to;
  32923. private _isStarted;
  32924. private _isPaused;
  32925. private _speedRatio;
  32926. private _loopAnimation;
  32927. /**
  32928. * Gets or sets the unique id of the node
  32929. */
  32930. uniqueId: number;
  32931. /**
  32932. * This observable will notify when one animation have ended
  32933. */
  32934. onAnimationEndObservable: Observable<TargetedAnimation>;
  32935. /**
  32936. * Observer raised when one animation loops
  32937. */
  32938. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32939. /**
  32940. * This observable will notify when all animations have ended.
  32941. */
  32942. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32943. /**
  32944. * This observable will notify when all animations have paused.
  32945. */
  32946. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32947. /**
  32948. * This observable will notify when all animations are playing.
  32949. */
  32950. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32951. /**
  32952. * Gets the first frame
  32953. */
  32954. readonly from: number;
  32955. /**
  32956. * Gets the last frame
  32957. */
  32958. readonly to: number;
  32959. /**
  32960. * Define if the animations are started
  32961. */
  32962. readonly isStarted: boolean;
  32963. /**
  32964. * Gets a value indicating that the current group is playing
  32965. */
  32966. readonly isPlaying: boolean;
  32967. /**
  32968. * Gets or sets the speed ratio to use for all animations
  32969. */
  32970. /**
  32971. * Gets or sets the speed ratio to use for all animations
  32972. */
  32973. speedRatio: number;
  32974. /**
  32975. * Gets or sets if all animations should loop or not
  32976. */
  32977. loopAnimation: boolean;
  32978. /**
  32979. * Gets the targeted animations for this animation group
  32980. */
  32981. readonly targetedAnimations: Array<TargetedAnimation>;
  32982. /**
  32983. * returning the list of animatables controlled by this animation group.
  32984. */
  32985. readonly animatables: Array<Animatable>;
  32986. /**
  32987. * Instantiates a new Animation Group.
  32988. * This helps managing several animations at once.
  32989. * @see http://doc.babylonjs.com/how_to/group
  32990. * @param name Defines the name of the group
  32991. * @param scene Defines the scene the group belongs to
  32992. */
  32993. constructor(
  32994. /** The name of the animation group */
  32995. name: string, scene?: Nullable<Scene>);
  32996. /**
  32997. * Add an animation (with its target) in the group
  32998. * @param animation defines the animation we want to add
  32999. * @param target defines the target of the animation
  33000. * @returns the TargetedAnimation object
  33001. */
  33002. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33003. /**
  33004. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33005. * It can add constant keys at begin or end
  33006. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33007. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33008. * @returns the animation group
  33009. */
  33010. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33011. /**
  33012. * Start all animations on given targets
  33013. * @param loop defines if animations must loop
  33014. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33015. * @param from defines the from key (optional)
  33016. * @param to defines the to key (optional)
  33017. * @returns the current animation group
  33018. */
  33019. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33020. /**
  33021. * Pause all animations
  33022. * @returns the animation group
  33023. */
  33024. pause(): AnimationGroup;
  33025. /**
  33026. * Play all animations to initial state
  33027. * This function will start() the animations if they were not started or will restart() them if they were paused
  33028. * @param loop defines if animations must loop
  33029. * @returns the animation group
  33030. */
  33031. play(loop?: boolean): AnimationGroup;
  33032. /**
  33033. * Reset all animations to initial state
  33034. * @returns the animation group
  33035. */
  33036. reset(): AnimationGroup;
  33037. /**
  33038. * Restart animations from key 0
  33039. * @returns the animation group
  33040. */
  33041. restart(): AnimationGroup;
  33042. /**
  33043. * Stop all animations
  33044. * @returns the animation group
  33045. */
  33046. stop(): AnimationGroup;
  33047. /**
  33048. * Set animation weight for all animatables
  33049. * @param weight defines the weight to use
  33050. * @return the animationGroup
  33051. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33052. */
  33053. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33054. /**
  33055. * Synchronize and normalize all animatables with a source animatable
  33056. * @param root defines the root animatable to synchronize with
  33057. * @return the animationGroup
  33058. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33059. */
  33060. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33061. /**
  33062. * Goes to a specific frame in this animation group
  33063. * @param frame the frame number to go to
  33064. * @return the animationGroup
  33065. */
  33066. goToFrame(frame: number): AnimationGroup;
  33067. /**
  33068. * Dispose all associated resources
  33069. */
  33070. dispose(): void;
  33071. private _checkAnimationGroupEnded;
  33072. /**
  33073. * Clone the current animation group and returns a copy
  33074. * @param newName defines the name of the new group
  33075. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33076. * @returns the new aniamtion group
  33077. */
  33078. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33079. /**
  33080. * Serializes the animationGroup to an object
  33081. * @returns Serialized object
  33082. */
  33083. serialize(): any;
  33084. /**
  33085. * Returns a new AnimationGroup object parsed from the source provided.
  33086. * @param parsedAnimationGroup defines the source
  33087. * @param scene defines the scene that will receive the animationGroup
  33088. * @returns a new AnimationGroup
  33089. */
  33090. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33091. /**
  33092. * Returns the string "AnimationGroup"
  33093. * @returns "AnimationGroup"
  33094. */
  33095. getClassName(): string;
  33096. /**
  33097. * Creates a detailled string about the object
  33098. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33099. * @returns a string representing the object
  33100. */
  33101. toString(fullDetails?: boolean): string;
  33102. }
  33103. }
  33104. declare module "babylonjs/scene" {
  33105. import { Nullable } from "babylonjs/types";
  33106. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  33107. import { Observable } from "babylonjs/Misc/observable";
  33108. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33109. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  33110. import { Geometry } from "babylonjs/Meshes/geometry";
  33111. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33112. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33114. import { Mesh } from "babylonjs/Meshes/mesh";
  33115. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33116. import { Bone } from "babylonjs/Bones/bone";
  33117. import { Skeleton } from "babylonjs/Bones/skeleton";
  33118. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33119. import { Camera } from "babylonjs/Cameras/camera";
  33120. import { AbstractScene } from "babylonjs/abstractScene";
  33121. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33122. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33123. import { Material } from "babylonjs/Materials/material";
  33124. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33125. import { Effect } from "babylonjs/Materials/effect";
  33126. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33127. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33128. import { Light } from "babylonjs/Lights/light";
  33129. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33130. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33131. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33132. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33133. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33134. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33135. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33136. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33137. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33138. import { Engine } from "babylonjs/Engines/engine";
  33139. import { Node } from "babylonjs/node";
  33140. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33141. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33142. import { WebRequest } from "babylonjs/Misc/webRequest";
  33143. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33144. import { Ray } from "babylonjs/Culling/ray";
  33145. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33146. import { Animation } from "babylonjs/Animations/animation";
  33147. import { Animatable } from "babylonjs/Animations/animatable";
  33148. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33149. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33150. import { Collider } from "babylonjs/Collisions/collider";
  33151. /**
  33152. * Define an interface for all classes that will hold resources
  33153. */
  33154. export interface IDisposable {
  33155. /**
  33156. * Releases all held resources
  33157. */
  33158. dispose(): void;
  33159. }
  33160. /** Interface defining initialization parameters for Scene class */
  33161. export interface SceneOptions {
  33162. /**
  33163. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33164. * It will improve performance when the number of geometries becomes important.
  33165. */
  33166. useGeometryUniqueIdsMap?: boolean;
  33167. /**
  33168. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33169. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33170. */
  33171. useMaterialMeshMap?: boolean;
  33172. /**
  33173. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33174. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33175. */
  33176. useClonedMeshhMap?: boolean;
  33177. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33178. virtual?: boolean;
  33179. }
  33180. /**
  33181. * Represents a scene to be rendered by the engine.
  33182. * @see http://doc.babylonjs.com/features/scene
  33183. */
  33184. export class Scene extends AbstractScene implements IAnimatable {
  33185. private static _uniqueIdCounter;
  33186. /** The fog is deactivated */
  33187. static readonly FOGMODE_NONE: number;
  33188. /** The fog density is following an exponential function */
  33189. static readonly FOGMODE_EXP: number;
  33190. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33191. static readonly FOGMODE_EXP2: number;
  33192. /** The fog density is following a linear function. */
  33193. static readonly FOGMODE_LINEAR: number;
  33194. /**
  33195. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33196. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33197. */
  33198. static MinDeltaTime: number;
  33199. /**
  33200. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33201. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33202. */
  33203. static MaxDeltaTime: number;
  33204. /**
  33205. * Factory used to create the default material.
  33206. * @param name The name of the material to create
  33207. * @param scene The scene to create the material for
  33208. * @returns The default material
  33209. */
  33210. static DefaultMaterialFactory(scene: Scene): Material;
  33211. /**
  33212. * Factory used to create the a collision coordinator.
  33213. * @returns The collision coordinator
  33214. */
  33215. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33216. /** @hidden */
  33217. _inputManager: InputManager;
  33218. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33219. cameraToUseForPointers: Nullable<Camera>;
  33220. /** @hidden */
  33221. readonly _isScene: boolean;
  33222. /**
  33223. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33224. */
  33225. autoClear: boolean;
  33226. /**
  33227. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33228. */
  33229. autoClearDepthAndStencil: boolean;
  33230. /**
  33231. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33232. */
  33233. clearColor: Color4;
  33234. /**
  33235. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33236. */
  33237. ambientColor: Color3;
  33238. /**
  33239. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33240. * It should only be one of the following (if not the default embedded one):
  33241. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33242. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33243. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33244. * The material properties need to be setup according to the type of texture in use.
  33245. */
  33246. environmentBRDFTexture: BaseTexture;
  33247. /** @hidden */
  33248. protected _environmentTexture: Nullable<BaseTexture>;
  33249. /**
  33250. * Texture used in all pbr material as the reflection texture.
  33251. * As in the majority of the scene they are the same (exception for multi room and so on),
  33252. * this is easier to reference from here than from all the materials.
  33253. */
  33254. /**
  33255. * Texture used in all pbr material as the reflection texture.
  33256. * As in the majority of the scene they are the same (exception for multi room and so on),
  33257. * this is easier to set here than in all the materials.
  33258. */
  33259. environmentTexture: Nullable<BaseTexture>;
  33260. /** @hidden */
  33261. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33262. /**
  33263. * Default image processing configuration used either in the rendering
  33264. * Forward main pass or through the imageProcessingPostProcess if present.
  33265. * As in the majority of the scene they are the same (exception for multi camera),
  33266. * this is easier to reference from here than from all the materials and post process.
  33267. *
  33268. * No setter as we it is a shared configuration, you can set the values instead.
  33269. */
  33270. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33271. private _forceWireframe;
  33272. /**
  33273. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33274. */
  33275. forceWireframe: boolean;
  33276. private _forcePointsCloud;
  33277. /**
  33278. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33279. */
  33280. forcePointsCloud: boolean;
  33281. /**
  33282. * Gets or sets the active clipplane 1
  33283. */
  33284. clipPlane: Nullable<Plane>;
  33285. /**
  33286. * Gets or sets the active clipplane 2
  33287. */
  33288. clipPlane2: Nullable<Plane>;
  33289. /**
  33290. * Gets or sets the active clipplane 3
  33291. */
  33292. clipPlane3: Nullable<Plane>;
  33293. /**
  33294. * Gets or sets the active clipplane 4
  33295. */
  33296. clipPlane4: Nullable<Plane>;
  33297. /**
  33298. * Gets or sets a boolean indicating if animations are enabled
  33299. */
  33300. animationsEnabled: boolean;
  33301. private _animationPropertiesOverride;
  33302. /**
  33303. * Gets or sets the animation properties override
  33304. */
  33305. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33306. /**
  33307. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33308. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33309. */
  33310. useConstantAnimationDeltaTime: boolean;
  33311. /**
  33312. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33313. * Please note that it requires to run a ray cast through the scene on every frame
  33314. */
  33315. constantlyUpdateMeshUnderPointer: boolean;
  33316. /**
  33317. * Defines the HTML cursor to use when hovering over interactive elements
  33318. */
  33319. hoverCursor: string;
  33320. /**
  33321. * Defines the HTML default cursor to use (empty by default)
  33322. */
  33323. defaultCursor: string;
  33324. /**
  33325. * This is used to call preventDefault() on pointer down
  33326. * in order to block unwanted artifacts like system double clicks
  33327. */
  33328. preventDefaultOnPointerDown: boolean;
  33329. /**
  33330. * This is used to call preventDefault() on pointer up
  33331. * in order to block unwanted artifacts like system double clicks
  33332. */
  33333. preventDefaultOnPointerUp: boolean;
  33334. /**
  33335. * Gets or sets user defined metadata
  33336. */
  33337. metadata: any;
  33338. /**
  33339. * For internal use only. Please do not use.
  33340. */
  33341. reservedDataStore: any;
  33342. /**
  33343. * Gets the name of the plugin used to load this scene (null by default)
  33344. */
  33345. loadingPluginName: string;
  33346. /**
  33347. * Use this array to add regular expressions used to disable offline support for specific urls
  33348. */
  33349. disableOfflineSupportExceptionRules: RegExp[];
  33350. /**
  33351. * An event triggered when the scene is disposed.
  33352. */
  33353. onDisposeObservable: Observable<Scene>;
  33354. private _onDisposeObserver;
  33355. /** Sets a function to be executed when this scene is disposed. */
  33356. onDispose: () => void;
  33357. /**
  33358. * An event triggered before rendering the scene (right after animations and physics)
  33359. */
  33360. onBeforeRenderObservable: Observable<Scene>;
  33361. private _onBeforeRenderObserver;
  33362. /** Sets a function to be executed before rendering this scene */
  33363. beforeRender: Nullable<() => void>;
  33364. /**
  33365. * An event triggered after rendering the scene
  33366. */
  33367. onAfterRenderObservable: Observable<Scene>;
  33368. /**
  33369. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33370. */
  33371. onAfterRenderCameraObservable: Observable<Camera>;
  33372. private _onAfterRenderObserver;
  33373. /** Sets a function to be executed after rendering this scene */
  33374. afterRender: Nullable<() => void>;
  33375. /**
  33376. * An event triggered before animating the scene
  33377. */
  33378. onBeforeAnimationsObservable: Observable<Scene>;
  33379. /**
  33380. * An event triggered after animations processing
  33381. */
  33382. onAfterAnimationsObservable: Observable<Scene>;
  33383. /**
  33384. * An event triggered before draw calls are ready to be sent
  33385. */
  33386. onBeforeDrawPhaseObservable: Observable<Scene>;
  33387. /**
  33388. * An event triggered after draw calls have been sent
  33389. */
  33390. onAfterDrawPhaseObservable: Observable<Scene>;
  33391. /**
  33392. * An event triggered when the scene is ready
  33393. */
  33394. onReadyObservable: Observable<Scene>;
  33395. /**
  33396. * An event triggered before rendering a camera
  33397. */
  33398. onBeforeCameraRenderObservable: Observable<Camera>;
  33399. private _onBeforeCameraRenderObserver;
  33400. /** Sets a function to be executed before rendering a camera*/
  33401. beforeCameraRender: () => void;
  33402. /**
  33403. * An event triggered after rendering a camera
  33404. */
  33405. onAfterCameraRenderObservable: Observable<Camera>;
  33406. private _onAfterCameraRenderObserver;
  33407. /** Sets a function to be executed after rendering a camera*/
  33408. afterCameraRender: () => void;
  33409. /**
  33410. * An event triggered when active meshes evaluation is about to start
  33411. */
  33412. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33413. /**
  33414. * An event triggered when active meshes evaluation is done
  33415. */
  33416. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33417. /**
  33418. * An event triggered when particles rendering is about to start
  33419. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33420. */
  33421. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33422. /**
  33423. * An event triggered when particles rendering is done
  33424. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33425. */
  33426. onAfterParticlesRenderingObservable: Observable<Scene>;
  33427. /**
  33428. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33429. */
  33430. onDataLoadedObservable: Observable<Scene>;
  33431. /**
  33432. * An event triggered when a camera is created
  33433. */
  33434. onNewCameraAddedObservable: Observable<Camera>;
  33435. /**
  33436. * An event triggered when a camera is removed
  33437. */
  33438. onCameraRemovedObservable: Observable<Camera>;
  33439. /**
  33440. * An event triggered when a light is created
  33441. */
  33442. onNewLightAddedObservable: Observable<Light>;
  33443. /**
  33444. * An event triggered when a light is removed
  33445. */
  33446. onLightRemovedObservable: Observable<Light>;
  33447. /**
  33448. * An event triggered when a geometry is created
  33449. */
  33450. onNewGeometryAddedObservable: Observable<Geometry>;
  33451. /**
  33452. * An event triggered when a geometry is removed
  33453. */
  33454. onGeometryRemovedObservable: Observable<Geometry>;
  33455. /**
  33456. * An event triggered when a transform node is created
  33457. */
  33458. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33459. /**
  33460. * An event triggered when a transform node is removed
  33461. */
  33462. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33463. /**
  33464. * An event triggered when a mesh is created
  33465. */
  33466. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33467. /**
  33468. * An event triggered when a mesh is removed
  33469. */
  33470. onMeshRemovedObservable: Observable<AbstractMesh>;
  33471. /**
  33472. * An event triggered when a skeleton is created
  33473. */
  33474. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33475. /**
  33476. * An event triggered when a skeleton is removed
  33477. */
  33478. onSkeletonRemovedObservable: Observable<Skeleton>;
  33479. /**
  33480. * An event triggered when a material is created
  33481. */
  33482. onNewMaterialAddedObservable: Observable<Material>;
  33483. /**
  33484. * An event triggered when a material is removed
  33485. */
  33486. onMaterialRemovedObservable: Observable<Material>;
  33487. /**
  33488. * An event triggered when a texture is created
  33489. */
  33490. onNewTextureAddedObservable: Observable<BaseTexture>;
  33491. /**
  33492. * An event triggered when a texture is removed
  33493. */
  33494. onTextureRemovedObservable: Observable<BaseTexture>;
  33495. /**
  33496. * An event triggered when render targets are about to be rendered
  33497. * Can happen multiple times per frame.
  33498. */
  33499. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33500. /**
  33501. * An event triggered when render targets were rendered.
  33502. * Can happen multiple times per frame.
  33503. */
  33504. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33505. /**
  33506. * An event triggered before calculating deterministic simulation step
  33507. */
  33508. onBeforeStepObservable: Observable<Scene>;
  33509. /**
  33510. * An event triggered after calculating deterministic simulation step
  33511. */
  33512. onAfterStepObservable: Observable<Scene>;
  33513. /**
  33514. * An event triggered when the activeCamera property is updated
  33515. */
  33516. onActiveCameraChanged: Observable<Scene>;
  33517. /**
  33518. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33519. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33520. * 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)
  33521. */
  33522. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33523. /**
  33524. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33525. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33526. * 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)
  33527. */
  33528. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33529. /**
  33530. * This Observable will when a mesh has been imported into the scene.
  33531. */
  33532. onMeshImportedObservable: Observable<AbstractMesh>;
  33533. /**
  33534. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33535. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33536. */
  33537. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33538. /** @hidden */
  33539. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33540. /**
  33541. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33542. */
  33543. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33544. /**
  33545. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33546. */
  33547. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33548. /**
  33549. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33550. */
  33551. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33552. /** Callback called when a pointer move is detected */
  33553. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33554. /** Callback called when a pointer down is detected */
  33555. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33556. /** Callback called when a pointer up is detected */
  33557. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33558. /** Callback called when a pointer pick is detected */
  33559. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33560. /**
  33561. * 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).
  33562. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33563. */
  33564. onPrePointerObservable: Observable<PointerInfoPre>;
  33565. /**
  33566. * Observable event triggered each time an input event is received from the rendering canvas
  33567. */
  33568. onPointerObservable: Observable<PointerInfo>;
  33569. /**
  33570. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33571. */
  33572. readonly unTranslatedPointer: Vector2;
  33573. /**
  33574. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33575. */
  33576. static DragMovementThreshold: number;
  33577. /**
  33578. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33579. */
  33580. static LongPressDelay: number;
  33581. /**
  33582. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33583. */
  33584. static DoubleClickDelay: number;
  33585. /** If you need to check double click without raising a single click at first click, enable this flag */
  33586. static ExclusiveDoubleClickMode: boolean;
  33587. /** @hidden */
  33588. _mirroredCameraPosition: Nullable<Vector3>;
  33589. /**
  33590. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33591. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33592. */
  33593. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33594. /**
  33595. * Observable event triggered each time an keyboard event is received from the hosting window
  33596. */
  33597. onKeyboardObservable: Observable<KeyboardInfo>;
  33598. private _useRightHandedSystem;
  33599. /**
  33600. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33601. */
  33602. useRightHandedSystem: boolean;
  33603. private _timeAccumulator;
  33604. private _currentStepId;
  33605. private _currentInternalStep;
  33606. /**
  33607. * Sets the step Id used by deterministic lock step
  33608. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33609. * @param newStepId defines the step Id
  33610. */
  33611. setStepId(newStepId: number): void;
  33612. /**
  33613. * Gets the step Id used by deterministic lock step
  33614. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33615. * @returns the step Id
  33616. */
  33617. getStepId(): number;
  33618. /**
  33619. * Gets the internal step used by deterministic lock step
  33620. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33621. * @returns the internal step
  33622. */
  33623. getInternalStep(): number;
  33624. private _fogEnabled;
  33625. /**
  33626. * Gets or sets a boolean indicating if fog is enabled on this scene
  33627. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33628. * (Default is true)
  33629. */
  33630. fogEnabled: boolean;
  33631. private _fogMode;
  33632. /**
  33633. * Gets or sets the fog mode to use
  33634. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33635. * | mode | value |
  33636. * | --- | --- |
  33637. * | FOGMODE_NONE | 0 |
  33638. * | FOGMODE_EXP | 1 |
  33639. * | FOGMODE_EXP2 | 2 |
  33640. * | FOGMODE_LINEAR | 3 |
  33641. */
  33642. fogMode: number;
  33643. /**
  33644. * Gets or sets the fog color to use
  33645. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33646. * (Default is Color3(0.2, 0.2, 0.3))
  33647. */
  33648. fogColor: Color3;
  33649. /**
  33650. * Gets or sets the fog density to use
  33651. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33652. * (Default is 0.1)
  33653. */
  33654. fogDensity: number;
  33655. /**
  33656. * Gets or sets the fog start distance to use
  33657. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33658. * (Default is 0)
  33659. */
  33660. fogStart: number;
  33661. /**
  33662. * Gets or sets the fog end distance to use
  33663. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33664. * (Default is 1000)
  33665. */
  33666. fogEnd: number;
  33667. private _shadowsEnabled;
  33668. /**
  33669. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33670. */
  33671. shadowsEnabled: boolean;
  33672. private _lightsEnabled;
  33673. /**
  33674. * Gets or sets a boolean indicating if lights are enabled on this scene
  33675. */
  33676. lightsEnabled: boolean;
  33677. /** All of the active cameras added to this scene. */
  33678. activeCameras: Camera[];
  33679. /** @hidden */
  33680. _activeCamera: Nullable<Camera>;
  33681. /** Gets or sets the current active camera */
  33682. activeCamera: Nullable<Camera>;
  33683. private _defaultMaterial;
  33684. /** The default material used on meshes when no material is affected */
  33685. /** The default material used on meshes when no material is affected */
  33686. defaultMaterial: Material;
  33687. private _texturesEnabled;
  33688. /**
  33689. * Gets or sets a boolean indicating if textures are enabled on this scene
  33690. */
  33691. texturesEnabled: boolean;
  33692. /**
  33693. * Gets or sets a boolean indicating if particles are enabled on this scene
  33694. */
  33695. particlesEnabled: boolean;
  33696. /**
  33697. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33698. */
  33699. spritesEnabled: boolean;
  33700. private _skeletonsEnabled;
  33701. /**
  33702. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33703. */
  33704. skeletonsEnabled: boolean;
  33705. /**
  33706. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33707. */
  33708. lensFlaresEnabled: boolean;
  33709. /**
  33710. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33711. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33712. */
  33713. collisionsEnabled: boolean;
  33714. private _collisionCoordinator;
  33715. /** @hidden */
  33716. readonly collisionCoordinator: ICollisionCoordinator;
  33717. /**
  33718. * Defines the gravity applied to this scene (used only for collisions)
  33719. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33720. */
  33721. gravity: Vector3;
  33722. /**
  33723. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33724. */
  33725. postProcessesEnabled: boolean;
  33726. /**
  33727. * The list of postprocesses added to the scene
  33728. */
  33729. postProcesses: PostProcess[];
  33730. /**
  33731. * Gets the current postprocess manager
  33732. */
  33733. postProcessManager: PostProcessManager;
  33734. /**
  33735. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33736. */
  33737. renderTargetsEnabled: boolean;
  33738. /**
  33739. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33740. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33741. */
  33742. dumpNextRenderTargets: boolean;
  33743. /**
  33744. * The list of user defined render targets added to the scene
  33745. */
  33746. customRenderTargets: RenderTargetTexture[];
  33747. /**
  33748. * Defines if texture loading must be delayed
  33749. * If true, textures will only be loaded when they need to be rendered
  33750. */
  33751. useDelayedTextureLoading: boolean;
  33752. /**
  33753. * Gets the list of meshes imported to the scene through SceneLoader
  33754. */
  33755. importedMeshesFiles: String[];
  33756. /**
  33757. * Gets or sets a boolean indicating if probes are enabled on this scene
  33758. */
  33759. probesEnabled: boolean;
  33760. /**
  33761. * Gets or sets the current offline provider to use to store scene data
  33762. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33763. */
  33764. offlineProvider: IOfflineProvider;
  33765. /**
  33766. * Gets or sets the action manager associated with the scene
  33767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33768. */
  33769. actionManager: AbstractActionManager;
  33770. private _meshesForIntersections;
  33771. /**
  33772. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33773. */
  33774. proceduralTexturesEnabled: boolean;
  33775. private _engine;
  33776. private _totalVertices;
  33777. /** @hidden */
  33778. _activeIndices: PerfCounter;
  33779. /** @hidden */
  33780. _activeParticles: PerfCounter;
  33781. /** @hidden */
  33782. _activeBones: PerfCounter;
  33783. private _animationRatio;
  33784. /** @hidden */
  33785. _animationTimeLast: number;
  33786. /** @hidden */
  33787. _animationTime: number;
  33788. /**
  33789. * Gets or sets a general scale for animation speed
  33790. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33791. */
  33792. animationTimeScale: number;
  33793. /** @hidden */
  33794. _cachedMaterial: Nullable<Material>;
  33795. /** @hidden */
  33796. _cachedEffect: Nullable<Effect>;
  33797. /** @hidden */
  33798. _cachedVisibility: Nullable<number>;
  33799. private _renderId;
  33800. private _frameId;
  33801. private _executeWhenReadyTimeoutId;
  33802. private _intermediateRendering;
  33803. private _viewUpdateFlag;
  33804. private _projectionUpdateFlag;
  33805. /** @hidden */
  33806. _toBeDisposed: Nullable<IDisposable>[];
  33807. private _activeRequests;
  33808. /** @hidden */
  33809. _pendingData: any[];
  33810. private _isDisposed;
  33811. /**
  33812. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33813. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33814. */
  33815. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33816. private _activeMeshes;
  33817. private _processedMaterials;
  33818. private _renderTargets;
  33819. /** @hidden */
  33820. _activeParticleSystems: SmartArray<IParticleSystem>;
  33821. private _activeSkeletons;
  33822. private _softwareSkinnedMeshes;
  33823. private _renderingManager;
  33824. /** @hidden */
  33825. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33826. private _transformMatrix;
  33827. private _sceneUbo;
  33828. /** @hidden */
  33829. _viewMatrix: Matrix;
  33830. private _projectionMatrix;
  33831. /** @hidden */
  33832. _forcedViewPosition: Nullable<Vector3>;
  33833. /** @hidden */
  33834. _frustumPlanes: Plane[];
  33835. /**
  33836. * Gets the list of frustum planes (built from the active camera)
  33837. */
  33838. readonly frustumPlanes: Plane[];
  33839. /**
  33840. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33841. * This is useful if there are more lights that the maximum simulteanous authorized
  33842. */
  33843. requireLightSorting: boolean;
  33844. /** @hidden */
  33845. readonly useMaterialMeshMap: boolean;
  33846. /** @hidden */
  33847. readonly useClonedMeshhMap: boolean;
  33848. private _externalData;
  33849. private _uid;
  33850. /**
  33851. * @hidden
  33852. * Backing store of defined scene components.
  33853. */
  33854. _components: ISceneComponent[];
  33855. /**
  33856. * @hidden
  33857. * Backing store of defined scene components.
  33858. */
  33859. _serializableComponents: ISceneSerializableComponent[];
  33860. /**
  33861. * List of components to register on the next registration step.
  33862. */
  33863. private _transientComponents;
  33864. /**
  33865. * Registers the transient components if needed.
  33866. */
  33867. private _registerTransientComponents;
  33868. /**
  33869. * @hidden
  33870. * Add a component to the scene.
  33871. * Note that the ccomponent could be registered on th next frame if this is called after
  33872. * the register component stage.
  33873. * @param component Defines the component to add to the scene
  33874. */
  33875. _addComponent(component: ISceneComponent): void;
  33876. /**
  33877. * @hidden
  33878. * Gets a component from the scene.
  33879. * @param name defines the name of the component to retrieve
  33880. * @returns the component or null if not present
  33881. */
  33882. _getComponent(name: string): Nullable<ISceneComponent>;
  33883. /**
  33884. * @hidden
  33885. * Defines the actions happening before camera updates.
  33886. */
  33887. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33888. /**
  33889. * @hidden
  33890. * Defines the actions happening before clear the canvas.
  33891. */
  33892. _beforeClearStage: Stage<SimpleStageAction>;
  33893. /**
  33894. * @hidden
  33895. * Defines the actions when collecting render targets for the frame.
  33896. */
  33897. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33898. /**
  33899. * @hidden
  33900. * Defines the actions happening for one camera in the frame.
  33901. */
  33902. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33903. /**
  33904. * @hidden
  33905. * Defines the actions happening during the per mesh ready checks.
  33906. */
  33907. _isReadyForMeshStage: Stage<MeshStageAction>;
  33908. /**
  33909. * @hidden
  33910. * Defines the actions happening before evaluate active mesh checks.
  33911. */
  33912. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33913. /**
  33914. * @hidden
  33915. * Defines the actions happening during the evaluate sub mesh checks.
  33916. */
  33917. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33918. /**
  33919. * @hidden
  33920. * Defines the actions happening during the active mesh stage.
  33921. */
  33922. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33923. /**
  33924. * @hidden
  33925. * Defines the actions happening during the per camera render target step.
  33926. */
  33927. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33928. /**
  33929. * @hidden
  33930. * Defines the actions happening just before the active camera is drawing.
  33931. */
  33932. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33933. /**
  33934. * @hidden
  33935. * Defines the actions happening just before a render target is drawing.
  33936. */
  33937. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33938. /**
  33939. * @hidden
  33940. * Defines the actions happening just before a rendering group is drawing.
  33941. */
  33942. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33943. /**
  33944. * @hidden
  33945. * Defines the actions happening just before a mesh is drawing.
  33946. */
  33947. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33948. /**
  33949. * @hidden
  33950. * Defines the actions happening just after a mesh has been drawn.
  33951. */
  33952. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33953. /**
  33954. * @hidden
  33955. * Defines the actions happening just after a rendering group has been drawn.
  33956. */
  33957. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33958. /**
  33959. * @hidden
  33960. * Defines the actions happening just after the active camera has been drawn.
  33961. */
  33962. _afterCameraDrawStage: Stage<CameraStageAction>;
  33963. /**
  33964. * @hidden
  33965. * Defines the actions happening just after a render target has been drawn.
  33966. */
  33967. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33968. /**
  33969. * @hidden
  33970. * Defines the actions happening just after rendering all cameras and computing intersections.
  33971. */
  33972. _afterRenderStage: Stage<SimpleStageAction>;
  33973. /**
  33974. * @hidden
  33975. * Defines the actions happening when a pointer move event happens.
  33976. */
  33977. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33978. /**
  33979. * @hidden
  33980. * Defines the actions happening when a pointer down event happens.
  33981. */
  33982. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33983. /**
  33984. * @hidden
  33985. * Defines the actions happening when a pointer up event happens.
  33986. */
  33987. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33988. /**
  33989. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33990. */
  33991. private geometriesByUniqueId;
  33992. /**
  33993. * Creates a new Scene
  33994. * @param engine defines the engine to use to render this scene
  33995. * @param options defines the scene options
  33996. */
  33997. constructor(engine: Engine, options?: SceneOptions);
  33998. /**
  33999. * Gets a string idenfifying the name of the class
  34000. * @returns "Scene" string
  34001. */
  34002. getClassName(): string;
  34003. private _defaultMeshCandidates;
  34004. /**
  34005. * @hidden
  34006. */
  34007. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34008. private _defaultSubMeshCandidates;
  34009. /**
  34010. * @hidden
  34011. */
  34012. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34013. /**
  34014. * Sets the default candidate providers for the scene.
  34015. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34016. * and getCollidingSubMeshCandidates to their default function
  34017. */
  34018. setDefaultCandidateProviders(): void;
  34019. /**
  34020. * Gets the mesh that is currently under the pointer
  34021. */
  34022. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34023. /**
  34024. * Gets or sets the current on-screen X position of the pointer
  34025. */
  34026. pointerX: number;
  34027. /**
  34028. * Gets or sets the current on-screen Y position of the pointer
  34029. */
  34030. pointerY: number;
  34031. /**
  34032. * Gets the cached material (ie. the latest rendered one)
  34033. * @returns the cached material
  34034. */
  34035. getCachedMaterial(): Nullable<Material>;
  34036. /**
  34037. * Gets the cached effect (ie. the latest rendered one)
  34038. * @returns the cached effect
  34039. */
  34040. getCachedEffect(): Nullable<Effect>;
  34041. /**
  34042. * Gets the cached visibility state (ie. the latest rendered one)
  34043. * @returns the cached visibility state
  34044. */
  34045. getCachedVisibility(): Nullable<number>;
  34046. /**
  34047. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34048. * @param material defines the current material
  34049. * @param effect defines the current effect
  34050. * @param visibility defines the current visibility state
  34051. * @returns true if one parameter is not cached
  34052. */
  34053. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34054. /**
  34055. * Gets the engine associated with the scene
  34056. * @returns an Engine
  34057. */
  34058. getEngine(): Engine;
  34059. /**
  34060. * Gets the total number of vertices rendered per frame
  34061. * @returns the total number of vertices rendered per frame
  34062. */
  34063. getTotalVertices(): number;
  34064. /**
  34065. * Gets the performance counter for total vertices
  34066. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34067. */
  34068. readonly totalVerticesPerfCounter: PerfCounter;
  34069. /**
  34070. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34071. * @returns the total number of active indices rendered per frame
  34072. */
  34073. getActiveIndices(): number;
  34074. /**
  34075. * Gets the performance counter for active indices
  34076. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34077. */
  34078. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34079. /**
  34080. * Gets the total number of active particles rendered per frame
  34081. * @returns the total number of active particles rendered per frame
  34082. */
  34083. getActiveParticles(): number;
  34084. /**
  34085. * Gets the performance counter for active particles
  34086. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34087. */
  34088. readonly activeParticlesPerfCounter: PerfCounter;
  34089. /**
  34090. * Gets the total number of active bones rendered per frame
  34091. * @returns the total number of active bones rendered per frame
  34092. */
  34093. getActiveBones(): number;
  34094. /**
  34095. * Gets the performance counter for active bones
  34096. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34097. */
  34098. readonly activeBonesPerfCounter: PerfCounter;
  34099. /**
  34100. * Gets the array of active meshes
  34101. * @returns an array of AbstractMesh
  34102. */
  34103. getActiveMeshes(): SmartArray<AbstractMesh>;
  34104. /**
  34105. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34106. * @returns a number
  34107. */
  34108. getAnimationRatio(): number;
  34109. /**
  34110. * Gets an unique Id for the current render phase
  34111. * @returns a number
  34112. */
  34113. getRenderId(): number;
  34114. /**
  34115. * Gets an unique Id for the current frame
  34116. * @returns a number
  34117. */
  34118. getFrameId(): number;
  34119. /** Call this function if you want to manually increment the render Id*/
  34120. incrementRenderId(): void;
  34121. private _createUbo;
  34122. /**
  34123. * Use this method to simulate a pointer move on a mesh
  34124. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34125. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34126. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34127. * @returns the current scene
  34128. */
  34129. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34130. /**
  34131. * Use this method to simulate a pointer down on a mesh
  34132. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34133. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34134. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34135. * @returns the current scene
  34136. */
  34137. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34138. /**
  34139. * Use this method to simulate a pointer up on a mesh
  34140. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34141. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34142. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34143. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34144. * @returns the current scene
  34145. */
  34146. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34147. /**
  34148. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34149. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34150. * @returns true if the pointer was captured
  34151. */
  34152. isPointerCaptured(pointerId?: number): boolean;
  34153. /**
  34154. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34155. * @param attachUp defines if you want to attach events to pointerup
  34156. * @param attachDown defines if you want to attach events to pointerdown
  34157. * @param attachMove defines if you want to attach events to pointermove
  34158. */
  34159. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34160. /** Detaches all event handlers*/
  34161. detachControl(): void;
  34162. /**
  34163. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34164. * Delay loaded resources are not taking in account
  34165. * @return true if all required resources are ready
  34166. */
  34167. isReady(): boolean;
  34168. /** Resets all cached information relative to material (including effect and visibility) */
  34169. resetCachedMaterial(): void;
  34170. /**
  34171. * Registers a function to be called before every frame render
  34172. * @param func defines the function to register
  34173. */
  34174. registerBeforeRender(func: () => void): void;
  34175. /**
  34176. * Unregisters a function called before every frame render
  34177. * @param func defines the function to unregister
  34178. */
  34179. unregisterBeforeRender(func: () => void): void;
  34180. /**
  34181. * Registers a function to be called after every frame render
  34182. * @param func defines the function to register
  34183. */
  34184. registerAfterRender(func: () => void): void;
  34185. /**
  34186. * Unregisters a function called after every frame render
  34187. * @param func defines the function to unregister
  34188. */
  34189. unregisterAfterRender(func: () => void): void;
  34190. private _executeOnceBeforeRender;
  34191. /**
  34192. * The provided function will run before render once and will be disposed afterwards.
  34193. * A timeout delay can be provided so that the function will be executed in N ms.
  34194. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34195. * @param func The function to be executed.
  34196. * @param timeout optional delay in ms
  34197. */
  34198. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34199. /** @hidden */
  34200. _addPendingData(data: any): void;
  34201. /** @hidden */
  34202. _removePendingData(data: any): void;
  34203. /**
  34204. * Returns the number of items waiting to be loaded
  34205. * @returns the number of items waiting to be loaded
  34206. */
  34207. getWaitingItemsCount(): number;
  34208. /**
  34209. * Returns a boolean indicating if the scene is still loading data
  34210. */
  34211. readonly isLoading: boolean;
  34212. /**
  34213. * Registers a function to be executed when the scene is ready
  34214. * @param {Function} func - the function to be executed
  34215. */
  34216. executeWhenReady(func: () => void): void;
  34217. /**
  34218. * Returns a promise that resolves when the scene is ready
  34219. * @returns A promise that resolves when the scene is ready
  34220. */
  34221. whenReadyAsync(): Promise<void>;
  34222. /** @hidden */
  34223. _checkIsReady(): void;
  34224. /**
  34225. * Gets all animatable attached to the scene
  34226. */
  34227. readonly animatables: Animatable[];
  34228. /**
  34229. * Resets the last animation time frame.
  34230. * Useful to override when animations start running when loading a scene for the first time.
  34231. */
  34232. resetLastAnimationTimeFrame(): void;
  34233. /**
  34234. * Gets the current view matrix
  34235. * @returns a Matrix
  34236. */
  34237. getViewMatrix(): Matrix;
  34238. /**
  34239. * Gets the current projection matrix
  34240. * @returns a Matrix
  34241. */
  34242. getProjectionMatrix(): Matrix;
  34243. /**
  34244. * Gets the current transform matrix
  34245. * @returns a Matrix made of View * Projection
  34246. */
  34247. getTransformMatrix(): Matrix;
  34248. /**
  34249. * Sets the current transform matrix
  34250. * @param viewL defines the View matrix to use
  34251. * @param projectionL defines the Projection matrix to use
  34252. * @param viewR defines the right View matrix to use (if provided)
  34253. * @param projectionR defines the right Projection matrix to use (if provided)
  34254. */
  34255. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34256. /**
  34257. * Gets the uniform buffer used to store scene data
  34258. * @returns a UniformBuffer
  34259. */
  34260. getSceneUniformBuffer(): UniformBuffer;
  34261. /**
  34262. * Gets an unique (relatively to the current scene) Id
  34263. * @returns an unique number for the scene
  34264. */
  34265. getUniqueId(): number;
  34266. /**
  34267. * Add a mesh to the list of scene's meshes
  34268. * @param newMesh defines the mesh to add
  34269. * @param recursive if all child meshes should also be added to the scene
  34270. */
  34271. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34272. /**
  34273. * Remove a mesh for the list of scene's meshes
  34274. * @param toRemove defines the mesh to remove
  34275. * @param recursive if all child meshes should also be removed from the scene
  34276. * @returns the index where the mesh was in the mesh list
  34277. */
  34278. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34279. /**
  34280. * Add a transform node to the list of scene's transform nodes
  34281. * @param newTransformNode defines the transform node to add
  34282. */
  34283. addTransformNode(newTransformNode: TransformNode): void;
  34284. /**
  34285. * Remove a transform node for the list of scene's transform nodes
  34286. * @param toRemove defines the transform node to remove
  34287. * @returns the index where the transform node was in the transform node list
  34288. */
  34289. removeTransformNode(toRemove: TransformNode): number;
  34290. /**
  34291. * Remove a skeleton for the list of scene's skeletons
  34292. * @param toRemove defines the skeleton to remove
  34293. * @returns the index where the skeleton was in the skeleton list
  34294. */
  34295. removeSkeleton(toRemove: Skeleton): number;
  34296. /**
  34297. * Remove a morph target for the list of scene's morph targets
  34298. * @param toRemove defines the morph target to remove
  34299. * @returns the index where the morph target was in the morph target list
  34300. */
  34301. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34302. /**
  34303. * Remove a light for the list of scene's lights
  34304. * @param toRemove defines the light to remove
  34305. * @returns the index where the light was in the light list
  34306. */
  34307. removeLight(toRemove: Light): number;
  34308. /**
  34309. * Remove a camera for the list of scene's cameras
  34310. * @param toRemove defines the camera to remove
  34311. * @returns the index where the camera was in the camera list
  34312. */
  34313. removeCamera(toRemove: Camera): number;
  34314. /**
  34315. * Remove a particle system for the list of scene's particle systems
  34316. * @param toRemove defines the particle system to remove
  34317. * @returns the index where the particle system was in the particle system list
  34318. */
  34319. removeParticleSystem(toRemove: IParticleSystem): number;
  34320. /**
  34321. * Remove a animation for the list of scene's animations
  34322. * @param toRemove defines the animation to remove
  34323. * @returns the index where the animation was in the animation list
  34324. */
  34325. removeAnimation(toRemove: Animation): number;
  34326. /**
  34327. * Will stop the animation of the given target
  34328. * @param target - the target
  34329. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34330. * @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)
  34331. */
  34332. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34333. /**
  34334. * Removes the given animation group from this scene.
  34335. * @param toRemove The animation group to remove
  34336. * @returns The index of the removed animation group
  34337. */
  34338. removeAnimationGroup(toRemove: AnimationGroup): number;
  34339. /**
  34340. * Removes the given multi-material from this scene.
  34341. * @param toRemove The multi-material to remove
  34342. * @returns The index of the removed multi-material
  34343. */
  34344. removeMultiMaterial(toRemove: MultiMaterial): number;
  34345. /**
  34346. * Removes the given material from this scene.
  34347. * @param toRemove The material to remove
  34348. * @returns The index of the removed material
  34349. */
  34350. removeMaterial(toRemove: Material): number;
  34351. /**
  34352. * Removes the given action manager from this scene.
  34353. * @param toRemove The action manager to remove
  34354. * @returns The index of the removed action manager
  34355. */
  34356. removeActionManager(toRemove: AbstractActionManager): number;
  34357. /**
  34358. * Removes the given texture from this scene.
  34359. * @param toRemove The texture to remove
  34360. * @returns The index of the removed texture
  34361. */
  34362. removeTexture(toRemove: BaseTexture): number;
  34363. /**
  34364. * Adds the given light to this scene
  34365. * @param newLight The light to add
  34366. */
  34367. addLight(newLight: Light): void;
  34368. /**
  34369. * Sorts the list list based on light priorities
  34370. */
  34371. sortLightsByPriority(): void;
  34372. /**
  34373. * Adds the given camera to this scene
  34374. * @param newCamera The camera to add
  34375. */
  34376. addCamera(newCamera: Camera): void;
  34377. /**
  34378. * Adds the given skeleton to this scene
  34379. * @param newSkeleton The skeleton to add
  34380. */
  34381. addSkeleton(newSkeleton: Skeleton): void;
  34382. /**
  34383. * Adds the given particle system to this scene
  34384. * @param newParticleSystem The particle system to add
  34385. */
  34386. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34387. /**
  34388. * Adds the given animation to this scene
  34389. * @param newAnimation The animation to add
  34390. */
  34391. addAnimation(newAnimation: Animation): void;
  34392. /**
  34393. * Adds the given animation group to this scene.
  34394. * @param newAnimationGroup The animation group to add
  34395. */
  34396. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34397. /**
  34398. * Adds the given multi-material to this scene
  34399. * @param newMultiMaterial The multi-material to add
  34400. */
  34401. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34402. /**
  34403. * Adds the given material to this scene
  34404. * @param newMaterial The material to add
  34405. */
  34406. addMaterial(newMaterial: Material): void;
  34407. /**
  34408. * Adds the given morph target to this scene
  34409. * @param newMorphTargetManager The morph target to add
  34410. */
  34411. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34412. /**
  34413. * Adds the given geometry to this scene
  34414. * @param newGeometry The geometry to add
  34415. */
  34416. addGeometry(newGeometry: Geometry): void;
  34417. /**
  34418. * Adds the given action manager to this scene
  34419. * @param newActionManager The action manager to add
  34420. */
  34421. addActionManager(newActionManager: AbstractActionManager): void;
  34422. /**
  34423. * Adds the given texture to this scene.
  34424. * @param newTexture The texture to add
  34425. */
  34426. addTexture(newTexture: BaseTexture): void;
  34427. /**
  34428. * Switch active camera
  34429. * @param newCamera defines the new active camera
  34430. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34431. */
  34432. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34433. /**
  34434. * sets the active camera of the scene using its ID
  34435. * @param id defines the camera's ID
  34436. * @return the new active camera or null if none found.
  34437. */
  34438. setActiveCameraByID(id: string): Nullable<Camera>;
  34439. /**
  34440. * sets the active camera of the scene using its name
  34441. * @param name defines the camera's name
  34442. * @returns the new active camera or null if none found.
  34443. */
  34444. setActiveCameraByName(name: string): Nullable<Camera>;
  34445. /**
  34446. * get an animation group using its name
  34447. * @param name defines the material's name
  34448. * @return the animation group or null if none found.
  34449. */
  34450. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34451. /**
  34452. * Get a material using its unique id
  34453. * @param uniqueId defines the material's unique id
  34454. * @return the material or null if none found.
  34455. */
  34456. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34457. /**
  34458. * get a material using its id
  34459. * @param id defines the material's ID
  34460. * @return the material or null if none found.
  34461. */
  34462. getMaterialByID(id: string): Nullable<Material>;
  34463. /**
  34464. * Gets a the last added material using a given id
  34465. * @param id defines the material's ID
  34466. * @return the last material with the given id or null if none found.
  34467. */
  34468. getLastMaterialByID(id: string): Nullable<Material>;
  34469. /**
  34470. * Gets a material using its name
  34471. * @param name defines the material's name
  34472. * @return the material or null if none found.
  34473. */
  34474. getMaterialByName(name: string): Nullable<Material>;
  34475. /**
  34476. * Gets a camera using its id
  34477. * @param id defines the id to look for
  34478. * @returns the camera or null if not found
  34479. */
  34480. getCameraByID(id: string): Nullable<Camera>;
  34481. /**
  34482. * Gets a camera using its unique id
  34483. * @param uniqueId defines the unique id to look for
  34484. * @returns the camera or null if not found
  34485. */
  34486. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34487. /**
  34488. * Gets a camera using its name
  34489. * @param name defines the camera's name
  34490. * @return the camera or null if none found.
  34491. */
  34492. getCameraByName(name: string): Nullable<Camera>;
  34493. /**
  34494. * Gets a bone using its id
  34495. * @param id defines the bone's id
  34496. * @return the bone or null if not found
  34497. */
  34498. getBoneByID(id: string): Nullable<Bone>;
  34499. /**
  34500. * Gets a bone using its id
  34501. * @param name defines the bone's name
  34502. * @return the bone or null if not found
  34503. */
  34504. getBoneByName(name: string): Nullable<Bone>;
  34505. /**
  34506. * Gets a light node using its name
  34507. * @param name defines the the light's name
  34508. * @return the light or null if none found.
  34509. */
  34510. getLightByName(name: string): Nullable<Light>;
  34511. /**
  34512. * Gets a light node using its id
  34513. * @param id defines the light's id
  34514. * @return the light or null if none found.
  34515. */
  34516. getLightByID(id: string): Nullable<Light>;
  34517. /**
  34518. * Gets a light node using its scene-generated unique ID
  34519. * @param uniqueId defines the light's unique id
  34520. * @return the light or null if none found.
  34521. */
  34522. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34523. /**
  34524. * Gets a particle system by id
  34525. * @param id defines the particle system id
  34526. * @return the corresponding system or null if none found
  34527. */
  34528. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34529. /**
  34530. * Gets a geometry using its ID
  34531. * @param id defines the geometry's id
  34532. * @return the geometry or null if none found.
  34533. */
  34534. getGeometryByID(id: string): Nullable<Geometry>;
  34535. private _getGeometryByUniqueID;
  34536. /**
  34537. * Add a new geometry to this scene
  34538. * @param geometry defines the geometry to be added to the scene.
  34539. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34540. * @return a boolean defining if the geometry was added or not
  34541. */
  34542. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34543. /**
  34544. * Removes an existing geometry
  34545. * @param geometry defines the geometry to be removed from the scene
  34546. * @return a boolean defining if the geometry was removed or not
  34547. */
  34548. removeGeometry(geometry: Geometry): boolean;
  34549. /**
  34550. * Gets the list of geometries attached to the scene
  34551. * @returns an array of Geometry
  34552. */
  34553. getGeometries(): Geometry[];
  34554. /**
  34555. * Gets the first added mesh found of a given ID
  34556. * @param id defines the id to search for
  34557. * @return the mesh found or null if not found at all
  34558. */
  34559. getMeshByID(id: string): Nullable<AbstractMesh>;
  34560. /**
  34561. * Gets a list of meshes using their id
  34562. * @param id defines the id to search for
  34563. * @returns a list of meshes
  34564. */
  34565. getMeshesByID(id: string): Array<AbstractMesh>;
  34566. /**
  34567. * Gets the first added transform node found of a given ID
  34568. * @param id defines the id to search for
  34569. * @return the found transform node or null if not found at all.
  34570. */
  34571. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34572. /**
  34573. * Gets a transform node with its auto-generated unique id
  34574. * @param uniqueId efines the unique id to search for
  34575. * @return the found transform node or null if not found at all.
  34576. */
  34577. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34578. /**
  34579. * Gets a list of transform nodes using their id
  34580. * @param id defines the id to search for
  34581. * @returns a list of transform nodes
  34582. */
  34583. getTransformNodesByID(id: string): Array<TransformNode>;
  34584. /**
  34585. * Gets a mesh with its auto-generated unique id
  34586. * @param uniqueId defines the unique id to search for
  34587. * @return the found mesh or null if not found at all.
  34588. */
  34589. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34590. /**
  34591. * Gets a the last added mesh using a given id
  34592. * @param id defines the id to search for
  34593. * @return the found mesh or null if not found at all.
  34594. */
  34595. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34596. /**
  34597. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34598. * @param id defines the id to search for
  34599. * @return the found node or null if not found at all
  34600. */
  34601. getLastEntryByID(id: string): Nullable<Node>;
  34602. /**
  34603. * Gets a node (Mesh, Camera, Light) using a given id
  34604. * @param id defines the id to search for
  34605. * @return the found node or null if not found at all
  34606. */
  34607. getNodeByID(id: string): Nullable<Node>;
  34608. /**
  34609. * Gets a node (Mesh, Camera, Light) using a given name
  34610. * @param name defines the name to search for
  34611. * @return the found node or null if not found at all.
  34612. */
  34613. getNodeByName(name: string): Nullable<Node>;
  34614. /**
  34615. * Gets a mesh using a given name
  34616. * @param name defines the name to search for
  34617. * @return the found mesh or null if not found at all.
  34618. */
  34619. getMeshByName(name: string): Nullable<AbstractMesh>;
  34620. /**
  34621. * Gets a transform node using a given name
  34622. * @param name defines the name to search for
  34623. * @return the found transform node or null if not found at all.
  34624. */
  34625. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34626. /**
  34627. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34628. * @param id defines the id to search for
  34629. * @return the found skeleton or null if not found at all.
  34630. */
  34631. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34632. /**
  34633. * Gets a skeleton using a given auto generated unique id
  34634. * @param uniqueId defines the unique id to search for
  34635. * @return the found skeleton or null if not found at all.
  34636. */
  34637. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34638. /**
  34639. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34640. * @param id defines the id to search for
  34641. * @return the found skeleton or null if not found at all.
  34642. */
  34643. getSkeletonById(id: string): Nullable<Skeleton>;
  34644. /**
  34645. * Gets a skeleton using a given name
  34646. * @param name defines the name to search for
  34647. * @return the found skeleton or null if not found at all.
  34648. */
  34649. getSkeletonByName(name: string): Nullable<Skeleton>;
  34650. /**
  34651. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34652. * @param id defines the id to search for
  34653. * @return the found morph target manager or null if not found at all.
  34654. */
  34655. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34656. /**
  34657. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34658. * @param id defines the id to search for
  34659. * @return the found morph target or null if not found at all.
  34660. */
  34661. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34662. /**
  34663. * Gets a boolean indicating if the given mesh is active
  34664. * @param mesh defines the mesh to look for
  34665. * @returns true if the mesh is in the active list
  34666. */
  34667. isActiveMesh(mesh: AbstractMesh): boolean;
  34668. /**
  34669. * Return a unique id as a string which can serve as an identifier for the scene
  34670. */
  34671. readonly uid: string;
  34672. /**
  34673. * Add an externaly attached data from its key.
  34674. * This method call will fail and return false, if such key already exists.
  34675. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34676. * @param key the unique key that identifies the data
  34677. * @param data the data object to associate to the key for this Engine instance
  34678. * @return true if no such key were already present and the data was added successfully, false otherwise
  34679. */
  34680. addExternalData<T>(key: string, data: T): boolean;
  34681. /**
  34682. * Get an externaly attached data from its key
  34683. * @param key the unique key that identifies the data
  34684. * @return the associated data, if present (can be null), or undefined if not present
  34685. */
  34686. getExternalData<T>(key: string): Nullable<T>;
  34687. /**
  34688. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34689. * @param key the unique key that identifies the data
  34690. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34691. * @return the associated data, can be null if the factory returned null.
  34692. */
  34693. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34694. /**
  34695. * Remove an externaly attached data from the Engine instance
  34696. * @param key the unique key that identifies the data
  34697. * @return true if the data was successfully removed, false if it doesn't exist
  34698. */
  34699. removeExternalData(key: string): boolean;
  34700. private _evaluateSubMesh;
  34701. /**
  34702. * Clear the processed materials smart array preventing retention point in material dispose.
  34703. */
  34704. freeProcessedMaterials(): void;
  34705. private _preventFreeActiveMeshesAndRenderingGroups;
  34706. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34707. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34708. * when disposing several meshes in a row or a hierarchy of meshes.
  34709. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34710. */
  34711. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34712. /**
  34713. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34714. */
  34715. freeActiveMeshes(): void;
  34716. /**
  34717. * Clear the info related to rendering groups preventing retention points during dispose.
  34718. */
  34719. freeRenderingGroups(): void;
  34720. /** @hidden */
  34721. _isInIntermediateRendering(): boolean;
  34722. /**
  34723. * Lambda returning the list of potentially active meshes.
  34724. */
  34725. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34726. /**
  34727. * Lambda returning the list of potentially active sub meshes.
  34728. */
  34729. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34730. /**
  34731. * Lambda returning the list of potentially intersecting sub meshes.
  34732. */
  34733. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34734. /**
  34735. * Lambda returning the list of potentially colliding sub meshes.
  34736. */
  34737. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34738. private _activeMeshesFrozen;
  34739. /**
  34740. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34741. * @returns the current scene
  34742. */
  34743. freezeActiveMeshes(): Scene;
  34744. /**
  34745. * Use this function to restart evaluating active meshes on every frame
  34746. * @returns the current scene
  34747. */
  34748. unfreezeActiveMeshes(): Scene;
  34749. private _evaluateActiveMeshes;
  34750. private _activeMesh;
  34751. /**
  34752. * Update the transform matrix to update from the current active camera
  34753. * @param force defines a boolean used to force the update even if cache is up to date
  34754. */
  34755. updateTransformMatrix(force?: boolean): void;
  34756. private _bindFrameBuffer;
  34757. /** @hidden */
  34758. _allowPostProcessClearColor: boolean;
  34759. /** @hidden */
  34760. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34761. private _processSubCameras;
  34762. private _checkIntersections;
  34763. /** @hidden */
  34764. _advancePhysicsEngineStep(step: number): void;
  34765. /**
  34766. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34767. */
  34768. getDeterministicFrameTime: () => number;
  34769. /** @hidden */
  34770. _animate(): void;
  34771. /** Execute all animations (for a frame) */
  34772. animate(): void;
  34773. /**
  34774. * Render the scene
  34775. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34776. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34777. */
  34778. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34779. /**
  34780. * Freeze all materials
  34781. * A frozen material will not be updatable but should be faster to render
  34782. */
  34783. freezeMaterials(): void;
  34784. /**
  34785. * Unfreeze all materials
  34786. * A frozen material will not be updatable but should be faster to render
  34787. */
  34788. unfreezeMaterials(): void;
  34789. /**
  34790. * Releases all held ressources
  34791. */
  34792. dispose(): void;
  34793. /**
  34794. * Gets if the scene is already disposed
  34795. */
  34796. readonly isDisposed: boolean;
  34797. /**
  34798. * Call this function to reduce memory footprint of the scene.
  34799. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34800. */
  34801. clearCachedVertexData(): void;
  34802. /**
  34803. * This function will remove the local cached buffer data from texture.
  34804. * It will save memory but will prevent the texture from being rebuilt
  34805. */
  34806. cleanCachedTextureBuffer(): void;
  34807. /**
  34808. * Get the world extend vectors with an optional filter
  34809. *
  34810. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34811. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34812. */
  34813. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34814. min: Vector3;
  34815. max: Vector3;
  34816. };
  34817. /**
  34818. * Creates a ray that can be used to pick in the scene
  34819. * @param x defines the x coordinate of the origin (on-screen)
  34820. * @param y defines the y coordinate of the origin (on-screen)
  34821. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34822. * @param camera defines the camera to use for the picking
  34823. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34824. * @returns a Ray
  34825. */
  34826. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34827. /**
  34828. * Creates a ray that can be used to pick in the scene
  34829. * @param x defines the x coordinate of the origin (on-screen)
  34830. * @param y defines the y coordinate of the origin (on-screen)
  34831. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34832. * @param result defines the ray where to store the picking ray
  34833. * @param camera defines the camera to use for the picking
  34834. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34835. * @returns the current scene
  34836. */
  34837. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34838. /**
  34839. * Creates a ray that can be used to pick in the scene
  34840. * @param x defines the x coordinate of the origin (on-screen)
  34841. * @param y defines the y coordinate of the origin (on-screen)
  34842. * @param camera defines the camera to use for the picking
  34843. * @returns a Ray
  34844. */
  34845. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34846. /**
  34847. * Creates a ray that can be used to pick in the scene
  34848. * @param x defines the x coordinate of the origin (on-screen)
  34849. * @param y defines the y coordinate of the origin (on-screen)
  34850. * @param result defines the ray where to store the picking ray
  34851. * @param camera defines the camera to use for the picking
  34852. * @returns the current scene
  34853. */
  34854. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34855. /** Launch a ray to try to pick a mesh in the scene
  34856. * @param x position on screen
  34857. * @param y position on screen
  34858. * @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
  34859. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34860. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34861. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34862. * @returns a PickingInfo
  34863. */
  34864. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34865. /** Use the given ray to pick a mesh in the scene
  34866. * @param ray The ray to use to pick meshes
  34867. * @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
  34868. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34869. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34870. * @returns a PickingInfo
  34871. */
  34872. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34873. /**
  34874. * Launch a ray to try to pick a mesh in the scene
  34875. * @param x X position on screen
  34876. * @param y Y position on screen
  34877. * @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
  34878. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34879. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34880. * @returns an array of PickingInfo
  34881. */
  34882. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34883. /**
  34884. * Launch a ray to try to pick a mesh in the scene
  34885. * @param ray Ray to use
  34886. * @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
  34887. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34888. * @returns an array of PickingInfo
  34889. */
  34890. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34891. /**
  34892. * Force the value of meshUnderPointer
  34893. * @param mesh defines the mesh to use
  34894. */
  34895. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34896. /**
  34897. * Gets the mesh under the pointer
  34898. * @returns a Mesh or null if no mesh is under the pointer
  34899. */
  34900. getPointerOverMesh(): Nullable<AbstractMesh>;
  34901. /** @hidden */
  34902. _rebuildGeometries(): void;
  34903. /** @hidden */
  34904. _rebuildTextures(): void;
  34905. private _getByTags;
  34906. /**
  34907. * Get a list of meshes by tags
  34908. * @param tagsQuery defines the tags query to use
  34909. * @param forEach defines a predicate used to filter results
  34910. * @returns an array of Mesh
  34911. */
  34912. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34913. /**
  34914. * Get a list of cameras by tags
  34915. * @param tagsQuery defines the tags query to use
  34916. * @param forEach defines a predicate used to filter results
  34917. * @returns an array of Camera
  34918. */
  34919. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34920. /**
  34921. * Get a list of lights by tags
  34922. * @param tagsQuery defines the tags query to use
  34923. * @param forEach defines a predicate used to filter results
  34924. * @returns an array of Light
  34925. */
  34926. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34927. /**
  34928. * Get a list of materials by tags
  34929. * @param tagsQuery defines the tags query to use
  34930. * @param forEach defines a predicate used to filter results
  34931. * @returns an array of Material
  34932. */
  34933. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34934. /**
  34935. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34936. * This allowed control for front to back rendering or reversly depending of the special needs.
  34937. *
  34938. * @param renderingGroupId The rendering group id corresponding to its index
  34939. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34940. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34941. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34942. */
  34943. 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;
  34944. /**
  34945. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34946. *
  34947. * @param renderingGroupId The rendering group id corresponding to its index
  34948. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34949. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34950. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34951. */
  34952. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34953. /**
  34954. * Gets the current auto clear configuration for one rendering group of the rendering
  34955. * manager.
  34956. * @param index the rendering group index to get the information for
  34957. * @returns The auto clear setup for the requested rendering group
  34958. */
  34959. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34960. private _blockMaterialDirtyMechanism;
  34961. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34962. blockMaterialDirtyMechanism: boolean;
  34963. /**
  34964. * Will flag all materials as dirty to trigger new shader compilation
  34965. * @param flag defines the flag used to specify which material part must be marked as dirty
  34966. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34967. */
  34968. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34969. /** @hidden */
  34970. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34971. /** @hidden */
  34972. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34973. }
  34974. }
  34975. declare module "babylonjs/assetContainer" {
  34976. import { AbstractScene } from "babylonjs/abstractScene";
  34977. import { Scene } from "babylonjs/scene";
  34978. import { Mesh } from "babylonjs/Meshes/mesh";
  34979. /**
  34980. * Set of assets to keep when moving a scene into an asset container.
  34981. */
  34982. export class KeepAssets extends AbstractScene {
  34983. }
  34984. /**
  34985. * Container with a set of assets that can be added or removed from a scene.
  34986. */
  34987. export class AssetContainer extends AbstractScene {
  34988. /**
  34989. * The scene the AssetContainer belongs to.
  34990. */
  34991. scene: Scene;
  34992. /**
  34993. * Instantiates an AssetContainer.
  34994. * @param scene The scene the AssetContainer belongs to.
  34995. */
  34996. constructor(scene: Scene);
  34997. /**
  34998. * Adds all the assets from the container to the scene.
  34999. */
  35000. addAllToScene(): void;
  35001. /**
  35002. * Removes all the assets in the container from the scene
  35003. */
  35004. removeAllFromScene(): void;
  35005. /**
  35006. * Disposes all the assets in the container
  35007. */
  35008. dispose(): void;
  35009. private _moveAssets;
  35010. /**
  35011. * Removes all the assets contained in the scene and adds them to the container.
  35012. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35013. */
  35014. moveAllFromScene(keepAssets?: KeepAssets): void;
  35015. /**
  35016. * 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.
  35017. * @returns the root mesh
  35018. */
  35019. createRootMesh(): Mesh;
  35020. }
  35021. }
  35022. declare module "babylonjs/abstractScene" {
  35023. import { Scene } from "babylonjs/scene";
  35024. import { Nullable } from "babylonjs/types";
  35025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35026. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35027. import { Geometry } from "babylonjs/Meshes/geometry";
  35028. import { Skeleton } from "babylonjs/Bones/skeleton";
  35029. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35030. import { AssetContainer } from "babylonjs/assetContainer";
  35031. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35032. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35033. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35034. import { Material } from "babylonjs/Materials/material";
  35035. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35036. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35037. import { Camera } from "babylonjs/Cameras/camera";
  35038. import { Light } from "babylonjs/Lights/light";
  35039. import { Node } from "babylonjs/node";
  35040. import { Animation } from "babylonjs/Animations/animation";
  35041. /**
  35042. * Defines how the parser contract is defined.
  35043. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35044. */
  35045. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35046. /**
  35047. * Defines how the individual parser contract is defined.
  35048. * These parser can parse an individual asset
  35049. */
  35050. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35051. /**
  35052. * Base class of the scene acting as a container for the different elements composing a scene.
  35053. * This class is dynamically extended by the different components of the scene increasing
  35054. * flexibility and reducing coupling
  35055. */
  35056. export abstract class AbstractScene {
  35057. /**
  35058. * Stores the list of available parsers in the application.
  35059. */
  35060. private static _BabylonFileParsers;
  35061. /**
  35062. * Stores the list of available individual parsers in the application.
  35063. */
  35064. private static _IndividualBabylonFileParsers;
  35065. /**
  35066. * Adds a parser in the list of available ones
  35067. * @param name Defines the name of the parser
  35068. * @param parser Defines the parser to add
  35069. */
  35070. static AddParser(name: string, parser: BabylonFileParser): void;
  35071. /**
  35072. * Gets a general parser from the list of avaialble ones
  35073. * @param name Defines the name of the parser
  35074. * @returns the requested parser or null
  35075. */
  35076. static GetParser(name: string): Nullable<BabylonFileParser>;
  35077. /**
  35078. * Adds n individual parser in the list of available ones
  35079. * @param name Defines the name of the parser
  35080. * @param parser Defines the parser to add
  35081. */
  35082. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35083. /**
  35084. * Gets an individual parser from the list of avaialble ones
  35085. * @param name Defines the name of the parser
  35086. * @returns the requested parser or null
  35087. */
  35088. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35089. /**
  35090. * Parser json data and populate both a scene and its associated container object
  35091. * @param jsonData Defines the data to parse
  35092. * @param scene Defines the scene to parse the data for
  35093. * @param container Defines the container attached to the parsing sequence
  35094. * @param rootUrl Defines the root url of the data
  35095. */
  35096. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35097. /**
  35098. * Gets the list of root nodes (ie. nodes with no parent)
  35099. */
  35100. rootNodes: Node[];
  35101. /** All of the cameras added to this scene
  35102. * @see http://doc.babylonjs.com/babylon101/cameras
  35103. */
  35104. cameras: Camera[];
  35105. /**
  35106. * All of the lights added to this scene
  35107. * @see http://doc.babylonjs.com/babylon101/lights
  35108. */
  35109. lights: Light[];
  35110. /**
  35111. * All of the (abstract) meshes added to this scene
  35112. */
  35113. meshes: AbstractMesh[];
  35114. /**
  35115. * The list of skeletons added to the scene
  35116. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35117. */
  35118. skeletons: Skeleton[];
  35119. /**
  35120. * All of the particle systems added to this scene
  35121. * @see http://doc.babylonjs.com/babylon101/particles
  35122. */
  35123. particleSystems: IParticleSystem[];
  35124. /**
  35125. * Gets a list of Animations associated with the scene
  35126. */
  35127. animations: Animation[];
  35128. /**
  35129. * All of the animation groups added to this scene
  35130. * @see http://doc.babylonjs.com/how_to/group
  35131. */
  35132. animationGroups: AnimationGroup[];
  35133. /**
  35134. * All of the multi-materials added to this scene
  35135. * @see http://doc.babylonjs.com/how_to/multi_materials
  35136. */
  35137. multiMaterials: MultiMaterial[];
  35138. /**
  35139. * All of the materials added to this scene
  35140. * In the context of a Scene, it is not supposed to be modified manually.
  35141. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35142. * Note also that the order of the Material wihin the array is not significant and might change.
  35143. * @see http://doc.babylonjs.com/babylon101/materials
  35144. */
  35145. materials: Material[];
  35146. /**
  35147. * The list of morph target managers added to the scene
  35148. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35149. */
  35150. morphTargetManagers: MorphTargetManager[];
  35151. /**
  35152. * The list of geometries used in the scene.
  35153. */
  35154. geometries: Geometry[];
  35155. /**
  35156. * All of the tranform nodes added to this scene
  35157. * In the context of a Scene, it is not supposed to be modified manually.
  35158. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35159. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35160. * @see http://doc.babylonjs.com/how_to/transformnode
  35161. */
  35162. transformNodes: TransformNode[];
  35163. /**
  35164. * ActionManagers available on the scene.
  35165. */
  35166. actionManagers: AbstractActionManager[];
  35167. /**
  35168. * Textures to keep.
  35169. */
  35170. textures: BaseTexture[];
  35171. /**
  35172. * Environment texture for the scene
  35173. */
  35174. environmentTexture: Nullable<BaseTexture>;
  35175. }
  35176. }
  35177. declare module "babylonjs/Audio/sound" {
  35178. import { Observable } from "babylonjs/Misc/observable";
  35179. import { Vector3 } from "babylonjs/Maths/math";
  35180. import { Nullable } from "babylonjs/types";
  35181. import { Scene } from "babylonjs/scene";
  35182. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35183. /**
  35184. * Interface used to define options for Sound class
  35185. */
  35186. export interface ISoundOptions {
  35187. /**
  35188. * Does the sound autoplay once loaded.
  35189. */
  35190. autoplay?: boolean;
  35191. /**
  35192. * Does the sound loop after it finishes playing once.
  35193. */
  35194. loop?: boolean;
  35195. /**
  35196. * Sound's volume
  35197. */
  35198. volume?: number;
  35199. /**
  35200. * Is it a spatial sound?
  35201. */
  35202. spatialSound?: boolean;
  35203. /**
  35204. * Maximum distance to hear that sound
  35205. */
  35206. maxDistance?: number;
  35207. /**
  35208. * Uses user defined attenuation function
  35209. */
  35210. useCustomAttenuation?: boolean;
  35211. /**
  35212. * Define the roll off factor of spatial sounds.
  35213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35214. */
  35215. rolloffFactor?: number;
  35216. /**
  35217. * Define the reference distance the sound should be heard perfectly.
  35218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35219. */
  35220. refDistance?: number;
  35221. /**
  35222. * Define the distance attenuation model the sound will follow.
  35223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35224. */
  35225. distanceModel?: string;
  35226. /**
  35227. * Defines the playback speed (1 by default)
  35228. */
  35229. playbackRate?: number;
  35230. /**
  35231. * Defines if the sound is from a streaming source
  35232. */
  35233. streaming?: boolean;
  35234. /**
  35235. * Defines an optional length (in seconds) inside the sound file
  35236. */
  35237. length?: number;
  35238. /**
  35239. * Defines an optional offset (in seconds) inside the sound file
  35240. */
  35241. offset?: number;
  35242. /**
  35243. * If true, URLs will not be required to state the audio file codec to use.
  35244. */
  35245. skipCodecCheck?: boolean;
  35246. }
  35247. /**
  35248. * Defines a sound that can be played in the application.
  35249. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35251. */
  35252. export class Sound {
  35253. /**
  35254. * The name of the sound in the scene.
  35255. */
  35256. name: string;
  35257. /**
  35258. * Does the sound autoplay once loaded.
  35259. */
  35260. autoplay: boolean;
  35261. /**
  35262. * Does the sound loop after it finishes playing once.
  35263. */
  35264. loop: boolean;
  35265. /**
  35266. * Does the sound use a custom attenuation curve to simulate the falloff
  35267. * happening when the source gets further away from the camera.
  35268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35269. */
  35270. useCustomAttenuation: boolean;
  35271. /**
  35272. * The sound track id this sound belongs to.
  35273. */
  35274. soundTrackId: number;
  35275. /**
  35276. * Is this sound currently played.
  35277. */
  35278. isPlaying: boolean;
  35279. /**
  35280. * Is this sound currently paused.
  35281. */
  35282. isPaused: boolean;
  35283. /**
  35284. * Does this sound enables spatial sound.
  35285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35286. */
  35287. spatialSound: boolean;
  35288. /**
  35289. * Define the reference distance the sound should be heard perfectly.
  35290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35291. */
  35292. refDistance: number;
  35293. /**
  35294. * Define the roll off factor of spatial sounds.
  35295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35296. */
  35297. rolloffFactor: number;
  35298. /**
  35299. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35301. */
  35302. maxDistance: number;
  35303. /**
  35304. * Define the distance attenuation model the sound will follow.
  35305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35306. */
  35307. distanceModel: string;
  35308. /**
  35309. * @hidden
  35310. * Back Compat
  35311. **/
  35312. onended: () => any;
  35313. /**
  35314. * Observable event when the current playing sound finishes.
  35315. */
  35316. onEndedObservable: Observable<Sound>;
  35317. private _panningModel;
  35318. private _playbackRate;
  35319. private _streaming;
  35320. private _startTime;
  35321. private _startOffset;
  35322. private _position;
  35323. /** @hidden */
  35324. _positionInEmitterSpace: boolean;
  35325. private _localDirection;
  35326. private _volume;
  35327. private _isReadyToPlay;
  35328. private _isDirectional;
  35329. private _readyToPlayCallback;
  35330. private _audioBuffer;
  35331. private _soundSource;
  35332. private _streamingSource;
  35333. private _soundPanner;
  35334. private _soundGain;
  35335. private _inputAudioNode;
  35336. private _outputAudioNode;
  35337. private _coneInnerAngle;
  35338. private _coneOuterAngle;
  35339. private _coneOuterGain;
  35340. private _scene;
  35341. private _connectedTransformNode;
  35342. private _customAttenuationFunction;
  35343. private _registerFunc;
  35344. private _isOutputConnected;
  35345. private _htmlAudioElement;
  35346. private _urlType;
  35347. private _length?;
  35348. private _offset?;
  35349. /** @hidden */
  35350. static _SceneComponentInitialization: (scene: Scene) => void;
  35351. /**
  35352. * Create a sound and attach it to a scene
  35353. * @param name Name of your sound
  35354. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35355. * @param scene defines the scene the sound belongs to
  35356. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35357. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35358. */
  35359. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35360. /**
  35361. * Release the sound and its associated resources
  35362. */
  35363. dispose(): void;
  35364. /**
  35365. * Gets if the sounds is ready to be played or not.
  35366. * @returns true if ready, otherwise false
  35367. */
  35368. isReady(): boolean;
  35369. private _soundLoaded;
  35370. /**
  35371. * Sets the data of the sound from an audiobuffer
  35372. * @param audioBuffer The audioBuffer containing the data
  35373. */
  35374. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35375. /**
  35376. * Updates the current sounds options such as maxdistance, loop...
  35377. * @param options A JSON object containing values named as the object properties
  35378. */
  35379. updateOptions(options: ISoundOptions): void;
  35380. private _createSpatialParameters;
  35381. private _updateSpatialParameters;
  35382. /**
  35383. * Switch the panning model to HRTF:
  35384. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35386. */
  35387. switchPanningModelToHRTF(): void;
  35388. /**
  35389. * Switch the panning model to Equal Power:
  35390. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35391. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35392. */
  35393. switchPanningModelToEqualPower(): void;
  35394. private _switchPanningModel;
  35395. /**
  35396. * Connect this sound to a sound track audio node like gain...
  35397. * @param soundTrackAudioNode the sound track audio node to connect to
  35398. */
  35399. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35400. /**
  35401. * Transform this sound into a directional source
  35402. * @param coneInnerAngle Size of the inner cone in degree
  35403. * @param coneOuterAngle Size of the outer cone in degree
  35404. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35405. */
  35406. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35407. /**
  35408. * Gets or sets the inner angle for the directional cone.
  35409. */
  35410. /**
  35411. * Gets or sets the inner angle for the directional cone.
  35412. */
  35413. directionalConeInnerAngle: number;
  35414. /**
  35415. * Gets or sets the outer angle for the directional cone.
  35416. */
  35417. /**
  35418. * Gets or sets the outer angle for the directional cone.
  35419. */
  35420. directionalConeOuterAngle: number;
  35421. /**
  35422. * Sets the position of the emitter if spatial sound is enabled
  35423. * @param newPosition Defines the new posisiton
  35424. */
  35425. setPosition(newPosition: Vector3): void;
  35426. /**
  35427. * Sets the local direction of the emitter if spatial sound is enabled
  35428. * @param newLocalDirection Defines the new local direction
  35429. */
  35430. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35431. private _updateDirection;
  35432. /** @hidden */
  35433. updateDistanceFromListener(): void;
  35434. /**
  35435. * Sets a new custom attenuation function for the sound.
  35436. * @param callback Defines the function used for the attenuation
  35437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35438. */
  35439. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35440. /**
  35441. * Play the sound
  35442. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35443. * @param offset (optional) Start the sound at a specific time in seconds
  35444. * @param length (optional) Sound duration (in seconds)
  35445. */
  35446. play(time?: number, offset?: number, length?: number): void;
  35447. private _onended;
  35448. /**
  35449. * Stop the sound
  35450. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35451. */
  35452. stop(time?: number): void;
  35453. /**
  35454. * Put the sound in pause
  35455. */
  35456. pause(): void;
  35457. /**
  35458. * Sets a dedicated volume for this sounds
  35459. * @param newVolume Define the new volume of the sound
  35460. * @param time Define time for gradual change to new volume
  35461. */
  35462. setVolume(newVolume: number, time?: number): void;
  35463. /**
  35464. * Set the sound play back rate
  35465. * @param newPlaybackRate Define the playback rate the sound should be played at
  35466. */
  35467. setPlaybackRate(newPlaybackRate: number): void;
  35468. /**
  35469. * Gets the volume of the sound.
  35470. * @returns the volume of the sound
  35471. */
  35472. getVolume(): number;
  35473. /**
  35474. * Attach the sound to a dedicated mesh
  35475. * @param transformNode The transform node to connect the sound with
  35476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35477. */
  35478. attachToMesh(transformNode: TransformNode): void;
  35479. /**
  35480. * Detach the sound from the previously attached mesh
  35481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35482. */
  35483. detachFromMesh(): void;
  35484. private _onRegisterAfterWorldMatrixUpdate;
  35485. /**
  35486. * Clone the current sound in the scene.
  35487. * @returns the new sound clone
  35488. */
  35489. clone(): Nullable<Sound>;
  35490. /**
  35491. * Gets the current underlying audio buffer containing the data
  35492. * @returns the audio buffer
  35493. */
  35494. getAudioBuffer(): Nullable<AudioBuffer>;
  35495. /**
  35496. * Serializes the Sound in a JSON representation
  35497. * @returns the JSON representation of the sound
  35498. */
  35499. serialize(): any;
  35500. /**
  35501. * Parse a JSON representation of a sound to innstantiate in a given scene
  35502. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35503. * @param scene Define the scene the new parsed sound should be created in
  35504. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35505. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35506. * @returns the newly parsed sound
  35507. */
  35508. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35509. }
  35510. }
  35511. declare module "babylonjs/Actions/directAudioActions" {
  35512. import { Action } from "babylonjs/Actions/action";
  35513. import { Condition } from "babylonjs/Actions/condition";
  35514. import { Sound } from "babylonjs/Audio/sound";
  35515. /**
  35516. * This defines an action helpful to play a defined sound on a triggered action.
  35517. */
  35518. export class PlaySoundAction extends Action {
  35519. private _sound;
  35520. /**
  35521. * Instantiate the action
  35522. * @param triggerOptions defines the trigger options
  35523. * @param sound defines the sound to play
  35524. * @param condition defines the trigger related conditions
  35525. */
  35526. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35527. /** @hidden */
  35528. _prepare(): void;
  35529. /**
  35530. * Execute the action and play the sound.
  35531. */
  35532. execute(): void;
  35533. /**
  35534. * Serializes the actions and its related information.
  35535. * @param parent defines the object to serialize in
  35536. * @returns the serialized object
  35537. */
  35538. serialize(parent: any): any;
  35539. }
  35540. /**
  35541. * This defines an action helpful to stop a defined sound on a triggered action.
  35542. */
  35543. export class StopSoundAction extends Action {
  35544. private _sound;
  35545. /**
  35546. * Instantiate the action
  35547. * @param triggerOptions defines the trigger options
  35548. * @param sound defines the sound to stop
  35549. * @param condition defines the trigger related conditions
  35550. */
  35551. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35552. /** @hidden */
  35553. _prepare(): void;
  35554. /**
  35555. * Execute the action and stop the sound.
  35556. */
  35557. execute(): void;
  35558. /**
  35559. * Serializes the actions and its related information.
  35560. * @param parent defines the object to serialize in
  35561. * @returns the serialized object
  35562. */
  35563. serialize(parent: any): any;
  35564. }
  35565. }
  35566. declare module "babylonjs/Actions/interpolateValueAction" {
  35567. import { Action } from "babylonjs/Actions/action";
  35568. import { Condition } from "babylonjs/Actions/condition";
  35569. import { Observable } from "babylonjs/Misc/observable";
  35570. /**
  35571. * This defines an action responsible to change the value of a property
  35572. * by interpolating between its current value and the newly set one once triggered.
  35573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35574. */
  35575. export class InterpolateValueAction extends Action {
  35576. /**
  35577. * Defines the path of the property where the value should be interpolated
  35578. */
  35579. propertyPath: string;
  35580. /**
  35581. * Defines the target value at the end of the interpolation.
  35582. */
  35583. value: any;
  35584. /**
  35585. * Defines the time it will take for the property to interpolate to the value.
  35586. */
  35587. duration: number;
  35588. /**
  35589. * Defines if the other scene animations should be stopped when the action has been triggered
  35590. */
  35591. stopOtherAnimations?: boolean;
  35592. /**
  35593. * Defines a callback raised once the interpolation animation has been done.
  35594. */
  35595. onInterpolationDone?: () => void;
  35596. /**
  35597. * Observable triggered once the interpolation animation has been done.
  35598. */
  35599. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35600. private _target;
  35601. private _effectiveTarget;
  35602. private _property;
  35603. /**
  35604. * Instantiate the action
  35605. * @param triggerOptions defines the trigger options
  35606. * @param target defines the object containing the value to interpolate
  35607. * @param propertyPath defines the path to the property in the target object
  35608. * @param value defines the target value at the end of the interpolation
  35609. * @param duration deines the time it will take for the property to interpolate to the value.
  35610. * @param condition defines the trigger related conditions
  35611. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35612. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35613. */
  35614. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35615. /** @hidden */
  35616. _prepare(): void;
  35617. /**
  35618. * Execute the action starts the value interpolation.
  35619. */
  35620. execute(): void;
  35621. /**
  35622. * Serializes the actions and its related information.
  35623. * @param parent defines the object to serialize in
  35624. * @returns the serialized object
  35625. */
  35626. serialize(parent: any): any;
  35627. }
  35628. }
  35629. declare module "babylonjs/Actions/index" {
  35630. export * from "babylonjs/Actions/action";
  35631. export * from "babylonjs/Actions/actionEvent";
  35632. export * from "babylonjs/Actions/actionManager";
  35633. export * from "babylonjs/Actions/condition";
  35634. export * from "babylonjs/Actions/directActions";
  35635. export * from "babylonjs/Actions/directAudioActions";
  35636. export * from "babylonjs/Actions/interpolateValueAction";
  35637. }
  35638. declare module "babylonjs/Animations/index" {
  35639. export * from "babylonjs/Animations/animatable";
  35640. export * from "babylonjs/Animations/animation";
  35641. export * from "babylonjs/Animations/animationGroup";
  35642. export * from "babylonjs/Animations/animationPropertiesOverride";
  35643. export * from "babylonjs/Animations/easing";
  35644. export * from "babylonjs/Animations/runtimeAnimation";
  35645. export * from "babylonjs/Animations/animationEvent";
  35646. export * from "babylonjs/Animations/animationGroup";
  35647. export * from "babylonjs/Animations/animationKey";
  35648. export * from "babylonjs/Animations/animationRange";
  35649. }
  35650. declare module "babylonjs/Audio/soundTrack" {
  35651. import { Sound } from "babylonjs/Audio/sound";
  35652. import { Analyser } from "babylonjs/Audio/analyser";
  35653. import { Scene } from "babylonjs/scene";
  35654. /**
  35655. * Options allowed during the creation of a sound track.
  35656. */
  35657. export interface ISoundTrackOptions {
  35658. /**
  35659. * The volume the sound track should take during creation
  35660. */
  35661. volume?: number;
  35662. /**
  35663. * Define if the sound track is the main sound track of the scene
  35664. */
  35665. mainTrack?: boolean;
  35666. }
  35667. /**
  35668. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35669. * It will be also used in a future release to apply effects on a specific track.
  35670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35671. */
  35672. export class SoundTrack {
  35673. /**
  35674. * The unique identifier of the sound track in the scene.
  35675. */
  35676. id: number;
  35677. /**
  35678. * The list of sounds included in the sound track.
  35679. */
  35680. soundCollection: Array<Sound>;
  35681. private _outputAudioNode;
  35682. private _scene;
  35683. private _isMainTrack;
  35684. private _connectedAnalyser;
  35685. private _options;
  35686. private _isInitialized;
  35687. /**
  35688. * Creates a new sound track.
  35689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35690. * @param scene Define the scene the sound track belongs to
  35691. * @param options
  35692. */
  35693. constructor(scene: Scene, options?: ISoundTrackOptions);
  35694. private _initializeSoundTrackAudioGraph;
  35695. /**
  35696. * Release the sound track and its associated resources
  35697. */
  35698. dispose(): void;
  35699. /**
  35700. * Adds a sound to this sound track
  35701. * @param sound define the cound to add
  35702. * @ignoreNaming
  35703. */
  35704. AddSound(sound: Sound): void;
  35705. /**
  35706. * Removes a sound to this sound track
  35707. * @param sound define the cound to remove
  35708. * @ignoreNaming
  35709. */
  35710. RemoveSound(sound: Sound): void;
  35711. /**
  35712. * Set a global volume for the full sound track.
  35713. * @param newVolume Define the new volume of the sound track
  35714. */
  35715. setVolume(newVolume: number): void;
  35716. /**
  35717. * Switch the panning model to HRTF:
  35718. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35720. */
  35721. switchPanningModelToHRTF(): void;
  35722. /**
  35723. * Switch the panning model to Equal Power:
  35724. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35726. */
  35727. switchPanningModelToEqualPower(): void;
  35728. /**
  35729. * Connect the sound track to an audio analyser allowing some amazing
  35730. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35732. * @param analyser The analyser to connect to the engine
  35733. */
  35734. connectToAnalyser(analyser: Analyser): void;
  35735. }
  35736. }
  35737. declare module "babylonjs/Audio/audioSceneComponent" {
  35738. import { Sound } from "babylonjs/Audio/sound";
  35739. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35740. import { Nullable } from "babylonjs/types";
  35741. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35742. import { Scene } from "babylonjs/scene";
  35743. import { AbstractScene } from "babylonjs/abstractScene";
  35744. module "babylonjs/abstractScene" {
  35745. interface AbstractScene {
  35746. /**
  35747. * The list of sounds used in the scene.
  35748. */
  35749. sounds: Nullable<Array<Sound>>;
  35750. }
  35751. }
  35752. module "babylonjs/scene" {
  35753. interface Scene {
  35754. /**
  35755. * @hidden
  35756. * Backing field
  35757. */
  35758. _mainSoundTrack: SoundTrack;
  35759. /**
  35760. * The main sound track played by the scene.
  35761. * It cotains your primary collection of sounds.
  35762. */
  35763. mainSoundTrack: SoundTrack;
  35764. /**
  35765. * The list of sound tracks added to the scene
  35766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35767. */
  35768. soundTracks: Nullable<Array<SoundTrack>>;
  35769. /**
  35770. * Gets a sound using a given name
  35771. * @param name defines the name to search for
  35772. * @return the found sound or null if not found at all.
  35773. */
  35774. getSoundByName(name: string): Nullable<Sound>;
  35775. /**
  35776. * Gets or sets if audio support is enabled
  35777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35778. */
  35779. audioEnabled: boolean;
  35780. /**
  35781. * Gets or sets if audio will be output to headphones
  35782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35783. */
  35784. headphone: boolean;
  35785. }
  35786. }
  35787. /**
  35788. * Defines the sound scene component responsible to manage any sounds
  35789. * in a given scene.
  35790. */
  35791. export class AudioSceneComponent implements ISceneSerializableComponent {
  35792. /**
  35793. * The component name helpfull to identify the component in the list of scene components.
  35794. */
  35795. readonly name: string;
  35796. /**
  35797. * The scene the component belongs to.
  35798. */
  35799. scene: Scene;
  35800. private _audioEnabled;
  35801. /**
  35802. * Gets whether audio is enabled or not.
  35803. * Please use related enable/disable method to switch state.
  35804. */
  35805. readonly audioEnabled: boolean;
  35806. private _headphone;
  35807. /**
  35808. * Gets whether audio is outputing to headphone or not.
  35809. * Please use the according Switch methods to change output.
  35810. */
  35811. readonly headphone: boolean;
  35812. /**
  35813. * Creates a new instance of the component for the given scene
  35814. * @param scene Defines the scene to register the component in
  35815. */
  35816. constructor(scene: Scene);
  35817. /**
  35818. * Registers the component in a given scene
  35819. */
  35820. register(): void;
  35821. /**
  35822. * Rebuilds the elements related to this component in case of
  35823. * context lost for instance.
  35824. */
  35825. rebuild(): void;
  35826. /**
  35827. * Serializes the component data to the specified json object
  35828. * @param serializationObject The object to serialize to
  35829. */
  35830. serialize(serializationObject: any): void;
  35831. /**
  35832. * Adds all the elements from the container to the scene
  35833. * @param container the container holding the elements
  35834. */
  35835. addFromContainer(container: AbstractScene): void;
  35836. /**
  35837. * Removes all the elements in the container from the scene
  35838. * @param container contains the elements to remove
  35839. * @param dispose if the removed element should be disposed (default: false)
  35840. */
  35841. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35842. /**
  35843. * Disposes the component and the associated ressources.
  35844. */
  35845. dispose(): void;
  35846. /**
  35847. * Disables audio in the associated scene.
  35848. */
  35849. disableAudio(): void;
  35850. /**
  35851. * Enables audio in the associated scene.
  35852. */
  35853. enableAudio(): void;
  35854. /**
  35855. * Switch audio to headphone output.
  35856. */
  35857. switchAudioModeForHeadphones(): void;
  35858. /**
  35859. * Switch audio to normal speakers.
  35860. */
  35861. switchAudioModeForNormalSpeakers(): void;
  35862. private _afterRender;
  35863. }
  35864. }
  35865. declare module "babylonjs/Audio/weightedsound" {
  35866. import { Sound } from "babylonjs/Audio/sound";
  35867. /**
  35868. * Wraps one or more Sound objects and selects one with random weight for playback.
  35869. */
  35870. export class WeightedSound {
  35871. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35872. loop: boolean;
  35873. private _coneInnerAngle;
  35874. private _coneOuterAngle;
  35875. private _volume;
  35876. /** A Sound is currently playing. */
  35877. isPlaying: boolean;
  35878. /** A Sound is currently paused. */
  35879. isPaused: boolean;
  35880. private _sounds;
  35881. private _weights;
  35882. private _currentIndex?;
  35883. /**
  35884. * Creates a new WeightedSound from the list of sounds given.
  35885. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35886. * @param sounds Array of Sounds that will be selected from.
  35887. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35888. */
  35889. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35890. /**
  35891. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35892. */
  35893. /**
  35894. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35895. */
  35896. directionalConeInnerAngle: number;
  35897. /**
  35898. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35899. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35900. */
  35901. /**
  35902. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35903. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35904. */
  35905. directionalConeOuterAngle: number;
  35906. /**
  35907. * Playback volume.
  35908. */
  35909. /**
  35910. * Playback volume.
  35911. */
  35912. volume: number;
  35913. private _onended;
  35914. /**
  35915. * Suspend playback
  35916. */
  35917. pause(): void;
  35918. /**
  35919. * Stop playback
  35920. */
  35921. stop(): void;
  35922. /**
  35923. * Start playback.
  35924. * @param startOffset Position the clip head at a specific time in seconds.
  35925. */
  35926. play(startOffset?: number): void;
  35927. }
  35928. }
  35929. declare module "babylonjs/Audio/index" {
  35930. export * from "babylonjs/Audio/analyser";
  35931. export * from "babylonjs/Audio/audioEngine";
  35932. export * from "babylonjs/Audio/audioSceneComponent";
  35933. export * from "babylonjs/Audio/sound";
  35934. export * from "babylonjs/Audio/soundTrack";
  35935. export * from "babylonjs/Audio/weightedsound";
  35936. }
  35937. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35938. import { Behavior } from "babylonjs/Behaviors/behavior";
  35939. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35940. import { BackEase } from "babylonjs/Animations/easing";
  35941. /**
  35942. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35943. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35944. */
  35945. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35946. /**
  35947. * Gets the name of the behavior.
  35948. */
  35949. readonly name: string;
  35950. /**
  35951. * The easing function used by animations
  35952. */
  35953. static EasingFunction: BackEase;
  35954. /**
  35955. * The easing mode used by animations
  35956. */
  35957. static EasingMode: number;
  35958. /**
  35959. * The duration of the animation, in milliseconds
  35960. */
  35961. transitionDuration: number;
  35962. /**
  35963. * Length of the distance animated by the transition when lower radius is reached
  35964. */
  35965. lowerRadiusTransitionRange: number;
  35966. /**
  35967. * Length of the distance animated by the transition when upper radius is reached
  35968. */
  35969. upperRadiusTransitionRange: number;
  35970. private _autoTransitionRange;
  35971. /**
  35972. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35973. */
  35974. /**
  35975. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35976. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35977. */
  35978. autoTransitionRange: boolean;
  35979. private _attachedCamera;
  35980. private _onAfterCheckInputsObserver;
  35981. private _onMeshTargetChangedObserver;
  35982. /**
  35983. * Initializes the behavior.
  35984. */
  35985. init(): void;
  35986. /**
  35987. * Attaches the behavior to its arc rotate camera.
  35988. * @param camera Defines the camera to attach the behavior to
  35989. */
  35990. attach(camera: ArcRotateCamera): void;
  35991. /**
  35992. * Detaches the behavior from its current arc rotate camera.
  35993. */
  35994. detach(): void;
  35995. private _radiusIsAnimating;
  35996. private _radiusBounceTransition;
  35997. private _animatables;
  35998. private _cachedWheelPrecision;
  35999. /**
  36000. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36001. * @param radiusLimit The limit to check against.
  36002. * @return Bool to indicate if at limit.
  36003. */
  36004. private _isRadiusAtLimit;
  36005. /**
  36006. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36007. * @param radiusDelta The delta by which to animate to. Can be negative.
  36008. */
  36009. private _applyBoundRadiusAnimation;
  36010. /**
  36011. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36012. */
  36013. protected _clearAnimationLocks(): void;
  36014. /**
  36015. * Stops and removes all animations that have been applied to the camera
  36016. */
  36017. stopAllAnimations(): void;
  36018. }
  36019. }
  36020. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36021. import { Behavior } from "babylonjs/Behaviors/behavior";
  36022. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36023. import { ExponentialEase } from "babylonjs/Animations/easing";
  36024. import { Nullable } from "babylonjs/types";
  36025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36026. import { Vector3 } from "babylonjs/Maths/math";
  36027. /**
  36028. * 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.
  36029. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36030. */
  36031. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36032. /**
  36033. * Gets the name of the behavior.
  36034. */
  36035. readonly name: string;
  36036. private _mode;
  36037. private _radiusScale;
  36038. private _positionScale;
  36039. private _defaultElevation;
  36040. private _elevationReturnTime;
  36041. private _elevationReturnWaitTime;
  36042. private _zoomStopsAnimation;
  36043. private _framingTime;
  36044. /**
  36045. * The easing function used by animations
  36046. */
  36047. static EasingFunction: ExponentialEase;
  36048. /**
  36049. * The easing mode used by animations
  36050. */
  36051. static EasingMode: number;
  36052. /**
  36053. * Sets the current mode used by the behavior
  36054. */
  36055. /**
  36056. * Gets current mode used by the behavior.
  36057. */
  36058. mode: number;
  36059. /**
  36060. * Sets the scale applied to the radius (1 by default)
  36061. */
  36062. /**
  36063. * Gets the scale applied to the radius
  36064. */
  36065. radiusScale: number;
  36066. /**
  36067. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36068. */
  36069. /**
  36070. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36071. */
  36072. positionScale: number;
  36073. /**
  36074. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36075. * behaviour is triggered, in radians.
  36076. */
  36077. /**
  36078. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36079. * behaviour is triggered, in radians.
  36080. */
  36081. defaultElevation: number;
  36082. /**
  36083. * Sets the time (in milliseconds) taken to return to the default beta position.
  36084. * Negative value indicates camera should not return to default.
  36085. */
  36086. /**
  36087. * Gets the time (in milliseconds) taken to return to the default beta position.
  36088. * Negative value indicates camera should not return to default.
  36089. */
  36090. elevationReturnTime: number;
  36091. /**
  36092. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36093. */
  36094. /**
  36095. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36096. */
  36097. elevationReturnWaitTime: number;
  36098. /**
  36099. * Sets the flag that indicates if user zooming should stop animation.
  36100. */
  36101. /**
  36102. * Gets the flag that indicates if user zooming should stop animation.
  36103. */
  36104. zoomStopsAnimation: boolean;
  36105. /**
  36106. * Sets the transition time when framing the mesh, in milliseconds
  36107. */
  36108. /**
  36109. * Gets the transition time when framing the mesh, in milliseconds
  36110. */
  36111. framingTime: number;
  36112. /**
  36113. * Define if the behavior should automatically change the configured
  36114. * camera limits and sensibilities.
  36115. */
  36116. autoCorrectCameraLimitsAndSensibility: boolean;
  36117. private _onPrePointerObservableObserver;
  36118. private _onAfterCheckInputsObserver;
  36119. private _onMeshTargetChangedObserver;
  36120. private _attachedCamera;
  36121. private _isPointerDown;
  36122. private _lastInteractionTime;
  36123. /**
  36124. * Initializes the behavior.
  36125. */
  36126. init(): void;
  36127. /**
  36128. * Attaches the behavior to its arc rotate camera.
  36129. * @param camera Defines the camera to attach the behavior to
  36130. */
  36131. attach(camera: ArcRotateCamera): void;
  36132. /**
  36133. * Detaches the behavior from its current arc rotate camera.
  36134. */
  36135. detach(): void;
  36136. private _animatables;
  36137. private _betaIsAnimating;
  36138. private _betaTransition;
  36139. private _radiusTransition;
  36140. private _vectorTransition;
  36141. /**
  36142. * Targets the given mesh and updates zoom level accordingly.
  36143. * @param mesh The mesh to target.
  36144. * @param radius Optional. If a cached radius position already exists, overrides default.
  36145. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36146. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36147. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36148. */
  36149. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36150. /**
  36151. * Targets the given mesh with its children and updates zoom level accordingly.
  36152. * @param mesh The mesh to target.
  36153. * @param radius Optional. If a cached radius position already exists, overrides default.
  36154. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36155. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36156. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36157. */
  36158. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36159. /**
  36160. * Targets the given meshes with their children and updates zoom level accordingly.
  36161. * @param meshes The mesh to target.
  36162. * @param radius Optional. If a cached radius position already exists, overrides default.
  36163. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36164. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36165. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36166. */
  36167. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36168. /**
  36169. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36170. * @param minimumWorld Determines the smaller position of the bounding box extend
  36171. * @param maximumWorld Determines the bigger position of the bounding box extend
  36172. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36173. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36174. */
  36175. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36176. /**
  36177. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36178. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36179. * frustum width.
  36180. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36181. * to fully enclose the mesh in the viewing frustum.
  36182. */
  36183. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36184. /**
  36185. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36186. * is automatically returned to its default position (expected to be above ground plane).
  36187. */
  36188. private _maintainCameraAboveGround;
  36189. /**
  36190. * Returns the frustum slope based on the canvas ratio and camera FOV
  36191. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36192. */
  36193. private _getFrustumSlope;
  36194. /**
  36195. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36196. */
  36197. private _clearAnimationLocks;
  36198. /**
  36199. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36200. */
  36201. private _applyUserInteraction;
  36202. /**
  36203. * Stops and removes all animations that have been applied to the camera
  36204. */
  36205. stopAllAnimations(): void;
  36206. /**
  36207. * Gets a value indicating if the user is moving the camera
  36208. */
  36209. readonly isUserIsMoving: boolean;
  36210. /**
  36211. * The camera can move all the way towards the mesh.
  36212. */
  36213. static IgnoreBoundsSizeMode: number;
  36214. /**
  36215. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36216. */
  36217. static FitFrustumSidesMode: number;
  36218. }
  36219. }
  36220. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36221. import { Nullable } from "babylonjs/types";
  36222. import { Camera } from "babylonjs/Cameras/camera";
  36223. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36224. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36225. /**
  36226. * Base class for Camera Pointer Inputs.
  36227. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36228. * for example usage.
  36229. */
  36230. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36231. /**
  36232. * Defines the camera the input is attached to.
  36233. */
  36234. abstract camera: Camera;
  36235. /**
  36236. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36237. */
  36238. protected _altKey: boolean;
  36239. protected _ctrlKey: boolean;
  36240. protected _metaKey: boolean;
  36241. protected _shiftKey: boolean;
  36242. /**
  36243. * Which mouse buttons were pressed at time of last mouse event.
  36244. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36245. */
  36246. protected _buttonsPressed: number;
  36247. /**
  36248. * Defines the buttons associated with the input to handle camera move.
  36249. */
  36250. buttons: number[];
  36251. /**
  36252. * Attach the input controls to a specific dom element to get the input from.
  36253. * @param element Defines the element the controls should be listened from
  36254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36255. */
  36256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36257. /**
  36258. * Detach the current controls from the specified dom element.
  36259. * @param element Defines the element to stop listening the inputs from
  36260. */
  36261. detachControl(element: Nullable<HTMLElement>): void;
  36262. /**
  36263. * Gets the class name of the current input.
  36264. * @returns the class name
  36265. */
  36266. getClassName(): string;
  36267. /**
  36268. * Get the friendly name associated with the input class.
  36269. * @returns the input friendly name
  36270. */
  36271. getSimpleName(): string;
  36272. /**
  36273. * Called on pointer POINTERDOUBLETAP event.
  36274. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36275. */
  36276. protected onDoubleTap(type: string): void;
  36277. /**
  36278. * Called on pointer POINTERMOVE event if only a single touch is active.
  36279. * Override this method to provide functionality.
  36280. */
  36281. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36282. /**
  36283. * Called on pointer POINTERMOVE event if multiple touches are active.
  36284. * Override this method to provide functionality.
  36285. */
  36286. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36287. /**
  36288. * Called on JS contextmenu event.
  36289. * Override this method to provide functionality.
  36290. */
  36291. protected onContextMenu(evt: PointerEvent): void;
  36292. /**
  36293. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36294. * press.
  36295. * Override this method to provide functionality.
  36296. */
  36297. protected onButtonDown(evt: PointerEvent): void;
  36298. /**
  36299. * Called each time a new POINTERUP event occurs. Ie, for each button
  36300. * release.
  36301. * Override this method to provide functionality.
  36302. */
  36303. protected onButtonUp(evt: PointerEvent): void;
  36304. /**
  36305. * Called when window becomes inactive.
  36306. * Override this method to provide functionality.
  36307. */
  36308. protected onLostFocus(): void;
  36309. private _pointerInput;
  36310. private _observer;
  36311. private _onLostFocus;
  36312. private pointA;
  36313. private pointB;
  36314. }
  36315. }
  36316. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36317. import { Nullable } from "babylonjs/types";
  36318. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36319. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36320. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36321. /**
  36322. * Manage the pointers inputs to control an arc rotate camera.
  36323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36324. */
  36325. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36326. /**
  36327. * Defines the camera the input is attached to.
  36328. */
  36329. camera: ArcRotateCamera;
  36330. /**
  36331. * Gets the class name of the current input.
  36332. * @returns the class name
  36333. */
  36334. getClassName(): string;
  36335. /**
  36336. * Defines the buttons associated with the input to handle camera move.
  36337. */
  36338. buttons: number[];
  36339. /**
  36340. * Defines the pointer angular sensibility along the X axis or how fast is
  36341. * the camera rotating.
  36342. */
  36343. angularSensibilityX: number;
  36344. /**
  36345. * Defines the pointer angular sensibility along the Y axis or how fast is
  36346. * the camera rotating.
  36347. */
  36348. angularSensibilityY: number;
  36349. /**
  36350. * Defines the pointer pinch precision or how fast is the camera zooming.
  36351. */
  36352. pinchPrecision: number;
  36353. /**
  36354. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36355. * from 0.
  36356. * It defines the percentage of current camera.radius to use as delta when
  36357. * pinch zoom is used.
  36358. */
  36359. pinchDeltaPercentage: number;
  36360. /**
  36361. * Defines the pointer panning sensibility or how fast is the camera moving.
  36362. */
  36363. panningSensibility: number;
  36364. /**
  36365. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36366. */
  36367. multiTouchPanning: boolean;
  36368. /**
  36369. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36370. * zoom (pinch) through multitouch.
  36371. */
  36372. multiTouchPanAndZoom: boolean;
  36373. /**
  36374. * Revers pinch action direction.
  36375. */
  36376. pinchInwards: boolean;
  36377. private _isPanClick;
  36378. private _twoFingerActivityCount;
  36379. private _isPinching;
  36380. /**
  36381. * Called on pointer POINTERMOVE event if only a single touch is active.
  36382. */
  36383. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36384. /**
  36385. * Called on pointer POINTERDOUBLETAP event.
  36386. */
  36387. protected onDoubleTap(type: string): void;
  36388. /**
  36389. * Called on pointer POINTERMOVE event if multiple touches are active.
  36390. */
  36391. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36392. /**
  36393. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36394. * press.
  36395. */
  36396. protected onButtonDown(evt: PointerEvent): void;
  36397. /**
  36398. * Called each time a new POINTERUP event occurs. Ie, for each button
  36399. * release.
  36400. */
  36401. protected onButtonUp(evt: PointerEvent): void;
  36402. /**
  36403. * Called when window becomes inactive.
  36404. */
  36405. protected onLostFocus(): void;
  36406. }
  36407. }
  36408. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36409. import { Nullable } from "babylonjs/types";
  36410. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36411. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36412. /**
  36413. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36414. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36415. */
  36416. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36417. /**
  36418. * Defines the camera the input is attached to.
  36419. */
  36420. camera: ArcRotateCamera;
  36421. /**
  36422. * Defines the list of key codes associated with the up action (increase alpha)
  36423. */
  36424. keysUp: number[];
  36425. /**
  36426. * Defines the list of key codes associated with the down action (decrease alpha)
  36427. */
  36428. keysDown: number[];
  36429. /**
  36430. * Defines the list of key codes associated with the left action (increase beta)
  36431. */
  36432. keysLeft: number[];
  36433. /**
  36434. * Defines the list of key codes associated with the right action (decrease beta)
  36435. */
  36436. keysRight: number[];
  36437. /**
  36438. * Defines the list of key codes associated with the reset action.
  36439. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36440. */
  36441. keysReset: number[];
  36442. /**
  36443. * Defines the panning sensibility of the inputs.
  36444. * (How fast is the camera paning)
  36445. */
  36446. panningSensibility: number;
  36447. /**
  36448. * Defines the zooming sensibility of the inputs.
  36449. * (How fast is the camera zooming)
  36450. */
  36451. zoomingSensibility: number;
  36452. /**
  36453. * Defines wether maintaining the alt key down switch the movement mode from
  36454. * orientation to zoom.
  36455. */
  36456. useAltToZoom: boolean;
  36457. /**
  36458. * Rotation speed of the camera
  36459. */
  36460. angularSpeed: number;
  36461. private _keys;
  36462. private _ctrlPressed;
  36463. private _altPressed;
  36464. private _onCanvasBlurObserver;
  36465. private _onKeyboardObserver;
  36466. private _engine;
  36467. private _scene;
  36468. /**
  36469. * Attach the input controls to a specific dom element to get the input from.
  36470. * @param element Defines the element the controls should be listened from
  36471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36472. */
  36473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36474. /**
  36475. * Detach the current controls from the specified dom element.
  36476. * @param element Defines the element to stop listening the inputs from
  36477. */
  36478. detachControl(element: Nullable<HTMLElement>): void;
  36479. /**
  36480. * Update the current camera state depending on the inputs that have been used this frame.
  36481. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36482. */
  36483. checkInputs(): void;
  36484. /**
  36485. * Gets the class name of the current intput.
  36486. * @returns the class name
  36487. */
  36488. getClassName(): string;
  36489. /**
  36490. * Get the friendly name associated with the input class.
  36491. * @returns the input friendly name
  36492. */
  36493. getSimpleName(): string;
  36494. }
  36495. }
  36496. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36497. import { Nullable } from "babylonjs/types";
  36498. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36499. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36500. /**
  36501. * Manage the mouse wheel inputs to control an arc rotate camera.
  36502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36503. */
  36504. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36505. /**
  36506. * Defines the camera the input is attached to.
  36507. */
  36508. camera: ArcRotateCamera;
  36509. /**
  36510. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36511. */
  36512. wheelPrecision: number;
  36513. /**
  36514. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36515. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36516. */
  36517. wheelDeltaPercentage: number;
  36518. private _wheel;
  36519. private _observer;
  36520. private computeDeltaFromMouseWheelLegacyEvent;
  36521. /**
  36522. * Attach the input controls to a specific dom element to get the input from.
  36523. * @param element Defines the element the controls should be listened from
  36524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36525. */
  36526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36527. /**
  36528. * Detach the current controls from the specified dom element.
  36529. * @param element Defines the element to stop listening the inputs from
  36530. */
  36531. detachControl(element: Nullable<HTMLElement>): void;
  36532. /**
  36533. * Gets the class name of the current intput.
  36534. * @returns the class name
  36535. */
  36536. getClassName(): string;
  36537. /**
  36538. * Get the friendly name associated with the input class.
  36539. * @returns the input friendly name
  36540. */
  36541. getSimpleName(): string;
  36542. }
  36543. }
  36544. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36545. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36546. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36547. /**
  36548. * Default Inputs manager for the ArcRotateCamera.
  36549. * It groups all the default supported inputs for ease of use.
  36550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36551. */
  36552. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36553. /**
  36554. * Instantiates a new ArcRotateCameraInputsManager.
  36555. * @param camera Defines the camera the inputs belong to
  36556. */
  36557. constructor(camera: ArcRotateCamera);
  36558. /**
  36559. * Add mouse wheel input support to the input manager.
  36560. * @returns the current input manager
  36561. */
  36562. addMouseWheel(): ArcRotateCameraInputsManager;
  36563. /**
  36564. * Add pointers input support to the input manager.
  36565. * @returns the current input manager
  36566. */
  36567. addPointers(): ArcRotateCameraInputsManager;
  36568. /**
  36569. * Add keyboard input support to the input manager.
  36570. * @returns the current input manager
  36571. */
  36572. addKeyboard(): ArcRotateCameraInputsManager;
  36573. }
  36574. }
  36575. declare module "babylonjs/Cameras/arcRotateCamera" {
  36576. import { Observable } from "babylonjs/Misc/observable";
  36577. import { Nullable } from "babylonjs/types";
  36578. import { Scene } from "babylonjs/scene";
  36579. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36581. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36582. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36583. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36584. import { Camera } from "babylonjs/Cameras/camera";
  36585. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36586. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36587. import { Collider } from "babylonjs/Collisions/collider";
  36588. /**
  36589. * This represents an orbital type of camera.
  36590. *
  36591. * 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.
  36592. * 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.
  36593. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36594. */
  36595. export class ArcRotateCamera extends TargetCamera {
  36596. /**
  36597. * Defines the rotation angle of the camera along the longitudinal axis.
  36598. */
  36599. alpha: number;
  36600. /**
  36601. * Defines the rotation angle of the camera along the latitudinal axis.
  36602. */
  36603. beta: number;
  36604. /**
  36605. * Defines the radius of the camera from it s target point.
  36606. */
  36607. radius: number;
  36608. protected _target: Vector3;
  36609. protected _targetHost: Nullable<AbstractMesh>;
  36610. /**
  36611. * Defines the target point of the camera.
  36612. * The camera looks towards it form the radius distance.
  36613. */
  36614. target: Vector3;
  36615. /**
  36616. * Define the current local position of the camera in the scene
  36617. */
  36618. position: Vector3;
  36619. protected _upVector: Vector3;
  36620. protected _upToYMatrix: Matrix;
  36621. protected _YToUpMatrix: Matrix;
  36622. /**
  36623. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36624. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36625. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36626. */
  36627. upVector: Vector3;
  36628. /**
  36629. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36630. */
  36631. setMatUp(): void;
  36632. /**
  36633. * Current inertia value on the longitudinal axis.
  36634. * The bigger this number the longer it will take for the camera to stop.
  36635. */
  36636. inertialAlphaOffset: number;
  36637. /**
  36638. * Current inertia value on the latitudinal axis.
  36639. * The bigger this number the longer it will take for the camera to stop.
  36640. */
  36641. inertialBetaOffset: number;
  36642. /**
  36643. * Current inertia value on the radius axis.
  36644. * The bigger this number the longer it will take for the camera to stop.
  36645. */
  36646. inertialRadiusOffset: number;
  36647. /**
  36648. * Minimum allowed angle on the longitudinal axis.
  36649. * This can help limiting how the Camera is able to move in the scene.
  36650. */
  36651. lowerAlphaLimit: Nullable<number>;
  36652. /**
  36653. * Maximum allowed angle on the longitudinal axis.
  36654. * This can help limiting how the Camera is able to move in the scene.
  36655. */
  36656. upperAlphaLimit: Nullable<number>;
  36657. /**
  36658. * Minimum allowed angle on the latitudinal axis.
  36659. * This can help limiting how the Camera is able to move in the scene.
  36660. */
  36661. lowerBetaLimit: number;
  36662. /**
  36663. * Maximum allowed angle on the latitudinal axis.
  36664. * This can help limiting how the Camera is able to move in the scene.
  36665. */
  36666. upperBetaLimit: number;
  36667. /**
  36668. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36669. * This can help limiting how the Camera is able to move in the scene.
  36670. */
  36671. lowerRadiusLimit: Nullable<number>;
  36672. /**
  36673. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36674. * This can help limiting how the Camera is able to move in the scene.
  36675. */
  36676. upperRadiusLimit: Nullable<number>;
  36677. /**
  36678. * Defines the current inertia value used during panning of the camera along the X axis.
  36679. */
  36680. inertialPanningX: number;
  36681. /**
  36682. * Defines the current inertia value used during panning of the camera along the Y axis.
  36683. */
  36684. inertialPanningY: number;
  36685. /**
  36686. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36687. * Basically if your fingers moves away from more than this distance you will be considered
  36688. * in pinch mode.
  36689. */
  36690. pinchToPanMaxDistance: number;
  36691. /**
  36692. * Defines the maximum distance the camera can pan.
  36693. * This could help keeping the cammera always in your scene.
  36694. */
  36695. panningDistanceLimit: Nullable<number>;
  36696. /**
  36697. * Defines the target of the camera before paning.
  36698. */
  36699. panningOriginTarget: Vector3;
  36700. /**
  36701. * Defines the value of the inertia used during panning.
  36702. * 0 would mean stop inertia and one would mean no decelleration at all.
  36703. */
  36704. panningInertia: number;
  36705. /**
  36706. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36707. */
  36708. angularSensibilityX: number;
  36709. /**
  36710. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36711. */
  36712. angularSensibilityY: number;
  36713. /**
  36714. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36715. */
  36716. pinchPrecision: number;
  36717. /**
  36718. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36719. * It will be used instead of pinchDeltaPrecision if different from 0.
  36720. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36721. */
  36722. pinchDeltaPercentage: number;
  36723. /**
  36724. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36725. */
  36726. panningSensibility: number;
  36727. /**
  36728. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36729. */
  36730. keysUp: number[];
  36731. /**
  36732. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36733. */
  36734. keysDown: number[];
  36735. /**
  36736. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36737. */
  36738. keysLeft: number[];
  36739. /**
  36740. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36741. */
  36742. keysRight: number[];
  36743. /**
  36744. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36745. */
  36746. wheelPrecision: number;
  36747. /**
  36748. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36749. * It will be used instead of pinchDeltaPrecision if different from 0.
  36750. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36751. */
  36752. wheelDeltaPercentage: number;
  36753. /**
  36754. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36755. */
  36756. zoomOnFactor: number;
  36757. /**
  36758. * Defines a screen offset for the camera position.
  36759. */
  36760. targetScreenOffset: Vector2;
  36761. /**
  36762. * Allows the camera to be completely reversed.
  36763. * If false the camera can not arrive upside down.
  36764. */
  36765. allowUpsideDown: boolean;
  36766. /**
  36767. * Define if double tap/click is used to restore the previously saved state of the camera.
  36768. */
  36769. useInputToRestoreState: boolean;
  36770. /** @hidden */
  36771. _viewMatrix: Matrix;
  36772. /** @hidden */
  36773. _useCtrlForPanning: boolean;
  36774. /** @hidden */
  36775. _panningMouseButton: number;
  36776. /**
  36777. * Defines the input associated to the camera.
  36778. */
  36779. inputs: ArcRotateCameraInputsManager;
  36780. /** @hidden */
  36781. _reset: () => void;
  36782. /**
  36783. * Defines the allowed panning axis.
  36784. */
  36785. panningAxis: Vector3;
  36786. protected _localDirection: Vector3;
  36787. protected _transformedDirection: Vector3;
  36788. private _bouncingBehavior;
  36789. /**
  36790. * Gets the bouncing behavior of the camera if it has been enabled.
  36791. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36792. */
  36793. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36794. /**
  36795. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36796. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36797. */
  36798. useBouncingBehavior: boolean;
  36799. private _framingBehavior;
  36800. /**
  36801. * Gets the framing behavior of the camera if it has been enabled.
  36802. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36803. */
  36804. readonly framingBehavior: Nullable<FramingBehavior>;
  36805. /**
  36806. * Defines if the framing behavior of the camera is enabled on the camera.
  36807. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36808. */
  36809. useFramingBehavior: boolean;
  36810. private _autoRotationBehavior;
  36811. /**
  36812. * Gets the auto rotation behavior of the camera if it has been enabled.
  36813. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36814. */
  36815. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36816. /**
  36817. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36818. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36819. */
  36820. useAutoRotationBehavior: boolean;
  36821. /**
  36822. * Observable triggered when the mesh target has been changed on the camera.
  36823. */
  36824. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36825. /**
  36826. * Event raised when the camera is colliding with a mesh.
  36827. */
  36828. onCollide: (collidedMesh: AbstractMesh) => void;
  36829. /**
  36830. * Defines whether the camera should check collision with the objects oh the scene.
  36831. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36832. */
  36833. checkCollisions: boolean;
  36834. /**
  36835. * Defines the collision radius of the camera.
  36836. * This simulates a sphere around the camera.
  36837. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36838. */
  36839. collisionRadius: Vector3;
  36840. protected _collider: Collider;
  36841. protected _previousPosition: Vector3;
  36842. protected _collisionVelocity: Vector3;
  36843. protected _newPosition: Vector3;
  36844. protected _previousAlpha: number;
  36845. protected _previousBeta: number;
  36846. protected _previousRadius: number;
  36847. protected _collisionTriggered: boolean;
  36848. protected _targetBoundingCenter: Nullable<Vector3>;
  36849. private _computationVector;
  36850. /**
  36851. * Instantiates a new ArcRotateCamera in a given scene
  36852. * @param name Defines the name of the camera
  36853. * @param alpha Defines the camera rotation along the logitudinal axis
  36854. * @param beta Defines the camera rotation along the latitudinal axis
  36855. * @param radius Defines the camera distance from its target
  36856. * @param target Defines the camera target
  36857. * @param scene Defines the scene the camera belongs to
  36858. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36859. */
  36860. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36861. /** @hidden */
  36862. _initCache(): void;
  36863. /** @hidden */
  36864. _updateCache(ignoreParentClass?: boolean): void;
  36865. protected _getTargetPosition(): Vector3;
  36866. private _storedAlpha;
  36867. private _storedBeta;
  36868. private _storedRadius;
  36869. private _storedTarget;
  36870. /**
  36871. * Stores the current state of the camera (alpha, beta, radius and target)
  36872. * @returns the camera itself
  36873. */
  36874. storeState(): Camera;
  36875. /**
  36876. * @hidden
  36877. * Restored camera state. You must call storeState() first
  36878. */
  36879. _restoreStateValues(): boolean;
  36880. /** @hidden */
  36881. _isSynchronizedViewMatrix(): boolean;
  36882. /**
  36883. * Attached controls to the current camera.
  36884. * @param element Defines the element the controls should be listened from
  36885. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36886. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36887. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36888. */
  36889. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36890. /**
  36891. * Detach the current controls from the camera.
  36892. * The camera will stop reacting to inputs.
  36893. * @param element Defines the element to stop listening the inputs from
  36894. */
  36895. detachControl(element: HTMLElement): void;
  36896. /** @hidden */
  36897. _checkInputs(): void;
  36898. protected _checkLimits(): void;
  36899. /**
  36900. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36901. */
  36902. rebuildAnglesAndRadius(): void;
  36903. /**
  36904. * Use a position to define the current camera related information like aplha, beta and radius
  36905. * @param position Defines the position to set the camera at
  36906. */
  36907. setPosition(position: Vector3): void;
  36908. /**
  36909. * Defines the target the camera should look at.
  36910. * This will automatically adapt alpha beta and radius to fit within the new target.
  36911. * @param target Defines the new target as a Vector or a mesh
  36912. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36913. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36914. */
  36915. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36916. /** @hidden */
  36917. _getViewMatrix(): Matrix;
  36918. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36919. /**
  36920. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36921. * @param meshes Defines the mesh to zoom on
  36922. * @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)
  36923. */
  36924. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36925. /**
  36926. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36927. * The target will be changed but the radius
  36928. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36929. * @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)
  36930. */
  36931. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36932. min: Vector3;
  36933. max: Vector3;
  36934. distance: number;
  36935. }, doNotUpdateMaxZ?: boolean): void;
  36936. /**
  36937. * @override
  36938. * Override Camera.createRigCamera
  36939. */
  36940. createRigCamera(name: string, cameraIndex: number): Camera;
  36941. /**
  36942. * @hidden
  36943. * @override
  36944. * Override Camera._updateRigCameras
  36945. */
  36946. _updateRigCameras(): void;
  36947. /**
  36948. * Destroy the camera and release the current resources hold by it.
  36949. */
  36950. dispose(): void;
  36951. /**
  36952. * Gets the current object class name.
  36953. * @return the class name
  36954. */
  36955. getClassName(): string;
  36956. }
  36957. }
  36958. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36959. import { Behavior } from "babylonjs/Behaviors/behavior";
  36960. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36961. /**
  36962. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36963. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36964. */
  36965. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36966. /**
  36967. * Gets the name of the behavior.
  36968. */
  36969. readonly name: string;
  36970. private _zoomStopsAnimation;
  36971. private _idleRotationSpeed;
  36972. private _idleRotationWaitTime;
  36973. private _idleRotationSpinupTime;
  36974. /**
  36975. * Sets the flag that indicates if user zooming should stop animation.
  36976. */
  36977. /**
  36978. * Gets the flag that indicates if user zooming should stop animation.
  36979. */
  36980. zoomStopsAnimation: boolean;
  36981. /**
  36982. * Sets the default speed at which the camera rotates around the model.
  36983. */
  36984. /**
  36985. * Gets the default speed at which the camera rotates around the model.
  36986. */
  36987. idleRotationSpeed: number;
  36988. /**
  36989. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36990. */
  36991. /**
  36992. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36993. */
  36994. idleRotationWaitTime: number;
  36995. /**
  36996. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36997. */
  36998. /**
  36999. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37000. */
  37001. idleRotationSpinupTime: number;
  37002. /**
  37003. * Gets a value indicating if the camera is currently rotating because of this behavior
  37004. */
  37005. readonly rotationInProgress: boolean;
  37006. private _onPrePointerObservableObserver;
  37007. private _onAfterCheckInputsObserver;
  37008. private _attachedCamera;
  37009. private _isPointerDown;
  37010. private _lastFrameTime;
  37011. private _lastInteractionTime;
  37012. private _cameraRotationSpeed;
  37013. /**
  37014. * Initializes the behavior.
  37015. */
  37016. init(): void;
  37017. /**
  37018. * Attaches the behavior to its arc rotate camera.
  37019. * @param camera Defines the camera to attach the behavior to
  37020. */
  37021. attach(camera: ArcRotateCamera): void;
  37022. /**
  37023. * Detaches the behavior from its current arc rotate camera.
  37024. */
  37025. detach(): void;
  37026. /**
  37027. * Returns true if user is scrolling.
  37028. * @return true if user is scrolling.
  37029. */
  37030. private _userIsZooming;
  37031. private _lastFrameRadius;
  37032. private _shouldAnimationStopForInteraction;
  37033. /**
  37034. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37035. */
  37036. private _applyUserInteraction;
  37037. private _userIsMoving;
  37038. }
  37039. }
  37040. declare module "babylonjs/Behaviors/Cameras/index" {
  37041. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37042. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37043. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37044. }
  37045. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37046. import { Mesh } from "babylonjs/Meshes/mesh";
  37047. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37048. import { Behavior } from "babylonjs/Behaviors/behavior";
  37049. /**
  37050. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37051. */
  37052. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37053. private ui;
  37054. /**
  37055. * The name of the behavior
  37056. */
  37057. name: string;
  37058. /**
  37059. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37060. */
  37061. distanceAwayFromFace: number;
  37062. /**
  37063. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37064. */
  37065. distanceAwayFromBottomOfFace: number;
  37066. private _faceVectors;
  37067. private _target;
  37068. private _scene;
  37069. private _onRenderObserver;
  37070. private _tmpMatrix;
  37071. private _tmpVector;
  37072. /**
  37073. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37074. * @param ui The transform node that should be attched to the mesh
  37075. */
  37076. constructor(ui: TransformNode);
  37077. /**
  37078. * Initializes the behavior
  37079. */
  37080. init(): void;
  37081. private _closestFace;
  37082. private _zeroVector;
  37083. private _lookAtTmpMatrix;
  37084. private _lookAtToRef;
  37085. /**
  37086. * Attaches the AttachToBoxBehavior to the passed in mesh
  37087. * @param target The mesh that the specified node will be attached to
  37088. */
  37089. attach(target: Mesh): void;
  37090. /**
  37091. * Detaches the behavior from the mesh
  37092. */
  37093. detach(): void;
  37094. }
  37095. }
  37096. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37097. import { Behavior } from "babylonjs/Behaviors/behavior";
  37098. import { Mesh } from "babylonjs/Meshes/mesh";
  37099. /**
  37100. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37101. */
  37102. export class FadeInOutBehavior implements Behavior<Mesh> {
  37103. /**
  37104. * Time in milliseconds to delay before fading in (Default: 0)
  37105. */
  37106. delay: number;
  37107. /**
  37108. * Time in milliseconds for the mesh to fade in (Default: 300)
  37109. */
  37110. fadeInTime: number;
  37111. private _millisecondsPerFrame;
  37112. private _hovered;
  37113. private _hoverValue;
  37114. private _ownerNode;
  37115. /**
  37116. * Instatiates the FadeInOutBehavior
  37117. */
  37118. constructor();
  37119. /**
  37120. * The name of the behavior
  37121. */
  37122. readonly name: string;
  37123. /**
  37124. * Initializes the behavior
  37125. */
  37126. init(): void;
  37127. /**
  37128. * Attaches the fade behavior on the passed in mesh
  37129. * @param ownerNode The mesh that will be faded in/out once attached
  37130. */
  37131. attach(ownerNode: Mesh): void;
  37132. /**
  37133. * Detaches the behavior from the mesh
  37134. */
  37135. detach(): void;
  37136. /**
  37137. * Triggers the mesh to begin fading in or out
  37138. * @param value if the object should fade in or out (true to fade in)
  37139. */
  37140. fadeIn(value: boolean): void;
  37141. private _update;
  37142. private _setAllVisibility;
  37143. }
  37144. }
  37145. declare module "babylonjs/Misc/pivotTools" {
  37146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37147. /**
  37148. * Class containing a set of static utilities functions for managing Pivots
  37149. * @hidden
  37150. */
  37151. export class PivotTools {
  37152. private static _PivotCached;
  37153. private static _OldPivotPoint;
  37154. private static _PivotTranslation;
  37155. private static _PivotTmpVector;
  37156. /** @hidden */
  37157. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37158. /** @hidden */
  37159. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37160. }
  37161. }
  37162. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37163. import { Scene } from "babylonjs/scene";
  37164. import { Vector4, Plane } from "babylonjs/Maths/math";
  37165. import { Mesh } from "babylonjs/Meshes/mesh";
  37166. import { Nullable } from "babylonjs/types";
  37167. /**
  37168. * Class containing static functions to help procedurally build meshes
  37169. */
  37170. export class PlaneBuilder {
  37171. /**
  37172. * Creates a plane mesh
  37173. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37174. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37175. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37179. * @param name defines the name of the mesh
  37180. * @param options defines the options used to create the mesh
  37181. * @param scene defines the hosting scene
  37182. * @returns the plane mesh
  37183. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37184. */
  37185. static CreatePlane(name: string, options: {
  37186. size?: number;
  37187. width?: number;
  37188. height?: number;
  37189. sideOrientation?: number;
  37190. frontUVs?: Vector4;
  37191. backUVs?: Vector4;
  37192. updatable?: boolean;
  37193. sourcePlane?: Plane;
  37194. }, scene?: Nullable<Scene>): Mesh;
  37195. }
  37196. }
  37197. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37198. import { Behavior } from "babylonjs/Behaviors/behavior";
  37199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37200. import { Observable } from "babylonjs/Misc/observable";
  37201. import { Vector3 } from "babylonjs/Maths/math";
  37202. import { Ray } from "babylonjs/Culling/ray";
  37203. import "babylonjs/Meshes/Builders/planeBuilder";
  37204. /**
  37205. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37206. */
  37207. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37208. private static _AnyMouseID;
  37209. /**
  37210. * Abstract mesh the behavior is set on
  37211. */
  37212. attachedNode: AbstractMesh;
  37213. private _dragPlane;
  37214. private _scene;
  37215. private _pointerObserver;
  37216. private _beforeRenderObserver;
  37217. private static _planeScene;
  37218. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37219. /**
  37220. * 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)
  37221. */
  37222. maxDragAngle: number;
  37223. /**
  37224. * @hidden
  37225. */
  37226. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37227. /**
  37228. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37229. */
  37230. currentDraggingPointerID: number;
  37231. /**
  37232. * The last position where the pointer hit the drag plane in world space
  37233. */
  37234. lastDragPosition: Vector3;
  37235. /**
  37236. * If the behavior is currently in a dragging state
  37237. */
  37238. dragging: boolean;
  37239. /**
  37240. * 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)
  37241. */
  37242. dragDeltaRatio: number;
  37243. /**
  37244. * If the drag plane orientation should be updated during the dragging (Default: true)
  37245. */
  37246. updateDragPlane: boolean;
  37247. private _debugMode;
  37248. private _moving;
  37249. /**
  37250. * Fires each time the attached mesh is dragged with the pointer
  37251. * * delta between last drag position and current drag position in world space
  37252. * * dragDistance along the drag axis
  37253. * * dragPlaneNormal normal of the current drag plane used during the drag
  37254. * * dragPlanePoint in world space where the drag intersects the drag plane
  37255. */
  37256. onDragObservable: Observable<{
  37257. delta: Vector3;
  37258. dragPlanePoint: Vector3;
  37259. dragPlaneNormal: Vector3;
  37260. dragDistance: number;
  37261. pointerId: number;
  37262. }>;
  37263. /**
  37264. * Fires each time a drag begins (eg. mouse down on mesh)
  37265. */
  37266. onDragStartObservable: Observable<{
  37267. dragPlanePoint: Vector3;
  37268. pointerId: number;
  37269. }>;
  37270. /**
  37271. * Fires each time a drag ends (eg. mouse release after drag)
  37272. */
  37273. onDragEndObservable: Observable<{
  37274. dragPlanePoint: Vector3;
  37275. pointerId: number;
  37276. }>;
  37277. /**
  37278. * If the attached mesh should be moved when dragged
  37279. */
  37280. moveAttached: boolean;
  37281. /**
  37282. * If the drag behavior will react to drag events (Default: true)
  37283. */
  37284. enabled: boolean;
  37285. /**
  37286. * If pointer events should start and release the drag (Default: true)
  37287. */
  37288. startAndReleaseDragOnPointerEvents: boolean;
  37289. /**
  37290. * If camera controls should be detached during the drag
  37291. */
  37292. detachCameraControls: boolean;
  37293. /**
  37294. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37295. */
  37296. useObjectOrienationForDragging: boolean;
  37297. private _options;
  37298. /**
  37299. * Creates a pointer drag behavior that can be attached to a mesh
  37300. * @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)
  37301. */
  37302. constructor(options?: {
  37303. dragAxis?: Vector3;
  37304. dragPlaneNormal?: Vector3;
  37305. });
  37306. /**
  37307. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37308. */
  37309. validateDrag: (targetPosition: Vector3) => boolean;
  37310. /**
  37311. * The name of the behavior
  37312. */
  37313. readonly name: string;
  37314. /**
  37315. * Initializes the behavior
  37316. */
  37317. init(): void;
  37318. private _tmpVector;
  37319. private _alternatePickedPoint;
  37320. private _worldDragAxis;
  37321. private _targetPosition;
  37322. private _attachedElement;
  37323. /**
  37324. * Attaches the drag behavior the passed in mesh
  37325. * @param ownerNode The mesh that will be dragged around once attached
  37326. */
  37327. attach(ownerNode: AbstractMesh): void;
  37328. /**
  37329. * Force relase the drag action by code.
  37330. */
  37331. releaseDrag(): void;
  37332. private _startDragRay;
  37333. private _lastPointerRay;
  37334. /**
  37335. * Simulates the start of a pointer drag event on the behavior
  37336. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37337. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37338. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37339. */
  37340. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37341. private _startDrag;
  37342. private _dragDelta;
  37343. private _moveDrag;
  37344. private _pickWithRayOnDragPlane;
  37345. private _pointA;
  37346. private _pointB;
  37347. private _pointC;
  37348. private _lineA;
  37349. private _lineB;
  37350. private _localAxis;
  37351. private _lookAt;
  37352. private _updateDragPlanePosition;
  37353. /**
  37354. * Detaches the behavior from the mesh
  37355. */
  37356. detach(): void;
  37357. }
  37358. }
  37359. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37360. import { Mesh } from "babylonjs/Meshes/mesh";
  37361. import { Behavior } from "babylonjs/Behaviors/behavior";
  37362. /**
  37363. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37364. */
  37365. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37366. private _dragBehaviorA;
  37367. private _dragBehaviorB;
  37368. private _startDistance;
  37369. private _initialScale;
  37370. private _targetScale;
  37371. private _ownerNode;
  37372. private _sceneRenderObserver;
  37373. /**
  37374. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37375. */
  37376. constructor();
  37377. /**
  37378. * The name of the behavior
  37379. */
  37380. readonly name: string;
  37381. /**
  37382. * Initializes the behavior
  37383. */
  37384. init(): void;
  37385. private _getCurrentDistance;
  37386. /**
  37387. * Attaches the scale behavior the passed in mesh
  37388. * @param ownerNode The mesh that will be scaled around once attached
  37389. */
  37390. attach(ownerNode: Mesh): void;
  37391. /**
  37392. * Detaches the behavior from the mesh
  37393. */
  37394. detach(): void;
  37395. }
  37396. }
  37397. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37398. import { Behavior } from "babylonjs/Behaviors/behavior";
  37399. import { Mesh } from "babylonjs/Meshes/mesh";
  37400. import { Observable } from "babylonjs/Misc/observable";
  37401. /**
  37402. * 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
  37403. */
  37404. export class SixDofDragBehavior implements Behavior<Mesh> {
  37405. private static _virtualScene;
  37406. private _ownerNode;
  37407. private _sceneRenderObserver;
  37408. private _scene;
  37409. private _targetPosition;
  37410. private _virtualOriginMesh;
  37411. private _virtualDragMesh;
  37412. private _pointerObserver;
  37413. private _moving;
  37414. private _startingOrientation;
  37415. /**
  37416. * 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)
  37417. */
  37418. private zDragFactor;
  37419. /**
  37420. * If the object should rotate to face the drag origin
  37421. */
  37422. rotateDraggedObject: boolean;
  37423. /**
  37424. * If the behavior is currently in a dragging state
  37425. */
  37426. dragging: boolean;
  37427. /**
  37428. * 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)
  37429. */
  37430. dragDeltaRatio: number;
  37431. /**
  37432. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37433. */
  37434. currentDraggingPointerID: number;
  37435. /**
  37436. * If camera controls should be detached during the drag
  37437. */
  37438. detachCameraControls: boolean;
  37439. /**
  37440. * Fires each time a drag starts
  37441. */
  37442. onDragStartObservable: Observable<{}>;
  37443. /**
  37444. * Fires each time a drag ends (eg. mouse release after drag)
  37445. */
  37446. onDragEndObservable: Observable<{}>;
  37447. /**
  37448. * 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
  37449. */
  37450. constructor();
  37451. /**
  37452. * The name of the behavior
  37453. */
  37454. readonly name: string;
  37455. /**
  37456. * Initializes the behavior
  37457. */
  37458. init(): void;
  37459. /**
  37460. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37461. */
  37462. private readonly _pointerCamera;
  37463. /**
  37464. * Attaches the scale behavior the passed in mesh
  37465. * @param ownerNode The mesh that will be scaled around once attached
  37466. */
  37467. attach(ownerNode: Mesh): void;
  37468. /**
  37469. * Detaches the behavior from the mesh
  37470. */
  37471. detach(): void;
  37472. }
  37473. }
  37474. declare module "babylonjs/Behaviors/Meshes/index" {
  37475. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37476. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37477. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37478. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37479. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37480. }
  37481. declare module "babylonjs/Behaviors/index" {
  37482. export * from "babylonjs/Behaviors/behavior";
  37483. export * from "babylonjs/Behaviors/Cameras/index";
  37484. export * from "babylonjs/Behaviors/Meshes/index";
  37485. }
  37486. declare module "babylonjs/Bones/boneIKController" {
  37487. import { Bone } from "babylonjs/Bones/bone";
  37488. import { Vector3 } from "babylonjs/Maths/math";
  37489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37490. import { Nullable } from "babylonjs/types";
  37491. /**
  37492. * Class used to apply inverse kinematics to bones
  37493. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37494. */
  37495. export class BoneIKController {
  37496. private static _tmpVecs;
  37497. private static _tmpQuat;
  37498. private static _tmpMats;
  37499. /**
  37500. * Gets or sets the target mesh
  37501. */
  37502. targetMesh: AbstractMesh;
  37503. /** Gets or sets the mesh used as pole */
  37504. poleTargetMesh: AbstractMesh;
  37505. /**
  37506. * Gets or sets the bone used as pole
  37507. */
  37508. poleTargetBone: Nullable<Bone>;
  37509. /**
  37510. * Gets or sets the target position
  37511. */
  37512. targetPosition: Vector3;
  37513. /**
  37514. * Gets or sets the pole target position
  37515. */
  37516. poleTargetPosition: Vector3;
  37517. /**
  37518. * Gets or sets the pole target local offset
  37519. */
  37520. poleTargetLocalOffset: Vector3;
  37521. /**
  37522. * Gets or sets the pole angle
  37523. */
  37524. poleAngle: number;
  37525. /**
  37526. * Gets or sets the mesh associated with the controller
  37527. */
  37528. mesh: AbstractMesh;
  37529. /**
  37530. * 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)
  37531. */
  37532. slerpAmount: number;
  37533. private _bone1Quat;
  37534. private _bone1Mat;
  37535. private _bone2Ang;
  37536. private _bone1;
  37537. private _bone2;
  37538. private _bone1Length;
  37539. private _bone2Length;
  37540. private _maxAngle;
  37541. private _maxReach;
  37542. private _rightHandedSystem;
  37543. private _bendAxis;
  37544. private _slerping;
  37545. private _adjustRoll;
  37546. /**
  37547. * Gets or sets maximum allowed angle
  37548. */
  37549. maxAngle: number;
  37550. /**
  37551. * Creates a new BoneIKController
  37552. * @param mesh defines the mesh to control
  37553. * @param bone defines the bone to control
  37554. * @param options defines options to set up the controller
  37555. */
  37556. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37557. targetMesh?: AbstractMesh;
  37558. poleTargetMesh?: AbstractMesh;
  37559. poleTargetBone?: Bone;
  37560. poleTargetLocalOffset?: Vector3;
  37561. poleAngle?: number;
  37562. bendAxis?: Vector3;
  37563. maxAngle?: number;
  37564. slerpAmount?: number;
  37565. });
  37566. private _setMaxAngle;
  37567. /**
  37568. * Force the controller to update the bones
  37569. */
  37570. update(): void;
  37571. }
  37572. }
  37573. declare module "babylonjs/Bones/boneLookController" {
  37574. import { Vector3, Space } from "babylonjs/Maths/math";
  37575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37576. import { Bone } from "babylonjs/Bones/bone";
  37577. /**
  37578. * Class used to make a bone look toward a point in space
  37579. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37580. */
  37581. export class BoneLookController {
  37582. private static _tmpVecs;
  37583. private static _tmpQuat;
  37584. private static _tmpMats;
  37585. /**
  37586. * The target Vector3 that the bone will look at
  37587. */
  37588. target: Vector3;
  37589. /**
  37590. * The mesh that the bone is attached to
  37591. */
  37592. mesh: AbstractMesh;
  37593. /**
  37594. * The bone that will be looking to the target
  37595. */
  37596. bone: Bone;
  37597. /**
  37598. * The up axis of the coordinate system that is used when the bone is rotated
  37599. */
  37600. upAxis: Vector3;
  37601. /**
  37602. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37603. */
  37604. upAxisSpace: Space;
  37605. /**
  37606. * Used to make an adjustment to the yaw of the bone
  37607. */
  37608. adjustYaw: number;
  37609. /**
  37610. * Used to make an adjustment to the pitch of the bone
  37611. */
  37612. adjustPitch: number;
  37613. /**
  37614. * Used to make an adjustment to the roll of the bone
  37615. */
  37616. adjustRoll: number;
  37617. /**
  37618. * 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)
  37619. */
  37620. slerpAmount: number;
  37621. private _minYaw;
  37622. private _maxYaw;
  37623. private _minPitch;
  37624. private _maxPitch;
  37625. private _minYawSin;
  37626. private _minYawCos;
  37627. private _maxYawSin;
  37628. private _maxYawCos;
  37629. private _midYawConstraint;
  37630. private _minPitchTan;
  37631. private _maxPitchTan;
  37632. private _boneQuat;
  37633. private _slerping;
  37634. private _transformYawPitch;
  37635. private _transformYawPitchInv;
  37636. private _firstFrameSkipped;
  37637. private _yawRange;
  37638. private _fowardAxis;
  37639. /**
  37640. * Gets or sets the minimum yaw angle that the bone can look to
  37641. */
  37642. minYaw: number;
  37643. /**
  37644. * Gets or sets the maximum yaw angle that the bone can look to
  37645. */
  37646. maxYaw: number;
  37647. /**
  37648. * Gets or sets the minimum pitch angle that the bone can look to
  37649. */
  37650. minPitch: number;
  37651. /**
  37652. * Gets or sets the maximum pitch angle that the bone can look to
  37653. */
  37654. maxPitch: number;
  37655. /**
  37656. * Create a BoneLookController
  37657. * @param mesh the mesh that the bone belongs to
  37658. * @param bone the bone that will be looking to the target
  37659. * @param target the target Vector3 to look at
  37660. * @param options optional settings:
  37661. * * maxYaw: the maximum angle the bone will yaw to
  37662. * * minYaw: the minimum angle the bone will yaw to
  37663. * * maxPitch: the maximum angle the bone will pitch to
  37664. * * minPitch: the minimum angle the bone will yaw to
  37665. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37666. * * upAxis: the up axis of the coordinate system
  37667. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37668. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37669. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37670. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37671. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37672. * * adjustRoll: used to make an adjustment to the roll of the bone
  37673. **/
  37674. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37675. maxYaw?: number;
  37676. minYaw?: number;
  37677. maxPitch?: number;
  37678. minPitch?: number;
  37679. slerpAmount?: number;
  37680. upAxis?: Vector3;
  37681. upAxisSpace?: Space;
  37682. yawAxis?: Vector3;
  37683. pitchAxis?: Vector3;
  37684. adjustYaw?: number;
  37685. adjustPitch?: number;
  37686. adjustRoll?: number;
  37687. });
  37688. /**
  37689. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37690. */
  37691. update(): void;
  37692. private _getAngleDiff;
  37693. private _getAngleBetween;
  37694. private _isAngleBetween;
  37695. }
  37696. }
  37697. declare module "babylonjs/Bones/index" {
  37698. export * from "babylonjs/Bones/bone";
  37699. export * from "babylonjs/Bones/boneIKController";
  37700. export * from "babylonjs/Bones/boneLookController";
  37701. export * from "babylonjs/Bones/skeleton";
  37702. }
  37703. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37704. import { Nullable } from "babylonjs/types";
  37705. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37706. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37707. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37708. /**
  37709. * Manage the gamepad inputs to control an arc rotate camera.
  37710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37711. */
  37712. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37713. /**
  37714. * Defines the camera the input is attached to.
  37715. */
  37716. camera: ArcRotateCamera;
  37717. /**
  37718. * Defines the gamepad the input is gathering event from.
  37719. */
  37720. gamepad: Nullable<Gamepad>;
  37721. /**
  37722. * Defines the gamepad rotation sensiblity.
  37723. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37724. */
  37725. gamepadRotationSensibility: number;
  37726. /**
  37727. * Defines the gamepad move sensiblity.
  37728. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37729. */
  37730. gamepadMoveSensibility: number;
  37731. private _onGamepadConnectedObserver;
  37732. private _onGamepadDisconnectedObserver;
  37733. /**
  37734. * Attach the input controls to a specific dom element to get the input from.
  37735. * @param element Defines the element the controls should be listened from
  37736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37737. */
  37738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37739. /**
  37740. * Detach the current controls from the specified dom element.
  37741. * @param element Defines the element to stop listening the inputs from
  37742. */
  37743. detachControl(element: Nullable<HTMLElement>): void;
  37744. /**
  37745. * Update the current camera state depending on the inputs that have been used this frame.
  37746. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37747. */
  37748. checkInputs(): void;
  37749. /**
  37750. * Gets the class name of the current intput.
  37751. * @returns the class name
  37752. */
  37753. getClassName(): string;
  37754. /**
  37755. * Get the friendly name associated with the input class.
  37756. * @returns the input friendly name
  37757. */
  37758. getSimpleName(): string;
  37759. }
  37760. }
  37761. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37762. import { Nullable } from "babylonjs/types";
  37763. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37764. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37765. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37766. interface ArcRotateCameraInputsManager {
  37767. /**
  37768. * Add orientation input support to the input manager.
  37769. * @returns the current input manager
  37770. */
  37771. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37772. }
  37773. }
  37774. /**
  37775. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37777. */
  37778. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37779. /**
  37780. * Defines the camera the input is attached to.
  37781. */
  37782. camera: ArcRotateCamera;
  37783. /**
  37784. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37785. */
  37786. alphaCorrection: number;
  37787. /**
  37788. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37789. */
  37790. gammaCorrection: number;
  37791. private _alpha;
  37792. private _gamma;
  37793. private _dirty;
  37794. private _deviceOrientationHandler;
  37795. /**
  37796. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37797. */
  37798. constructor();
  37799. /**
  37800. * Attach the input controls to a specific dom element to get the input from.
  37801. * @param element Defines the element the controls should be listened from
  37802. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37803. */
  37804. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37805. /** @hidden */
  37806. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37807. /**
  37808. * Update the current camera state depending on the inputs that have been used this frame.
  37809. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37810. */
  37811. checkInputs(): void;
  37812. /**
  37813. * Detach the current controls from the specified dom element.
  37814. * @param element Defines the element to stop listening the inputs from
  37815. */
  37816. detachControl(element: Nullable<HTMLElement>): void;
  37817. /**
  37818. * Gets the class name of the current intput.
  37819. * @returns the class name
  37820. */
  37821. getClassName(): string;
  37822. /**
  37823. * Get the friendly name associated with the input class.
  37824. * @returns the input friendly name
  37825. */
  37826. getSimpleName(): string;
  37827. }
  37828. }
  37829. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37830. import { Nullable } from "babylonjs/types";
  37831. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37832. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37833. /**
  37834. * Listen to mouse events to control the camera.
  37835. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37836. */
  37837. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37838. /**
  37839. * Defines the camera the input is attached to.
  37840. */
  37841. camera: FlyCamera;
  37842. /**
  37843. * Defines if touch is enabled. (Default is true.)
  37844. */
  37845. touchEnabled: boolean;
  37846. /**
  37847. * Defines the buttons associated with the input to handle camera rotation.
  37848. */
  37849. buttons: number[];
  37850. /**
  37851. * Assign buttons for Yaw control.
  37852. */
  37853. buttonsYaw: number[];
  37854. /**
  37855. * Assign buttons for Pitch control.
  37856. */
  37857. buttonsPitch: number[];
  37858. /**
  37859. * Assign buttons for Roll control.
  37860. */
  37861. buttonsRoll: number[];
  37862. /**
  37863. * Detect if any button is being pressed while mouse is moved.
  37864. * -1 = Mouse locked.
  37865. * 0 = Left button.
  37866. * 1 = Middle Button.
  37867. * 2 = Right Button.
  37868. */
  37869. activeButton: number;
  37870. /**
  37871. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37872. * Higher values reduce its sensitivity.
  37873. */
  37874. angularSensibility: number;
  37875. private _mousemoveCallback;
  37876. private _observer;
  37877. private _rollObserver;
  37878. private previousPosition;
  37879. private noPreventDefault;
  37880. private element;
  37881. /**
  37882. * Listen to mouse events to control the camera.
  37883. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37884. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37885. */
  37886. constructor(touchEnabled?: boolean);
  37887. /**
  37888. * Attach the mouse control to the HTML DOM element.
  37889. * @param element Defines the element that listens to the input events.
  37890. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37891. */
  37892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37893. /**
  37894. * Detach the current controls from the specified dom element.
  37895. * @param element Defines the element to stop listening the inputs from
  37896. */
  37897. detachControl(element: Nullable<HTMLElement>): void;
  37898. /**
  37899. * Gets the class name of the current input.
  37900. * @returns the class name.
  37901. */
  37902. getClassName(): string;
  37903. /**
  37904. * Get the friendly name associated with the input class.
  37905. * @returns the input's friendly name.
  37906. */
  37907. getSimpleName(): string;
  37908. private _pointerInput;
  37909. private _onMouseMove;
  37910. /**
  37911. * Rotate camera by mouse offset.
  37912. */
  37913. private rotateCamera;
  37914. }
  37915. }
  37916. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37917. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37918. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37919. /**
  37920. * Default Inputs manager for the FlyCamera.
  37921. * It groups all the default supported inputs for ease of use.
  37922. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37923. */
  37924. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37925. /**
  37926. * Instantiates a new FlyCameraInputsManager.
  37927. * @param camera Defines the camera the inputs belong to.
  37928. */
  37929. constructor(camera: FlyCamera);
  37930. /**
  37931. * Add keyboard input support to the input manager.
  37932. * @returns the new FlyCameraKeyboardMoveInput().
  37933. */
  37934. addKeyboard(): FlyCameraInputsManager;
  37935. /**
  37936. * Add mouse input support to the input manager.
  37937. * @param touchEnabled Enable touch screen support.
  37938. * @returns the new FlyCameraMouseInput().
  37939. */
  37940. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37941. }
  37942. }
  37943. declare module "babylonjs/Cameras/flyCamera" {
  37944. import { Scene } from "babylonjs/scene";
  37945. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37947. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37948. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37949. /**
  37950. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37951. * such as in a 3D Space Shooter or a Flight Simulator.
  37952. */
  37953. export class FlyCamera extends TargetCamera {
  37954. /**
  37955. * Define the collision ellipsoid of the camera.
  37956. * This is helpful for simulating a camera body, like a player's body.
  37957. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37958. */
  37959. ellipsoid: Vector3;
  37960. /**
  37961. * Define an offset for the position of the ellipsoid around the camera.
  37962. * This can be helpful if the camera is attached away from the player's body center,
  37963. * such as at its head.
  37964. */
  37965. ellipsoidOffset: Vector3;
  37966. /**
  37967. * Enable or disable collisions of the camera with the rest of the scene objects.
  37968. */
  37969. checkCollisions: boolean;
  37970. /**
  37971. * Enable or disable gravity on the camera.
  37972. */
  37973. applyGravity: boolean;
  37974. /**
  37975. * Define the current direction the camera is moving to.
  37976. */
  37977. cameraDirection: Vector3;
  37978. /**
  37979. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37980. * This overrides and empties cameraRotation.
  37981. */
  37982. rotationQuaternion: Quaternion;
  37983. /**
  37984. * Track Roll to maintain the wanted Rolling when looking around.
  37985. */
  37986. _trackRoll: number;
  37987. /**
  37988. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37989. */
  37990. rollCorrect: number;
  37991. /**
  37992. * Mimic a banked turn, Rolling the camera when Yawing.
  37993. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37994. */
  37995. bankedTurn: boolean;
  37996. /**
  37997. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37998. */
  37999. bankedTurnLimit: number;
  38000. /**
  38001. * Value of 0 disables the banked Roll.
  38002. * Value of 1 is equal to the Yaw angle in radians.
  38003. */
  38004. bankedTurnMultiplier: number;
  38005. /**
  38006. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38007. */
  38008. inputs: FlyCameraInputsManager;
  38009. /**
  38010. * Gets the input sensibility for mouse input.
  38011. * Higher values reduce sensitivity.
  38012. */
  38013. /**
  38014. * Sets the input sensibility for a mouse input.
  38015. * Higher values reduce sensitivity.
  38016. */
  38017. angularSensibility: number;
  38018. /**
  38019. * Get the keys for camera movement forward.
  38020. */
  38021. /**
  38022. * Set the keys for camera movement forward.
  38023. */
  38024. keysForward: number[];
  38025. /**
  38026. * Get the keys for camera movement backward.
  38027. */
  38028. keysBackward: number[];
  38029. /**
  38030. * Get the keys for camera movement up.
  38031. */
  38032. /**
  38033. * Set the keys for camera movement up.
  38034. */
  38035. keysUp: number[];
  38036. /**
  38037. * Get the keys for camera movement down.
  38038. */
  38039. /**
  38040. * Set the keys for camera movement down.
  38041. */
  38042. keysDown: number[];
  38043. /**
  38044. * Get the keys for camera movement left.
  38045. */
  38046. /**
  38047. * Set the keys for camera movement left.
  38048. */
  38049. keysLeft: number[];
  38050. /**
  38051. * Set the keys for camera movement right.
  38052. */
  38053. /**
  38054. * Set the keys for camera movement right.
  38055. */
  38056. keysRight: number[];
  38057. /**
  38058. * Event raised when the camera collides with a mesh in the scene.
  38059. */
  38060. onCollide: (collidedMesh: AbstractMesh) => void;
  38061. private _collider;
  38062. private _needMoveForGravity;
  38063. private _oldPosition;
  38064. private _diffPosition;
  38065. private _newPosition;
  38066. /** @hidden */
  38067. _localDirection: Vector3;
  38068. /** @hidden */
  38069. _transformedDirection: Vector3;
  38070. /**
  38071. * Instantiates a FlyCamera.
  38072. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38073. * such as in a 3D Space Shooter or a Flight Simulator.
  38074. * @param name Define the name of the camera in the scene.
  38075. * @param position Define the starting position of the camera in the scene.
  38076. * @param scene Define the scene the camera belongs to.
  38077. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38078. */
  38079. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38080. /**
  38081. * Attach a control to the HTML DOM element.
  38082. * @param element Defines the element that listens to the input events.
  38083. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38084. */
  38085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38086. /**
  38087. * Detach a control from the HTML DOM element.
  38088. * The camera will stop reacting to that input.
  38089. * @param element Defines the element that listens to the input events.
  38090. */
  38091. detachControl(element: HTMLElement): void;
  38092. private _collisionMask;
  38093. /**
  38094. * Get the mask that the camera ignores in collision events.
  38095. */
  38096. /**
  38097. * Set the mask that the camera ignores in collision events.
  38098. */
  38099. collisionMask: number;
  38100. /** @hidden */
  38101. _collideWithWorld(displacement: Vector3): void;
  38102. /** @hidden */
  38103. private _onCollisionPositionChange;
  38104. /** @hidden */
  38105. _checkInputs(): void;
  38106. /** @hidden */
  38107. _decideIfNeedsToMove(): boolean;
  38108. /** @hidden */
  38109. _updatePosition(): void;
  38110. /**
  38111. * Restore the Roll to its target value at the rate specified.
  38112. * @param rate - Higher means slower restoring.
  38113. * @hidden
  38114. */
  38115. restoreRoll(rate: number): void;
  38116. /**
  38117. * Destroy the camera and release the current resources held by it.
  38118. */
  38119. dispose(): void;
  38120. /**
  38121. * Get the current object class name.
  38122. * @returns the class name.
  38123. */
  38124. getClassName(): string;
  38125. }
  38126. }
  38127. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38128. import { Nullable } from "babylonjs/types";
  38129. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38130. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38131. /**
  38132. * Listen to keyboard events to control the camera.
  38133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38134. */
  38135. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38136. /**
  38137. * Defines the camera the input is attached to.
  38138. */
  38139. camera: FlyCamera;
  38140. /**
  38141. * The list of keyboard keys used to control the forward move of the camera.
  38142. */
  38143. keysForward: number[];
  38144. /**
  38145. * The list of keyboard keys used to control the backward move of the camera.
  38146. */
  38147. keysBackward: number[];
  38148. /**
  38149. * The list of keyboard keys used to control the forward move of the camera.
  38150. */
  38151. keysUp: number[];
  38152. /**
  38153. * The list of keyboard keys used to control the backward move of the camera.
  38154. */
  38155. keysDown: number[];
  38156. /**
  38157. * The list of keyboard keys used to control the right strafe move of the camera.
  38158. */
  38159. keysRight: number[];
  38160. /**
  38161. * The list of keyboard keys used to control the left strafe move of the camera.
  38162. */
  38163. keysLeft: number[];
  38164. private _keys;
  38165. private _onCanvasBlurObserver;
  38166. private _onKeyboardObserver;
  38167. private _engine;
  38168. private _scene;
  38169. /**
  38170. * Attach the input controls to a specific dom element to get the input from.
  38171. * @param element Defines the element the controls should be listened from
  38172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38173. */
  38174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38175. /**
  38176. * Detach the current controls from the specified dom element.
  38177. * @param element Defines the element to stop listening the inputs from
  38178. */
  38179. detachControl(element: Nullable<HTMLElement>): void;
  38180. /**
  38181. * Gets the class name of the current intput.
  38182. * @returns the class name
  38183. */
  38184. getClassName(): string;
  38185. /** @hidden */
  38186. _onLostFocus(e: FocusEvent): void;
  38187. /**
  38188. * Get the friendly name associated with the input class.
  38189. * @returns the input friendly name
  38190. */
  38191. getSimpleName(): string;
  38192. /**
  38193. * Update the current camera state depending on the inputs that have been used this frame.
  38194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38195. */
  38196. checkInputs(): void;
  38197. }
  38198. }
  38199. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38200. import { Nullable } from "babylonjs/types";
  38201. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38202. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38203. /**
  38204. * Manage the mouse wheel inputs to control a follow camera.
  38205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38206. */
  38207. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38208. /**
  38209. * Defines the camera the input is attached to.
  38210. */
  38211. camera: FollowCamera;
  38212. /**
  38213. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38214. */
  38215. axisControlRadius: boolean;
  38216. /**
  38217. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38218. */
  38219. axisControlHeight: boolean;
  38220. /**
  38221. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38222. */
  38223. axisControlRotation: boolean;
  38224. /**
  38225. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38226. * relation to mouseWheel events.
  38227. */
  38228. wheelPrecision: number;
  38229. /**
  38230. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38231. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38232. */
  38233. wheelDeltaPercentage: number;
  38234. private _wheel;
  38235. private _observer;
  38236. /**
  38237. * Attach the input controls to a specific dom element to get the input from.
  38238. * @param element Defines the element the controls should be listened from
  38239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38240. */
  38241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38242. /**
  38243. * Detach the current controls from the specified dom element.
  38244. * @param element Defines the element to stop listening the inputs from
  38245. */
  38246. detachControl(element: Nullable<HTMLElement>): void;
  38247. /**
  38248. * Gets the class name of the current intput.
  38249. * @returns the class name
  38250. */
  38251. getClassName(): string;
  38252. /**
  38253. * Get the friendly name associated with the input class.
  38254. * @returns the input friendly name
  38255. */
  38256. getSimpleName(): string;
  38257. }
  38258. }
  38259. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38260. import { Nullable } from "babylonjs/types";
  38261. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38262. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38263. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38264. /**
  38265. * Manage the pointers inputs to control an follow camera.
  38266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38267. */
  38268. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38269. /**
  38270. * Defines the camera the input is attached to.
  38271. */
  38272. camera: FollowCamera;
  38273. /**
  38274. * Gets the class name of the current input.
  38275. * @returns the class name
  38276. */
  38277. getClassName(): string;
  38278. /**
  38279. * Defines the pointer angular sensibility along the X axis or how fast is
  38280. * the camera rotating.
  38281. * A negative number will reverse the axis direction.
  38282. */
  38283. angularSensibilityX: number;
  38284. /**
  38285. * Defines the pointer angular sensibility along the Y axis or how fast is
  38286. * the camera rotating.
  38287. * A negative number will reverse the axis direction.
  38288. */
  38289. angularSensibilityY: number;
  38290. /**
  38291. * Defines the pointer pinch precision or how fast is the camera zooming.
  38292. * A negative number will reverse the axis direction.
  38293. */
  38294. pinchPrecision: number;
  38295. /**
  38296. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38297. * from 0.
  38298. * It defines the percentage of current camera.radius to use as delta when
  38299. * pinch zoom is used.
  38300. */
  38301. pinchDeltaPercentage: number;
  38302. /**
  38303. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38304. */
  38305. axisXControlRadius: boolean;
  38306. /**
  38307. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38308. */
  38309. axisXControlHeight: boolean;
  38310. /**
  38311. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38312. */
  38313. axisXControlRotation: boolean;
  38314. /**
  38315. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38316. */
  38317. axisYControlRadius: boolean;
  38318. /**
  38319. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38320. */
  38321. axisYControlHeight: boolean;
  38322. /**
  38323. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38324. */
  38325. axisYControlRotation: boolean;
  38326. /**
  38327. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38328. */
  38329. axisPinchControlRadius: boolean;
  38330. /**
  38331. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38332. */
  38333. axisPinchControlHeight: boolean;
  38334. /**
  38335. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38336. */
  38337. axisPinchControlRotation: boolean;
  38338. /**
  38339. * Log error messages if basic misconfiguration has occurred.
  38340. */
  38341. warningEnable: boolean;
  38342. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38343. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38344. private _warningCounter;
  38345. private _warning;
  38346. }
  38347. }
  38348. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38349. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38350. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38351. /**
  38352. * Default Inputs manager for the FollowCamera.
  38353. * It groups all the default supported inputs for ease of use.
  38354. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38355. */
  38356. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38357. /**
  38358. * Instantiates a new FollowCameraInputsManager.
  38359. * @param camera Defines the camera the inputs belong to
  38360. */
  38361. constructor(camera: FollowCamera);
  38362. /**
  38363. * Add keyboard input support to the input manager.
  38364. * @returns the current input manager
  38365. */
  38366. addKeyboard(): FollowCameraInputsManager;
  38367. /**
  38368. * Add mouse wheel input support to the input manager.
  38369. * @returns the current input manager
  38370. */
  38371. addMouseWheel(): FollowCameraInputsManager;
  38372. /**
  38373. * Add pointers input support to the input manager.
  38374. * @returns the current input manager
  38375. */
  38376. addPointers(): FollowCameraInputsManager;
  38377. /**
  38378. * Add orientation input support to the input manager.
  38379. * @returns the current input manager
  38380. */
  38381. addVRDeviceOrientation(): FollowCameraInputsManager;
  38382. }
  38383. }
  38384. declare module "babylonjs/Cameras/followCamera" {
  38385. import { Nullable } from "babylonjs/types";
  38386. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38387. import { Scene } from "babylonjs/scene";
  38388. import { Vector3 } from "babylonjs/Maths/math";
  38389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38390. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38391. /**
  38392. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38393. * an arc rotate version arcFollowCamera are available.
  38394. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38395. */
  38396. export class FollowCamera extends TargetCamera {
  38397. /**
  38398. * Distance the follow camera should follow an object at
  38399. */
  38400. radius: number;
  38401. /**
  38402. * Minimum allowed distance of the camera to the axis of rotation
  38403. * (The camera can not get closer).
  38404. * This can help limiting how the Camera is able to move in the scene.
  38405. */
  38406. lowerRadiusLimit: Nullable<number>;
  38407. /**
  38408. * Maximum allowed distance of the camera to the axis of rotation
  38409. * (The camera can not get further).
  38410. * This can help limiting how the Camera is able to move in the scene.
  38411. */
  38412. upperRadiusLimit: Nullable<number>;
  38413. /**
  38414. * Define a rotation offset between the camera and the object it follows
  38415. */
  38416. rotationOffset: number;
  38417. /**
  38418. * Minimum allowed angle to camera position relative to target object.
  38419. * This can help limiting how the Camera is able to move in the scene.
  38420. */
  38421. lowerRotationOffsetLimit: Nullable<number>;
  38422. /**
  38423. * Maximum allowed angle to camera position relative to target object.
  38424. * This can help limiting how the Camera is able to move in the scene.
  38425. */
  38426. upperRotationOffsetLimit: Nullable<number>;
  38427. /**
  38428. * Define a height offset between the camera and the object it follows.
  38429. * It can help following an object from the top (like a car chaing a plane)
  38430. */
  38431. heightOffset: number;
  38432. /**
  38433. * Minimum allowed height of camera position relative to target object.
  38434. * This can help limiting how the Camera is able to move in the scene.
  38435. */
  38436. lowerHeightOffsetLimit: Nullable<number>;
  38437. /**
  38438. * Maximum allowed height of camera position relative to target object.
  38439. * This can help limiting how the Camera is able to move in the scene.
  38440. */
  38441. upperHeightOffsetLimit: Nullable<number>;
  38442. /**
  38443. * Define how fast the camera can accelerate to follow it s target.
  38444. */
  38445. cameraAcceleration: number;
  38446. /**
  38447. * Define the speed limit of the camera following an object.
  38448. */
  38449. maxCameraSpeed: number;
  38450. /**
  38451. * Define the target of the camera.
  38452. */
  38453. lockedTarget: Nullable<AbstractMesh>;
  38454. /**
  38455. * Defines the input associated with the camera.
  38456. */
  38457. inputs: FollowCameraInputsManager;
  38458. /**
  38459. * Instantiates the follow camera.
  38460. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38461. * @param name Define the name of the camera in the scene
  38462. * @param position Define the position of the camera
  38463. * @param scene Define the scene the camera belong to
  38464. * @param lockedTarget Define the target of the camera
  38465. */
  38466. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38467. private _follow;
  38468. /**
  38469. * Attached controls to the current camera.
  38470. * @param element Defines the element the controls should be listened from
  38471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38472. */
  38473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38474. /**
  38475. * Detach the current controls from the camera.
  38476. * The camera will stop reacting to inputs.
  38477. * @param element Defines the element to stop listening the inputs from
  38478. */
  38479. detachControl(element: HTMLElement): void;
  38480. /** @hidden */
  38481. _checkInputs(): void;
  38482. private _checkLimits;
  38483. /**
  38484. * Gets the camera class name.
  38485. * @returns the class name
  38486. */
  38487. getClassName(): string;
  38488. }
  38489. /**
  38490. * Arc Rotate version of the follow camera.
  38491. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38492. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38493. */
  38494. export class ArcFollowCamera extends TargetCamera {
  38495. /** The longitudinal angle of the camera */
  38496. alpha: number;
  38497. /** The latitudinal angle of the camera */
  38498. beta: number;
  38499. /** The radius of the camera from its target */
  38500. radius: number;
  38501. /** Define the camera target (the messh it should follow) */
  38502. target: Nullable<AbstractMesh>;
  38503. private _cartesianCoordinates;
  38504. /**
  38505. * Instantiates a new ArcFollowCamera
  38506. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38507. * @param name Define the name of the camera
  38508. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38509. * @param beta Define the rotation angle of the camera around the elevation axis
  38510. * @param radius Define the radius of the camera from its target point
  38511. * @param target Define the target of the camera
  38512. * @param scene Define the scene the camera belongs to
  38513. */
  38514. constructor(name: string,
  38515. /** The longitudinal angle of the camera */
  38516. alpha: number,
  38517. /** The latitudinal angle of the camera */
  38518. beta: number,
  38519. /** The radius of the camera from its target */
  38520. radius: number,
  38521. /** Define the camera target (the messh it should follow) */
  38522. target: Nullable<AbstractMesh>, scene: Scene);
  38523. private _follow;
  38524. /** @hidden */
  38525. _checkInputs(): void;
  38526. /**
  38527. * Returns the class name of the object.
  38528. * It is mostly used internally for serialization purposes.
  38529. */
  38530. getClassName(): string;
  38531. }
  38532. }
  38533. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38534. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38535. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38536. import { Nullable } from "babylonjs/types";
  38537. /**
  38538. * Manage the keyboard inputs to control the movement of a follow camera.
  38539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38540. */
  38541. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38542. /**
  38543. * Defines the camera the input is attached to.
  38544. */
  38545. camera: FollowCamera;
  38546. /**
  38547. * Defines the list of key codes associated with the up action (increase heightOffset)
  38548. */
  38549. keysHeightOffsetIncr: number[];
  38550. /**
  38551. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38552. */
  38553. keysHeightOffsetDecr: number[];
  38554. /**
  38555. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38556. */
  38557. keysHeightOffsetModifierAlt: boolean;
  38558. /**
  38559. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38560. */
  38561. keysHeightOffsetModifierCtrl: boolean;
  38562. /**
  38563. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38564. */
  38565. keysHeightOffsetModifierShift: boolean;
  38566. /**
  38567. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38568. */
  38569. keysRotationOffsetIncr: number[];
  38570. /**
  38571. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38572. */
  38573. keysRotationOffsetDecr: number[];
  38574. /**
  38575. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38576. */
  38577. keysRotationOffsetModifierAlt: boolean;
  38578. /**
  38579. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38580. */
  38581. keysRotationOffsetModifierCtrl: boolean;
  38582. /**
  38583. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38584. */
  38585. keysRotationOffsetModifierShift: boolean;
  38586. /**
  38587. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38588. */
  38589. keysRadiusIncr: number[];
  38590. /**
  38591. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38592. */
  38593. keysRadiusDecr: number[];
  38594. /**
  38595. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38596. */
  38597. keysRadiusModifierAlt: boolean;
  38598. /**
  38599. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38600. */
  38601. keysRadiusModifierCtrl: boolean;
  38602. /**
  38603. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38604. */
  38605. keysRadiusModifierShift: boolean;
  38606. /**
  38607. * Defines the rate of change of heightOffset.
  38608. */
  38609. heightSensibility: number;
  38610. /**
  38611. * Defines the rate of change of rotationOffset.
  38612. */
  38613. rotationSensibility: number;
  38614. /**
  38615. * Defines the rate of change of radius.
  38616. */
  38617. radiusSensibility: number;
  38618. private _keys;
  38619. private _ctrlPressed;
  38620. private _altPressed;
  38621. private _shiftPressed;
  38622. private _onCanvasBlurObserver;
  38623. private _onKeyboardObserver;
  38624. private _engine;
  38625. private _scene;
  38626. /**
  38627. * Attach the input controls to a specific dom element to get the input from.
  38628. * @param element Defines the element the controls should be listened from
  38629. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38630. */
  38631. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38632. /**
  38633. * Detach the current controls from the specified dom element.
  38634. * @param element Defines the element to stop listening the inputs from
  38635. */
  38636. detachControl(element: Nullable<HTMLElement>): void;
  38637. /**
  38638. * Update the current camera state depending on the inputs that have been used this frame.
  38639. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38640. */
  38641. checkInputs(): void;
  38642. /**
  38643. * Gets the class name of the current input.
  38644. * @returns the class name
  38645. */
  38646. getClassName(): string;
  38647. /**
  38648. * Get the friendly name associated with the input class.
  38649. * @returns the input friendly name
  38650. */
  38651. getSimpleName(): string;
  38652. /**
  38653. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38654. * allow modification of the heightOffset value.
  38655. */
  38656. private _modifierHeightOffset;
  38657. /**
  38658. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38659. * allow modification of the rotationOffset value.
  38660. */
  38661. private _modifierRotationOffset;
  38662. /**
  38663. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38664. * allow modification of the radius value.
  38665. */
  38666. private _modifierRadius;
  38667. }
  38668. }
  38669. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38670. import { Nullable } from "babylonjs/types";
  38671. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38672. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38673. import { Observable } from "babylonjs/Misc/observable";
  38674. module "babylonjs/Cameras/freeCameraInputsManager" {
  38675. interface FreeCameraInputsManager {
  38676. /**
  38677. * @hidden
  38678. */
  38679. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38680. /**
  38681. * Add orientation input support to the input manager.
  38682. * @returns the current input manager
  38683. */
  38684. addDeviceOrientation(): FreeCameraInputsManager;
  38685. }
  38686. }
  38687. /**
  38688. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38689. * Screen rotation is taken into account.
  38690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38691. */
  38692. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38693. private _camera;
  38694. private _screenOrientationAngle;
  38695. private _constantTranform;
  38696. private _screenQuaternion;
  38697. private _alpha;
  38698. private _beta;
  38699. private _gamma;
  38700. /**
  38701. * Can be used to detect if a device orientation sensor is availible on a device
  38702. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38703. * @returns a promise that will resolve on orientation change
  38704. */
  38705. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38706. /**
  38707. * @hidden
  38708. */
  38709. _onDeviceOrientationChangedObservable: Observable<void>;
  38710. /**
  38711. * Instantiates a new input
  38712. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38713. */
  38714. constructor();
  38715. /**
  38716. * Define the camera controlled by the input.
  38717. */
  38718. camera: FreeCamera;
  38719. /**
  38720. * Attach the input controls to a specific dom element to get the input from.
  38721. * @param element Defines the element the controls should be listened from
  38722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38723. */
  38724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38725. private _orientationChanged;
  38726. private _deviceOrientation;
  38727. /**
  38728. * Detach the current controls from the specified dom element.
  38729. * @param element Defines the element to stop listening the inputs from
  38730. */
  38731. detachControl(element: Nullable<HTMLElement>): void;
  38732. /**
  38733. * Update the current camera state depending on the inputs that have been used this frame.
  38734. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38735. */
  38736. checkInputs(): void;
  38737. /**
  38738. * Gets the class name of the current intput.
  38739. * @returns the class name
  38740. */
  38741. getClassName(): string;
  38742. /**
  38743. * Get the friendly name associated with the input class.
  38744. * @returns the input friendly name
  38745. */
  38746. getSimpleName(): string;
  38747. }
  38748. }
  38749. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38750. import { Nullable } from "babylonjs/types";
  38751. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38752. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38753. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38754. /**
  38755. * Manage the gamepad inputs to control a free camera.
  38756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38757. */
  38758. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38759. /**
  38760. * Define the camera the input is attached to.
  38761. */
  38762. camera: FreeCamera;
  38763. /**
  38764. * Define the Gamepad controlling the input
  38765. */
  38766. gamepad: Nullable<Gamepad>;
  38767. /**
  38768. * Defines the gamepad rotation sensiblity.
  38769. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38770. */
  38771. gamepadAngularSensibility: number;
  38772. /**
  38773. * Defines the gamepad move sensiblity.
  38774. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38775. */
  38776. gamepadMoveSensibility: number;
  38777. private _onGamepadConnectedObserver;
  38778. private _onGamepadDisconnectedObserver;
  38779. private _cameraTransform;
  38780. private _deltaTransform;
  38781. private _vector3;
  38782. private _vector2;
  38783. /**
  38784. * Attach the input controls to a specific dom element to get the input from.
  38785. * @param element Defines the element the controls should be listened from
  38786. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38787. */
  38788. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38789. /**
  38790. * Detach the current controls from the specified dom element.
  38791. * @param element Defines the element to stop listening the inputs from
  38792. */
  38793. detachControl(element: Nullable<HTMLElement>): void;
  38794. /**
  38795. * Update the current camera state depending on the inputs that have been used this frame.
  38796. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38797. */
  38798. checkInputs(): void;
  38799. /**
  38800. * Gets the class name of the current intput.
  38801. * @returns the class name
  38802. */
  38803. getClassName(): string;
  38804. /**
  38805. * Get the friendly name associated with the input class.
  38806. * @returns the input friendly name
  38807. */
  38808. getSimpleName(): string;
  38809. }
  38810. }
  38811. declare module "babylonjs/Misc/virtualJoystick" {
  38812. import { Nullable } from "babylonjs/types";
  38813. import { Vector3 } from "babylonjs/Maths/math";
  38814. /**
  38815. * Defines the potential axis of a Joystick
  38816. */
  38817. export enum JoystickAxis {
  38818. /** X axis */
  38819. X = 0,
  38820. /** Y axis */
  38821. Y = 1,
  38822. /** Z axis */
  38823. Z = 2
  38824. }
  38825. /**
  38826. * Class used to define virtual joystick (used in touch mode)
  38827. */
  38828. export class VirtualJoystick {
  38829. /**
  38830. * Gets or sets a boolean indicating that left and right values must be inverted
  38831. */
  38832. reverseLeftRight: boolean;
  38833. /**
  38834. * Gets or sets a boolean indicating that up and down values must be inverted
  38835. */
  38836. reverseUpDown: boolean;
  38837. /**
  38838. * Gets the offset value for the position (ie. the change of the position value)
  38839. */
  38840. deltaPosition: Vector3;
  38841. /**
  38842. * Gets a boolean indicating if the virtual joystick was pressed
  38843. */
  38844. pressed: boolean;
  38845. /**
  38846. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38847. */
  38848. static Canvas: Nullable<HTMLCanvasElement>;
  38849. private static _globalJoystickIndex;
  38850. private static vjCanvasContext;
  38851. private static vjCanvasWidth;
  38852. private static vjCanvasHeight;
  38853. private static halfWidth;
  38854. private _action;
  38855. private _axisTargetedByLeftAndRight;
  38856. private _axisTargetedByUpAndDown;
  38857. private _joystickSensibility;
  38858. private _inversedSensibility;
  38859. private _joystickPointerID;
  38860. private _joystickColor;
  38861. private _joystickPointerPos;
  38862. private _joystickPreviousPointerPos;
  38863. private _joystickPointerStartPos;
  38864. private _deltaJoystickVector;
  38865. private _leftJoystick;
  38866. private _touches;
  38867. private _onPointerDownHandlerRef;
  38868. private _onPointerMoveHandlerRef;
  38869. private _onPointerUpHandlerRef;
  38870. private _onResize;
  38871. /**
  38872. * Creates a new virtual joystick
  38873. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38874. */
  38875. constructor(leftJoystick?: boolean);
  38876. /**
  38877. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38878. * @param newJoystickSensibility defines the new sensibility
  38879. */
  38880. setJoystickSensibility(newJoystickSensibility: number): void;
  38881. private _onPointerDown;
  38882. private _onPointerMove;
  38883. private _onPointerUp;
  38884. /**
  38885. * Change the color of the virtual joystick
  38886. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38887. */
  38888. setJoystickColor(newColor: string): void;
  38889. /**
  38890. * Defines a callback to call when the joystick is touched
  38891. * @param action defines the callback
  38892. */
  38893. setActionOnTouch(action: () => any): void;
  38894. /**
  38895. * Defines which axis you'd like to control for left & right
  38896. * @param axis defines the axis to use
  38897. */
  38898. setAxisForLeftRight(axis: JoystickAxis): void;
  38899. /**
  38900. * Defines which axis you'd like to control for up & down
  38901. * @param axis defines the axis to use
  38902. */
  38903. setAxisForUpDown(axis: JoystickAxis): void;
  38904. private _drawVirtualJoystick;
  38905. /**
  38906. * Release internal HTML canvas
  38907. */
  38908. releaseCanvas(): void;
  38909. }
  38910. }
  38911. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38912. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38913. import { Nullable } from "babylonjs/types";
  38914. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38915. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38916. module "babylonjs/Cameras/freeCameraInputsManager" {
  38917. interface FreeCameraInputsManager {
  38918. /**
  38919. * Add virtual joystick input support to the input manager.
  38920. * @returns the current input manager
  38921. */
  38922. addVirtualJoystick(): FreeCameraInputsManager;
  38923. }
  38924. }
  38925. /**
  38926. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38927. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38928. */
  38929. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38930. /**
  38931. * Defines the camera the input is attached to.
  38932. */
  38933. camera: FreeCamera;
  38934. private _leftjoystick;
  38935. private _rightjoystick;
  38936. /**
  38937. * Gets the left stick of the virtual joystick.
  38938. * @returns The virtual Joystick
  38939. */
  38940. getLeftJoystick(): VirtualJoystick;
  38941. /**
  38942. * Gets the right stick of the virtual joystick.
  38943. * @returns The virtual Joystick
  38944. */
  38945. getRightJoystick(): VirtualJoystick;
  38946. /**
  38947. * Update the current camera state depending on the inputs that have been used this frame.
  38948. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38949. */
  38950. checkInputs(): void;
  38951. /**
  38952. * Attach the input controls to a specific dom element to get the input from.
  38953. * @param element Defines the element the controls should be listened from
  38954. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38955. */
  38956. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38957. /**
  38958. * Detach the current controls from the specified dom element.
  38959. * @param element Defines the element to stop listening the inputs from
  38960. */
  38961. detachControl(element: Nullable<HTMLElement>): void;
  38962. /**
  38963. * Gets the class name of the current intput.
  38964. * @returns the class name
  38965. */
  38966. getClassName(): string;
  38967. /**
  38968. * Get the friendly name associated with the input class.
  38969. * @returns the input friendly name
  38970. */
  38971. getSimpleName(): string;
  38972. }
  38973. }
  38974. declare module "babylonjs/Cameras/Inputs/index" {
  38975. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38976. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38977. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38978. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38979. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38980. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38981. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38982. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38983. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38984. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38985. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38986. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38987. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38988. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38989. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38990. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38991. }
  38992. declare module "babylonjs/Cameras/touchCamera" {
  38993. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38994. import { Scene } from "babylonjs/scene";
  38995. import { Vector3 } from "babylonjs/Maths/math";
  38996. /**
  38997. * This represents a FPS type of camera controlled by touch.
  38998. * This is like a universal camera minus the Gamepad controls.
  38999. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39000. */
  39001. export class TouchCamera extends FreeCamera {
  39002. /**
  39003. * Defines the touch sensibility for rotation.
  39004. * The higher the faster.
  39005. */
  39006. touchAngularSensibility: number;
  39007. /**
  39008. * Defines the touch sensibility for move.
  39009. * The higher the faster.
  39010. */
  39011. touchMoveSensibility: number;
  39012. /**
  39013. * Instantiates a new touch camera.
  39014. * This represents a FPS type of camera controlled by touch.
  39015. * This is like a universal camera minus the Gamepad controls.
  39016. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39017. * @param name Define the name of the camera in the scene
  39018. * @param position Define the start position of the camera in the scene
  39019. * @param scene Define the scene the camera belongs to
  39020. */
  39021. constructor(name: string, position: Vector3, scene: Scene);
  39022. /**
  39023. * Gets the current object class name.
  39024. * @return the class name
  39025. */
  39026. getClassName(): string;
  39027. /** @hidden */
  39028. _setupInputs(): void;
  39029. }
  39030. }
  39031. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39032. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39033. import { Scene } from "babylonjs/scene";
  39034. import { Vector3, Axis } from "babylonjs/Maths/math";
  39035. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39036. /**
  39037. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39038. * being tilted forward or back and left or right.
  39039. */
  39040. export class DeviceOrientationCamera extends FreeCamera {
  39041. private _initialQuaternion;
  39042. private _quaternionCache;
  39043. private _tmpDragQuaternion;
  39044. /**
  39045. * Creates a new device orientation camera
  39046. * @param name The name of the camera
  39047. * @param position The start position camera
  39048. * @param scene The scene the camera belongs to
  39049. */
  39050. constructor(name: string, position: Vector3, scene: Scene);
  39051. /**
  39052. * @hidden
  39053. * Disabled pointer input on first orientation sensor update (Default: true)
  39054. */
  39055. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39056. private _dragFactor;
  39057. /**
  39058. * Enabled turning on the y axis when the orientation sensor is active
  39059. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39060. */
  39061. enableHorizontalDragging(dragFactor?: number): void;
  39062. /**
  39063. * Gets the current instance class name ("DeviceOrientationCamera").
  39064. * This helps avoiding instanceof at run time.
  39065. * @returns the class name
  39066. */
  39067. getClassName(): string;
  39068. /**
  39069. * @hidden
  39070. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39071. */
  39072. _checkInputs(): void;
  39073. /**
  39074. * Reset the camera to its default orientation on the specified axis only.
  39075. * @param axis The axis to reset
  39076. */
  39077. resetToCurrentRotation(axis?: Axis): void;
  39078. }
  39079. }
  39080. declare module "babylonjs/Gamepads/xboxGamepad" {
  39081. import { Observable } from "babylonjs/Misc/observable";
  39082. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39083. /**
  39084. * Defines supported buttons for XBox360 compatible gamepads
  39085. */
  39086. export enum Xbox360Button {
  39087. /** A */
  39088. A = 0,
  39089. /** B */
  39090. B = 1,
  39091. /** X */
  39092. X = 2,
  39093. /** Y */
  39094. Y = 3,
  39095. /** Start */
  39096. Start = 4,
  39097. /** Back */
  39098. Back = 5,
  39099. /** Left button */
  39100. LB = 6,
  39101. /** Right button */
  39102. RB = 7,
  39103. /** Left stick */
  39104. LeftStick = 8,
  39105. /** Right stick */
  39106. RightStick = 9
  39107. }
  39108. /** Defines values for XBox360 DPad */
  39109. export enum Xbox360Dpad {
  39110. /** Up */
  39111. Up = 0,
  39112. /** Down */
  39113. Down = 1,
  39114. /** Left */
  39115. Left = 2,
  39116. /** Right */
  39117. Right = 3
  39118. }
  39119. /**
  39120. * Defines a XBox360 gamepad
  39121. */
  39122. export class Xbox360Pad extends Gamepad {
  39123. private _leftTrigger;
  39124. private _rightTrigger;
  39125. private _onlefttriggerchanged;
  39126. private _onrighttriggerchanged;
  39127. private _onbuttondown;
  39128. private _onbuttonup;
  39129. private _ondpaddown;
  39130. private _ondpadup;
  39131. /** Observable raised when a button is pressed */
  39132. onButtonDownObservable: Observable<Xbox360Button>;
  39133. /** Observable raised when a button is released */
  39134. onButtonUpObservable: Observable<Xbox360Button>;
  39135. /** Observable raised when a pad is pressed */
  39136. onPadDownObservable: Observable<Xbox360Dpad>;
  39137. /** Observable raised when a pad is released */
  39138. onPadUpObservable: Observable<Xbox360Dpad>;
  39139. private _buttonA;
  39140. private _buttonB;
  39141. private _buttonX;
  39142. private _buttonY;
  39143. private _buttonBack;
  39144. private _buttonStart;
  39145. private _buttonLB;
  39146. private _buttonRB;
  39147. private _buttonLeftStick;
  39148. private _buttonRightStick;
  39149. private _dPadUp;
  39150. private _dPadDown;
  39151. private _dPadLeft;
  39152. private _dPadRight;
  39153. private _isXboxOnePad;
  39154. /**
  39155. * Creates a new XBox360 gamepad object
  39156. * @param id defines the id of this gamepad
  39157. * @param index defines its index
  39158. * @param gamepad defines the internal HTML gamepad object
  39159. * @param xboxOne defines if it is a XBox One gamepad
  39160. */
  39161. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39162. /**
  39163. * Defines the callback to call when left trigger is pressed
  39164. * @param callback defines the callback to use
  39165. */
  39166. onlefttriggerchanged(callback: (value: number) => void): void;
  39167. /**
  39168. * Defines the callback to call when right trigger is pressed
  39169. * @param callback defines the callback to use
  39170. */
  39171. onrighttriggerchanged(callback: (value: number) => void): void;
  39172. /**
  39173. * Gets the left trigger value
  39174. */
  39175. /**
  39176. * Sets the left trigger value
  39177. */
  39178. leftTrigger: number;
  39179. /**
  39180. * Gets the right trigger value
  39181. */
  39182. /**
  39183. * Sets the right trigger value
  39184. */
  39185. rightTrigger: number;
  39186. /**
  39187. * Defines the callback to call when a button is pressed
  39188. * @param callback defines the callback to use
  39189. */
  39190. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39191. /**
  39192. * Defines the callback to call when a button is released
  39193. * @param callback defines the callback to use
  39194. */
  39195. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39196. /**
  39197. * Defines the callback to call when a pad is pressed
  39198. * @param callback defines the callback to use
  39199. */
  39200. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39201. /**
  39202. * Defines the callback to call when a pad is released
  39203. * @param callback defines the callback to use
  39204. */
  39205. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39206. private _setButtonValue;
  39207. private _setDPadValue;
  39208. /**
  39209. * Gets the value of the `A` button
  39210. */
  39211. /**
  39212. * Sets the value of the `A` button
  39213. */
  39214. buttonA: number;
  39215. /**
  39216. * Gets the value of the `B` button
  39217. */
  39218. /**
  39219. * Sets the value of the `B` button
  39220. */
  39221. buttonB: number;
  39222. /**
  39223. * Gets the value of the `X` button
  39224. */
  39225. /**
  39226. * Sets the value of the `X` button
  39227. */
  39228. buttonX: number;
  39229. /**
  39230. * Gets the value of the `Y` button
  39231. */
  39232. /**
  39233. * Sets the value of the `Y` button
  39234. */
  39235. buttonY: number;
  39236. /**
  39237. * Gets the value of the `Start` button
  39238. */
  39239. /**
  39240. * Sets the value of the `Start` button
  39241. */
  39242. buttonStart: number;
  39243. /**
  39244. * Gets the value of the `Back` button
  39245. */
  39246. /**
  39247. * Sets the value of the `Back` button
  39248. */
  39249. buttonBack: number;
  39250. /**
  39251. * Gets the value of the `Left` button
  39252. */
  39253. /**
  39254. * Sets the value of the `Left` button
  39255. */
  39256. buttonLB: number;
  39257. /**
  39258. * Gets the value of the `Right` button
  39259. */
  39260. /**
  39261. * Sets the value of the `Right` button
  39262. */
  39263. buttonRB: number;
  39264. /**
  39265. * Gets the value of the Left joystick
  39266. */
  39267. /**
  39268. * Sets the value of the Left joystick
  39269. */
  39270. buttonLeftStick: number;
  39271. /**
  39272. * Gets the value of the Right joystick
  39273. */
  39274. /**
  39275. * Sets the value of the Right joystick
  39276. */
  39277. buttonRightStick: number;
  39278. /**
  39279. * Gets the value of D-pad up
  39280. */
  39281. /**
  39282. * Sets the value of D-pad up
  39283. */
  39284. dPadUp: number;
  39285. /**
  39286. * Gets the value of D-pad down
  39287. */
  39288. /**
  39289. * Sets the value of D-pad down
  39290. */
  39291. dPadDown: number;
  39292. /**
  39293. * Gets the value of D-pad left
  39294. */
  39295. /**
  39296. * Sets the value of D-pad left
  39297. */
  39298. dPadLeft: number;
  39299. /**
  39300. * Gets the value of D-pad right
  39301. */
  39302. /**
  39303. * Sets the value of D-pad right
  39304. */
  39305. dPadRight: number;
  39306. /**
  39307. * Force the gamepad to synchronize with device values
  39308. */
  39309. update(): void;
  39310. /**
  39311. * Disposes the gamepad
  39312. */
  39313. dispose(): void;
  39314. }
  39315. }
  39316. declare module "babylonjs/Gamepads/gamepadManager" {
  39317. import { Observable } from "babylonjs/Misc/observable";
  39318. import { Nullable } from "babylonjs/types";
  39319. import { Scene } from "babylonjs/scene";
  39320. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39321. /**
  39322. * Manager for handling gamepads
  39323. */
  39324. export class GamepadManager {
  39325. private _scene?;
  39326. private _babylonGamepads;
  39327. private _oneGamepadConnected;
  39328. /** @hidden */
  39329. _isMonitoring: boolean;
  39330. private _gamepadEventSupported;
  39331. private _gamepadSupport;
  39332. /**
  39333. * observable to be triggered when the gamepad controller has been connected
  39334. */
  39335. onGamepadConnectedObservable: Observable<Gamepad>;
  39336. /**
  39337. * observable to be triggered when the gamepad controller has been disconnected
  39338. */
  39339. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39340. private _onGamepadConnectedEvent;
  39341. private _onGamepadDisconnectedEvent;
  39342. /**
  39343. * Initializes the gamepad manager
  39344. * @param _scene BabylonJS scene
  39345. */
  39346. constructor(_scene?: Scene | undefined);
  39347. /**
  39348. * The gamepads in the game pad manager
  39349. */
  39350. readonly gamepads: Gamepad[];
  39351. /**
  39352. * Get the gamepad controllers based on type
  39353. * @param type The type of gamepad controller
  39354. * @returns Nullable gamepad
  39355. */
  39356. getGamepadByType(type?: number): Nullable<Gamepad>;
  39357. /**
  39358. * Disposes the gamepad manager
  39359. */
  39360. dispose(): void;
  39361. private _addNewGamepad;
  39362. private _startMonitoringGamepads;
  39363. private _stopMonitoringGamepads;
  39364. /** @hidden */
  39365. _checkGamepadsStatus(): void;
  39366. private _updateGamepadObjects;
  39367. }
  39368. }
  39369. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39370. import { Nullable } from "babylonjs/types";
  39371. import { Scene } from "babylonjs/scene";
  39372. import { ISceneComponent } from "babylonjs/sceneComponent";
  39373. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39374. module "babylonjs/scene" {
  39375. interface Scene {
  39376. /** @hidden */
  39377. _gamepadManager: Nullable<GamepadManager>;
  39378. /**
  39379. * Gets the gamepad manager associated with the scene
  39380. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39381. */
  39382. gamepadManager: GamepadManager;
  39383. }
  39384. }
  39385. module "babylonjs/Cameras/freeCameraInputsManager" {
  39386. /**
  39387. * Interface representing a free camera inputs manager
  39388. */
  39389. interface FreeCameraInputsManager {
  39390. /**
  39391. * Adds gamepad input support to the FreeCameraInputsManager.
  39392. * @returns the FreeCameraInputsManager
  39393. */
  39394. addGamepad(): FreeCameraInputsManager;
  39395. }
  39396. }
  39397. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39398. /**
  39399. * Interface representing an arc rotate camera inputs manager
  39400. */
  39401. interface ArcRotateCameraInputsManager {
  39402. /**
  39403. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39404. * @returns the camera inputs manager
  39405. */
  39406. addGamepad(): ArcRotateCameraInputsManager;
  39407. }
  39408. }
  39409. /**
  39410. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39411. */
  39412. export class GamepadSystemSceneComponent implements ISceneComponent {
  39413. /**
  39414. * The component name helpfull to identify the component in the list of scene components.
  39415. */
  39416. readonly name: string;
  39417. /**
  39418. * The scene the component belongs to.
  39419. */
  39420. scene: Scene;
  39421. /**
  39422. * Creates a new instance of the component for the given scene
  39423. * @param scene Defines the scene to register the component in
  39424. */
  39425. constructor(scene: Scene);
  39426. /**
  39427. * Registers the component in a given scene
  39428. */
  39429. register(): void;
  39430. /**
  39431. * Rebuilds the elements related to this component in case of
  39432. * context lost for instance.
  39433. */
  39434. rebuild(): void;
  39435. /**
  39436. * Disposes the component and the associated ressources
  39437. */
  39438. dispose(): void;
  39439. private _beforeCameraUpdate;
  39440. }
  39441. }
  39442. declare module "babylonjs/Cameras/universalCamera" {
  39443. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39444. import { Scene } from "babylonjs/scene";
  39445. import { Vector3 } from "babylonjs/Maths/math";
  39446. import "babylonjs/Gamepads/gamepadSceneComponent";
  39447. /**
  39448. * 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,
  39449. * which still works and will still be found in many Playgrounds.
  39450. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39451. */
  39452. export class UniversalCamera extends TouchCamera {
  39453. /**
  39454. * Defines the gamepad rotation sensiblity.
  39455. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39456. */
  39457. gamepadAngularSensibility: number;
  39458. /**
  39459. * Defines the gamepad move sensiblity.
  39460. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39461. */
  39462. gamepadMoveSensibility: number;
  39463. /**
  39464. * 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,
  39465. * which still works and will still be found in many Playgrounds.
  39466. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39467. * @param name Define the name of the camera in the scene
  39468. * @param position Define the start position of the camera in the scene
  39469. * @param scene Define the scene the camera belongs to
  39470. */
  39471. constructor(name: string, position: Vector3, scene: Scene);
  39472. /**
  39473. * Gets the current object class name.
  39474. * @return the class name
  39475. */
  39476. getClassName(): string;
  39477. }
  39478. }
  39479. declare module "babylonjs/Cameras/gamepadCamera" {
  39480. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39481. import { Scene } from "babylonjs/scene";
  39482. import { Vector3 } from "babylonjs/Maths/math";
  39483. /**
  39484. * This represents a FPS type of camera. This is only here for back compat purpose.
  39485. * Please use the UniversalCamera instead as both are identical.
  39486. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39487. */
  39488. export class GamepadCamera extends UniversalCamera {
  39489. /**
  39490. * Instantiates a new Gamepad Camera
  39491. * This represents a FPS type of camera. This is only here for back compat purpose.
  39492. * Please use the UniversalCamera instead as both are identical.
  39493. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39494. * @param name Define the name of the camera in the scene
  39495. * @param position Define the start position of the camera in the scene
  39496. * @param scene Define the scene the camera belongs to
  39497. */
  39498. constructor(name: string, position: Vector3, scene: Scene);
  39499. /**
  39500. * Gets the current object class name.
  39501. * @return the class name
  39502. */
  39503. getClassName(): string;
  39504. }
  39505. }
  39506. declare module "babylonjs/Shaders/pass.fragment" {
  39507. /** @hidden */
  39508. export var passPixelShader: {
  39509. name: string;
  39510. shader: string;
  39511. };
  39512. }
  39513. declare module "babylonjs/Shaders/passCube.fragment" {
  39514. /** @hidden */
  39515. export var passCubePixelShader: {
  39516. name: string;
  39517. shader: string;
  39518. };
  39519. }
  39520. declare module "babylonjs/PostProcesses/passPostProcess" {
  39521. import { Nullable } from "babylonjs/types";
  39522. import { Camera } from "babylonjs/Cameras/camera";
  39523. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39524. import { Engine } from "babylonjs/Engines/engine";
  39525. import "babylonjs/Shaders/pass.fragment";
  39526. import "babylonjs/Shaders/passCube.fragment";
  39527. /**
  39528. * PassPostProcess which produces an output the same as it's input
  39529. */
  39530. export class PassPostProcess extends PostProcess {
  39531. /**
  39532. * Creates the PassPostProcess
  39533. * @param name The name of the effect.
  39534. * @param options The required width/height ratio to downsize to before computing the render pass.
  39535. * @param camera The camera to apply the render pass to.
  39536. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39537. * @param engine The engine which the post process will be applied. (default: current engine)
  39538. * @param reusable If the post process can be reused on the same frame. (default: false)
  39539. * @param textureType The type of texture to be used when performing the post processing.
  39540. * @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)
  39541. */
  39542. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39543. }
  39544. /**
  39545. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39546. */
  39547. export class PassCubePostProcess extends PostProcess {
  39548. private _face;
  39549. /**
  39550. * Gets or sets the cube face to display.
  39551. * * 0 is +X
  39552. * * 1 is -X
  39553. * * 2 is +Y
  39554. * * 3 is -Y
  39555. * * 4 is +Z
  39556. * * 5 is -Z
  39557. */
  39558. face: number;
  39559. /**
  39560. * Creates the PassCubePostProcess
  39561. * @param name The name of the effect.
  39562. * @param options The required width/height ratio to downsize to before computing the render pass.
  39563. * @param camera The camera to apply the render pass to.
  39564. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39565. * @param engine The engine which the post process will be applied. (default: current engine)
  39566. * @param reusable If the post process can be reused on the same frame. (default: false)
  39567. * @param textureType The type of texture to be used when performing the post processing.
  39568. * @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)
  39569. */
  39570. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39571. }
  39572. }
  39573. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39574. /** @hidden */
  39575. export var anaglyphPixelShader: {
  39576. name: string;
  39577. shader: string;
  39578. };
  39579. }
  39580. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39581. import { Engine } from "babylonjs/Engines/engine";
  39582. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39583. import { Camera } from "babylonjs/Cameras/camera";
  39584. import "babylonjs/Shaders/anaglyph.fragment";
  39585. /**
  39586. * Postprocess used to generate anaglyphic rendering
  39587. */
  39588. export class AnaglyphPostProcess extends PostProcess {
  39589. private _passedProcess;
  39590. /**
  39591. * Creates a new AnaglyphPostProcess
  39592. * @param name defines postprocess name
  39593. * @param options defines creation options or target ratio scale
  39594. * @param rigCameras defines cameras using this postprocess
  39595. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39596. * @param engine defines hosting engine
  39597. * @param reusable defines if the postprocess will be reused multiple times per frame
  39598. */
  39599. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39600. }
  39601. }
  39602. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39603. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39604. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39605. import { Scene } from "babylonjs/scene";
  39606. import { Vector3 } from "babylonjs/Maths/math";
  39607. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39608. /**
  39609. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39610. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39611. */
  39612. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39613. /**
  39614. * Creates a new AnaglyphArcRotateCamera
  39615. * @param name defines camera name
  39616. * @param alpha defines alpha angle (in radians)
  39617. * @param beta defines beta angle (in radians)
  39618. * @param radius defines radius
  39619. * @param target defines camera target
  39620. * @param interaxialDistance defines distance between each color axis
  39621. * @param scene defines the hosting scene
  39622. */
  39623. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39624. /**
  39625. * Gets camera class name
  39626. * @returns AnaglyphArcRotateCamera
  39627. */
  39628. getClassName(): string;
  39629. }
  39630. }
  39631. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39632. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39633. import { Scene } from "babylonjs/scene";
  39634. import { Vector3 } from "babylonjs/Maths/math";
  39635. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39636. /**
  39637. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39638. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39639. */
  39640. export class AnaglyphFreeCamera extends FreeCamera {
  39641. /**
  39642. * Creates a new AnaglyphFreeCamera
  39643. * @param name defines camera name
  39644. * @param position defines initial position
  39645. * @param interaxialDistance defines distance between each color axis
  39646. * @param scene defines the hosting scene
  39647. */
  39648. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39649. /**
  39650. * Gets camera class name
  39651. * @returns AnaglyphFreeCamera
  39652. */
  39653. getClassName(): string;
  39654. }
  39655. }
  39656. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39657. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39658. import { Scene } from "babylonjs/scene";
  39659. import { Vector3 } from "babylonjs/Maths/math";
  39660. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39661. /**
  39662. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39663. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39664. */
  39665. export class AnaglyphGamepadCamera extends GamepadCamera {
  39666. /**
  39667. * Creates a new AnaglyphGamepadCamera
  39668. * @param name defines camera name
  39669. * @param position defines initial position
  39670. * @param interaxialDistance defines distance between each color axis
  39671. * @param scene defines the hosting scene
  39672. */
  39673. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39674. /**
  39675. * Gets camera class name
  39676. * @returns AnaglyphGamepadCamera
  39677. */
  39678. getClassName(): string;
  39679. }
  39680. }
  39681. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39682. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39683. import { Scene } from "babylonjs/scene";
  39684. import { Vector3 } from "babylonjs/Maths/math";
  39685. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39686. /**
  39687. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39688. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39689. */
  39690. export class AnaglyphUniversalCamera extends UniversalCamera {
  39691. /**
  39692. * Creates a new AnaglyphUniversalCamera
  39693. * @param name defines camera name
  39694. * @param position defines initial position
  39695. * @param interaxialDistance defines distance between each color axis
  39696. * @param scene defines the hosting scene
  39697. */
  39698. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39699. /**
  39700. * Gets camera class name
  39701. * @returns AnaglyphUniversalCamera
  39702. */
  39703. getClassName(): string;
  39704. }
  39705. }
  39706. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39707. /** @hidden */
  39708. export var stereoscopicInterlacePixelShader: {
  39709. name: string;
  39710. shader: string;
  39711. };
  39712. }
  39713. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39714. import { Camera } from "babylonjs/Cameras/camera";
  39715. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39716. import { Engine } from "babylonjs/Engines/engine";
  39717. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39718. /**
  39719. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39720. */
  39721. export class StereoscopicInterlacePostProcess extends PostProcess {
  39722. private _stepSize;
  39723. private _passedProcess;
  39724. /**
  39725. * Initializes a StereoscopicInterlacePostProcess
  39726. * @param name The name of the effect.
  39727. * @param rigCameras The rig cameras to be appled to the post process
  39728. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39729. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39730. * @param engine The engine which the post process will be applied. (default: current engine)
  39731. * @param reusable If the post process can be reused on the same frame. (default: false)
  39732. */
  39733. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39734. }
  39735. }
  39736. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39737. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39738. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39739. import { Scene } from "babylonjs/scene";
  39740. import { Vector3 } from "babylonjs/Maths/math";
  39741. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39742. /**
  39743. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39744. * @see http://doc.babylonjs.com/features/cameras
  39745. */
  39746. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39747. /**
  39748. * Creates a new StereoscopicArcRotateCamera
  39749. * @param name defines camera name
  39750. * @param alpha defines alpha angle (in radians)
  39751. * @param beta defines beta angle (in radians)
  39752. * @param radius defines radius
  39753. * @param target defines camera target
  39754. * @param interaxialDistance defines distance between each color axis
  39755. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39756. * @param scene defines the hosting scene
  39757. */
  39758. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39759. /**
  39760. * Gets camera class name
  39761. * @returns StereoscopicArcRotateCamera
  39762. */
  39763. getClassName(): string;
  39764. }
  39765. }
  39766. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39767. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39768. import { Scene } from "babylonjs/scene";
  39769. import { Vector3 } from "babylonjs/Maths/math";
  39770. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39771. /**
  39772. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39773. * @see http://doc.babylonjs.com/features/cameras
  39774. */
  39775. export class StereoscopicFreeCamera extends FreeCamera {
  39776. /**
  39777. * Creates a new StereoscopicFreeCamera
  39778. * @param name defines camera name
  39779. * @param position defines initial position
  39780. * @param interaxialDistance defines distance between each color axis
  39781. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39782. * @param scene defines the hosting scene
  39783. */
  39784. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39785. /**
  39786. * Gets camera class name
  39787. * @returns StereoscopicFreeCamera
  39788. */
  39789. getClassName(): string;
  39790. }
  39791. }
  39792. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39793. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39794. import { Scene } from "babylonjs/scene";
  39795. import { Vector3 } from "babylonjs/Maths/math";
  39796. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39797. /**
  39798. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39799. * @see http://doc.babylonjs.com/features/cameras
  39800. */
  39801. export class StereoscopicGamepadCamera extends GamepadCamera {
  39802. /**
  39803. * Creates a new StereoscopicGamepadCamera
  39804. * @param name defines camera name
  39805. * @param position defines initial position
  39806. * @param interaxialDistance defines distance between each color axis
  39807. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39808. * @param scene defines the hosting scene
  39809. */
  39810. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39811. /**
  39812. * Gets camera class name
  39813. * @returns StereoscopicGamepadCamera
  39814. */
  39815. getClassName(): string;
  39816. }
  39817. }
  39818. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39819. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39820. import { Scene } from "babylonjs/scene";
  39821. import { Vector3 } from "babylonjs/Maths/math";
  39822. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39823. /**
  39824. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39825. * @see http://doc.babylonjs.com/features/cameras
  39826. */
  39827. export class StereoscopicUniversalCamera extends UniversalCamera {
  39828. /**
  39829. * Creates a new StereoscopicUniversalCamera
  39830. * @param name defines camera name
  39831. * @param position defines initial position
  39832. * @param interaxialDistance defines distance between each color axis
  39833. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39834. * @param scene defines the hosting scene
  39835. */
  39836. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39837. /**
  39838. * Gets camera class name
  39839. * @returns StereoscopicUniversalCamera
  39840. */
  39841. getClassName(): string;
  39842. }
  39843. }
  39844. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39845. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39846. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39847. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39848. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39849. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39850. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39851. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39852. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39853. }
  39854. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39855. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39856. import { Scene } from "babylonjs/scene";
  39857. import { Vector3 } from "babylonjs/Maths/math";
  39858. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39859. /**
  39860. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39861. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39862. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39863. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39864. */
  39865. export class VirtualJoysticksCamera extends FreeCamera {
  39866. /**
  39867. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39868. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39869. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39870. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39871. * @param name Define the name of the camera in the scene
  39872. * @param position Define the start position of the camera in the scene
  39873. * @param scene Define the scene the camera belongs to
  39874. */
  39875. constructor(name: string, position: Vector3, scene: Scene);
  39876. /**
  39877. * Gets the current object class name.
  39878. * @return the class name
  39879. */
  39880. getClassName(): string;
  39881. }
  39882. }
  39883. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39884. import { Matrix } from "babylonjs/Maths/math";
  39885. /**
  39886. * This represents all the required metrics to create a VR camera.
  39887. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39888. */
  39889. export class VRCameraMetrics {
  39890. /**
  39891. * Define the horizontal resolution off the screen.
  39892. */
  39893. hResolution: number;
  39894. /**
  39895. * Define the vertical resolution off the screen.
  39896. */
  39897. vResolution: number;
  39898. /**
  39899. * Define the horizontal screen size.
  39900. */
  39901. hScreenSize: number;
  39902. /**
  39903. * Define the vertical screen size.
  39904. */
  39905. vScreenSize: number;
  39906. /**
  39907. * Define the vertical screen center position.
  39908. */
  39909. vScreenCenter: number;
  39910. /**
  39911. * Define the distance of the eyes to the screen.
  39912. */
  39913. eyeToScreenDistance: number;
  39914. /**
  39915. * Define the distance between both lenses
  39916. */
  39917. lensSeparationDistance: number;
  39918. /**
  39919. * Define the distance between both viewer's eyes.
  39920. */
  39921. interpupillaryDistance: number;
  39922. /**
  39923. * Define the distortion factor of the VR postprocess.
  39924. * Please, touch with care.
  39925. */
  39926. distortionK: number[];
  39927. /**
  39928. * Define the chromatic aberration correction factors for the VR post process.
  39929. */
  39930. chromaAbCorrection: number[];
  39931. /**
  39932. * Define the scale factor of the post process.
  39933. * The smaller the better but the slower.
  39934. */
  39935. postProcessScaleFactor: number;
  39936. /**
  39937. * Define an offset for the lens center.
  39938. */
  39939. lensCenterOffset: number;
  39940. /**
  39941. * Define if the current vr camera should compensate the distortion of the lense or not.
  39942. */
  39943. compensateDistortion: boolean;
  39944. /**
  39945. * Defines if multiview should be enabled when rendering (Default: false)
  39946. */
  39947. multiviewEnabled: boolean;
  39948. /**
  39949. * Gets the rendering aspect ratio based on the provided resolutions.
  39950. */
  39951. readonly aspectRatio: number;
  39952. /**
  39953. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39954. */
  39955. readonly aspectRatioFov: number;
  39956. /**
  39957. * @hidden
  39958. */
  39959. readonly leftHMatrix: Matrix;
  39960. /**
  39961. * @hidden
  39962. */
  39963. readonly rightHMatrix: Matrix;
  39964. /**
  39965. * @hidden
  39966. */
  39967. readonly leftPreViewMatrix: Matrix;
  39968. /**
  39969. * @hidden
  39970. */
  39971. readonly rightPreViewMatrix: Matrix;
  39972. /**
  39973. * Get the default VRMetrics based on the most generic setup.
  39974. * @returns the default vr metrics
  39975. */
  39976. static GetDefault(): VRCameraMetrics;
  39977. }
  39978. }
  39979. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39980. /** @hidden */
  39981. export var vrDistortionCorrectionPixelShader: {
  39982. name: string;
  39983. shader: string;
  39984. };
  39985. }
  39986. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39987. import { Camera } from "babylonjs/Cameras/camera";
  39988. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39989. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39990. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39991. /**
  39992. * VRDistortionCorrectionPostProcess used for mobile VR
  39993. */
  39994. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39995. private _isRightEye;
  39996. private _distortionFactors;
  39997. private _postProcessScaleFactor;
  39998. private _lensCenterOffset;
  39999. private _scaleIn;
  40000. private _scaleFactor;
  40001. private _lensCenter;
  40002. /**
  40003. * Initializes the VRDistortionCorrectionPostProcess
  40004. * @param name The name of the effect.
  40005. * @param camera The camera to apply the render pass to.
  40006. * @param isRightEye If this is for the right eye distortion
  40007. * @param vrMetrics All the required metrics for the VR camera
  40008. */
  40009. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40010. }
  40011. }
  40012. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40013. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40014. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40015. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40016. import { Scene } from "babylonjs/scene";
  40017. import { Vector3 } from "babylonjs/Maths/math";
  40018. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40019. import "babylonjs/Cameras/RigModes/vrRigMode";
  40020. /**
  40021. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40022. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40023. */
  40024. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40025. /**
  40026. * Creates a new VRDeviceOrientationArcRotateCamera
  40027. * @param name defines camera name
  40028. * @param alpha defines the camera rotation along the logitudinal axis
  40029. * @param beta defines the camera rotation along the latitudinal axis
  40030. * @param radius defines the camera distance from its target
  40031. * @param target defines the camera target
  40032. * @param scene defines the scene the camera belongs to
  40033. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40034. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40035. */
  40036. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40037. /**
  40038. * Gets camera class name
  40039. * @returns VRDeviceOrientationArcRotateCamera
  40040. */
  40041. getClassName(): string;
  40042. }
  40043. }
  40044. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40045. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40046. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40047. import { Scene } from "babylonjs/scene";
  40048. import { Vector3 } from "babylonjs/Maths/math";
  40049. import "babylonjs/Cameras/RigModes/vrRigMode";
  40050. /**
  40051. * Camera used to simulate VR rendering (based on FreeCamera)
  40052. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40053. */
  40054. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40055. /**
  40056. * Creates a new VRDeviceOrientationFreeCamera
  40057. * @param name defines camera name
  40058. * @param position defines the start position of the camera
  40059. * @param scene defines the scene the camera belongs to
  40060. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40061. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40062. */
  40063. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40064. /**
  40065. * Gets camera class name
  40066. * @returns VRDeviceOrientationFreeCamera
  40067. */
  40068. getClassName(): string;
  40069. }
  40070. }
  40071. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40072. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40073. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40074. import { Scene } from "babylonjs/scene";
  40075. import { Vector3 } from "babylonjs/Maths/math";
  40076. import "babylonjs/Gamepads/gamepadSceneComponent";
  40077. /**
  40078. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40079. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40080. */
  40081. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40082. /**
  40083. * Creates a new VRDeviceOrientationGamepadCamera
  40084. * @param name defines camera name
  40085. * @param position defines the start position of the camera
  40086. * @param scene defines the scene the camera belongs to
  40087. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40088. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40089. */
  40090. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40091. /**
  40092. * Gets camera class name
  40093. * @returns VRDeviceOrientationGamepadCamera
  40094. */
  40095. getClassName(): string;
  40096. }
  40097. }
  40098. declare module "babylonjs/Materials/pushMaterial" {
  40099. import { Nullable } from "babylonjs/types";
  40100. import { Scene } from "babylonjs/scene";
  40101. import { Matrix } from "babylonjs/Maths/math";
  40102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40103. import { Mesh } from "babylonjs/Meshes/mesh";
  40104. import { Material } from "babylonjs/Materials/material";
  40105. import { Effect } from "babylonjs/Materials/effect";
  40106. /**
  40107. * Base class of materials working in push mode in babylon JS
  40108. * @hidden
  40109. */
  40110. export class PushMaterial extends Material {
  40111. protected _activeEffect: Effect;
  40112. protected _normalMatrix: Matrix;
  40113. /**
  40114. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40115. * This means that the material can keep using a previous shader while a new one is being compiled.
  40116. * This is mostly used when shader parallel compilation is supported (true by default)
  40117. */
  40118. allowShaderHotSwapping: boolean;
  40119. constructor(name: string, scene: Scene);
  40120. getEffect(): Effect;
  40121. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40122. /**
  40123. * Binds the given world matrix to the active effect
  40124. *
  40125. * @param world the matrix to bind
  40126. */
  40127. bindOnlyWorldMatrix(world: Matrix): void;
  40128. /**
  40129. * Binds the given normal matrix to the active effect
  40130. *
  40131. * @param normalMatrix the matrix to bind
  40132. */
  40133. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40134. bind(world: Matrix, mesh?: Mesh): void;
  40135. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40136. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40137. }
  40138. }
  40139. declare module "babylonjs/Materials/materialFlags" {
  40140. /**
  40141. * This groups all the flags used to control the materials channel.
  40142. */
  40143. export class MaterialFlags {
  40144. private static _DiffuseTextureEnabled;
  40145. /**
  40146. * Are diffuse textures enabled in the application.
  40147. */
  40148. static DiffuseTextureEnabled: boolean;
  40149. private static _AmbientTextureEnabled;
  40150. /**
  40151. * Are ambient textures enabled in the application.
  40152. */
  40153. static AmbientTextureEnabled: boolean;
  40154. private static _OpacityTextureEnabled;
  40155. /**
  40156. * Are opacity textures enabled in the application.
  40157. */
  40158. static OpacityTextureEnabled: boolean;
  40159. private static _ReflectionTextureEnabled;
  40160. /**
  40161. * Are reflection textures enabled in the application.
  40162. */
  40163. static ReflectionTextureEnabled: boolean;
  40164. private static _EmissiveTextureEnabled;
  40165. /**
  40166. * Are emissive textures enabled in the application.
  40167. */
  40168. static EmissiveTextureEnabled: boolean;
  40169. private static _SpecularTextureEnabled;
  40170. /**
  40171. * Are specular textures enabled in the application.
  40172. */
  40173. static SpecularTextureEnabled: boolean;
  40174. private static _BumpTextureEnabled;
  40175. /**
  40176. * Are bump textures enabled in the application.
  40177. */
  40178. static BumpTextureEnabled: boolean;
  40179. private static _LightmapTextureEnabled;
  40180. /**
  40181. * Are lightmap textures enabled in the application.
  40182. */
  40183. static LightmapTextureEnabled: boolean;
  40184. private static _RefractionTextureEnabled;
  40185. /**
  40186. * Are refraction textures enabled in the application.
  40187. */
  40188. static RefractionTextureEnabled: boolean;
  40189. private static _ColorGradingTextureEnabled;
  40190. /**
  40191. * Are color grading textures enabled in the application.
  40192. */
  40193. static ColorGradingTextureEnabled: boolean;
  40194. private static _FresnelEnabled;
  40195. /**
  40196. * Are fresnels enabled in the application.
  40197. */
  40198. static FresnelEnabled: boolean;
  40199. private static _ClearCoatTextureEnabled;
  40200. /**
  40201. * Are clear coat textures enabled in the application.
  40202. */
  40203. static ClearCoatTextureEnabled: boolean;
  40204. private static _ClearCoatBumpTextureEnabled;
  40205. /**
  40206. * Are clear coat bump textures enabled in the application.
  40207. */
  40208. static ClearCoatBumpTextureEnabled: boolean;
  40209. private static _ClearCoatTintTextureEnabled;
  40210. /**
  40211. * Are clear coat tint textures enabled in the application.
  40212. */
  40213. static ClearCoatTintTextureEnabled: boolean;
  40214. private static _SheenTextureEnabled;
  40215. /**
  40216. * Are sheen textures enabled in the application.
  40217. */
  40218. static SheenTextureEnabled: boolean;
  40219. private static _AnisotropicTextureEnabled;
  40220. /**
  40221. * Are anisotropic textures enabled in the application.
  40222. */
  40223. static AnisotropicTextureEnabled: boolean;
  40224. private static _ThicknessTextureEnabled;
  40225. /**
  40226. * Are thickness textures enabled in the application.
  40227. */
  40228. static ThicknessTextureEnabled: boolean;
  40229. }
  40230. }
  40231. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40232. /** @hidden */
  40233. export var defaultFragmentDeclaration: {
  40234. name: string;
  40235. shader: string;
  40236. };
  40237. }
  40238. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40239. /** @hidden */
  40240. export var defaultUboDeclaration: {
  40241. name: string;
  40242. shader: string;
  40243. };
  40244. }
  40245. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40246. /** @hidden */
  40247. export var lightFragmentDeclaration: {
  40248. name: string;
  40249. shader: string;
  40250. };
  40251. }
  40252. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40253. /** @hidden */
  40254. export var lightUboDeclaration: {
  40255. name: string;
  40256. shader: string;
  40257. };
  40258. }
  40259. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40260. /** @hidden */
  40261. export var lightsFragmentFunctions: {
  40262. name: string;
  40263. shader: string;
  40264. };
  40265. }
  40266. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40267. /** @hidden */
  40268. export var shadowsFragmentFunctions: {
  40269. name: string;
  40270. shader: string;
  40271. };
  40272. }
  40273. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40274. /** @hidden */
  40275. export var fresnelFunction: {
  40276. name: string;
  40277. shader: string;
  40278. };
  40279. }
  40280. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40281. /** @hidden */
  40282. export var reflectionFunction: {
  40283. name: string;
  40284. shader: string;
  40285. };
  40286. }
  40287. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40288. /** @hidden */
  40289. export var bumpFragmentFunctions: {
  40290. name: string;
  40291. shader: string;
  40292. };
  40293. }
  40294. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40295. /** @hidden */
  40296. export var logDepthDeclaration: {
  40297. name: string;
  40298. shader: string;
  40299. };
  40300. }
  40301. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40302. /** @hidden */
  40303. export var bumpFragment: {
  40304. name: string;
  40305. shader: string;
  40306. };
  40307. }
  40308. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40309. /** @hidden */
  40310. export var depthPrePass: {
  40311. name: string;
  40312. shader: string;
  40313. };
  40314. }
  40315. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40316. /** @hidden */
  40317. export var lightFragment: {
  40318. name: string;
  40319. shader: string;
  40320. };
  40321. }
  40322. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40323. /** @hidden */
  40324. export var logDepthFragment: {
  40325. name: string;
  40326. shader: string;
  40327. };
  40328. }
  40329. declare module "babylonjs/Shaders/default.fragment" {
  40330. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40331. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40332. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40333. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40334. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40335. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40336. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40337. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40338. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40339. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40340. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40341. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40342. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40343. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40344. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40345. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40346. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40347. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40348. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40349. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40350. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40351. /** @hidden */
  40352. export var defaultPixelShader: {
  40353. name: string;
  40354. shader: string;
  40355. };
  40356. }
  40357. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40358. /** @hidden */
  40359. export var defaultVertexDeclaration: {
  40360. name: string;
  40361. shader: string;
  40362. };
  40363. }
  40364. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40365. /** @hidden */
  40366. export var bumpVertexDeclaration: {
  40367. name: string;
  40368. shader: string;
  40369. };
  40370. }
  40371. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40372. /** @hidden */
  40373. export var bumpVertex: {
  40374. name: string;
  40375. shader: string;
  40376. };
  40377. }
  40378. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40379. /** @hidden */
  40380. export var fogVertex: {
  40381. name: string;
  40382. shader: string;
  40383. };
  40384. }
  40385. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40386. /** @hidden */
  40387. export var shadowsVertex: {
  40388. name: string;
  40389. shader: string;
  40390. };
  40391. }
  40392. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40393. /** @hidden */
  40394. export var pointCloudVertex: {
  40395. name: string;
  40396. shader: string;
  40397. };
  40398. }
  40399. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40400. /** @hidden */
  40401. export var logDepthVertex: {
  40402. name: string;
  40403. shader: string;
  40404. };
  40405. }
  40406. declare module "babylonjs/Shaders/default.vertex" {
  40407. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40408. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40409. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40410. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40411. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40412. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40413. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40414. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40415. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40416. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40417. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40418. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40419. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40420. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40421. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40422. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40423. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40424. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40425. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40426. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40427. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40428. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40429. /** @hidden */
  40430. export var defaultVertexShader: {
  40431. name: string;
  40432. shader: string;
  40433. };
  40434. }
  40435. declare module "babylonjs/Materials/standardMaterial" {
  40436. import { SmartArray } from "babylonjs/Misc/smartArray";
  40437. import { IAnimatable } from "babylonjs/Misc/tools";
  40438. import { Nullable } from "babylonjs/types";
  40439. import { Scene } from "babylonjs/scene";
  40440. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40441. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40443. import { Mesh } from "babylonjs/Meshes/mesh";
  40444. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40445. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40446. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40447. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40448. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40450. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40451. import "babylonjs/Shaders/default.fragment";
  40452. import "babylonjs/Shaders/default.vertex";
  40453. /** @hidden */
  40454. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40455. MAINUV1: boolean;
  40456. MAINUV2: boolean;
  40457. DIFFUSE: boolean;
  40458. DIFFUSEDIRECTUV: number;
  40459. AMBIENT: boolean;
  40460. AMBIENTDIRECTUV: number;
  40461. OPACITY: boolean;
  40462. OPACITYDIRECTUV: number;
  40463. OPACITYRGB: boolean;
  40464. REFLECTION: boolean;
  40465. EMISSIVE: boolean;
  40466. EMISSIVEDIRECTUV: number;
  40467. SPECULAR: boolean;
  40468. SPECULARDIRECTUV: number;
  40469. BUMP: boolean;
  40470. BUMPDIRECTUV: number;
  40471. PARALLAX: boolean;
  40472. PARALLAXOCCLUSION: boolean;
  40473. SPECULAROVERALPHA: boolean;
  40474. CLIPPLANE: boolean;
  40475. CLIPPLANE2: boolean;
  40476. CLIPPLANE3: boolean;
  40477. CLIPPLANE4: boolean;
  40478. ALPHATEST: boolean;
  40479. DEPTHPREPASS: boolean;
  40480. ALPHAFROMDIFFUSE: boolean;
  40481. POINTSIZE: boolean;
  40482. FOG: boolean;
  40483. SPECULARTERM: boolean;
  40484. DIFFUSEFRESNEL: boolean;
  40485. OPACITYFRESNEL: boolean;
  40486. REFLECTIONFRESNEL: boolean;
  40487. REFRACTIONFRESNEL: boolean;
  40488. EMISSIVEFRESNEL: boolean;
  40489. FRESNEL: boolean;
  40490. NORMAL: boolean;
  40491. UV1: boolean;
  40492. UV2: boolean;
  40493. VERTEXCOLOR: boolean;
  40494. VERTEXALPHA: boolean;
  40495. NUM_BONE_INFLUENCERS: number;
  40496. BonesPerMesh: number;
  40497. BONETEXTURE: boolean;
  40498. INSTANCES: boolean;
  40499. GLOSSINESS: boolean;
  40500. ROUGHNESS: boolean;
  40501. EMISSIVEASILLUMINATION: boolean;
  40502. LINKEMISSIVEWITHDIFFUSE: boolean;
  40503. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40504. LIGHTMAP: boolean;
  40505. LIGHTMAPDIRECTUV: number;
  40506. OBJECTSPACE_NORMALMAP: boolean;
  40507. USELIGHTMAPASSHADOWMAP: boolean;
  40508. REFLECTIONMAP_3D: boolean;
  40509. REFLECTIONMAP_SPHERICAL: boolean;
  40510. REFLECTIONMAP_PLANAR: boolean;
  40511. REFLECTIONMAP_CUBIC: boolean;
  40512. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40513. REFLECTIONMAP_PROJECTION: boolean;
  40514. REFLECTIONMAP_SKYBOX: boolean;
  40515. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40516. REFLECTIONMAP_EXPLICIT: boolean;
  40517. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40518. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40519. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40520. INVERTCUBICMAP: boolean;
  40521. LOGARITHMICDEPTH: boolean;
  40522. REFRACTION: boolean;
  40523. REFRACTIONMAP_3D: boolean;
  40524. REFLECTIONOVERALPHA: boolean;
  40525. TWOSIDEDLIGHTING: boolean;
  40526. SHADOWFLOAT: boolean;
  40527. MORPHTARGETS: boolean;
  40528. MORPHTARGETS_NORMAL: boolean;
  40529. MORPHTARGETS_TANGENT: boolean;
  40530. MORPHTARGETS_UV: boolean;
  40531. NUM_MORPH_INFLUENCERS: number;
  40532. NONUNIFORMSCALING: boolean;
  40533. PREMULTIPLYALPHA: boolean;
  40534. IMAGEPROCESSING: boolean;
  40535. VIGNETTE: boolean;
  40536. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40537. VIGNETTEBLENDMODEOPAQUE: boolean;
  40538. TONEMAPPING: boolean;
  40539. TONEMAPPING_ACES: boolean;
  40540. CONTRAST: boolean;
  40541. COLORCURVES: boolean;
  40542. COLORGRADING: boolean;
  40543. COLORGRADING3D: boolean;
  40544. SAMPLER3DGREENDEPTH: boolean;
  40545. SAMPLER3DBGRMAP: boolean;
  40546. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40547. MULTIVIEW: boolean;
  40548. /**
  40549. * If the reflection texture on this material is in linear color space
  40550. * @hidden
  40551. */
  40552. IS_REFLECTION_LINEAR: boolean;
  40553. /**
  40554. * If the refraction texture on this material is in linear color space
  40555. * @hidden
  40556. */
  40557. IS_REFRACTION_LINEAR: boolean;
  40558. EXPOSURE: boolean;
  40559. constructor();
  40560. setReflectionMode(modeToEnable: string): void;
  40561. }
  40562. /**
  40563. * This is the default material used in Babylon. It is the best trade off between quality
  40564. * and performances.
  40565. * @see http://doc.babylonjs.com/babylon101/materials
  40566. */
  40567. export class StandardMaterial extends PushMaterial {
  40568. private _diffuseTexture;
  40569. /**
  40570. * The basic texture of the material as viewed under a light.
  40571. */
  40572. diffuseTexture: Nullable<BaseTexture>;
  40573. private _ambientTexture;
  40574. /**
  40575. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40576. */
  40577. ambientTexture: Nullable<BaseTexture>;
  40578. private _opacityTexture;
  40579. /**
  40580. * Define the transparency of the material from a texture.
  40581. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40582. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40583. */
  40584. opacityTexture: Nullable<BaseTexture>;
  40585. private _reflectionTexture;
  40586. /**
  40587. * Define the texture used to display the reflection.
  40588. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40589. */
  40590. reflectionTexture: Nullable<BaseTexture>;
  40591. private _emissiveTexture;
  40592. /**
  40593. * Define texture of the material as if self lit.
  40594. * This will be mixed in the final result even in the absence of light.
  40595. */
  40596. emissiveTexture: Nullable<BaseTexture>;
  40597. private _specularTexture;
  40598. /**
  40599. * Define how the color and intensity of the highlight given by the light in the material.
  40600. */
  40601. specularTexture: Nullable<BaseTexture>;
  40602. private _bumpTexture;
  40603. /**
  40604. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40605. * 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.
  40606. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40607. */
  40608. bumpTexture: Nullable<BaseTexture>;
  40609. private _lightmapTexture;
  40610. /**
  40611. * Complex lighting can be computationally expensive to compute at runtime.
  40612. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40613. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40614. */
  40615. lightmapTexture: Nullable<BaseTexture>;
  40616. private _refractionTexture;
  40617. /**
  40618. * Define the texture used to display the refraction.
  40619. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40620. */
  40621. refractionTexture: Nullable<BaseTexture>;
  40622. /**
  40623. * The color of the material lit by the environmental background lighting.
  40624. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40625. */
  40626. ambientColor: Color3;
  40627. /**
  40628. * The basic color of the material as viewed under a light.
  40629. */
  40630. diffuseColor: Color3;
  40631. /**
  40632. * Define how the color and intensity of the highlight given by the light in the material.
  40633. */
  40634. specularColor: Color3;
  40635. /**
  40636. * Define the color of the material as if self lit.
  40637. * This will be mixed in the final result even in the absence of light.
  40638. */
  40639. emissiveColor: Color3;
  40640. /**
  40641. * Defines how sharp are the highlights in the material.
  40642. * The bigger the value the sharper giving a more glossy feeling to the result.
  40643. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40644. */
  40645. specularPower: number;
  40646. private _useAlphaFromDiffuseTexture;
  40647. /**
  40648. * Does the transparency come from the diffuse texture alpha channel.
  40649. */
  40650. useAlphaFromDiffuseTexture: boolean;
  40651. private _useEmissiveAsIllumination;
  40652. /**
  40653. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40654. */
  40655. useEmissiveAsIllumination: boolean;
  40656. private _linkEmissiveWithDiffuse;
  40657. /**
  40658. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40659. * the emissive level when the final color is close to one.
  40660. */
  40661. linkEmissiveWithDiffuse: boolean;
  40662. private _useSpecularOverAlpha;
  40663. /**
  40664. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40665. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40666. */
  40667. useSpecularOverAlpha: boolean;
  40668. private _useReflectionOverAlpha;
  40669. /**
  40670. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40671. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40672. */
  40673. useReflectionOverAlpha: boolean;
  40674. private _disableLighting;
  40675. /**
  40676. * Does lights from the scene impacts this material.
  40677. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40678. */
  40679. disableLighting: boolean;
  40680. private _useObjectSpaceNormalMap;
  40681. /**
  40682. * Allows using an object space normal map (instead of tangent space).
  40683. */
  40684. useObjectSpaceNormalMap: boolean;
  40685. private _useParallax;
  40686. /**
  40687. * Is parallax enabled or not.
  40688. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40689. */
  40690. useParallax: boolean;
  40691. private _useParallaxOcclusion;
  40692. /**
  40693. * Is parallax occlusion enabled or not.
  40694. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40695. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40696. */
  40697. useParallaxOcclusion: boolean;
  40698. /**
  40699. * 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.
  40700. */
  40701. parallaxScaleBias: number;
  40702. private _roughness;
  40703. /**
  40704. * Helps to define how blurry the reflections should appears in the material.
  40705. */
  40706. roughness: number;
  40707. /**
  40708. * In case of refraction, define the value of the index of refraction.
  40709. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40710. */
  40711. indexOfRefraction: number;
  40712. /**
  40713. * Invert the refraction texture alongside the y axis.
  40714. * It can be useful with procedural textures or probe for instance.
  40715. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40716. */
  40717. invertRefractionY: boolean;
  40718. /**
  40719. * Defines the alpha limits in alpha test mode.
  40720. */
  40721. alphaCutOff: number;
  40722. private _useLightmapAsShadowmap;
  40723. /**
  40724. * In case of light mapping, define whether the map contains light or shadow informations.
  40725. */
  40726. useLightmapAsShadowmap: boolean;
  40727. private _diffuseFresnelParameters;
  40728. /**
  40729. * Define the diffuse fresnel parameters of the material.
  40730. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40731. */
  40732. diffuseFresnelParameters: FresnelParameters;
  40733. private _opacityFresnelParameters;
  40734. /**
  40735. * Define the opacity fresnel parameters of the material.
  40736. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40737. */
  40738. opacityFresnelParameters: FresnelParameters;
  40739. private _reflectionFresnelParameters;
  40740. /**
  40741. * Define the reflection fresnel parameters of the material.
  40742. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40743. */
  40744. reflectionFresnelParameters: FresnelParameters;
  40745. private _refractionFresnelParameters;
  40746. /**
  40747. * Define the refraction fresnel parameters of the material.
  40748. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40749. */
  40750. refractionFresnelParameters: FresnelParameters;
  40751. private _emissiveFresnelParameters;
  40752. /**
  40753. * Define the emissive fresnel parameters of the material.
  40754. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40755. */
  40756. emissiveFresnelParameters: FresnelParameters;
  40757. private _useReflectionFresnelFromSpecular;
  40758. /**
  40759. * If true automatically deducts the fresnels values from the material specularity.
  40760. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40761. */
  40762. useReflectionFresnelFromSpecular: boolean;
  40763. private _useGlossinessFromSpecularMapAlpha;
  40764. /**
  40765. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40766. */
  40767. useGlossinessFromSpecularMapAlpha: boolean;
  40768. private _maxSimultaneousLights;
  40769. /**
  40770. * Defines the maximum number of lights that can be used in the material
  40771. */
  40772. maxSimultaneousLights: number;
  40773. private _invertNormalMapX;
  40774. /**
  40775. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40776. */
  40777. invertNormalMapX: boolean;
  40778. private _invertNormalMapY;
  40779. /**
  40780. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40781. */
  40782. invertNormalMapY: boolean;
  40783. private _twoSidedLighting;
  40784. /**
  40785. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40786. */
  40787. twoSidedLighting: boolean;
  40788. /**
  40789. * Default configuration related to image processing available in the standard Material.
  40790. */
  40791. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40792. /**
  40793. * Gets the image processing configuration used either in this material.
  40794. */
  40795. /**
  40796. * Sets the Default image processing configuration used either in the this material.
  40797. *
  40798. * If sets to null, the scene one is in use.
  40799. */
  40800. imageProcessingConfiguration: ImageProcessingConfiguration;
  40801. /**
  40802. * Keep track of the image processing observer to allow dispose and replace.
  40803. */
  40804. private _imageProcessingObserver;
  40805. /**
  40806. * Attaches a new image processing configuration to the Standard Material.
  40807. * @param configuration
  40808. */
  40809. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40810. /**
  40811. * Gets wether the color curves effect is enabled.
  40812. */
  40813. /**
  40814. * Sets wether the color curves effect is enabled.
  40815. */
  40816. cameraColorCurvesEnabled: boolean;
  40817. /**
  40818. * Gets wether the color grading effect is enabled.
  40819. */
  40820. /**
  40821. * Gets wether the color grading effect is enabled.
  40822. */
  40823. cameraColorGradingEnabled: boolean;
  40824. /**
  40825. * Gets wether tonemapping is enabled or not.
  40826. */
  40827. /**
  40828. * Sets wether tonemapping is enabled or not
  40829. */
  40830. cameraToneMappingEnabled: boolean;
  40831. /**
  40832. * The camera exposure used on this material.
  40833. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40834. * This corresponds to a photographic exposure.
  40835. */
  40836. /**
  40837. * The camera exposure used on this material.
  40838. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40839. * This corresponds to a photographic exposure.
  40840. */
  40841. cameraExposure: number;
  40842. /**
  40843. * Gets The camera contrast used on this material.
  40844. */
  40845. /**
  40846. * Sets The camera contrast used on this material.
  40847. */
  40848. cameraContrast: number;
  40849. /**
  40850. * Gets the Color Grading 2D Lookup Texture.
  40851. */
  40852. /**
  40853. * Sets the Color Grading 2D Lookup Texture.
  40854. */
  40855. cameraColorGradingTexture: Nullable<BaseTexture>;
  40856. /**
  40857. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40858. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40859. * 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;
  40860. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40861. */
  40862. /**
  40863. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40864. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40865. * 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;
  40866. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40867. */
  40868. cameraColorCurves: Nullable<ColorCurves>;
  40869. /**
  40870. * Custom callback helping to override the default shader used in the material.
  40871. */
  40872. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40873. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40874. protected _worldViewProjectionMatrix: Matrix;
  40875. protected _globalAmbientColor: Color3;
  40876. protected _useLogarithmicDepth: boolean;
  40877. /**
  40878. * Instantiates a new standard material.
  40879. * This is the default material used in Babylon. It is the best trade off between quality
  40880. * and performances.
  40881. * @see http://doc.babylonjs.com/babylon101/materials
  40882. * @param name Define the name of the material in the scene
  40883. * @param scene Define the scene the material belong to
  40884. */
  40885. constructor(name: string, scene: Scene);
  40886. /**
  40887. * Gets a boolean indicating that current material needs to register RTT
  40888. */
  40889. readonly hasRenderTargetTextures: boolean;
  40890. /**
  40891. * Gets the current class name of the material e.g. "StandardMaterial"
  40892. * Mainly use in serialization.
  40893. * @returns the class name
  40894. */
  40895. getClassName(): string;
  40896. /**
  40897. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40898. * You can try switching to logarithmic depth.
  40899. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40900. */
  40901. useLogarithmicDepth: boolean;
  40902. /**
  40903. * Specifies if the material will require alpha blending
  40904. * @returns a boolean specifying if alpha blending is needed
  40905. */
  40906. needAlphaBlending(): boolean;
  40907. /**
  40908. * Specifies if this material should be rendered in alpha test mode
  40909. * @returns a boolean specifying if an alpha test is needed.
  40910. */
  40911. needAlphaTesting(): boolean;
  40912. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40913. /**
  40914. * Get the texture used for alpha test purpose.
  40915. * @returns the diffuse texture in case of the standard material.
  40916. */
  40917. getAlphaTestTexture(): Nullable<BaseTexture>;
  40918. /**
  40919. * Get if the submesh is ready to be used and all its information available.
  40920. * Child classes can use it to update shaders
  40921. * @param mesh defines the mesh to check
  40922. * @param subMesh defines which submesh to check
  40923. * @param useInstances specifies that instances should be used
  40924. * @returns a boolean indicating that the submesh is ready or not
  40925. */
  40926. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40927. /**
  40928. * Builds the material UBO layouts.
  40929. * Used internally during the effect preparation.
  40930. */
  40931. buildUniformLayout(): void;
  40932. /**
  40933. * Unbinds the material from the mesh
  40934. */
  40935. unbind(): void;
  40936. /**
  40937. * Binds the submesh to this material by preparing the effect and shader to draw
  40938. * @param world defines the world transformation matrix
  40939. * @param mesh defines the mesh containing the submesh
  40940. * @param subMesh defines the submesh to bind the material to
  40941. */
  40942. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40943. /**
  40944. * Get the list of animatables in the material.
  40945. * @returns the list of animatables object used in the material
  40946. */
  40947. getAnimatables(): IAnimatable[];
  40948. /**
  40949. * Gets the active textures from the material
  40950. * @returns an array of textures
  40951. */
  40952. getActiveTextures(): BaseTexture[];
  40953. /**
  40954. * Specifies if the material uses a texture
  40955. * @param texture defines the texture to check against the material
  40956. * @returns a boolean specifying if the material uses the texture
  40957. */
  40958. hasTexture(texture: BaseTexture): boolean;
  40959. /**
  40960. * Disposes the material
  40961. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40962. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40963. */
  40964. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40965. /**
  40966. * Makes a duplicate of the material, and gives it a new name
  40967. * @param name defines the new name for the duplicated material
  40968. * @returns the cloned material
  40969. */
  40970. clone(name: string): StandardMaterial;
  40971. /**
  40972. * Serializes this material in a JSON representation
  40973. * @returns the serialized material object
  40974. */
  40975. serialize(): any;
  40976. /**
  40977. * Creates a standard material from parsed material data
  40978. * @param source defines the JSON representation of the material
  40979. * @param scene defines the hosting scene
  40980. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40981. * @returns a new standard material
  40982. */
  40983. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40984. /**
  40985. * Are diffuse textures enabled in the application.
  40986. */
  40987. static DiffuseTextureEnabled: boolean;
  40988. /**
  40989. * Are ambient textures enabled in the application.
  40990. */
  40991. static AmbientTextureEnabled: boolean;
  40992. /**
  40993. * Are opacity textures enabled in the application.
  40994. */
  40995. static OpacityTextureEnabled: boolean;
  40996. /**
  40997. * Are reflection textures enabled in the application.
  40998. */
  40999. static ReflectionTextureEnabled: boolean;
  41000. /**
  41001. * Are emissive textures enabled in the application.
  41002. */
  41003. static EmissiveTextureEnabled: boolean;
  41004. /**
  41005. * Are specular textures enabled in the application.
  41006. */
  41007. static SpecularTextureEnabled: boolean;
  41008. /**
  41009. * Are bump textures enabled in the application.
  41010. */
  41011. static BumpTextureEnabled: boolean;
  41012. /**
  41013. * Are lightmap textures enabled in the application.
  41014. */
  41015. static LightmapTextureEnabled: boolean;
  41016. /**
  41017. * Are refraction textures enabled in the application.
  41018. */
  41019. static RefractionTextureEnabled: boolean;
  41020. /**
  41021. * Are color grading textures enabled in the application.
  41022. */
  41023. static ColorGradingTextureEnabled: boolean;
  41024. /**
  41025. * Are fresnels enabled in the application.
  41026. */
  41027. static FresnelEnabled: boolean;
  41028. }
  41029. }
  41030. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41031. import { Scene } from "babylonjs/scene";
  41032. import { Texture } from "babylonjs/Materials/Textures/texture";
  41033. /**
  41034. * A class extending Texture allowing drawing on a texture
  41035. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41036. */
  41037. export class DynamicTexture extends Texture {
  41038. private _generateMipMaps;
  41039. private _canvas;
  41040. private _context;
  41041. private _engine;
  41042. /**
  41043. * Creates a DynamicTexture
  41044. * @param name defines the name of the texture
  41045. * @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
  41046. * @param scene defines the scene where you want the texture
  41047. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41048. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41049. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41050. */
  41051. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41052. /**
  41053. * Get the current class name of the texture useful for serialization or dynamic coding.
  41054. * @returns "DynamicTexture"
  41055. */
  41056. getClassName(): string;
  41057. /**
  41058. * Gets the current state of canRescale
  41059. */
  41060. readonly canRescale: boolean;
  41061. private _recreate;
  41062. /**
  41063. * Scales the texture
  41064. * @param ratio the scale factor to apply to both width and height
  41065. */
  41066. scale(ratio: number): void;
  41067. /**
  41068. * Resizes the texture
  41069. * @param width the new width
  41070. * @param height the new height
  41071. */
  41072. scaleTo(width: number, height: number): void;
  41073. /**
  41074. * Gets the context of the canvas used by the texture
  41075. * @returns the canvas context of the dynamic texture
  41076. */
  41077. getContext(): CanvasRenderingContext2D;
  41078. /**
  41079. * Clears the texture
  41080. */
  41081. clear(): void;
  41082. /**
  41083. * Updates the texture
  41084. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41085. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41086. */
  41087. update(invertY?: boolean, premulAlpha?: boolean): void;
  41088. /**
  41089. * Draws text onto the texture
  41090. * @param text defines the text to be drawn
  41091. * @param x defines the placement of the text from the left
  41092. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41093. * @param font defines the font to be used with font-style, font-size, font-name
  41094. * @param color defines the color used for the text
  41095. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41096. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41097. * @param update defines whether texture is immediately update (default is true)
  41098. */
  41099. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41100. /**
  41101. * Clones the texture
  41102. * @returns the clone of the texture.
  41103. */
  41104. clone(): DynamicTexture;
  41105. /**
  41106. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41107. * @returns a serialized dynamic texture object
  41108. */
  41109. serialize(): any;
  41110. /** @hidden */
  41111. _rebuild(): void;
  41112. }
  41113. }
  41114. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41115. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41116. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41117. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41118. /** @hidden */
  41119. export var imageProcessingPixelShader: {
  41120. name: string;
  41121. shader: string;
  41122. };
  41123. }
  41124. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41125. import { Nullable } from "babylonjs/types";
  41126. import { Color4 } from "babylonjs/Maths/math";
  41127. import { Camera } from "babylonjs/Cameras/camera";
  41128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41129. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41130. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41131. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41132. import { Engine } from "babylonjs/Engines/engine";
  41133. import "babylonjs/Shaders/imageProcessing.fragment";
  41134. import "babylonjs/Shaders/postprocess.vertex";
  41135. /**
  41136. * ImageProcessingPostProcess
  41137. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41138. */
  41139. export class ImageProcessingPostProcess extends PostProcess {
  41140. /**
  41141. * Default configuration related to image processing available in the PBR Material.
  41142. */
  41143. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41144. /**
  41145. * Gets the image processing configuration used either in this material.
  41146. */
  41147. /**
  41148. * Sets the Default image processing configuration used either in the this material.
  41149. *
  41150. * If sets to null, the scene one is in use.
  41151. */
  41152. imageProcessingConfiguration: ImageProcessingConfiguration;
  41153. /**
  41154. * Keep track of the image processing observer to allow dispose and replace.
  41155. */
  41156. private _imageProcessingObserver;
  41157. /**
  41158. * Attaches a new image processing configuration to the PBR Material.
  41159. * @param configuration
  41160. */
  41161. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41162. /**
  41163. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41164. */
  41165. /**
  41166. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41167. */
  41168. colorCurves: Nullable<ColorCurves>;
  41169. /**
  41170. * Gets wether the color curves effect is enabled.
  41171. */
  41172. /**
  41173. * Sets wether the color curves effect is enabled.
  41174. */
  41175. colorCurvesEnabled: boolean;
  41176. /**
  41177. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41178. */
  41179. /**
  41180. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41181. */
  41182. colorGradingTexture: Nullable<BaseTexture>;
  41183. /**
  41184. * Gets wether the color grading effect is enabled.
  41185. */
  41186. /**
  41187. * Gets wether the color grading effect is enabled.
  41188. */
  41189. colorGradingEnabled: boolean;
  41190. /**
  41191. * Gets exposure used in the effect.
  41192. */
  41193. /**
  41194. * Sets exposure used in the effect.
  41195. */
  41196. exposure: number;
  41197. /**
  41198. * Gets wether tonemapping is enabled or not.
  41199. */
  41200. /**
  41201. * Sets wether tonemapping is enabled or not
  41202. */
  41203. toneMappingEnabled: boolean;
  41204. /**
  41205. * Gets the type of tone mapping effect.
  41206. */
  41207. /**
  41208. * Sets the type of tone mapping effect.
  41209. */
  41210. toneMappingType: number;
  41211. /**
  41212. * Gets contrast used in the effect.
  41213. */
  41214. /**
  41215. * Sets contrast used in the effect.
  41216. */
  41217. contrast: number;
  41218. /**
  41219. * Gets Vignette stretch size.
  41220. */
  41221. /**
  41222. * Sets Vignette stretch size.
  41223. */
  41224. vignetteStretch: number;
  41225. /**
  41226. * Gets Vignette centre X Offset.
  41227. */
  41228. /**
  41229. * Sets Vignette centre X Offset.
  41230. */
  41231. vignetteCentreX: number;
  41232. /**
  41233. * Gets Vignette centre Y Offset.
  41234. */
  41235. /**
  41236. * Sets Vignette centre Y Offset.
  41237. */
  41238. vignetteCentreY: number;
  41239. /**
  41240. * Gets Vignette weight or intensity of the vignette effect.
  41241. */
  41242. /**
  41243. * Sets Vignette weight or intensity of the vignette effect.
  41244. */
  41245. vignetteWeight: number;
  41246. /**
  41247. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41248. * if vignetteEnabled is set to true.
  41249. */
  41250. /**
  41251. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41252. * if vignetteEnabled is set to true.
  41253. */
  41254. vignetteColor: Color4;
  41255. /**
  41256. * Gets Camera field of view used by the Vignette effect.
  41257. */
  41258. /**
  41259. * Sets Camera field of view used by the Vignette effect.
  41260. */
  41261. vignetteCameraFov: number;
  41262. /**
  41263. * Gets the vignette blend mode allowing different kind of effect.
  41264. */
  41265. /**
  41266. * Sets the vignette blend mode allowing different kind of effect.
  41267. */
  41268. vignetteBlendMode: number;
  41269. /**
  41270. * Gets wether the vignette effect is enabled.
  41271. */
  41272. /**
  41273. * Sets wether the vignette effect is enabled.
  41274. */
  41275. vignetteEnabled: boolean;
  41276. private _fromLinearSpace;
  41277. /**
  41278. * Gets wether the input of the processing is in Gamma or Linear Space.
  41279. */
  41280. /**
  41281. * Sets wether the input of the processing is in Gamma or Linear Space.
  41282. */
  41283. fromLinearSpace: boolean;
  41284. /**
  41285. * Defines cache preventing GC.
  41286. */
  41287. private _defines;
  41288. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41289. /**
  41290. * "ImageProcessingPostProcess"
  41291. * @returns "ImageProcessingPostProcess"
  41292. */
  41293. getClassName(): string;
  41294. protected _updateParameters(): void;
  41295. dispose(camera?: Camera): void;
  41296. }
  41297. }
  41298. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41299. import { Scene } from "babylonjs/scene";
  41300. import { Color3 } from "babylonjs/Maths/math";
  41301. import { Mesh } from "babylonjs/Meshes/mesh";
  41302. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41303. import { Nullable } from "babylonjs/types";
  41304. /**
  41305. * Class containing static functions to help procedurally build meshes
  41306. */
  41307. export class GroundBuilder {
  41308. /**
  41309. * Creates a ground mesh
  41310. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41311. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41313. * @param name defines the name of the mesh
  41314. * @param options defines the options used to create the mesh
  41315. * @param scene defines the hosting scene
  41316. * @returns the ground mesh
  41317. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41318. */
  41319. static CreateGround(name: string, options: {
  41320. width?: number;
  41321. height?: number;
  41322. subdivisions?: number;
  41323. subdivisionsX?: number;
  41324. subdivisionsY?: number;
  41325. updatable?: boolean;
  41326. }, scene: any): Mesh;
  41327. /**
  41328. * Creates a tiled ground mesh
  41329. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41330. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41331. * * 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
  41332. * * 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
  41333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41334. * @param name defines the name of the mesh
  41335. * @param options defines the options used to create the mesh
  41336. * @param scene defines the hosting scene
  41337. * @returns the tiled ground mesh
  41338. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41339. */
  41340. static CreateTiledGround(name: string, options: {
  41341. xmin: number;
  41342. zmin: number;
  41343. xmax: number;
  41344. zmax: number;
  41345. subdivisions?: {
  41346. w: number;
  41347. h: number;
  41348. };
  41349. precision?: {
  41350. w: number;
  41351. h: number;
  41352. };
  41353. updatable?: boolean;
  41354. }, scene?: Nullable<Scene>): Mesh;
  41355. /**
  41356. * Creates a ground mesh from a height map
  41357. * * The parameter `url` sets the URL of the height map image resource.
  41358. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41359. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41360. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41361. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41362. * * 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.
  41363. * * 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).
  41364. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41366. * @param name defines the name of the mesh
  41367. * @param url defines the url to the height map
  41368. * @param options defines the options used to create the mesh
  41369. * @param scene defines the hosting scene
  41370. * @returns the ground mesh
  41371. * @see https://doc.babylonjs.com/babylon101/height_map
  41372. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41373. */
  41374. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41375. width?: number;
  41376. height?: number;
  41377. subdivisions?: number;
  41378. minHeight?: number;
  41379. maxHeight?: number;
  41380. colorFilter?: Color3;
  41381. alphaFilter?: number;
  41382. updatable?: boolean;
  41383. onReady?: (mesh: GroundMesh) => void;
  41384. }, scene?: Nullable<Scene>): GroundMesh;
  41385. }
  41386. }
  41387. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41388. import { Vector4 } from "babylonjs/Maths/math";
  41389. import { Mesh } from "babylonjs/Meshes/mesh";
  41390. /**
  41391. * Class containing static functions to help procedurally build meshes
  41392. */
  41393. export class TorusBuilder {
  41394. /**
  41395. * Creates a torus mesh
  41396. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41397. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41398. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41402. * @param name defines the name of the mesh
  41403. * @param options defines the options used to create the mesh
  41404. * @param scene defines the hosting scene
  41405. * @returns the torus mesh
  41406. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41407. */
  41408. static CreateTorus(name: string, options: {
  41409. diameter?: number;
  41410. thickness?: number;
  41411. tessellation?: number;
  41412. updatable?: boolean;
  41413. sideOrientation?: number;
  41414. frontUVs?: Vector4;
  41415. backUVs?: Vector4;
  41416. }, scene: any): Mesh;
  41417. }
  41418. }
  41419. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41420. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41421. import { Mesh } from "babylonjs/Meshes/mesh";
  41422. /**
  41423. * Class containing static functions to help procedurally build meshes
  41424. */
  41425. export class CylinderBuilder {
  41426. /**
  41427. * Creates a cylinder or a cone mesh
  41428. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41429. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41430. * * 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.
  41431. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41432. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41433. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41434. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41435. * * 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).
  41436. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41437. * * 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).
  41438. * * 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
  41439. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41440. * * 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
  41441. * * 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.
  41442. * * If `enclose` is false, a ring surface is one element.
  41443. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41444. * * 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
  41445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41448. * @param name defines the name of the mesh
  41449. * @param options defines the options used to create the mesh
  41450. * @param scene defines the hosting scene
  41451. * @returns the cylinder mesh
  41452. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41453. */
  41454. static CreateCylinder(name: string, options: {
  41455. height?: number;
  41456. diameterTop?: number;
  41457. diameterBottom?: number;
  41458. diameter?: number;
  41459. tessellation?: number;
  41460. subdivisions?: number;
  41461. arc?: number;
  41462. faceColors?: Color4[];
  41463. faceUV?: Vector4[];
  41464. updatable?: boolean;
  41465. hasRings?: boolean;
  41466. enclose?: boolean;
  41467. cap?: number;
  41468. sideOrientation?: number;
  41469. frontUVs?: Vector4;
  41470. backUVs?: Vector4;
  41471. }, scene: any): Mesh;
  41472. }
  41473. }
  41474. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41475. import { Observable } from "babylonjs/Misc/observable";
  41476. import { Nullable } from "babylonjs/types";
  41477. import { Camera } from "babylonjs/Cameras/camera";
  41478. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41479. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41480. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41481. import { Scene } from "babylonjs/scene";
  41482. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41483. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41485. import { Mesh } from "babylonjs/Meshes/mesh";
  41486. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41487. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41488. import "babylonjs/Meshes/Builders/groundBuilder";
  41489. import "babylonjs/Meshes/Builders/torusBuilder";
  41490. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41491. import "babylonjs/Gamepads/gamepadSceneComponent";
  41492. import "babylonjs/Animations/animatable";
  41493. /**
  41494. * Options to modify the vr teleportation behavior.
  41495. */
  41496. export interface VRTeleportationOptions {
  41497. /**
  41498. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41499. */
  41500. floorMeshName?: string;
  41501. /**
  41502. * A list of meshes to be used as the teleportation floor. (default: empty)
  41503. */
  41504. floorMeshes?: Mesh[];
  41505. }
  41506. /**
  41507. * Options to modify the vr experience helper's behavior.
  41508. */
  41509. export interface VRExperienceHelperOptions extends WebVROptions {
  41510. /**
  41511. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41512. */
  41513. createDeviceOrientationCamera?: boolean;
  41514. /**
  41515. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41516. */
  41517. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41518. /**
  41519. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41520. */
  41521. laserToggle?: boolean;
  41522. /**
  41523. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41524. */
  41525. floorMeshes?: Mesh[];
  41526. /**
  41527. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41528. */
  41529. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41530. }
  41531. /**
  41532. * Event containing information after VR has been entered
  41533. */
  41534. export class OnAfterEnteringVRObservableEvent {
  41535. /**
  41536. * If entering vr was successful
  41537. */
  41538. success: boolean;
  41539. }
  41540. /**
  41541. * Helps to quickly add VR support to an existing scene.
  41542. * See http://doc.babylonjs.com/how_to/webvr_helper
  41543. */
  41544. export class VRExperienceHelper {
  41545. /** Options to modify the vr experience helper's behavior. */
  41546. webVROptions: VRExperienceHelperOptions;
  41547. private _scene;
  41548. private _position;
  41549. private _btnVR;
  41550. private _btnVRDisplayed;
  41551. private _webVRsupported;
  41552. private _webVRready;
  41553. private _webVRrequesting;
  41554. private _webVRpresenting;
  41555. private _hasEnteredVR;
  41556. private _fullscreenVRpresenting;
  41557. private _canvas;
  41558. private _webVRCamera;
  41559. private _vrDeviceOrientationCamera;
  41560. private _deviceOrientationCamera;
  41561. private _existingCamera;
  41562. private _onKeyDown;
  41563. private _onVrDisplayPresentChange;
  41564. private _onVRDisplayChanged;
  41565. private _onVRRequestPresentStart;
  41566. private _onVRRequestPresentComplete;
  41567. /**
  41568. * Observable raised right before entering VR.
  41569. */
  41570. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41571. /**
  41572. * Observable raised when entering VR has completed.
  41573. */
  41574. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41575. /**
  41576. * Observable raised when exiting VR.
  41577. */
  41578. onExitingVRObservable: Observable<VRExperienceHelper>;
  41579. /**
  41580. * Observable raised when controller mesh is loaded.
  41581. */
  41582. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41583. /** Return this.onEnteringVRObservable
  41584. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41585. */
  41586. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41587. /** Return this.onExitingVRObservable
  41588. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41589. */
  41590. readonly onExitingVR: Observable<VRExperienceHelper>;
  41591. /** Return this.onControllerMeshLoadedObservable
  41592. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41593. */
  41594. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41595. private _rayLength;
  41596. private _useCustomVRButton;
  41597. private _teleportationRequested;
  41598. private _teleportActive;
  41599. private _floorMeshName;
  41600. private _floorMeshesCollection;
  41601. private _rotationAllowed;
  41602. private _teleportBackwardsVector;
  41603. private _teleportationTarget;
  41604. private _isDefaultTeleportationTarget;
  41605. private _postProcessMove;
  41606. private _teleportationFillColor;
  41607. private _teleportationBorderColor;
  41608. private _rotationAngle;
  41609. private _haloCenter;
  41610. private _cameraGazer;
  41611. private _padSensibilityUp;
  41612. private _padSensibilityDown;
  41613. private _leftController;
  41614. private _rightController;
  41615. /**
  41616. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41617. */
  41618. onNewMeshSelected: Observable<AbstractMesh>;
  41619. /**
  41620. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41621. */
  41622. onNewMeshPicked: Observable<PickingInfo>;
  41623. private _circleEase;
  41624. /**
  41625. * Observable raised before camera teleportation
  41626. */
  41627. onBeforeCameraTeleport: Observable<Vector3>;
  41628. /**
  41629. * Observable raised after camera teleportation
  41630. */
  41631. onAfterCameraTeleport: Observable<Vector3>;
  41632. /**
  41633. * Observable raised when current selected mesh gets unselected
  41634. */
  41635. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41636. private _raySelectionPredicate;
  41637. /**
  41638. * To be optionaly changed by user to define custom ray selection
  41639. */
  41640. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41641. /**
  41642. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41643. */
  41644. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41645. /**
  41646. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41647. */
  41648. teleportationEnabled: boolean;
  41649. private _defaultHeight;
  41650. private _teleportationInitialized;
  41651. private _interactionsEnabled;
  41652. private _interactionsRequested;
  41653. private _displayGaze;
  41654. private _displayLaserPointer;
  41655. /**
  41656. * The mesh used to display where the user is going to teleport.
  41657. */
  41658. /**
  41659. * Sets the mesh to be used to display where the user is going to teleport.
  41660. */
  41661. teleportationTarget: Mesh;
  41662. /**
  41663. * 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
  41664. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41665. * See http://doc.babylonjs.com/resources/baking_transformations
  41666. */
  41667. gazeTrackerMesh: Mesh;
  41668. /**
  41669. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41670. */
  41671. updateGazeTrackerScale: boolean;
  41672. /**
  41673. * If the gaze trackers color should be updated when selecting meshes
  41674. */
  41675. updateGazeTrackerColor: boolean;
  41676. /**
  41677. * The gaze tracking mesh corresponding to the left controller
  41678. */
  41679. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41680. /**
  41681. * The gaze tracking mesh corresponding to the right controller
  41682. */
  41683. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41684. /**
  41685. * If the ray of the gaze should be displayed.
  41686. */
  41687. /**
  41688. * Sets if the ray of the gaze should be displayed.
  41689. */
  41690. displayGaze: boolean;
  41691. /**
  41692. * If the ray of the LaserPointer should be displayed.
  41693. */
  41694. /**
  41695. * Sets if the ray of the LaserPointer should be displayed.
  41696. */
  41697. displayLaserPointer: boolean;
  41698. /**
  41699. * The deviceOrientationCamera used as the camera when not in VR.
  41700. */
  41701. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41702. /**
  41703. * Based on the current WebVR support, returns the current VR camera used.
  41704. */
  41705. readonly currentVRCamera: Nullable<Camera>;
  41706. /**
  41707. * The webVRCamera which is used when in VR.
  41708. */
  41709. readonly webVRCamera: WebVRFreeCamera;
  41710. /**
  41711. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41712. */
  41713. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41714. private readonly _teleportationRequestInitiated;
  41715. /**
  41716. * Defines wether or not Pointer lock should be requested when switching to
  41717. * full screen.
  41718. */
  41719. requestPointerLockOnFullScreen: boolean;
  41720. /**
  41721. * Instantiates a VRExperienceHelper.
  41722. * Helps to quickly add VR support to an existing scene.
  41723. * @param scene The scene the VRExperienceHelper belongs to.
  41724. * @param webVROptions Options to modify the vr experience helper's behavior.
  41725. */
  41726. constructor(scene: Scene,
  41727. /** Options to modify the vr experience helper's behavior. */
  41728. webVROptions?: VRExperienceHelperOptions);
  41729. private _onDefaultMeshLoaded;
  41730. private _onResize;
  41731. private _onFullscreenChange;
  41732. /**
  41733. * Gets a value indicating if we are currently in VR mode.
  41734. */
  41735. readonly isInVRMode: boolean;
  41736. private onVrDisplayPresentChange;
  41737. private onVRDisplayChanged;
  41738. private moveButtonToBottomRight;
  41739. private displayVRButton;
  41740. private updateButtonVisibility;
  41741. private _cachedAngularSensibility;
  41742. /**
  41743. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41744. * Otherwise, will use the fullscreen API.
  41745. */
  41746. enterVR(): void;
  41747. /**
  41748. * Attempt to exit VR, or fullscreen.
  41749. */
  41750. exitVR(): void;
  41751. /**
  41752. * The position of the vr experience helper.
  41753. */
  41754. /**
  41755. * Sets the position of the vr experience helper.
  41756. */
  41757. position: Vector3;
  41758. /**
  41759. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41760. */
  41761. enableInteractions(): void;
  41762. private readonly _noControllerIsActive;
  41763. private beforeRender;
  41764. private _isTeleportationFloor;
  41765. /**
  41766. * Adds a floor mesh to be used for teleportation.
  41767. * @param floorMesh the mesh to be used for teleportation.
  41768. */
  41769. addFloorMesh(floorMesh: Mesh): void;
  41770. /**
  41771. * Removes a floor mesh from being used for teleportation.
  41772. * @param floorMesh the mesh to be removed.
  41773. */
  41774. removeFloorMesh(floorMesh: Mesh): void;
  41775. /**
  41776. * Enables interactions and teleportation using the VR controllers and gaze.
  41777. * @param vrTeleportationOptions options to modify teleportation behavior.
  41778. */
  41779. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41780. private _onNewGamepadConnected;
  41781. private _tryEnableInteractionOnController;
  41782. private _onNewGamepadDisconnected;
  41783. private _enableInteractionOnController;
  41784. private _checkTeleportWithRay;
  41785. private _checkRotate;
  41786. private _checkTeleportBackwards;
  41787. private _enableTeleportationOnController;
  41788. private _createTeleportationCircles;
  41789. private _displayTeleportationTarget;
  41790. private _hideTeleportationTarget;
  41791. private _rotateCamera;
  41792. private _moveTeleportationSelectorTo;
  41793. private _workingVector;
  41794. private _workingQuaternion;
  41795. private _workingMatrix;
  41796. /**
  41797. * Teleports the users feet to the desired location
  41798. * @param location The location where the user's feet should be placed
  41799. */
  41800. teleportCamera(location: Vector3): void;
  41801. private _convertNormalToDirectionOfRay;
  41802. private _castRayAndSelectObject;
  41803. private _notifySelectedMeshUnselected;
  41804. /**
  41805. * Sets the color of the laser ray from the vr controllers.
  41806. * @param color new color for the ray.
  41807. */
  41808. changeLaserColor(color: Color3): void;
  41809. /**
  41810. * Sets the color of the ray from the vr headsets gaze.
  41811. * @param color new color for the ray.
  41812. */
  41813. changeGazeColor(color: Color3): void;
  41814. /**
  41815. * Exits VR and disposes of the vr experience helper
  41816. */
  41817. dispose(): void;
  41818. /**
  41819. * Gets the name of the VRExperienceHelper class
  41820. * @returns "VRExperienceHelper"
  41821. */
  41822. getClassName(): string;
  41823. }
  41824. }
  41825. declare module "babylonjs/Cameras/VR/index" {
  41826. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41827. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41828. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41829. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41830. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41831. export * from "babylonjs/Cameras/VR/webVRCamera";
  41832. }
  41833. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41834. import { Observable } from "babylonjs/Misc/observable";
  41835. import { Nullable } from "babylonjs/types";
  41836. import { IDisposable, Scene } from "babylonjs/scene";
  41837. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41838. /**
  41839. * Manages an XRSession to work with Babylon's engine
  41840. * @see https://doc.babylonjs.com/how_to/webxr
  41841. */
  41842. export class WebXRSessionManager implements IDisposable {
  41843. private scene;
  41844. /**
  41845. * Fires every time a new xrFrame arrives which can be used to update the camera
  41846. */
  41847. onXRFrameObservable: Observable<any>;
  41848. /**
  41849. * Fires when the xr session is ended either by the device or manually done
  41850. */
  41851. onXRSessionEnded: Observable<any>;
  41852. /**
  41853. * Underlying xr session
  41854. */
  41855. session: XRSession;
  41856. /**
  41857. * Type of reference space used when creating the session
  41858. */
  41859. referenceSpace: XRReferenceSpace;
  41860. /** @hidden */
  41861. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41862. /**
  41863. * Current XR frame
  41864. */
  41865. currentFrame: Nullable<XRFrame>;
  41866. private _xrNavigator;
  41867. private baseLayer;
  41868. /**
  41869. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41870. * @param scene The scene which the session should be created for
  41871. */
  41872. constructor(scene: Scene);
  41873. /**
  41874. * Initializes the manager
  41875. * After initialization enterXR can be called to start an XR session
  41876. * @returns Promise which resolves after it is initialized
  41877. */
  41878. initializeAsync(): Promise<void>;
  41879. /**
  41880. * Initializes an xr session
  41881. * @param xrSessionMode mode to initialize
  41882. * @returns a promise which will resolve once the session has been initialized
  41883. */
  41884. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41885. /**
  41886. * Sets the reference space on the xr session
  41887. * @param referenceSpace space to set
  41888. * @returns a promise that will resolve once the reference space has been set
  41889. */
  41890. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41891. /**
  41892. * Updates the render state of the session
  41893. * @param state state to set
  41894. * @returns a promise that resolves once the render state has been updated
  41895. */
  41896. updateRenderStateAsync(state: any): Promise<void>;
  41897. /**
  41898. * Starts rendering to the xr layer
  41899. * @returns a promise that will resolve once rendering has started
  41900. */
  41901. startRenderingToXRAsync(): Promise<void>;
  41902. /**
  41903. * Stops the xrSession and restores the renderloop
  41904. * @returns Promise which resolves after it exits XR
  41905. */
  41906. exitXRAsync(): Promise<void>;
  41907. /**
  41908. * Checks if a session would be supported for the creation options specified
  41909. * @param sessionMode session mode to check if supported eg. immersive-vr
  41910. * @returns true if supported
  41911. */
  41912. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41913. /**
  41914. * @hidden
  41915. * Converts the render layer of xrSession to a render target
  41916. * @param session session to create render target for
  41917. * @param scene scene the new render target should be created for
  41918. */
  41919. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41920. /**
  41921. * Disposes of the session manager
  41922. */
  41923. dispose(): void;
  41924. }
  41925. }
  41926. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41927. import { Scene } from "babylonjs/scene";
  41928. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41929. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41930. /**
  41931. * WebXR Camera which holds the views for the xrSession
  41932. * @see https://doc.babylonjs.com/how_to/webxr
  41933. */
  41934. export class WebXRCamera extends FreeCamera {
  41935. private static _TmpMatrix;
  41936. /**
  41937. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41938. * @param name the name of the camera
  41939. * @param scene the scene to add the camera to
  41940. */
  41941. constructor(name: string, scene: Scene);
  41942. private _updateNumberOfRigCameras;
  41943. /** @hidden */
  41944. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41945. /**
  41946. * Updates the cameras position from the current pose information of the XR session
  41947. * @param xrSessionManager the session containing pose information
  41948. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41949. */
  41950. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41951. }
  41952. }
  41953. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41954. import { Nullable } from "babylonjs/types";
  41955. import { IDisposable } from "babylonjs/scene";
  41956. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41957. /**
  41958. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41959. */
  41960. export class WebXRManagedOutputCanvas implements IDisposable {
  41961. private helper;
  41962. private _canvas;
  41963. /**
  41964. * xrpresent context of the canvas which can be used to display/mirror xr content
  41965. */
  41966. canvasContext: WebGLRenderingContext;
  41967. /**
  41968. * xr layer for the canvas
  41969. */
  41970. xrLayer: Nullable<XRWebGLLayer>;
  41971. /**
  41972. * Initializes the xr layer for the session
  41973. * @param xrSession xr session
  41974. * @returns a promise that will resolve once the XR Layer has been created
  41975. */
  41976. initializeXRLayerAsync(xrSession: any): any;
  41977. /**
  41978. * Initializes the canvas to be added/removed upon entering/exiting xr
  41979. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41980. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41981. */
  41982. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41983. /**
  41984. * Disposes of the object
  41985. */
  41986. dispose(): void;
  41987. private _setManagedOutputCanvas;
  41988. private _addCanvas;
  41989. private _removeCanvas;
  41990. }
  41991. }
  41992. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41993. import { Observable } from "babylonjs/Misc/observable";
  41994. import { IDisposable, Scene } from "babylonjs/scene";
  41995. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41997. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41998. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41999. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42000. /**
  42001. * States of the webXR experience
  42002. */
  42003. export enum WebXRState {
  42004. /**
  42005. * Transitioning to being in XR mode
  42006. */
  42007. ENTERING_XR = 0,
  42008. /**
  42009. * Transitioning to non XR mode
  42010. */
  42011. EXITING_XR = 1,
  42012. /**
  42013. * In XR mode and presenting
  42014. */
  42015. IN_XR = 2,
  42016. /**
  42017. * Not entered XR mode
  42018. */
  42019. NOT_IN_XR = 3
  42020. }
  42021. /**
  42022. * Helper class used to enable XR
  42023. * @see https://doc.babylonjs.com/how_to/webxr
  42024. */
  42025. export class WebXRExperienceHelper implements IDisposable {
  42026. private scene;
  42027. /**
  42028. * 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
  42029. */
  42030. container: AbstractMesh;
  42031. /**
  42032. * Camera used to render xr content
  42033. */
  42034. camera: WebXRCamera;
  42035. /**
  42036. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42037. */
  42038. state: WebXRState;
  42039. private _setState;
  42040. private static _TmpVector;
  42041. /**
  42042. * Fires when the state of the experience helper has changed
  42043. */
  42044. onStateChangedObservable: Observable<WebXRState>;
  42045. /** Session manager used to keep track of xr session */
  42046. sessionManager: WebXRSessionManager;
  42047. private _nonVRCamera;
  42048. private _originalSceneAutoClear;
  42049. private _supported;
  42050. /**
  42051. * Creates the experience helper
  42052. * @param scene the scene to attach the experience helper to
  42053. * @returns a promise for the experience helper
  42054. */
  42055. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42056. /**
  42057. * Creates a WebXRExperienceHelper
  42058. * @param scene The scene the helper should be created in
  42059. */
  42060. private constructor();
  42061. /**
  42062. * Exits XR mode and returns the scene to its original state
  42063. * @returns promise that resolves after xr mode has exited
  42064. */
  42065. exitXRAsync(): Promise<void>;
  42066. /**
  42067. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42068. * @param sessionCreationOptions options for the XR session
  42069. * @param referenceSpaceType frame of reference of the XR session
  42070. * @param outputCanvas the output canvas that will be used to enter XR mode
  42071. * @returns promise that resolves after xr mode has entered
  42072. */
  42073. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42074. /**
  42075. * Updates the global position of the camera by moving the camera's container
  42076. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42077. * @param position The desired global position of the camera
  42078. */
  42079. setPositionOfCameraUsingContainer(position: Vector3): void;
  42080. /**
  42081. * Rotates the xr camera by rotating the camera's container around the camera's position
  42082. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42083. * @param rotation the desired quaternion rotation to apply to the camera
  42084. */
  42085. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42086. /**
  42087. * Disposes of the experience helper
  42088. */
  42089. dispose(): void;
  42090. }
  42091. }
  42092. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42093. import { Nullable } from "babylonjs/types";
  42094. import { Observable } from "babylonjs/Misc/observable";
  42095. import { IDisposable, Scene } from "babylonjs/scene";
  42096. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42097. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42098. /**
  42099. * Button which can be used to enter a different mode of XR
  42100. */
  42101. export class WebXREnterExitUIButton {
  42102. /** button element */
  42103. element: HTMLElement;
  42104. /** XR initialization options for the button */
  42105. sessionMode: XRSessionMode;
  42106. /** Reference space type */
  42107. referenceSpaceType: XRReferenceSpaceType;
  42108. /**
  42109. * Creates a WebXREnterExitUIButton
  42110. * @param element button element
  42111. * @param sessionMode XR initialization session mode
  42112. * @param referenceSpaceType the type of reference space to be used
  42113. */
  42114. constructor(
  42115. /** button element */
  42116. element: HTMLElement,
  42117. /** XR initialization options for the button */
  42118. sessionMode: XRSessionMode,
  42119. /** Reference space type */
  42120. referenceSpaceType: XRReferenceSpaceType);
  42121. /**
  42122. * Overwritable function which can be used to update the button's visuals when the state changes
  42123. * @param activeButton the current active button in the UI
  42124. */
  42125. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42126. }
  42127. /**
  42128. * Options to create the webXR UI
  42129. */
  42130. export class WebXREnterExitUIOptions {
  42131. /**
  42132. * Context to enter xr with
  42133. */
  42134. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42135. /**
  42136. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42137. */
  42138. customButtons?: Array<WebXREnterExitUIButton>;
  42139. }
  42140. /**
  42141. * UI to allow the user to enter/exit XR mode
  42142. */
  42143. export class WebXREnterExitUI implements IDisposable {
  42144. private scene;
  42145. private _overlay;
  42146. private _buttons;
  42147. private _activeButton;
  42148. /**
  42149. * Fired every time the active button is changed.
  42150. *
  42151. * When xr is entered via a button that launches xr that button will be the callback parameter
  42152. *
  42153. * When exiting xr the callback parameter will be null)
  42154. */
  42155. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42156. /**
  42157. * Creates UI to allow the user to enter/exit XR mode
  42158. * @param scene the scene to add the ui to
  42159. * @param helper the xr experience helper to enter/exit xr with
  42160. * @param options options to configure the UI
  42161. * @returns the created ui
  42162. */
  42163. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42164. private constructor();
  42165. private _updateButtons;
  42166. /**
  42167. * Disposes of the object
  42168. */
  42169. dispose(): void;
  42170. }
  42171. }
  42172. declare module "babylonjs/Cameras/XR/webXRInput" {
  42173. import { Nullable } from "babylonjs/types";
  42174. import { Observable } from "babylonjs/Misc/observable";
  42175. import { IDisposable, Scene } from "babylonjs/scene";
  42176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42177. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42178. /**
  42179. * Represents an XR input
  42180. */
  42181. export class WebXRController {
  42182. private scene;
  42183. /** The underlying input source for the controller */
  42184. inputSource: XRInputSource;
  42185. private parentContainer;
  42186. /**
  42187. * 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
  42188. */
  42189. grip?: AbstractMesh;
  42190. /**
  42191. * Pointer which can be used to select objects or attach a visible laser to
  42192. */
  42193. pointer: AbstractMesh;
  42194. private _tmpMatrix;
  42195. /**
  42196. * Creates the controller
  42197. * @see https://doc.babylonjs.com/how_to/webxr
  42198. * @param scene the scene which the controller should be associated to
  42199. * @param inputSource the underlying input source for the controller
  42200. * @param parentContainer parent that the controller meshes should be children of
  42201. */
  42202. constructor(scene: Scene,
  42203. /** The underlying input source for the controller */
  42204. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42205. /**
  42206. * Updates the controller pose based on the given XRFrame
  42207. * @param xrFrame xr frame to update the pose with
  42208. * @param referenceSpace reference space to use
  42209. */
  42210. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42211. /**
  42212. * Disposes of the object
  42213. */
  42214. dispose(): void;
  42215. }
  42216. /**
  42217. * XR input used to track XR inputs such as controllers/rays
  42218. */
  42219. export class WebXRInput implements IDisposable {
  42220. private helper;
  42221. /**
  42222. * XR controllers being tracked
  42223. */
  42224. controllers: Array<WebXRController>;
  42225. private _frameObserver;
  42226. /**
  42227. * Event when a controller has been connected/added
  42228. */
  42229. onControllerAddedObservable: Observable<WebXRController>;
  42230. /**
  42231. * Event when a controller has been removed/disconnected
  42232. */
  42233. onControllerRemovedObservable: Observable<WebXRController>;
  42234. /**
  42235. * Initializes the WebXRInput
  42236. * @param helper experience helper which the input should be created for
  42237. */
  42238. constructor(helper: WebXRExperienceHelper);
  42239. private _onInputSourcesChange;
  42240. private _addAndRemoveControllers;
  42241. /**
  42242. * Disposes of the object
  42243. */
  42244. dispose(): void;
  42245. }
  42246. }
  42247. declare module "babylonjs/Cameras/XR/index" {
  42248. export * from "babylonjs/Cameras/XR/webXRCamera";
  42249. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  42250. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42251. export * from "babylonjs/Cameras/XR/webXRInput";
  42252. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42253. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  42254. }
  42255. declare module "babylonjs/Cameras/RigModes/index" {
  42256. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42257. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42258. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  42259. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  42260. }
  42261. declare module "babylonjs/Cameras/index" {
  42262. export * from "babylonjs/Cameras/Inputs/index";
  42263. export * from "babylonjs/Cameras/cameraInputsManager";
  42264. export * from "babylonjs/Cameras/camera";
  42265. export * from "babylonjs/Cameras/targetCamera";
  42266. export * from "babylonjs/Cameras/freeCamera";
  42267. export * from "babylonjs/Cameras/freeCameraInputsManager";
  42268. export * from "babylonjs/Cameras/touchCamera";
  42269. export * from "babylonjs/Cameras/arcRotateCamera";
  42270. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  42271. export * from "babylonjs/Cameras/deviceOrientationCamera";
  42272. export * from "babylonjs/Cameras/flyCamera";
  42273. export * from "babylonjs/Cameras/flyCameraInputsManager";
  42274. export * from "babylonjs/Cameras/followCamera";
  42275. export * from "babylonjs/Cameras/gamepadCamera";
  42276. export * from "babylonjs/Cameras/Stereoscopic/index";
  42277. export * from "babylonjs/Cameras/universalCamera";
  42278. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  42279. export * from "babylonjs/Cameras/VR/index";
  42280. export * from "babylonjs/Cameras/XR/index";
  42281. export * from "babylonjs/Cameras/RigModes/index";
  42282. }
  42283. declare module "babylonjs/Collisions/index" {
  42284. export * from "babylonjs/Collisions/collider";
  42285. export * from "babylonjs/Collisions/collisionCoordinator";
  42286. export * from "babylonjs/Collisions/pickingInfo";
  42287. export * from "babylonjs/Collisions/intersectionInfo";
  42288. export * from "babylonjs/Collisions/meshCollisionData";
  42289. }
  42290. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  42291. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  42292. import { Vector3, Plane } from "babylonjs/Maths/math";
  42293. import { Ray } from "babylonjs/Culling/ray";
  42294. /**
  42295. * Contains an array of blocks representing the octree
  42296. */
  42297. export interface IOctreeContainer<T> {
  42298. /**
  42299. * Blocks within the octree
  42300. */
  42301. blocks: Array<OctreeBlock<T>>;
  42302. }
  42303. /**
  42304. * Class used to store a cell in an octree
  42305. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42306. */
  42307. export class OctreeBlock<T> {
  42308. /**
  42309. * Gets the content of the current block
  42310. */
  42311. entries: T[];
  42312. /**
  42313. * Gets the list of block children
  42314. */
  42315. blocks: Array<OctreeBlock<T>>;
  42316. private _depth;
  42317. private _maxDepth;
  42318. private _capacity;
  42319. private _minPoint;
  42320. private _maxPoint;
  42321. private _boundingVectors;
  42322. private _creationFunc;
  42323. /**
  42324. * Creates a new block
  42325. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42326. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42327. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42328. * @param depth defines the current depth of this block in the octree
  42329. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42330. * @param creationFunc defines a callback to call when an element is added to the block
  42331. */
  42332. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42333. /**
  42334. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42335. */
  42336. readonly capacity: number;
  42337. /**
  42338. * Gets the minimum vector (in world space) of the block's bounding box
  42339. */
  42340. readonly minPoint: Vector3;
  42341. /**
  42342. * Gets the maximum vector (in world space) of the block's bounding box
  42343. */
  42344. readonly maxPoint: Vector3;
  42345. /**
  42346. * Add a new element to this block
  42347. * @param entry defines the element to add
  42348. */
  42349. addEntry(entry: T): void;
  42350. /**
  42351. * Remove an element from this block
  42352. * @param entry defines the element to remove
  42353. */
  42354. removeEntry(entry: T): void;
  42355. /**
  42356. * Add an array of elements to this block
  42357. * @param entries defines the array of elements to add
  42358. */
  42359. addEntries(entries: T[]): void;
  42360. /**
  42361. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42362. * @param frustumPlanes defines the frustum planes to test
  42363. * @param selection defines the array to store current content if selection is positive
  42364. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42365. */
  42366. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42367. /**
  42368. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42369. * @param sphereCenter defines the bounding sphere center
  42370. * @param sphereRadius defines the bounding sphere radius
  42371. * @param selection defines the array to store current content if selection is positive
  42372. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42373. */
  42374. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42375. /**
  42376. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42377. * @param ray defines the ray to test with
  42378. * @param selection defines the array to store current content if selection is positive
  42379. */
  42380. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42381. /**
  42382. * Subdivide the content into child blocks (this block will then be empty)
  42383. */
  42384. createInnerBlocks(): void;
  42385. /**
  42386. * @hidden
  42387. */
  42388. 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;
  42389. }
  42390. }
  42391. declare module "babylonjs/Culling/Octrees/octree" {
  42392. import { SmartArray } from "babylonjs/Misc/smartArray";
  42393. import { Vector3, Plane } from "babylonjs/Maths/math";
  42394. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42396. import { Ray } from "babylonjs/Culling/ray";
  42397. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  42398. /**
  42399. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42400. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42401. */
  42402. export class Octree<T> {
  42403. /** 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.) */
  42404. maxDepth: number;
  42405. /**
  42406. * Blocks within the octree containing objects
  42407. */
  42408. blocks: Array<OctreeBlock<T>>;
  42409. /**
  42410. * Content stored in the octree
  42411. */
  42412. dynamicContent: T[];
  42413. private _maxBlockCapacity;
  42414. private _selectionContent;
  42415. private _creationFunc;
  42416. /**
  42417. * Creates a octree
  42418. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42419. * @param creationFunc function to be used to instatiate the octree
  42420. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42421. * @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.)
  42422. */
  42423. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42424. /** 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.) */
  42425. maxDepth?: number);
  42426. /**
  42427. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42428. * @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);
  42429. * @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);
  42430. * @param entries meshes to be added to the octree blocks
  42431. */
  42432. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42433. /**
  42434. * Adds a mesh to the octree
  42435. * @param entry Mesh to add to the octree
  42436. */
  42437. addMesh(entry: T): void;
  42438. /**
  42439. * Remove an element from the octree
  42440. * @param entry defines the element to remove
  42441. */
  42442. removeMesh(entry: T): void;
  42443. /**
  42444. * Selects an array of meshes within the frustum
  42445. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42446. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42447. * @returns array of meshes within the frustum
  42448. */
  42449. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42450. /**
  42451. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42452. * @param sphereCenter defines the bounding sphere center
  42453. * @param sphereRadius defines the bounding sphere radius
  42454. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42455. * @returns an array of objects that intersect the sphere
  42456. */
  42457. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42458. /**
  42459. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42460. * @param ray defines the ray to test with
  42461. * @returns array of intersected objects
  42462. */
  42463. intersectsRay(ray: Ray): SmartArray<T>;
  42464. /**
  42465. * Adds a mesh into the octree block if it intersects the block
  42466. */
  42467. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42468. /**
  42469. * Adds a submesh into the octree block if it intersects the block
  42470. */
  42471. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42472. }
  42473. }
  42474. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  42475. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  42476. import { Scene } from "babylonjs/scene";
  42477. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42479. import { Ray } from "babylonjs/Culling/ray";
  42480. import { Octree } from "babylonjs/Culling/Octrees/octree";
  42481. import { Collider } from "babylonjs/Collisions/collider";
  42482. module "babylonjs/scene" {
  42483. interface Scene {
  42484. /**
  42485. * @hidden
  42486. * Backing Filed
  42487. */
  42488. _selectionOctree: Octree<AbstractMesh>;
  42489. /**
  42490. * Gets the octree used to boost mesh selection (picking)
  42491. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42492. */
  42493. selectionOctree: Octree<AbstractMesh>;
  42494. /**
  42495. * Creates or updates the octree used to boost selection (picking)
  42496. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42497. * @param maxCapacity defines the maximum capacity per leaf
  42498. * @param maxDepth defines the maximum depth of the octree
  42499. * @returns an octree of AbstractMesh
  42500. */
  42501. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42502. }
  42503. }
  42504. module "babylonjs/Meshes/abstractMesh" {
  42505. interface AbstractMesh {
  42506. /**
  42507. * @hidden
  42508. * Backing Field
  42509. */
  42510. _submeshesOctree: Octree<SubMesh>;
  42511. /**
  42512. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42513. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42514. * @param maxCapacity defines the maximum size of each block (64 by default)
  42515. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42516. * @returns the new octree
  42517. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42518. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42519. */
  42520. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42521. }
  42522. }
  42523. /**
  42524. * Defines the octree scene component responsible to manage any octrees
  42525. * in a given scene.
  42526. */
  42527. export class OctreeSceneComponent {
  42528. /**
  42529. * The component name help to identify the component in the list of scene components.
  42530. */
  42531. readonly name: string;
  42532. /**
  42533. * The scene the component belongs to.
  42534. */
  42535. scene: Scene;
  42536. /**
  42537. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42538. */
  42539. readonly checksIsEnabled: boolean;
  42540. /**
  42541. * Creates a new instance of the component for the given scene
  42542. * @param scene Defines the scene to register the component in
  42543. */
  42544. constructor(scene: Scene);
  42545. /**
  42546. * Registers the component in a given scene
  42547. */
  42548. register(): void;
  42549. /**
  42550. * Return the list of active meshes
  42551. * @returns the list of active meshes
  42552. */
  42553. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42554. /**
  42555. * Return the list of active sub meshes
  42556. * @param mesh The mesh to get the candidates sub meshes from
  42557. * @returns the list of active sub meshes
  42558. */
  42559. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42560. private _tempRay;
  42561. /**
  42562. * Return the list of sub meshes intersecting with a given local ray
  42563. * @param mesh defines the mesh to find the submesh for
  42564. * @param localRay defines the ray in local space
  42565. * @returns the list of intersecting sub meshes
  42566. */
  42567. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42568. /**
  42569. * Return the list of sub meshes colliding with a collider
  42570. * @param mesh defines the mesh to find the submesh for
  42571. * @param collider defines the collider to evaluate the collision against
  42572. * @returns the list of colliding sub meshes
  42573. */
  42574. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42575. /**
  42576. * Rebuilds the elements related to this component in case of
  42577. * context lost for instance.
  42578. */
  42579. rebuild(): void;
  42580. /**
  42581. * Disposes the component and the associated ressources.
  42582. */
  42583. dispose(): void;
  42584. }
  42585. }
  42586. declare module "babylonjs/Culling/Octrees/index" {
  42587. export * from "babylonjs/Culling/Octrees/octree";
  42588. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42589. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42590. }
  42591. declare module "babylonjs/Culling/index" {
  42592. export * from "babylonjs/Culling/boundingBox";
  42593. export * from "babylonjs/Culling/boundingInfo";
  42594. export * from "babylonjs/Culling/boundingSphere";
  42595. export * from "babylonjs/Culling/Octrees/index";
  42596. export * from "babylonjs/Culling/ray";
  42597. }
  42598. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42599. import { IDisposable, Scene } from "babylonjs/scene";
  42600. import { Nullable } from "babylonjs/types";
  42601. import { Observable } from "babylonjs/Misc/observable";
  42602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42603. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42604. import { Camera } from "babylonjs/Cameras/camera";
  42605. /**
  42606. * Renders a layer on top of an existing scene
  42607. */
  42608. export class UtilityLayerRenderer implements IDisposable {
  42609. /** the original scene that will be rendered on top of */
  42610. originalScene: Scene;
  42611. private _pointerCaptures;
  42612. private _lastPointerEvents;
  42613. private static _DefaultUtilityLayer;
  42614. private static _DefaultKeepDepthUtilityLayer;
  42615. private _sharedGizmoLight;
  42616. private _renderCamera;
  42617. /**
  42618. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42619. * @returns the camera that is used when rendering the utility layer
  42620. */
  42621. getRenderCamera(): Nullable<Camera>;
  42622. /**
  42623. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42624. * @param cam the camera that should be used when rendering the utility layer
  42625. */
  42626. setRenderCamera(cam: Nullable<Camera>): void;
  42627. /**
  42628. * @hidden
  42629. * Light which used by gizmos to get light shading
  42630. */
  42631. _getSharedGizmoLight(): HemisphericLight;
  42632. /**
  42633. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42634. */
  42635. pickUtilitySceneFirst: boolean;
  42636. /**
  42637. * 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)
  42638. */
  42639. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42640. /**
  42641. * 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)
  42642. */
  42643. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42644. /**
  42645. * The scene that is rendered on top of the original scene
  42646. */
  42647. utilityLayerScene: Scene;
  42648. /**
  42649. * If the utility layer should automatically be rendered on top of existing scene
  42650. */
  42651. shouldRender: boolean;
  42652. /**
  42653. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42654. */
  42655. onlyCheckPointerDownEvents: boolean;
  42656. /**
  42657. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42658. */
  42659. processAllEvents: boolean;
  42660. /**
  42661. * Observable raised when the pointer move from the utility layer scene to the main scene
  42662. */
  42663. onPointerOutObservable: Observable<number>;
  42664. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42665. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42666. private _afterRenderObserver;
  42667. private _sceneDisposeObserver;
  42668. private _originalPointerObserver;
  42669. /**
  42670. * Instantiates a UtilityLayerRenderer
  42671. * @param originalScene the original scene that will be rendered on top of
  42672. * @param handleEvents boolean indicating if the utility layer should handle events
  42673. */
  42674. constructor(
  42675. /** the original scene that will be rendered on top of */
  42676. originalScene: Scene, handleEvents?: boolean);
  42677. private _notifyObservers;
  42678. /**
  42679. * Renders the utility layers scene on top of the original scene
  42680. */
  42681. render(): void;
  42682. /**
  42683. * Disposes of the renderer
  42684. */
  42685. dispose(): void;
  42686. private _updateCamera;
  42687. }
  42688. }
  42689. declare module "babylonjs/Gizmos/gizmo" {
  42690. import { Nullable } from "babylonjs/types";
  42691. import { IDisposable } from "babylonjs/scene";
  42692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42693. import { Mesh } from "babylonjs/Meshes/mesh";
  42694. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42695. /**
  42696. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42697. */
  42698. export class Gizmo implements IDisposable {
  42699. /** The utility layer the gizmo will be added to */
  42700. gizmoLayer: UtilityLayerRenderer;
  42701. /**
  42702. * The root mesh of the gizmo
  42703. */
  42704. _rootMesh: Mesh;
  42705. private _attachedMesh;
  42706. /**
  42707. * Ratio for the scale of the gizmo (Default: 1)
  42708. */
  42709. scaleRatio: number;
  42710. /**
  42711. * If a custom mesh has been set (Default: false)
  42712. */
  42713. protected _customMeshSet: boolean;
  42714. /**
  42715. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42716. * * When set, interactions will be enabled
  42717. */
  42718. attachedMesh: Nullable<AbstractMesh>;
  42719. /**
  42720. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42721. * @param mesh The mesh to replace the default mesh of the gizmo
  42722. */
  42723. setCustomMesh(mesh: Mesh): void;
  42724. /**
  42725. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42726. */
  42727. updateGizmoRotationToMatchAttachedMesh: boolean;
  42728. /**
  42729. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42730. */
  42731. updateGizmoPositionToMatchAttachedMesh: boolean;
  42732. /**
  42733. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42734. */
  42735. protected _updateScale: boolean;
  42736. protected _interactionsEnabled: boolean;
  42737. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42738. private _beforeRenderObserver;
  42739. private _tempVector;
  42740. /**
  42741. * Creates a gizmo
  42742. * @param gizmoLayer The utility layer the gizmo will be added to
  42743. */
  42744. constructor(
  42745. /** The utility layer the gizmo will be added to */
  42746. gizmoLayer?: UtilityLayerRenderer);
  42747. /**
  42748. * Updates the gizmo to match the attached mesh's position/rotation
  42749. */
  42750. protected _update(): void;
  42751. /**
  42752. * Disposes of the gizmo
  42753. */
  42754. dispose(): void;
  42755. }
  42756. }
  42757. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42758. import { Observable } from "babylonjs/Misc/observable";
  42759. import { Nullable } from "babylonjs/types";
  42760. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42761. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42763. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42764. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42765. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42766. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42767. import { Scene } from "babylonjs/scene";
  42768. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42769. /**
  42770. * Single plane drag gizmo
  42771. */
  42772. export class PlaneDragGizmo extends Gizmo {
  42773. /**
  42774. * Drag behavior responsible for the gizmos dragging interactions
  42775. */
  42776. dragBehavior: PointerDragBehavior;
  42777. private _pointerObserver;
  42778. /**
  42779. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42780. */
  42781. snapDistance: number;
  42782. /**
  42783. * Event that fires each time the gizmo snaps to a new location.
  42784. * * snapDistance is the the change in distance
  42785. */
  42786. onSnapObservable: Observable<{
  42787. snapDistance: number;
  42788. }>;
  42789. private _plane;
  42790. private _coloredMaterial;
  42791. private _hoverMaterial;
  42792. private _isEnabled;
  42793. private _parent;
  42794. /** @hidden */
  42795. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42796. /** @hidden */
  42797. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42798. /**
  42799. * Creates a PlaneDragGizmo
  42800. * @param gizmoLayer The utility layer the gizmo will be added to
  42801. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42802. * @param color The color of the gizmo
  42803. */
  42804. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42805. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42806. /**
  42807. * If the gizmo is enabled
  42808. */
  42809. isEnabled: boolean;
  42810. /**
  42811. * Disposes of the gizmo
  42812. */
  42813. dispose(): void;
  42814. }
  42815. }
  42816. declare module "babylonjs/Gizmos/positionGizmo" {
  42817. import { Observable } from "babylonjs/Misc/observable";
  42818. import { Nullable } from "babylonjs/types";
  42819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42820. import { Mesh } from "babylonjs/Meshes/mesh";
  42821. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42822. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42823. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42824. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42825. /**
  42826. * Gizmo that enables dragging a mesh along 3 axis
  42827. */
  42828. export class PositionGizmo extends Gizmo {
  42829. /**
  42830. * Internal gizmo used for interactions on the x axis
  42831. */
  42832. xGizmo: AxisDragGizmo;
  42833. /**
  42834. * Internal gizmo used for interactions on the y axis
  42835. */
  42836. yGizmo: AxisDragGizmo;
  42837. /**
  42838. * Internal gizmo used for interactions on the z axis
  42839. */
  42840. zGizmo: AxisDragGizmo;
  42841. /**
  42842. * Internal gizmo used for interactions on the yz plane
  42843. */
  42844. xPlaneGizmo: PlaneDragGizmo;
  42845. /**
  42846. * Internal gizmo used for interactions on the xz plane
  42847. */
  42848. yPlaneGizmo: PlaneDragGizmo;
  42849. /**
  42850. * Internal gizmo used for interactions on the xy plane
  42851. */
  42852. zPlaneGizmo: PlaneDragGizmo;
  42853. /**
  42854. * private variables
  42855. */
  42856. private _meshAttached;
  42857. private _updateGizmoRotationToMatchAttachedMesh;
  42858. private _snapDistance;
  42859. private _scaleRatio;
  42860. /** Fires an event when any of it's sub gizmos are dragged */
  42861. onDragStartObservable: Observable<unknown>;
  42862. /** Fires an event when any of it's sub gizmos are released from dragging */
  42863. onDragEndObservable: Observable<unknown>;
  42864. /**
  42865. * If set to true, planar drag is enabled
  42866. */
  42867. private _planarGizmoEnabled;
  42868. attachedMesh: Nullable<AbstractMesh>;
  42869. /**
  42870. * Creates a PositionGizmo
  42871. * @param gizmoLayer The utility layer the gizmo will be added to
  42872. */
  42873. constructor(gizmoLayer?: UtilityLayerRenderer);
  42874. /**
  42875. * If the planar drag gizmo is enabled
  42876. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42877. */
  42878. planarGizmoEnabled: boolean;
  42879. updateGizmoRotationToMatchAttachedMesh: boolean;
  42880. /**
  42881. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42882. */
  42883. snapDistance: number;
  42884. /**
  42885. * Ratio for the scale of the gizmo (Default: 1)
  42886. */
  42887. scaleRatio: number;
  42888. /**
  42889. * Disposes of the gizmo
  42890. */
  42891. dispose(): void;
  42892. /**
  42893. * CustomMeshes are not supported by this gizmo
  42894. * @param mesh The mesh to replace the default mesh of the gizmo
  42895. */
  42896. setCustomMesh(mesh: Mesh): void;
  42897. }
  42898. }
  42899. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42900. import { Observable } from "babylonjs/Misc/observable";
  42901. import { Nullable } from "babylonjs/types";
  42902. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42903. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42905. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42906. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42907. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42908. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42909. import { Scene } from "babylonjs/scene";
  42910. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42911. /**
  42912. * Single axis drag gizmo
  42913. */
  42914. export class AxisDragGizmo extends Gizmo {
  42915. /**
  42916. * Drag behavior responsible for the gizmos dragging interactions
  42917. */
  42918. dragBehavior: PointerDragBehavior;
  42919. private _pointerObserver;
  42920. /**
  42921. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42922. */
  42923. snapDistance: number;
  42924. /**
  42925. * Event that fires each time the gizmo snaps to a new location.
  42926. * * snapDistance is the the change in distance
  42927. */
  42928. onSnapObservable: Observable<{
  42929. snapDistance: number;
  42930. }>;
  42931. private _isEnabled;
  42932. private _parent;
  42933. private _arrow;
  42934. private _coloredMaterial;
  42935. private _hoverMaterial;
  42936. /** @hidden */
  42937. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42938. /** @hidden */
  42939. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42940. /**
  42941. * Creates an AxisDragGizmo
  42942. * @param gizmoLayer The utility layer the gizmo will be added to
  42943. * @param dragAxis The axis which the gizmo will be able to drag on
  42944. * @param color The color of the gizmo
  42945. */
  42946. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42947. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42948. /**
  42949. * If the gizmo is enabled
  42950. */
  42951. isEnabled: boolean;
  42952. /**
  42953. * Disposes of the gizmo
  42954. */
  42955. dispose(): void;
  42956. }
  42957. }
  42958. declare module "babylonjs/Debug/axesViewer" {
  42959. import { Vector3 } from "babylonjs/Maths/math";
  42960. import { Nullable } from "babylonjs/types";
  42961. import { Scene } from "babylonjs/scene";
  42962. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42963. /**
  42964. * The Axes viewer will show 3 axes in a specific point in space
  42965. */
  42966. export class AxesViewer {
  42967. private _xAxis;
  42968. private _yAxis;
  42969. private _zAxis;
  42970. private _scaleLinesFactor;
  42971. private _instanced;
  42972. /**
  42973. * Gets the hosting scene
  42974. */
  42975. scene: Scene;
  42976. /**
  42977. * Gets or sets a number used to scale line length
  42978. */
  42979. scaleLines: number;
  42980. /** Gets the node hierarchy used to render x-axis */
  42981. readonly xAxis: TransformNode;
  42982. /** Gets the node hierarchy used to render y-axis */
  42983. readonly yAxis: TransformNode;
  42984. /** Gets the node hierarchy used to render z-axis */
  42985. readonly zAxis: TransformNode;
  42986. /**
  42987. * Creates a new AxesViewer
  42988. * @param scene defines the hosting scene
  42989. * @param scaleLines defines a number used to scale line length (1 by default)
  42990. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42991. * @param xAxis defines the node hierarchy used to render the x-axis
  42992. * @param yAxis defines the node hierarchy used to render the y-axis
  42993. * @param zAxis defines the node hierarchy used to render the z-axis
  42994. */
  42995. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42996. /**
  42997. * Force the viewer to update
  42998. * @param position defines the position of the viewer
  42999. * @param xaxis defines the x axis of the viewer
  43000. * @param yaxis defines the y axis of the viewer
  43001. * @param zaxis defines the z axis of the viewer
  43002. */
  43003. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43004. /**
  43005. * Creates an instance of this axes viewer.
  43006. * @returns a new axes viewer with instanced meshes
  43007. */
  43008. createInstance(): AxesViewer;
  43009. /** Releases resources */
  43010. dispose(): void;
  43011. private static _SetRenderingGroupId;
  43012. }
  43013. }
  43014. declare module "babylonjs/Debug/boneAxesViewer" {
  43015. import { Nullable } from "babylonjs/types";
  43016. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  43017. import { Vector3 } from "babylonjs/Maths/math";
  43018. import { Mesh } from "babylonjs/Meshes/mesh";
  43019. import { Bone } from "babylonjs/Bones/bone";
  43020. import { Scene } from "babylonjs/scene";
  43021. /**
  43022. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43023. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43024. */
  43025. export class BoneAxesViewer extends AxesViewer {
  43026. /**
  43027. * Gets or sets the target mesh where to display the axes viewer
  43028. */
  43029. mesh: Nullable<Mesh>;
  43030. /**
  43031. * Gets or sets the target bone where to display the axes viewer
  43032. */
  43033. bone: Nullable<Bone>;
  43034. /** Gets current position */
  43035. pos: Vector3;
  43036. /** Gets direction of X axis */
  43037. xaxis: Vector3;
  43038. /** Gets direction of Y axis */
  43039. yaxis: Vector3;
  43040. /** Gets direction of Z axis */
  43041. zaxis: Vector3;
  43042. /**
  43043. * Creates a new BoneAxesViewer
  43044. * @param scene defines the hosting scene
  43045. * @param bone defines the target bone
  43046. * @param mesh defines the target mesh
  43047. * @param scaleLines defines a scaling factor for line length (1 by default)
  43048. */
  43049. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43050. /**
  43051. * Force the viewer to update
  43052. */
  43053. update(): void;
  43054. /** Releases resources */
  43055. dispose(): void;
  43056. }
  43057. }
  43058. declare module "babylonjs/Debug/debugLayer" {
  43059. import { Scene } from "babylonjs/scene";
  43060. /**
  43061. * Interface used to define scene explorer extensibility option
  43062. */
  43063. export interface IExplorerExtensibilityOption {
  43064. /**
  43065. * Define the option label
  43066. */
  43067. label: string;
  43068. /**
  43069. * Defines the action to execute on click
  43070. */
  43071. action: (entity: any) => void;
  43072. }
  43073. /**
  43074. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43075. */
  43076. export interface IExplorerExtensibilityGroup {
  43077. /**
  43078. * Defines a predicate to test if a given type mut be extended
  43079. */
  43080. predicate: (entity: any) => boolean;
  43081. /**
  43082. * Gets the list of options added to a type
  43083. */
  43084. entries: IExplorerExtensibilityOption[];
  43085. }
  43086. /**
  43087. * Interface used to define the options to use to create the Inspector
  43088. */
  43089. export interface IInspectorOptions {
  43090. /**
  43091. * Display in overlay mode (default: false)
  43092. */
  43093. overlay?: boolean;
  43094. /**
  43095. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43096. */
  43097. globalRoot?: HTMLElement;
  43098. /**
  43099. * Display the Scene explorer
  43100. */
  43101. showExplorer?: boolean;
  43102. /**
  43103. * Display the property inspector
  43104. */
  43105. showInspector?: boolean;
  43106. /**
  43107. * Display in embed mode (both panes on the right)
  43108. */
  43109. embedMode?: boolean;
  43110. /**
  43111. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43112. */
  43113. handleResize?: boolean;
  43114. /**
  43115. * Allow the panes to popup (default: true)
  43116. */
  43117. enablePopup?: boolean;
  43118. /**
  43119. * Allow the panes to be closed by users (default: true)
  43120. */
  43121. enableClose?: boolean;
  43122. /**
  43123. * Optional list of extensibility entries
  43124. */
  43125. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43126. /**
  43127. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43128. */
  43129. inspectorURL?: string;
  43130. }
  43131. module "babylonjs/scene" {
  43132. interface Scene {
  43133. /**
  43134. * @hidden
  43135. * Backing field
  43136. */
  43137. _debugLayer: DebugLayer;
  43138. /**
  43139. * Gets the debug layer (aka Inspector) associated with the scene
  43140. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43141. */
  43142. debugLayer: DebugLayer;
  43143. }
  43144. }
  43145. /**
  43146. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43147. * what is happening in your scene
  43148. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43149. */
  43150. export class DebugLayer {
  43151. /**
  43152. * Define the url to get the inspector script from.
  43153. * By default it uses the babylonjs CDN.
  43154. * @ignoreNaming
  43155. */
  43156. static InspectorURL: string;
  43157. private _scene;
  43158. private BJSINSPECTOR;
  43159. private _onPropertyChangedObservable?;
  43160. /**
  43161. * Observable triggered when a property is changed through the inspector.
  43162. */
  43163. readonly onPropertyChangedObservable: any;
  43164. /**
  43165. * Instantiates a new debug layer.
  43166. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43167. * what is happening in your scene
  43168. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43169. * @param scene Defines the scene to inspect
  43170. */
  43171. constructor(scene: Scene);
  43172. /** Creates the inspector window. */
  43173. private _createInspector;
  43174. /**
  43175. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43176. * @param entity defines the entity to select
  43177. * @param lineContainerTitle defines the specific block to highlight
  43178. */
  43179. select(entity: any, lineContainerTitle?: string): void;
  43180. /** Get the inspector from bundle or global */
  43181. private _getGlobalInspector;
  43182. /**
  43183. * Get if the inspector is visible or not.
  43184. * @returns true if visible otherwise, false
  43185. */
  43186. isVisible(): boolean;
  43187. /**
  43188. * Hide the inspector and close its window.
  43189. */
  43190. hide(): void;
  43191. /**
  43192. * Launch the debugLayer.
  43193. * @param config Define the configuration of the inspector
  43194. * @return a promise fulfilled when the debug layer is visible
  43195. */
  43196. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43197. }
  43198. }
  43199. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  43200. import { Nullable } from "babylonjs/types";
  43201. import { Scene } from "babylonjs/scene";
  43202. import { Vector4, Color4 } from "babylonjs/Maths/math";
  43203. import { Mesh } from "babylonjs/Meshes/mesh";
  43204. /**
  43205. * Class containing static functions to help procedurally build meshes
  43206. */
  43207. export class BoxBuilder {
  43208. /**
  43209. * Creates a box mesh
  43210. * * The parameter `size` sets the size (float) of each box side (default 1)
  43211. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43212. * * 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)
  43213. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43217. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43218. * @param name defines the name of the mesh
  43219. * @param options defines the options used to create the mesh
  43220. * @param scene defines the hosting scene
  43221. * @returns the box mesh
  43222. */
  43223. static CreateBox(name: string, options: {
  43224. size?: number;
  43225. width?: number;
  43226. height?: number;
  43227. depth?: number;
  43228. faceUV?: Vector4[];
  43229. faceColors?: Color4[];
  43230. sideOrientation?: number;
  43231. frontUVs?: Vector4;
  43232. backUVs?: Vector4;
  43233. wrap?: boolean;
  43234. topBaseAt?: number;
  43235. bottomBaseAt?: number;
  43236. updatable?: boolean;
  43237. }, scene?: Nullable<Scene>): Mesh;
  43238. }
  43239. }
  43240. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  43241. import { Vector4 } from "babylonjs/Maths/math";
  43242. import { Mesh } from "babylonjs/Meshes/mesh";
  43243. /**
  43244. * Class containing static functions to help procedurally build meshes
  43245. */
  43246. export class SphereBuilder {
  43247. /**
  43248. * Creates a sphere mesh
  43249. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43250. * * 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`)
  43251. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43252. * * 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
  43253. * * 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)
  43254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43255. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43257. * @param name defines the name of the mesh
  43258. * @param options defines the options used to create the mesh
  43259. * @param scene defines the hosting scene
  43260. * @returns the sphere mesh
  43261. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43262. */
  43263. static CreateSphere(name: string, options: {
  43264. segments?: number;
  43265. diameter?: number;
  43266. diameterX?: number;
  43267. diameterY?: number;
  43268. diameterZ?: number;
  43269. arc?: number;
  43270. slice?: number;
  43271. sideOrientation?: number;
  43272. frontUVs?: Vector4;
  43273. backUVs?: Vector4;
  43274. updatable?: boolean;
  43275. }, scene: any): Mesh;
  43276. }
  43277. }
  43278. declare module "babylonjs/Debug/physicsViewer" {
  43279. import { Nullable } from "babylonjs/types";
  43280. import { Scene } from "babylonjs/scene";
  43281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43282. import { Mesh } from "babylonjs/Meshes/mesh";
  43283. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  43284. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  43285. /**
  43286. * Used to show the physics impostor around the specific mesh
  43287. */
  43288. export class PhysicsViewer {
  43289. /** @hidden */
  43290. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43291. /** @hidden */
  43292. protected _meshes: Array<Nullable<AbstractMesh>>;
  43293. /** @hidden */
  43294. protected _scene: Nullable<Scene>;
  43295. /** @hidden */
  43296. protected _numMeshes: number;
  43297. /** @hidden */
  43298. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43299. private _renderFunction;
  43300. private _utilityLayer;
  43301. private _debugBoxMesh;
  43302. private _debugSphereMesh;
  43303. private _debugCylinderMesh;
  43304. private _debugMaterial;
  43305. private _debugMeshMeshes;
  43306. /**
  43307. * Creates a new PhysicsViewer
  43308. * @param scene defines the hosting scene
  43309. */
  43310. constructor(scene: Scene);
  43311. /** @hidden */
  43312. protected _updateDebugMeshes(): void;
  43313. /**
  43314. * Renders a specified physic impostor
  43315. * @param impostor defines the impostor to render
  43316. * @param targetMesh defines the mesh represented by the impostor
  43317. * @returns the new debug mesh used to render the impostor
  43318. */
  43319. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43320. /**
  43321. * Hides a specified physic impostor
  43322. * @param impostor defines the impostor to hide
  43323. */
  43324. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43325. private _getDebugMaterial;
  43326. private _getDebugBoxMesh;
  43327. private _getDebugSphereMesh;
  43328. private _getDebugCylinderMesh;
  43329. private _getDebugMeshMesh;
  43330. private _getDebugMesh;
  43331. /** Releases all resources */
  43332. dispose(): void;
  43333. }
  43334. }
  43335. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  43336. import { Vector3, Color4 } from "babylonjs/Maths/math";
  43337. import { Nullable } from "babylonjs/types";
  43338. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43339. import { Scene } from "babylonjs/scene";
  43340. /**
  43341. * Class containing static functions to help procedurally build meshes
  43342. */
  43343. export class LinesBuilder {
  43344. /**
  43345. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43346. * * 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
  43347. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43348. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43349. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43350. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43351. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43352. * * 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
  43353. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43355. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43356. * @param name defines the name of the new line system
  43357. * @param options defines the options used to create the line system
  43358. * @param scene defines the hosting scene
  43359. * @returns a new line system mesh
  43360. */
  43361. static CreateLineSystem(name: string, options: {
  43362. lines: Vector3[][];
  43363. updatable?: boolean;
  43364. instance?: Nullable<LinesMesh>;
  43365. colors?: Nullable<Color4[][]>;
  43366. useVertexAlpha?: boolean;
  43367. }, scene: Nullable<Scene>): LinesMesh;
  43368. /**
  43369. * Creates a line mesh
  43370. * 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
  43371. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43372. * * The parameter `points` is an array successive Vector3
  43373. * * 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
  43374. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43375. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43376. * * When updating an instance, remember that only point positions can change, not the number of points
  43377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43379. * @param name defines the name of the new line system
  43380. * @param options defines the options used to create the line system
  43381. * @param scene defines the hosting scene
  43382. * @returns a new line mesh
  43383. */
  43384. static CreateLines(name: string, options: {
  43385. points: Vector3[];
  43386. updatable?: boolean;
  43387. instance?: Nullable<LinesMesh>;
  43388. colors?: Color4[];
  43389. useVertexAlpha?: boolean;
  43390. }, scene?: Nullable<Scene>): LinesMesh;
  43391. /**
  43392. * Creates a dashed line mesh
  43393. * * 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
  43394. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43395. * * The parameter `points` is an array successive Vector3
  43396. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43397. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43398. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43399. * * 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
  43400. * * When updating an instance, remember that only point positions can change, not the number of points
  43401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43402. * @param name defines the name of the mesh
  43403. * @param options defines the options used to create the mesh
  43404. * @param scene defines the hosting scene
  43405. * @returns the dashed line mesh
  43406. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43407. */
  43408. static CreateDashedLines(name: string, options: {
  43409. points: Vector3[];
  43410. dashSize?: number;
  43411. gapSize?: number;
  43412. dashNb?: number;
  43413. updatable?: boolean;
  43414. instance?: LinesMesh;
  43415. }, scene?: Nullable<Scene>): LinesMesh;
  43416. }
  43417. }
  43418. declare module "babylonjs/Debug/rayHelper" {
  43419. import { Nullable } from "babylonjs/types";
  43420. import { Ray } from "babylonjs/Culling/ray";
  43421. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43422. import { Scene } from "babylonjs/scene";
  43423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43424. import "babylonjs/Meshes/Builders/linesBuilder";
  43425. /**
  43426. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43427. * in order to better appreciate the issue one might have.
  43428. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43429. */
  43430. export class RayHelper {
  43431. /**
  43432. * Defines the ray we are currently tryin to visualize.
  43433. */
  43434. ray: Nullable<Ray>;
  43435. private _renderPoints;
  43436. private _renderLine;
  43437. private _renderFunction;
  43438. private _scene;
  43439. private _updateToMeshFunction;
  43440. private _attachedToMesh;
  43441. private _meshSpaceDirection;
  43442. private _meshSpaceOrigin;
  43443. /**
  43444. * Helper function to create a colored helper in a scene in one line.
  43445. * @param ray Defines the ray we are currently tryin to visualize
  43446. * @param scene Defines the scene the ray is used in
  43447. * @param color Defines the color we want to see the ray in
  43448. * @returns The newly created ray helper.
  43449. */
  43450. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43451. /**
  43452. * Instantiate a new ray helper.
  43453. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43454. * in order to better appreciate the issue one might have.
  43455. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43456. * @param ray Defines the ray we are currently tryin to visualize
  43457. */
  43458. constructor(ray: Ray);
  43459. /**
  43460. * Shows the ray we are willing to debug.
  43461. * @param scene Defines the scene the ray needs to be rendered in
  43462. * @param color Defines the color the ray needs to be rendered in
  43463. */
  43464. show(scene: Scene, color?: Color3): void;
  43465. /**
  43466. * Hides the ray we are debugging.
  43467. */
  43468. hide(): void;
  43469. private _render;
  43470. /**
  43471. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43472. * @param mesh Defines the mesh we want the helper attached to
  43473. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43474. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43475. * @param length Defines the length of the ray
  43476. */
  43477. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43478. /**
  43479. * Detach the ray helper from the mesh it has previously been attached to.
  43480. */
  43481. detachFromMesh(): void;
  43482. private _updateToMesh;
  43483. /**
  43484. * Dispose the helper and release its associated resources.
  43485. */
  43486. dispose(): void;
  43487. }
  43488. }
  43489. declare module "babylonjs/Debug/skeletonViewer" {
  43490. import { Color3 } from "babylonjs/Maths/math";
  43491. import { Scene } from "babylonjs/scene";
  43492. import { Nullable } from "babylonjs/types";
  43493. import { Skeleton } from "babylonjs/Bones/skeleton";
  43494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43495. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43496. /**
  43497. * Class used to render a debug view of a given skeleton
  43498. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43499. */
  43500. export class SkeletonViewer {
  43501. /** defines the skeleton to render */
  43502. skeleton: Skeleton;
  43503. /** defines the mesh attached to the skeleton */
  43504. mesh: AbstractMesh;
  43505. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43506. autoUpdateBonesMatrices: boolean;
  43507. /** defines the rendering group id to use with the viewer */
  43508. renderingGroupId: number;
  43509. /** Gets or sets the color used to render the skeleton */
  43510. color: Color3;
  43511. private _scene;
  43512. private _debugLines;
  43513. private _debugMesh;
  43514. private _isEnabled;
  43515. private _renderFunction;
  43516. private _utilityLayer;
  43517. /**
  43518. * Returns the mesh used to render the bones
  43519. */
  43520. readonly debugMesh: Nullable<LinesMesh>;
  43521. /**
  43522. * Creates a new SkeletonViewer
  43523. * @param skeleton defines the skeleton to render
  43524. * @param mesh defines the mesh attached to the skeleton
  43525. * @param scene defines the hosting scene
  43526. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43527. * @param renderingGroupId defines the rendering group id to use with the viewer
  43528. */
  43529. constructor(
  43530. /** defines the skeleton to render */
  43531. skeleton: Skeleton,
  43532. /** defines the mesh attached to the skeleton */
  43533. mesh: AbstractMesh, scene: Scene,
  43534. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43535. autoUpdateBonesMatrices?: boolean,
  43536. /** defines the rendering group id to use with the viewer */
  43537. renderingGroupId?: number);
  43538. /** Gets or sets a boolean indicating if the viewer is enabled */
  43539. isEnabled: boolean;
  43540. private _getBonePosition;
  43541. private _getLinesForBonesWithLength;
  43542. private _getLinesForBonesNoLength;
  43543. /** Update the viewer to sync with current skeleton state */
  43544. update(): void;
  43545. /** Release associated resources */
  43546. dispose(): void;
  43547. }
  43548. }
  43549. declare module "babylonjs/Debug/index" {
  43550. export * from "babylonjs/Debug/axesViewer";
  43551. export * from "babylonjs/Debug/boneAxesViewer";
  43552. export * from "babylonjs/Debug/debugLayer";
  43553. export * from "babylonjs/Debug/physicsViewer";
  43554. export * from "babylonjs/Debug/rayHelper";
  43555. export * from "babylonjs/Debug/skeletonViewer";
  43556. }
  43557. declare module "babylonjs/Engines/nullEngine" {
  43558. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43559. import { Scene } from "babylonjs/scene";
  43560. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43561. import { Engine } from "babylonjs/Engines/engine";
  43562. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43563. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43564. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43565. import { Effect } from "babylonjs/Materials/effect";
  43566. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43567. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43568. /**
  43569. * Options to create the null engine
  43570. */
  43571. export class NullEngineOptions {
  43572. /**
  43573. * Render width (Default: 512)
  43574. */
  43575. renderWidth: number;
  43576. /**
  43577. * Render height (Default: 256)
  43578. */
  43579. renderHeight: number;
  43580. /**
  43581. * Texture size (Default: 512)
  43582. */
  43583. textureSize: number;
  43584. /**
  43585. * If delta time between frames should be constant
  43586. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43587. */
  43588. deterministicLockstep: boolean;
  43589. /**
  43590. * Maximum about of steps between frames (Default: 4)
  43591. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43592. */
  43593. lockstepMaxSteps: number;
  43594. }
  43595. /**
  43596. * The null engine class provides support for headless version of babylon.js.
  43597. * This can be used in server side scenario or for testing purposes
  43598. */
  43599. export class NullEngine extends Engine {
  43600. private _options;
  43601. /**
  43602. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43603. */
  43604. isDeterministicLockStep(): boolean;
  43605. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43606. getLockstepMaxSteps(): number;
  43607. /**
  43608. * Sets hardware scaling, used to save performance if needed
  43609. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43610. */
  43611. getHardwareScalingLevel(): number;
  43612. constructor(options?: NullEngineOptions);
  43613. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43614. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43615. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43616. getRenderWidth(useScreen?: boolean): number;
  43617. getRenderHeight(useScreen?: boolean): number;
  43618. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43619. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43620. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43621. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43622. bindSamplers(effect: Effect): void;
  43623. enableEffect(effect: Effect): void;
  43624. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43625. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43626. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43627. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43628. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43629. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43630. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43631. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43632. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43633. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43634. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43635. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43636. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43637. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43638. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43639. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43640. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43641. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43642. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43643. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43644. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43645. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43646. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43647. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43648. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43649. bindBuffers(vertexBuffers: {
  43650. [key: string]: VertexBuffer;
  43651. }, indexBuffer: DataBuffer, effect: Effect): void;
  43652. wipeCaches(bruteForce?: boolean): void;
  43653. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43654. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43655. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43656. /** @hidden */
  43657. _createTexture(): WebGLTexture;
  43658. /** @hidden */
  43659. _releaseTexture(texture: InternalTexture): void;
  43660. 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;
  43661. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43662. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43663. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43664. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43665. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43666. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43667. areAllEffectsReady(): boolean;
  43668. /**
  43669. * @hidden
  43670. * Get the current error code of the webGL context
  43671. * @returns the error code
  43672. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43673. */
  43674. getError(): number;
  43675. /** @hidden */
  43676. _getUnpackAlignement(): number;
  43677. /** @hidden */
  43678. _unpackFlipY(value: boolean): void;
  43679. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43680. /**
  43681. * Updates a dynamic vertex buffer.
  43682. * @param vertexBuffer the vertex buffer to update
  43683. * @param data the data used to update the vertex buffer
  43684. * @param byteOffset the byte offset of the data (optional)
  43685. * @param byteLength the byte length of the data (optional)
  43686. */
  43687. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43688. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43689. /** @hidden */
  43690. _bindTexture(channel: number, texture: InternalTexture): void;
  43691. /** @hidden */
  43692. _releaseBuffer(buffer: DataBuffer): boolean;
  43693. releaseEffects(): void;
  43694. displayLoadingUI(): void;
  43695. hideLoadingUI(): void;
  43696. /** @hidden */
  43697. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43698. /** @hidden */
  43699. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43700. /** @hidden */
  43701. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43702. /** @hidden */
  43703. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43704. }
  43705. }
  43706. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43707. import { Nullable, int } from "babylonjs/types";
  43708. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43709. /** @hidden */
  43710. export class _OcclusionDataStorage {
  43711. /** @hidden */
  43712. occlusionInternalRetryCounter: number;
  43713. /** @hidden */
  43714. isOcclusionQueryInProgress: boolean;
  43715. /** @hidden */
  43716. isOccluded: boolean;
  43717. /** @hidden */
  43718. occlusionRetryCount: number;
  43719. /** @hidden */
  43720. occlusionType: number;
  43721. /** @hidden */
  43722. occlusionQueryAlgorithmType: number;
  43723. }
  43724. module "babylonjs/Engines/engine" {
  43725. interface Engine {
  43726. /**
  43727. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43728. * @return the new query
  43729. */
  43730. createQuery(): WebGLQuery;
  43731. /**
  43732. * Delete and release a webGL query
  43733. * @param query defines the query to delete
  43734. * @return the current engine
  43735. */
  43736. deleteQuery(query: WebGLQuery): Engine;
  43737. /**
  43738. * Check if a given query has resolved and got its value
  43739. * @param query defines the query to check
  43740. * @returns true if the query got its value
  43741. */
  43742. isQueryResultAvailable(query: WebGLQuery): boolean;
  43743. /**
  43744. * Gets the value of a given query
  43745. * @param query defines the query to check
  43746. * @returns the value of the query
  43747. */
  43748. getQueryResult(query: WebGLQuery): number;
  43749. /**
  43750. * Initiates an occlusion query
  43751. * @param algorithmType defines the algorithm to use
  43752. * @param query defines the query to use
  43753. * @returns the current engine
  43754. * @see http://doc.babylonjs.com/features/occlusionquery
  43755. */
  43756. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43757. /**
  43758. * Ends an occlusion query
  43759. * @see http://doc.babylonjs.com/features/occlusionquery
  43760. * @param algorithmType defines the algorithm to use
  43761. * @returns the current engine
  43762. */
  43763. endOcclusionQuery(algorithmType: number): Engine;
  43764. /**
  43765. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43766. * Please note that only one query can be issued at a time
  43767. * @returns a time token used to track the time span
  43768. */
  43769. startTimeQuery(): Nullable<_TimeToken>;
  43770. /**
  43771. * Ends a time query
  43772. * @param token defines the token used to measure the time span
  43773. * @returns the time spent (in ns)
  43774. */
  43775. endTimeQuery(token: _TimeToken): int;
  43776. /** @hidden */
  43777. _currentNonTimestampToken: Nullable<_TimeToken>;
  43778. /** @hidden */
  43779. _createTimeQuery(): WebGLQuery;
  43780. /** @hidden */
  43781. _deleteTimeQuery(query: WebGLQuery): void;
  43782. /** @hidden */
  43783. _getGlAlgorithmType(algorithmType: number): number;
  43784. /** @hidden */
  43785. _getTimeQueryResult(query: WebGLQuery): any;
  43786. /** @hidden */
  43787. _getTimeQueryAvailability(query: WebGLQuery): any;
  43788. }
  43789. }
  43790. module "babylonjs/Meshes/abstractMesh" {
  43791. interface AbstractMesh {
  43792. /**
  43793. * Backing filed
  43794. * @hidden
  43795. */
  43796. __occlusionDataStorage: _OcclusionDataStorage;
  43797. /**
  43798. * Access property
  43799. * @hidden
  43800. */
  43801. _occlusionDataStorage: _OcclusionDataStorage;
  43802. /**
  43803. * 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.
  43804. * The default value is -1 which means don't break the query and wait till the result
  43805. * @see http://doc.babylonjs.com/features/occlusionquery
  43806. */
  43807. occlusionRetryCount: number;
  43808. /**
  43809. * 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:
  43810. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43811. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43812. * * 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.
  43813. * @see http://doc.babylonjs.com/features/occlusionquery
  43814. */
  43815. occlusionType: number;
  43816. /**
  43817. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43818. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43819. * * 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.
  43820. * @see http://doc.babylonjs.com/features/occlusionquery
  43821. */
  43822. occlusionQueryAlgorithmType: number;
  43823. /**
  43824. * 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
  43825. * @see http://doc.babylonjs.com/features/occlusionquery
  43826. */
  43827. isOccluded: boolean;
  43828. /**
  43829. * Flag to check the progress status of the query
  43830. * @see http://doc.babylonjs.com/features/occlusionquery
  43831. */
  43832. isOcclusionQueryInProgress: boolean;
  43833. }
  43834. }
  43835. }
  43836. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43837. import { Nullable } from "babylonjs/types";
  43838. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43839. /** @hidden */
  43840. export var _forceTransformFeedbackToBundle: boolean;
  43841. module "babylonjs/Engines/engine" {
  43842. interface Engine {
  43843. /**
  43844. * Creates a webGL transform feedback object
  43845. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43846. * @returns the webGL transform feedback object
  43847. */
  43848. createTransformFeedback(): WebGLTransformFeedback;
  43849. /**
  43850. * Delete a webGL transform feedback object
  43851. * @param value defines the webGL transform feedback object to delete
  43852. */
  43853. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43854. /**
  43855. * Bind a webGL transform feedback object to the webgl context
  43856. * @param value defines the webGL transform feedback object to bind
  43857. */
  43858. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43859. /**
  43860. * Begins a transform feedback operation
  43861. * @param usePoints defines if points or triangles must be used
  43862. */
  43863. beginTransformFeedback(usePoints: boolean): void;
  43864. /**
  43865. * Ends a transform feedback operation
  43866. */
  43867. endTransformFeedback(): void;
  43868. /**
  43869. * Specify the varyings to use with transform feedback
  43870. * @param program defines the associated webGL program
  43871. * @param value defines the list of strings representing the varying names
  43872. */
  43873. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43874. /**
  43875. * Bind a webGL buffer for a transform feedback operation
  43876. * @param value defines the webGL buffer to bind
  43877. */
  43878. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43879. }
  43880. }
  43881. }
  43882. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43883. import { Scene } from "babylonjs/scene";
  43884. import { Engine } from "babylonjs/Engines/engine";
  43885. import { Texture } from "babylonjs/Materials/Textures/texture";
  43886. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43887. import "babylonjs/Engines/Extensions/engine.multiRender";
  43888. /**
  43889. * Creation options of the multi render target texture.
  43890. */
  43891. export interface IMultiRenderTargetOptions {
  43892. /**
  43893. * Define if the texture needs to create mip maps after render.
  43894. */
  43895. generateMipMaps?: boolean;
  43896. /**
  43897. * Define the types of all the draw buffers we want to create
  43898. */
  43899. types?: number[];
  43900. /**
  43901. * Define the sampling modes of all the draw buffers we want to create
  43902. */
  43903. samplingModes?: number[];
  43904. /**
  43905. * Define if a depth buffer is required
  43906. */
  43907. generateDepthBuffer?: boolean;
  43908. /**
  43909. * Define if a stencil buffer is required
  43910. */
  43911. generateStencilBuffer?: boolean;
  43912. /**
  43913. * Define if a depth texture is required instead of a depth buffer
  43914. */
  43915. generateDepthTexture?: boolean;
  43916. /**
  43917. * Define the number of desired draw buffers
  43918. */
  43919. textureCount?: number;
  43920. /**
  43921. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43922. */
  43923. doNotChangeAspectRatio?: boolean;
  43924. /**
  43925. * Define the default type of the buffers we are creating
  43926. */
  43927. defaultType?: number;
  43928. }
  43929. /**
  43930. * A multi render target, like a render target provides the ability to render to a texture.
  43931. * Unlike the render target, it can render to several draw buffers in one draw.
  43932. * This is specially interesting in deferred rendering or for any effects requiring more than
  43933. * just one color from a single pass.
  43934. */
  43935. export class MultiRenderTarget extends RenderTargetTexture {
  43936. private _internalTextures;
  43937. private _textures;
  43938. private _multiRenderTargetOptions;
  43939. /**
  43940. * Get if draw buffers are currently supported by the used hardware and browser.
  43941. */
  43942. readonly isSupported: boolean;
  43943. /**
  43944. * Get the list of textures generated by the multi render target.
  43945. */
  43946. readonly textures: Texture[];
  43947. /**
  43948. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43949. */
  43950. readonly depthTexture: Texture;
  43951. /**
  43952. * Set the wrapping mode on U of all the textures we are rendering to.
  43953. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43954. */
  43955. wrapU: number;
  43956. /**
  43957. * Set the wrapping mode on V of all the textures we are rendering to.
  43958. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43959. */
  43960. wrapV: number;
  43961. /**
  43962. * Instantiate a new multi render target texture.
  43963. * A multi render target, like a render target provides the ability to render to a texture.
  43964. * Unlike the render target, it can render to several draw buffers in one draw.
  43965. * This is specially interesting in deferred rendering or for any effects requiring more than
  43966. * just one color from a single pass.
  43967. * @param name Define the name of the texture
  43968. * @param size Define the size of the buffers to render to
  43969. * @param count Define the number of target we are rendering into
  43970. * @param scene Define the scene the texture belongs to
  43971. * @param options Define the options used to create the multi render target
  43972. */
  43973. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43974. /** @hidden */
  43975. _rebuild(): void;
  43976. private _createInternalTextures;
  43977. private _createTextures;
  43978. /**
  43979. * Define the number of samples used if MSAA is enabled.
  43980. */
  43981. samples: number;
  43982. /**
  43983. * Resize all the textures in the multi render target.
  43984. * Be carrefull as it will recreate all the data in the new texture.
  43985. * @param size Define the new size
  43986. */
  43987. resize(size: any): void;
  43988. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43989. /**
  43990. * Dispose the render targets and their associated resources
  43991. */
  43992. dispose(): void;
  43993. /**
  43994. * Release all the underlying texture used as draw buffers.
  43995. */
  43996. releaseInternalTextures(): void;
  43997. }
  43998. }
  43999. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  44000. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44001. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  44002. import { Nullable } from "babylonjs/types";
  44003. module "babylonjs/Engines/engine" {
  44004. interface Engine {
  44005. /**
  44006. * Unbind a list of render target textures from the webGL context
  44007. * This is used only when drawBuffer extension or webGL2 are active
  44008. * @param textures defines the render target textures to unbind
  44009. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44010. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44011. */
  44012. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44013. /**
  44014. * Create a multi render target texture
  44015. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44016. * @param size defines the size of the texture
  44017. * @param options defines the creation options
  44018. * @returns the cube texture as an InternalTexture
  44019. */
  44020. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44021. /**
  44022. * Update the sample count for a given multiple render target texture
  44023. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44024. * @param textures defines the textures to update
  44025. * @param samples defines the sample count to set
  44026. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44027. */
  44028. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44029. }
  44030. }
  44031. }
  44032. declare module "babylonjs/Engines/Extensions/index" {
  44033. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  44034. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  44035. export * from "babylonjs/Engines/Extensions/engine.multiview";
  44036. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  44037. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  44038. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  44039. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  44040. export * from "babylonjs/Engines/Extensions/engine.webVR";
  44041. }
  44042. declare module "babylonjs/Engines/index" {
  44043. export * from "babylonjs/Engines/constants";
  44044. export * from "babylonjs/Engines/engine";
  44045. export * from "babylonjs/Engines/engineStore";
  44046. export * from "babylonjs/Engines/nullEngine";
  44047. export * from "babylonjs/Engines/Extensions/index";
  44048. export * from "babylonjs/Engines/IPipelineContext";
  44049. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  44050. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  44051. }
  44052. declare module "babylonjs/Events/clipboardEvents" {
  44053. /**
  44054. * Gather the list of clipboard event types as constants.
  44055. */
  44056. export class ClipboardEventTypes {
  44057. /**
  44058. * The clipboard event is fired when a copy command is active (pressed).
  44059. */
  44060. static readonly COPY: number;
  44061. /**
  44062. * The clipboard event is fired when a cut command is active (pressed).
  44063. */
  44064. static readonly CUT: number;
  44065. /**
  44066. * The clipboard event is fired when a paste command is active (pressed).
  44067. */
  44068. static readonly PASTE: number;
  44069. }
  44070. /**
  44071. * This class is used to store clipboard related info for the onClipboardObservable event.
  44072. */
  44073. export class ClipboardInfo {
  44074. /**
  44075. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44076. */
  44077. type: number;
  44078. /**
  44079. * Defines the related dom event
  44080. */
  44081. event: ClipboardEvent;
  44082. /**
  44083. *Creates an instance of ClipboardInfo.
  44084. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44085. * @param event Defines the related dom event
  44086. */
  44087. constructor(
  44088. /**
  44089. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44090. */
  44091. type: number,
  44092. /**
  44093. * Defines the related dom event
  44094. */
  44095. event: ClipboardEvent);
  44096. /**
  44097. * Get the clipboard event's type from the keycode.
  44098. * @param keyCode Defines the keyCode for the current keyboard event.
  44099. * @return {number}
  44100. */
  44101. static GetTypeFromCharacter(keyCode: number): number;
  44102. }
  44103. }
  44104. declare module "babylonjs/Events/index" {
  44105. export * from "babylonjs/Events/keyboardEvents";
  44106. export * from "babylonjs/Events/pointerEvents";
  44107. export * from "babylonjs/Events/clipboardEvents";
  44108. }
  44109. declare module "babylonjs/Loading/sceneLoader" {
  44110. import { Observable } from "babylonjs/Misc/observable";
  44111. import { Nullable } from "babylonjs/types";
  44112. import { Scene } from "babylonjs/scene";
  44113. import { Engine } from "babylonjs/Engines/engine";
  44114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44115. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44116. import { AssetContainer } from "babylonjs/assetContainer";
  44117. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44118. import { Skeleton } from "babylonjs/Bones/skeleton";
  44119. /**
  44120. * Class used to represent data loading progression
  44121. */
  44122. export class SceneLoaderProgressEvent {
  44123. /** defines if data length to load can be evaluated */
  44124. readonly lengthComputable: boolean;
  44125. /** defines the loaded data length */
  44126. readonly loaded: number;
  44127. /** defines the data length to load */
  44128. readonly total: number;
  44129. /**
  44130. * Create a new progress event
  44131. * @param lengthComputable defines if data length to load can be evaluated
  44132. * @param loaded defines the loaded data length
  44133. * @param total defines the data length to load
  44134. */
  44135. constructor(
  44136. /** defines if data length to load can be evaluated */
  44137. lengthComputable: boolean,
  44138. /** defines the loaded data length */
  44139. loaded: number,
  44140. /** defines the data length to load */
  44141. total: number);
  44142. /**
  44143. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44144. * @param event defines the source event
  44145. * @returns a new SceneLoaderProgressEvent
  44146. */
  44147. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44148. }
  44149. /**
  44150. * Interface used by SceneLoader plugins to define supported file extensions
  44151. */
  44152. export interface ISceneLoaderPluginExtensions {
  44153. /**
  44154. * Defines the list of supported extensions
  44155. */
  44156. [extension: string]: {
  44157. isBinary: boolean;
  44158. };
  44159. }
  44160. /**
  44161. * Interface used by SceneLoader plugin factory
  44162. */
  44163. export interface ISceneLoaderPluginFactory {
  44164. /**
  44165. * Defines the name of the factory
  44166. */
  44167. name: string;
  44168. /**
  44169. * Function called to create a new plugin
  44170. * @return the new plugin
  44171. */
  44172. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44173. /**
  44174. * Boolean indicating if the plugin can direct load specific data
  44175. */
  44176. canDirectLoad?: (data: string) => boolean;
  44177. }
  44178. /**
  44179. * Interface used to define a SceneLoader plugin
  44180. */
  44181. export interface ISceneLoaderPlugin {
  44182. /**
  44183. * The friendly name of this plugin.
  44184. */
  44185. name: string;
  44186. /**
  44187. * The file extensions supported by this plugin.
  44188. */
  44189. extensions: string | ISceneLoaderPluginExtensions;
  44190. /**
  44191. * Import meshes into a scene.
  44192. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44193. * @param scene The scene to import into
  44194. * @param data The data to import
  44195. * @param rootUrl The root url for scene and resources
  44196. * @param meshes The meshes array to import into
  44197. * @param particleSystems The particle systems array to import into
  44198. * @param skeletons The skeletons array to import into
  44199. * @param onError The callback when import fails
  44200. * @returns True if successful or false otherwise
  44201. */
  44202. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44203. /**
  44204. * Load into a scene.
  44205. * @param scene The scene to load into
  44206. * @param data The data to import
  44207. * @param rootUrl The root url for scene and resources
  44208. * @param onError The callback when import fails
  44209. * @returns true if successful or false otherwise
  44210. */
  44211. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44212. /**
  44213. * The callback that returns true if the data can be directly loaded.
  44214. */
  44215. canDirectLoad?: (data: string) => boolean;
  44216. /**
  44217. * The callback that allows custom handling of the root url based on the response url.
  44218. */
  44219. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44220. /**
  44221. * Load into an asset container.
  44222. * @param scene The scene to load into
  44223. * @param data The data to import
  44224. * @param rootUrl The root url for scene and resources
  44225. * @param onError The callback when import fails
  44226. * @returns The loaded asset container
  44227. */
  44228. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44229. }
  44230. /**
  44231. * Interface used to define an async SceneLoader plugin
  44232. */
  44233. export interface ISceneLoaderPluginAsync {
  44234. /**
  44235. * The friendly name of this plugin.
  44236. */
  44237. name: string;
  44238. /**
  44239. * The file extensions supported by this plugin.
  44240. */
  44241. extensions: string | ISceneLoaderPluginExtensions;
  44242. /**
  44243. * Import meshes into a scene.
  44244. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44245. * @param scene The scene to import into
  44246. * @param data The data to import
  44247. * @param rootUrl The root url for scene and resources
  44248. * @param onProgress The callback when the load progresses
  44249. * @param fileName Defines the name of the file to load
  44250. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44251. */
  44252. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44253. meshes: AbstractMesh[];
  44254. particleSystems: IParticleSystem[];
  44255. skeletons: Skeleton[];
  44256. animationGroups: AnimationGroup[];
  44257. }>;
  44258. /**
  44259. * Load into a scene.
  44260. * @param scene The scene to load into
  44261. * @param data The data to import
  44262. * @param rootUrl The root url for scene and resources
  44263. * @param onProgress The callback when the load progresses
  44264. * @param fileName Defines the name of the file to load
  44265. * @returns Nothing
  44266. */
  44267. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44268. /**
  44269. * The callback that returns true if the data can be directly loaded.
  44270. */
  44271. canDirectLoad?: (data: string) => boolean;
  44272. /**
  44273. * The callback that allows custom handling of the root url based on the response url.
  44274. */
  44275. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44276. /**
  44277. * Load into an asset container.
  44278. * @param scene The scene to load into
  44279. * @param data The data to import
  44280. * @param rootUrl The root url for scene and resources
  44281. * @param onProgress The callback when the load progresses
  44282. * @param fileName Defines the name of the file to load
  44283. * @returns The loaded asset container
  44284. */
  44285. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44286. }
  44287. /**
  44288. * Class used to load scene from various file formats using registered plugins
  44289. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44290. */
  44291. export class SceneLoader {
  44292. /**
  44293. * No logging while loading
  44294. */
  44295. static readonly NO_LOGGING: number;
  44296. /**
  44297. * Minimal logging while loading
  44298. */
  44299. static readonly MINIMAL_LOGGING: number;
  44300. /**
  44301. * Summary logging while loading
  44302. */
  44303. static readonly SUMMARY_LOGGING: number;
  44304. /**
  44305. * Detailled logging while loading
  44306. */
  44307. static readonly DETAILED_LOGGING: number;
  44308. /**
  44309. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44310. */
  44311. static ForceFullSceneLoadingForIncremental: boolean;
  44312. /**
  44313. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44314. */
  44315. static ShowLoadingScreen: boolean;
  44316. /**
  44317. * Defines the current logging level (while loading the scene)
  44318. * @ignorenaming
  44319. */
  44320. static loggingLevel: number;
  44321. /**
  44322. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44323. */
  44324. static CleanBoneMatrixWeights: boolean;
  44325. /**
  44326. * Event raised when a plugin is used to load a scene
  44327. */
  44328. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44329. private static _registeredPlugins;
  44330. private static _getDefaultPlugin;
  44331. private static _getPluginForExtension;
  44332. private static _getPluginForDirectLoad;
  44333. private static _getPluginForFilename;
  44334. private static _getDirectLoad;
  44335. private static _loadData;
  44336. private static _getFileInfo;
  44337. /**
  44338. * Gets a plugin that can load the given extension
  44339. * @param extension defines the extension to load
  44340. * @returns a plugin or null if none works
  44341. */
  44342. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44343. /**
  44344. * Gets a boolean indicating that the given extension can be loaded
  44345. * @param extension defines the extension to load
  44346. * @returns true if the extension is supported
  44347. */
  44348. static IsPluginForExtensionAvailable(extension: string): boolean;
  44349. /**
  44350. * Adds a new plugin to the list of registered plugins
  44351. * @param plugin defines the plugin to add
  44352. */
  44353. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44354. /**
  44355. * Import meshes into a scene
  44356. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44357. * @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)
  44358. * @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)
  44359. * @param scene the instance of BABYLON.Scene to append to
  44360. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44361. * @param onProgress a callback with a progress event for each file being loaded
  44362. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44363. * @param pluginExtension the extension used to determine the plugin
  44364. * @returns The loaded plugin
  44365. */
  44366. 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>;
  44367. /**
  44368. * Import meshes into a scene
  44369. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44370. * @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)
  44371. * @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)
  44372. * @param scene the instance of BABYLON.Scene to append to
  44373. * @param onProgress a callback with a progress event for each file being loaded
  44374. * @param pluginExtension the extension used to determine the plugin
  44375. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44376. */
  44377. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44378. meshes: AbstractMesh[];
  44379. particleSystems: IParticleSystem[];
  44380. skeletons: Skeleton[];
  44381. animationGroups: AnimationGroup[];
  44382. }>;
  44383. /**
  44384. * Load a scene
  44385. * @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)
  44386. * @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)
  44387. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44388. * @param onSuccess a callback with the scene when import succeeds
  44389. * @param onProgress a callback with a progress event for each file being loaded
  44390. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44391. * @param pluginExtension the extension used to determine the plugin
  44392. * @returns The loaded plugin
  44393. */
  44394. 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>;
  44395. /**
  44396. * Load a scene
  44397. * @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)
  44398. * @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)
  44399. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44400. * @param onProgress a callback with a progress event for each file being loaded
  44401. * @param pluginExtension the extension used to determine the plugin
  44402. * @returns The loaded scene
  44403. */
  44404. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44405. /**
  44406. * Append a scene
  44407. * @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)
  44408. * @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)
  44409. * @param scene is the instance of BABYLON.Scene to append to
  44410. * @param onSuccess a callback with the scene when import succeeds
  44411. * @param onProgress a callback with a progress event for each file being loaded
  44412. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44413. * @param pluginExtension the extension used to determine the plugin
  44414. * @returns The loaded plugin
  44415. */
  44416. 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>;
  44417. /**
  44418. * Append a scene
  44419. * @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)
  44420. * @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)
  44421. * @param scene is the instance of BABYLON.Scene to append to
  44422. * @param onProgress a callback with a progress event for each file being loaded
  44423. * @param pluginExtension the extension used to determine the plugin
  44424. * @returns The given scene
  44425. */
  44426. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44427. /**
  44428. * Load a scene into an asset container
  44429. * @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)
  44430. * @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)
  44431. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44432. * @param onSuccess a callback with the scene when import succeeds
  44433. * @param onProgress a callback with a progress event for each file being loaded
  44434. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44435. * @param pluginExtension the extension used to determine the plugin
  44436. * @returns The loaded plugin
  44437. */
  44438. 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>;
  44439. /**
  44440. * Load a scene into an asset container
  44441. * @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)
  44442. * @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)
  44443. * @param scene is the instance of Scene to append to
  44444. * @param onProgress a callback with a progress event for each file being loaded
  44445. * @param pluginExtension the extension used to determine the plugin
  44446. * @returns The loaded asset container
  44447. */
  44448. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44449. }
  44450. }
  44451. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44452. import { Scene } from "babylonjs/scene";
  44453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44454. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44455. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44456. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44457. /**
  44458. * Google Daydream controller
  44459. */
  44460. export class DaydreamController extends WebVRController {
  44461. /**
  44462. * Base Url for the controller model.
  44463. */
  44464. static MODEL_BASE_URL: string;
  44465. /**
  44466. * File name for the controller model.
  44467. */
  44468. static MODEL_FILENAME: string;
  44469. /**
  44470. * Gamepad Id prefix used to identify Daydream Controller.
  44471. */
  44472. static readonly GAMEPAD_ID_PREFIX: string;
  44473. /**
  44474. * Creates a new DaydreamController from a gamepad
  44475. * @param vrGamepad the gamepad that the controller should be created from
  44476. */
  44477. constructor(vrGamepad: any);
  44478. /**
  44479. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44480. * @param scene scene in which to add meshes
  44481. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44482. */
  44483. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44484. /**
  44485. * Called once for each button that changed state since the last frame
  44486. * @param buttonIdx Which button index changed
  44487. * @param state New state of the button
  44488. * @param changes Which properties on the state changed since last frame
  44489. */
  44490. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44491. }
  44492. }
  44493. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44494. import { Scene } from "babylonjs/scene";
  44495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44496. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44497. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44498. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44499. /**
  44500. * Gear VR Controller
  44501. */
  44502. export class GearVRController extends WebVRController {
  44503. /**
  44504. * Base Url for the controller model.
  44505. */
  44506. static MODEL_BASE_URL: string;
  44507. /**
  44508. * File name for the controller model.
  44509. */
  44510. static MODEL_FILENAME: string;
  44511. /**
  44512. * Gamepad Id prefix used to identify this controller.
  44513. */
  44514. static readonly GAMEPAD_ID_PREFIX: string;
  44515. private readonly _buttonIndexToObservableNameMap;
  44516. /**
  44517. * Creates a new GearVRController from a gamepad
  44518. * @param vrGamepad the gamepad that the controller should be created from
  44519. */
  44520. constructor(vrGamepad: any);
  44521. /**
  44522. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44523. * @param scene scene in which to add meshes
  44524. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44525. */
  44526. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44527. /**
  44528. * Called once for each button that changed state since the last frame
  44529. * @param buttonIdx Which button index changed
  44530. * @param state New state of the button
  44531. * @param changes Which properties on the state changed since last frame
  44532. */
  44533. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44534. }
  44535. }
  44536. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44537. import { Scene } from "babylonjs/scene";
  44538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44539. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44540. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44541. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44542. /**
  44543. * Generic Controller
  44544. */
  44545. export class GenericController extends WebVRController {
  44546. /**
  44547. * Base Url for the controller model.
  44548. */
  44549. static readonly MODEL_BASE_URL: string;
  44550. /**
  44551. * File name for the controller model.
  44552. */
  44553. static readonly MODEL_FILENAME: string;
  44554. /**
  44555. * Creates a new GenericController from a gamepad
  44556. * @param vrGamepad the gamepad that the controller should be created from
  44557. */
  44558. constructor(vrGamepad: any);
  44559. /**
  44560. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44561. * @param scene scene in which to add meshes
  44562. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44563. */
  44564. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44565. /**
  44566. * Called once for each button that changed state since the last frame
  44567. * @param buttonIdx Which button index changed
  44568. * @param state New state of the button
  44569. * @param changes Which properties on the state changed since last frame
  44570. */
  44571. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44572. }
  44573. }
  44574. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44575. import { Observable } from "babylonjs/Misc/observable";
  44576. import { Scene } from "babylonjs/scene";
  44577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44578. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44579. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44580. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44581. /**
  44582. * Oculus Touch Controller
  44583. */
  44584. export class OculusTouchController extends WebVRController {
  44585. /**
  44586. * Base Url for the controller model.
  44587. */
  44588. static MODEL_BASE_URL: string;
  44589. /**
  44590. * File name for the left controller model.
  44591. */
  44592. static MODEL_LEFT_FILENAME: string;
  44593. /**
  44594. * File name for the right controller model.
  44595. */
  44596. static MODEL_RIGHT_FILENAME: string;
  44597. /**
  44598. * Base Url for the Quest controller model.
  44599. */
  44600. static QUEST_MODEL_BASE_URL: string;
  44601. /**
  44602. * @hidden
  44603. * If the controllers are running on a device that needs the updated Quest controller models
  44604. */
  44605. static _IsQuest: boolean;
  44606. /**
  44607. * Fired when the secondary trigger on this controller is modified
  44608. */
  44609. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44610. /**
  44611. * Fired when the thumb rest on this controller is modified
  44612. */
  44613. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44614. /**
  44615. * Creates a new OculusTouchController from a gamepad
  44616. * @param vrGamepad the gamepad that the controller should be created from
  44617. */
  44618. constructor(vrGamepad: any);
  44619. /**
  44620. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44621. * @param scene scene in which to add meshes
  44622. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44623. */
  44624. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44625. /**
  44626. * Fired when the A button on this controller is modified
  44627. */
  44628. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44629. /**
  44630. * Fired when the B button on this controller is modified
  44631. */
  44632. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44633. /**
  44634. * Fired when the X button on this controller is modified
  44635. */
  44636. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44637. /**
  44638. * Fired when the Y button on this controller is modified
  44639. */
  44640. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44641. /**
  44642. * Called once for each button that changed state since the last frame
  44643. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44644. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44645. * 2) secondary trigger (same)
  44646. * 3) A (right) X (left), touch, pressed = value
  44647. * 4) B / Y
  44648. * 5) thumb rest
  44649. * @param buttonIdx Which button index changed
  44650. * @param state New state of the button
  44651. * @param changes Which properties on the state changed since last frame
  44652. */
  44653. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44654. }
  44655. }
  44656. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44657. import { Scene } from "babylonjs/scene";
  44658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44659. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44660. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44661. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44662. import { Observable } from "babylonjs/Misc/observable";
  44663. /**
  44664. * Vive Controller
  44665. */
  44666. export class ViveController extends WebVRController {
  44667. /**
  44668. * Base Url for the controller model.
  44669. */
  44670. static MODEL_BASE_URL: string;
  44671. /**
  44672. * File name for the controller model.
  44673. */
  44674. static MODEL_FILENAME: string;
  44675. /**
  44676. * Creates a new ViveController from a gamepad
  44677. * @param vrGamepad the gamepad that the controller should be created from
  44678. */
  44679. constructor(vrGamepad: any);
  44680. /**
  44681. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44682. * @param scene scene in which to add meshes
  44683. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44684. */
  44685. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44686. /**
  44687. * Fired when the left button on this controller is modified
  44688. */
  44689. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44690. /**
  44691. * Fired when the right button on this controller is modified
  44692. */
  44693. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44694. /**
  44695. * Fired when the menu button on this controller is modified
  44696. */
  44697. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44698. /**
  44699. * Called once for each button that changed state since the last frame
  44700. * Vive mapping:
  44701. * 0: touchpad
  44702. * 1: trigger
  44703. * 2: left AND right buttons
  44704. * 3: menu button
  44705. * @param buttonIdx Which button index changed
  44706. * @param state New state of the button
  44707. * @param changes Which properties on the state changed since last frame
  44708. */
  44709. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44710. }
  44711. }
  44712. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44713. import { Observable } from "babylonjs/Misc/observable";
  44714. import { Scene } from "babylonjs/scene";
  44715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44716. import { Ray } from "babylonjs/Culling/ray";
  44717. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44718. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44719. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44720. /**
  44721. * Defines the WindowsMotionController object that the state of the windows motion controller
  44722. */
  44723. export class WindowsMotionController extends WebVRController {
  44724. /**
  44725. * The base url used to load the left and right controller models
  44726. */
  44727. static MODEL_BASE_URL: string;
  44728. /**
  44729. * The name of the left controller model file
  44730. */
  44731. static MODEL_LEFT_FILENAME: string;
  44732. /**
  44733. * The name of the right controller model file
  44734. */
  44735. static MODEL_RIGHT_FILENAME: string;
  44736. /**
  44737. * The controller name prefix for this controller type
  44738. */
  44739. static readonly GAMEPAD_ID_PREFIX: string;
  44740. /**
  44741. * The controller id pattern for this controller type
  44742. */
  44743. private static readonly GAMEPAD_ID_PATTERN;
  44744. private _loadedMeshInfo;
  44745. private readonly _mapping;
  44746. /**
  44747. * Fired when the trackpad on this controller is clicked
  44748. */
  44749. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44750. /**
  44751. * Fired when the trackpad on this controller is modified
  44752. */
  44753. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44754. /**
  44755. * The current x and y values of this controller's trackpad
  44756. */
  44757. trackpad: StickValues;
  44758. /**
  44759. * Creates a new WindowsMotionController from a gamepad
  44760. * @param vrGamepad the gamepad that the controller should be created from
  44761. */
  44762. constructor(vrGamepad: any);
  44763. /**
  44764. * Fired when the trigger on this controller is modified
  44765. */
  44766. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44767. /**
  44768. * Fired when the menu button on this controller is modified
  44769. */
  44770. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44771. /**
  44772. * Fired when the grip button on this controller is modified
  44773. */
  44774. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44775. /**
  44776. * Fired when the thumbstick button on this controller is modified
  44777. */
  44778. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44779. /**
  44780. * Fired when the touchpad button on this controller is modified
  44781. */
  44782. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44783. /**
  44784. * Fired when the touchpad values on this controller are modified
  44785. */
  44786. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44787. private _updateTrackpad;
  44788. /**
  44789. * Called once per frame by the engine.
  44790. */
  44791. update(): void;
  44792. /**
  44793. * Called once for each button that changed state since the last frame
  44794. * @param buttonIdx Which button index changed
  44795. * @param state New state of the button
  44796. * @param changes Which properties on the state changed since last frame
  44797. */
  44798. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44799. /**
  44800. * Moves the buttons on the controller mesh based on their current state
  44801. * @param buttonName the name of the button to move
  44802. * @param buttonValue the value of the button which determines the buttons new position
  44803. */
  44804. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44805. /**
  44806. * Moves the axis on the controller mesh based on its current state
  44807. * @param axis the index of the axis
  44808. * @param axisValue the value of the axis which determines the meshes new position
  44809. * @hidden
  44810. */
  44811. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44812. /**
  44813. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44814. * @param scene scene in which to add meshes
  44815. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44816. */
  44817. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44818. /**
  44819. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44820. * can be transformed by button presses and axes values, based on this._mapping.
  44821. *
  44822. * @param scene scene in which the meshes exist
  44823. * @param meshes list of meshes that make up the controller model to process
  44824. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44825. */
  44826. private processModel;
  44827. private createMeshInfo;
  44828. /**
  44829. * Gets the ray of the controller in the direction the controller is pointing
  44830. * @param length the length the resulting ray should be
  44831. * @returns a ray in the direction the controller is pointing
  44832. */
  44833. getForwardRay(length?: number): Ray;
  44834. /**
  44835. * Disposes of the controller
  44836. */
  44837. dispose(): void;
  44838. }
  44839. }
  44840. declare module "babylonjs/Gamepads/Controllers/index" {
  44841. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44842. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44843. export * from "babylonjs/Gamepads/Controllers/genericController";
  44844. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44845. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44846. export * from "babylonjs/Gamepads/Controllers/viveController";
  44847. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44848. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44849. }
  44850. declare module "babylonjs/Gamepads/index" {
  44851. export * from "babylonjs/Gamepads/Controllers/index";
  44852. export * from "babylonjs/Gamepads/gamepad";
  44853. export * from "babylonjs/Gamepads/gamepadManager";
  44854. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44855. export * from "babylonjs/Gamepads/xboxGamepad";
  44856. }
  44857. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44858. import { Scene } from "babylonjs/scene";
  44859. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44860. import { Mesh } from "babylonjs/Meshes/mesh";
  44861. import { Nullable } from "babylonjs/types";
  44862. /**
  44863. * Class containing static functions to help procedurally build meshes
  44864. */
  44865. export class PolyhedronBuilder {
  44866. /**
  44867. * Creates a polyhedron mesh
  44868. * * 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
  44869. * * The parameter `size` (positive float, default 1) sets the polygon size
  44870. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44871. * * 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`
  44872. * * 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
  44873. * * 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)`)
  44874. * * 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
  44875. * * 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
  44876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44877. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44879. * @param name defines the name of the mesh
  44880. * @param options defines the options used to create the mesh
  44881. * @param scene defines the hosting scene
  44882. * @returns the polyhedron mesh
  44883. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44884. */
  44885. static CreatePolyhedron(name: string, options: {
  44886. type?: number;
  44887. size?: number;
  44888. sizeX?: number;
  44889. sizeY?: number;
  44890. sizeZ?: number;
  44891. custom?: any;
  44892. faceUV?: Vector4[];
  44893. faceColors?: Color4[];
  44894. flat?: boolean;
  44895. updatable?: boolean;
  44896. sideOrientation?: number;
  44897. frontUVs?: Vector4;
  44898. backUVs?: Vector4;
  44899. }, scene?: Nullable<Scene>): Mesh;
  44900. }
  44901. }
  44902. declare module "babylonjs/Gizmos/scaleGizmo" {
  44903. import { Observable } from "babylonjs/Misc/observable";
  44904. import { Nullable } from "babylonjs/types";
  44905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44906. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44907. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44908. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44909. /**
  44910. * Gizmo that enables scaling a mesh along 3 axis
  44911. */
  44912. export class ScaleGizmo extends Gizmo {
  44913. /**
  44914. * Internal gizmo used for interactions on the x axis
  44915. */
  44916. xGizmo: AxisScaleGizmo;
  44917. /**
  44918. * Internal gizmo used for interactions on the y axis
  44919. */
  44920. yGizmo: AxisScaleGizmo;
  44921. /**
  44922. * Internal gizmo used for interactions on the z axis
  44923. */
  44924. zGizmo: AxisScaleGizmo;
  44925. /**
  44926. * Internal gizmo used to scale all axis equally
  44927. */
  44928. uniformScaleGizmo: AxisScaleGizmo;
  44929. private _meshAttached;
  44930. private _updateGizmoRotationToMatchAttachedMesh;
  44931. private _snapDistance;
  44932. private _scaleRatio;
  44933. private _uniformScalingMesh;
  44934. private _octahedron;
  44935. /** Fires an event when any of it's sub gizmos are dragged */
  44936. onDragStartObservable: Observable<unknown>;
  44937. /** Fires an event when any of it's sub gizmos are released from dragging */
  44938. onDragEndObservable: Observable<unknown>;
  44939. attachedMesh: Nullable<AbstractMesh>;
  44940. /**
  44941. * Creates a ScaleGizmo
  44942. * @param gizmoLayer The utility layer the gizmo will be added to
  44943. */
  44944. constructor(gizmoLayer?: UtilityLayerRenderer);
  44945. updateGizmoRotationToMatchAttachedMesh: boolean;
  44946. /**
  44947. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44948. */
  44949. snapDistance: number;
  44950. /**
  44951. * Ratio for the scale of the gizmo (Default: 1)
  44952. */
  44953. scaleRatio: number;
  44954. /**
  44955. * Disposes of the gizmo
  44956. */
  44957. dispose(): void;
  44958. }
  44959. }
  44960. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44961. import { Observable } from "babylonjs/Misc/observable";
  44962. import { Nullable } from "babylonjs/types";
  44963. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44965. import { Mesh } from "babylonjs/Meshes/mesh";
  44966. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44967. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44968. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44969. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44970. /**
  44971. * Single axis scale gizmo
  44972. */
  44973. export class AxisScaleGizmo extends Gizmo {
  44974. /**
  44975. * Drag behavior responsible for the gizmos dragging interactions
  44976. */
  44977. dragBehavior: PointerDragBehavior;
  44978. private _pointerObserver;
  44979. /**
  44980. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44981. */
  44982. snapDistance: number;
  44983. /**
  44984. * Event that fires each time the gizmo snaps to a new location.
  44985. * * snapDistance is the the change in distance
  44986. */
  44987. onSnapObservable: Observable<{
  44988. snapDistance: number;
  44989. }>;
  44990. /**
  44991. * If the scaling operation should be done on all axis (default: false)
  44992. */
  44993. uniformScaling: boolean;
  44994. private _isEnabled;
  44995. private _parent;
  44996. private _arrow;
  44997. private _coloredMaterial;
  44998. private _hoverMaterial;
  44999. /**
  45000. * Creates an AxisScaleGizmo
  45001. * @param gizmoLayer The utility layer the gizmo will be added to
  45002. * @param dragAxis The axis which the gizmo will be able to scale on
  45003. * @param color The color of the gizmo
  45004. */
  45005. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45006. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45007. /**
  45008. * If the gizmo is enabled
  45009. */
  45010. isEnabled: boolean;
  45011. /**
  45012. * Disposes of the gizmo
  45013. */
  45014. dispose(): void;
  45015. /**
  45016. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45017. * @param mesh The mesh to replace the default mesh of the gizmo
  45018. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45019. */
  45020. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45021. }
  45022. }
  45023. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45024. import { Observable } from "babylonjs/Misc/observable";
  45025. import { Nullable } from "babylonjs/types";
  45026. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45028. import { Mesh } from "babylonjs/Meshes/mesh";
  45029. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45030. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45031. import "babylonjs/Meshes/Builders/boxBuilder";
  45032. /**
  45033. * Bounding box gizmo
  45034. */
  45035. export class BoundingBoxGizmo extends Gizmo {
  45036. private _lineBoundingBox;
  45037. private _rotateSpheresParent;
  45038. private _scaleBoxesParent;
  45039. private _boundingDimensions;
  45040. private _renderObserver;
  45041. private _pointerObserver;
  45042. private _scaleDragSpeed;
  45043. private _tmpQuaternion;
  45044. private _tmpVector;
  45045. private _tmpRotationMatrix;
  45046. /**
  45047. * 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)
  45048. */
  45049. ignoreChildren: boolean;
  45050. /**
  45051. * 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)
  45052. */
  45053. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45054. /**
  45055. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45056. */
  45057. rotationSphereSize: number;
  45058. /**
  45059. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45060. */
  45061. scaleBoxSize: number;
  45062. /**
  45063. * 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)
  45064. */
  45065. fixedDragMeshScreenSize: boolean;
  45066. /**
  45067. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45068. */
  45069. fixedDragMeshScreenSizeDistanceFactor: number;
  45070. /**
  45071. * Fired when a rotation sphere or scale box is dragged
  45072. */
  45073. onDragStartObservable: Observable<{}>;
  45074. /**
  45075. * Fired when a scale box is dragged
  45076. */
  45077. onScaleBoxDragObservable: Observable<{}>;
  45078. /**
  45079. * Fired when a scale box drag is ended
  45080. */
  45081. onScaleBoxDragEndObservable: Observable<{}>;
  45082. /**
  45083. * Fired when a rotation sphere is dragged
  45084. */
  45085. onRotationSphereDragObservable: Observable<{}>;
  45086. /**
  45087. * Fired when a rotation sphere drag is ended
  45088. */
  45089. onRotationSphereDragEndObservable: Observable<{}>;
  45090. /**
  45091. * 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)
  45092. */
  45093. scalePivot: Nullable<Vector3>;
  45094. /**
  45095. * Mesh used as a pivot to rotate the attached mesh
  45096. */
  45097. private _anchorMesh;
  45098. private _existingMeshScale;
  45099. private _dragMesh;
  45100. private pointerDragBehavior;
  45101. private coloredMaterial;
  45102. private hoverColoredMaterial;
  45103. /**
  45104. * Sets the color of the bounding box gizmo
  45105. * @param color the color to set
  45106. */
  45107. setColor(color: Color3): void;
  45108. /**
  45109. * Creates an BoundingBoxGizmo
  45110. * @param gizmoLayer The utility layer the gizmo will be added to
  45111. * @param color The color of the gizmo
  45112. */
  45113. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45114. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45115. private _selectNode;
  45116. /**
  45117. * Updates the bounding box information for the Gizmo
  45118. */
  45119. updateBoundingBox(): void;
  45120. private _updateRotationSpheres;
  45121. private _updateScaleBoxes;
  45122. /**
  45123. * Enables rotation on the specified axis and disables rotation on the others
  45124. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45125. */
  45126. setEnabledRotationAxis(axis: string): void;
  45127. /**
  45128. * Enables/disables scaling
  45129. * @param enable if scaling should be enabled
  45130. */
  45131. setEnabledScaling(enable: boolean): void;
  45132. private _updateDummy;
  45133. /**
  45134. * Enables a pointer drag behavior on the bounding box of the gizmo
  45135. */
  45136. enableDragBehavior(): void;
  45137. /**
  45138. * Disposes of the gizmo
  45139. */
  45140. dispose(): void;
  45141. /**
  45142. * 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)
  45143. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45144. * @returns the bounding box mesh with the passed in mesh as a child
  45145. */
  45146. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45147. /**
  45148. * CustomMeshes are not supported by this gizmo
  45149. * @param mesh The mesh to replace the default mesh of the gizmo
  45150. */
  45151. setCustomMesh(mesh: Mesh): void;
  45152. }
  45153. }
  45154. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45155. import { Observable } from "babylonjs/Misc/observable";
  45156. import { Nullable } from "babylonjs/types";
  45157. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45159. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45160. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45161. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45162. import "babylonjs/Meshes/Builders/linesBuilder";
  45163. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45164. /**
  45165. * Single plane rotation gizmo
  45166. */
  45167. export class PlaneRotationGizmo extends Gizmo {
  45168. /**
  45169. * Drag behavior responsible for the gizmos dragging interactions
  45170. */
  45171. dragBehavior: PointerDragBehavior;
  45172. private _pointerObserver;
  45173. /**
  45174. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45175. */
  45176. snapDistance: number;
  45177. /**
  45178. * Event that fires each time the gizmo snaps to a new location.
  45179. * * snapDistance is the the change in distance
  45180. */
  45181. onSnapObservable: Observable<{
  45182. snapDistance: number;
  45183. }>;
  45184. private _isEnabled;
  45185. private _parent;
  45186. /**
  45187. * Creates a PlaneRotationGizmo
  45188. * @param gizmoLayer The utility layer the gizmo will be added to
  45189. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45190. * @param color The color of the gizmo
  45191. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45192. */
  45193. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45194. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45195. /**
  45196. * If the gizmo is enabled
  45197. */
  45198. isEnabled: boolean;
  45199. /**
  45200. * Disposes of the gizmo
  45201. */
  45202. dispose(): void;
  45203. }
  45204. }
  45205. declare module "babylonjs/Gizmos/rotationGizmo" {
  45206. import { Observable } from "babylonjs/Misc/observable";
  45207. import { Nullable } from "babylonjs/types";
  45208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45209. import { Mesh } from "babylonjs/Meshes/mesh";
  45210. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45211. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45212. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45213. /**
  45214. * Gizmo that enables rotating a mesh along 3 axis
  45215. */
  45216. export class RotationGizmo extends Gizmo {
  45217. /**
  45218. * Internal gizmo used for interactions on the x axis
  45219. */
  45220. xGizmo: PlaneRotationGizmo;
  45221. /**
  45222. * Internal gizmo used for interactions on the y axis
  45223. */
  45224. yGizmo: PlaneRotationGizmo;
  45225. /**
  45226. * Internal gizmo used for interactions on the z axis
  45227. */
  45228. zGizmo: PlaneRotationGizmo;
  45229. /** Fires an event when any of it's sub gizmos are dragged */
  45230. onDragStartObservable: Observable<unknown>;
  45231. /** Fires an event when any of it's sub gizmos are released from dragging */
  45232. onDragEndObservable: Observable<unknown>;
  45233. private _meshAttached;
  45234. attachedMesh: Nullable<AbstractMesh>;
  45235. /**
  45236. * Creates a RotationGizmo
  45237. * @param gizmoLayer The utility layer the gizmo will be added to
  45238. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45239. */
  45240. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45241. updateGizmoRotationToMatchAttachedMesh: boolean;
  45242. /**
  45243. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45244. */
  45245. snapDistance: number;
  45246. /**
  45247. * Ratio for the scale of the gizmo (Default: 1)
  45248. */
  45249. scaleRatio: number;
  45250. /**
  45251. * Disposes of the gizmo
  45252. */
  45253. dispose(): void;
  45254. /**
  45255. * CustomMeshes are not supported by this gizmo
  45256. * @param mesh The mesh to replace the default mesh of the gizmo
  45257. */
  45258. setCustomMesh(mesh: Mesh): void;
  45259. }
  45260. }
  45261. declare module "babylonjs/Gizmos/gizmoManager" {
  45262. import { Observable } from "babylonjs/Misc/observable";
  45263. import { Nullable } from "babylonjs/types";
  45264. import { Scene, IDisposable } from "babylonjs/scene";
  45265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45266. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45267. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45268. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45269. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45270. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45271. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45272. /**
  45273. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45274. */
  45275. export class GizmoManager implements IDisposable {
  45276. private scene;
  45277. /**
  45278. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45279. */
  45280. gizmos: {
  45281. positionGizmo: Nullable<PositionGizmo>;
  45282. rotationGizmo: Nullable<RotationGizmo>;
  45283. scaleGizmo: Nullable<ScaleGizmo>;
  45284. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45285. };
  45286. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45287. clearGizmoOnEmptyPointerEvent: boolean;
  45288. /** Fires an event when the manager is attached to a mesh */
  45289. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45290. private _gizmosEnabled;
  45291. private _pointerObserver;
  45292. private _attachedMesh;
  45293. private _boundingBoxColor;
  45294. private _defaultUtilityLayer;
  45295. private _defaultKeepDepthUtilityLayer;
  45296. /**
  45297. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45298. */
  45299. boundingBoxDragBehavior: SixDofDragBehavior;
  45300. /**
  45301. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45302. */
  45303. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45304. /**
  45305. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45306. */
  45307. usePointerToAttachGizmos: boolean;
  45308. /**
  45309. * Utility layer that the bounding box gizmo belongs to
  45310. */
  45311. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45312. /**
  45313. * Utility layer that all gizmos besides bounding box belong to
  45314. */
  45315. readonly utilityLayer: UtilityLayerRenderer;
  45316. /**
  45317. * Instatiates a gizmo manager
  45318. * @param scene the scene to overlay the gizmos on top of
  45319. */
  45320. constructor(scene: Scene);
  45321. /**
  45322. * Attaches a set of gizmos to the specified mesh
  45323. * @param mesh The mesh the gizmo's should be attached to
  45324. */
  45325. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45326. /**
  45327. * If the position gizmo is enabled
  45328. */
  45329. positionGizmoEnabled: boolean;
  45330. /**
  45331. * If the rotation gizmo is enabled
  45332. */
  45333. rotationGizmoEnabled: boolean;
  45334. /**
  45335. * If the scale gizmo is enabled
  45336. */
  45337. scaleGizmoEnabled: boolean;
  45338. /**
  45339. * If the boundingBox gizmo is enabled
  45340. */
  45341. boundingBoxGizmoEnabled: boolean;
  45342. /**
  45343. * Disposes of the gizmo manager
  45344. */
  45345. dispose(): void;
  45346. }
  45347. }
  45348. declare module "babylonjs/Lights/directionalLight" {
  45349. import { Camera } from "babylonjs/Cameras/camera";
  45350. import { Scene } from "babylonjs/scene";
  45351. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45353. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45354. import { Effect } from "babylonjs/Materials/effect";
  45355. /**
  45356. * A directional light is defined by a direction (what a surprise!).
  45357. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45358. * 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.
  45359. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45360. */
  45361. export class DirectionalLight extends ShadowLight {
  45362. private _shadowFrustumSize;
  45363. /**
  45364. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45365. */
  45366. /**
  45367. * Specifies a fix frustum size for the shadow generation.
  45368. */
  45369. shadowFrustumSize: number;
  45370. private _shadowOrthoScale;
  45371. /**
  45372. * Gets the shadow projection scale against the optimal computed one.
  45373. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45374. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45375. */
  45376. /**
  45377. * Sets the shadow projection scale against the optimal computed one.
  45378. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45379. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45380. */
  45381. shadowOrthoScale: number;
  45382. /**
  45383. * Automatically compute the projection matrix to best fit (including all the casters)
  45384. * on each frame.
  45385. */
  45386. autoUpdateExtends: boolean;
  45387. private _orthoLeft;
  45388. private _orthoRight;
  45389. private _orthoTop;
  45390. private _orthoBottom;
  45391. /**
  45392. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45393. * The directional light is emitted from everywhere in the given direction.
  45394. * It can cast shadows.
  45395. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45396. * @param name The friendly name of the light
  45397. * @param direction The direction of the light
  45398. * @param scene The scene the light belongs to
  45399. */
  45400. constructor(name: string, direction: Vector3, scene: Scene);
  45401. /**
  45402. * Returns the string "DirectionalLight".
  45403. * @return The class name
  45404. */
  45405. getClassName(): string;
  45406. /**
  45407. * Returns the integer 1.
  45408. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45409. */
  45410. getTypeID(): number;
  45411. /**
  45412. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45413. * Returns the DirectionalLight Shadow projection matrix.
  45414. */
  45415. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45416. /**
  45417. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45418. * Returns the DirectionalLight Shadow projection matrix.
  45419. */
  45420. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45421. /**
  45422. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45423. * Returns the DirectionalLight Shadow projection matrix.
  45424. */
  45425. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45426. protected _buildUniformLayout(): void;
  45427. /**
  45428. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45429. * @param effect The effect to update
  45430. * @param lightIndex The index of the light in the effect to update
  45431. * @returns The directional light
  45432. */
  45433. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45434. /**
  45435. * Gets the minZ used for shadow according to both the scene and the light.
  45436. *
  45437. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45438. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45439. * @param activeCamera The camera we are returning the min for
  45440. * @returns the depth min z
  45441. */
  45442. getDepthMinZ(activeCamera: Camera): number;
  45443. /**
  45444. * Gets the maxZ used for shadow according to both the scene and the light.
  45445. *
  45446. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45447. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45448. * @param activeCamera The camera we are returning the max for
  45449. * @returns the depth max z
  45450. */
  45451. getDepthMaxZ(activeCamera: Camera): number;
  45452. /**
  45453. * Prepares the list of defines specific to the light type.
  45454. * @param defines the list of defines
  45455. * @param lightIndex defines the index of the light for the effect
  45456. */
  45457. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45458. }
  45459. }
  45460. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45461. import { Mesh } from "babylonjs/Meshes/mesh";
  45462. /**
  45463. * Class containing static functions to help procedurally build meshes
  45464. */
  45465. export class HemisphereBuilder {
  45466. /**
  45467. * Creates a hemisphere mesh
  45468. * @param name defines the name of the mesh
  45469. * @param options defines the options used to create the mesh
  45470. * @param scene defines the hosting scene
  45471. * @returns the hemisphere mesh
  45472. */
  45473. static CreateHemisphere(name: string, options: {
  45474. segments?: number;
  45475. diameter?: number;
  45476. sideOrientation?: number;
  45477. }, scene: any): Mesh;
  45478. }
  45479. }
  45480. declare module "babylonjs/Lights/spotLight" {
  45481. import { Nullable } from "babylonjs/types";
  45482. import { Scene } from "babylonjs/scene";
  45483. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45485. import { Effect } from "babylonjs/Materials/effect";
  45486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45487. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45488. /**
  45489. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45490. * These values define a cone of light starting from the position, emitting toward the direction.
  45491. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45492. * and the exponent defines the speed of the decay of the light with distance (reach).
  45493. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45494. */
  45495. export class SpotLight extends ShadowLight {
  45496. private _angle;
  45497. private _innerAngle;
  45498. private _cosHalfAngle;
  45499. private _lightAngleScale;
  45500. private _lightAngleOffset;
  45501. /**
  45502. * Gets the cone angle of the spot light in Radians.
  45503. */
  45504. /**
  45505. * Sets the cone angle of the spot light in Radians.
  45506. */
  45507. angle: number;
  45508. /**
  45509. * Only used in gltf falloff mode, this defines the angle where
  45510. * the directional falloff will start before cutting at angle which could be seen
  45511. * as outer angle.
  45512. */
  45513. /**
  45514. * Only used in gltf falloff mode, this defines the angle where
  45515. * the directional falloff will start before cutting at angle which could be seen
  45516. * as outer angle.
  45517. */
  45518. innerAngle: number;
  45519. private _shadowAngleScale;
  45520. /**
  45521. * Allows scaling the angle of the light for shadow generation only.
  45522. */
  45523. /**
  45524. * Allows scaling the angle of the light for shadow generation only.
  45525. */
  45526. shadowAngleScale: number;
  45527. /**
  45528. * The light decay speed with the distance from the emission spot.
  45529. */
  45530. exponent: number;
  45531. private _projectionTextureMatrix;
  45532. /**
  45533. * Allows reading the projecton texture
  45534. */
  45535. readonly projectionTextureMatrix: Matrix;
  45536. protected _projectionTextureLightNear: number;
  45537. /**
  45538. * Gets the near clip of the Spotlight for texture projection.
  45539. */
  45540. /**
  45541. * Sets the near clip of the Spotlight for texture projection.
  45542. */
  45543. projectionTextureLightNear: number;
  45544. protected _projectionTextureLightFar: number;
  45545. /**
  45546. * Gets the far clip of the Spotlight for texture projection.
  45547. */
  45548. /**
  45549. * Sets the far clip of the Spotlight for texture projection.
  45550. */
  45551. projectionTextureLightFar: number;
  45552. protected _projectionTextureUpDirection: Vector3;
  45553. /**
  45554. * Gets the Up vector of the Spotlight for texture projection.
  45555. */
  45556. /**
  45557. * Sets the Up vector of the Spotlight for texture projection.
  45558. */
  45559. projectionTextureUpDirection: Vector3;
  45560. private _projectionTexture;
  45561. /**
  45562. * Gets the projection texture of the light.
  45563. */
  45564. /**
  45565. * Sets the projection texture of the light.
  45566. */
  45567. projectionTexture: Nullable<BaseTexture>;
  45568. private _projectionTextureViewLightDirty;
  45569. private _projectionTextureProjectionLightDirty;
  45570. private _projectionTextureDirty;
  45571. private _projectionTextureViewTargetVector;
  45572. private _projectionTextureViewLightMatrix;
  45573. private _projectionTextureProjectionLightMatrix;
  45574. private _projectionTextureScalingMatrix;
  45575. /**
  45576. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45577. * It can cast shadows.
  45578. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45579. * @param name The light friendly name
  45580. * @param position The position of the spot light in the scene
  45581. * @param direction The direction of the light in the scene
  45582. * @param angle The cone angle of the light in Radians
  45583. * @param exponent The light decay speed with the distance from the emission spot
  45584. * @param scene The scene the lights belongs to
  45585. */
  45586. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45587. /**
  45588. * Returns the string "SpotLight".
  45589. * @returns the class name
  45590. */
  45591. getClassName(): string;
  45592. /**
  45593. * Returns the integer 2.
  45594. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45595. */
  45596. getTypeID(): number;
  45597. /**
  45598. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45599. */
  45600. protected _setDirection(value: Vector3): void;
  45601. /**
  45602. * Overrides the position setter to recompute the projection texture view light Matrix.
  45603. */
  45604. protected _setPosition(value: Vector3): void;
  45605. /**
  45606. * 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.
  45607. * Returns the SpotLight.
  45608. */
  45609. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45610. protected _computeProjectionTextureViewLightMatrix(): void;
  45611. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45612. /**
  45613. * Main function for light texture projection matrix computing.
  45614. */
  45615. protected _computeProjectionTextureMatrix(): void;
  45616. protected _buildUniformLayout(): void;
  45617. private _computeAngleValues;
  45618. /**
  45619. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45620. * @param effect The effect to update
  45621. * @param lightIndex The index of the light in the effect to update
  45622. * @returns The spot light
  45623. */
  45624. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45625. /**
  45626. * Disposes the light and the associated resources.
  45627. */
  45628. dispose(): void;
  45629. /**
  45630. * Prepares the list of defines specific to the light type.
  45631. * @param defines the list of defines
  45632. * @param lightIndex defines the index of the light for the effect
  45633. */
  45634. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45635. }
  45636. }
  45637. declare module "babylonjs/Gizmos/lightGizmo" {
  45638. import { Nullable } from "babylonjs/types";
  45639. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45640. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45641. import { Light } from "babylonjs/Lights/light";
  45642. /**
  45643. * Gizmo that enables viewing a light
  45644. */
  45645. export class LightGizmo extends Gizmo {
  45646. private _lightMesh;
  45647. private _material;
  45648. private cachedPosition;
  45649. private cachedForward;
  45650. /**
  45651. * Creates a LightGizmo
  45652. * @param gizmoLayer The utility layer the gizmo will be added to
  45653. */
  45654. constructor(gizmoLayer?: UtilityLayerRenderer);
  45655. private _light;
  45656. /**
  45657. * The light that the gizmo is attached to
  45658. */
  45659. light: Nullable<Light>;
  45660. /**
  45661. * @hidden
  45662. * Updates the gizmo to match the attached mesh's position/rotation
  45663. */
  45664. protected _update(): void;
  45665. private static _Scale;
  45666. /**
  45667. * Creates the lines for a light mesh
  45668. */
  45669. private static _createLightLines;
  45670. /**
  45671. * Disposes of the light gizmo
  45672. */
  45673. dispose(): void;
  45674. private static _CreateHemisphericLightMesh;
  45675. private static _CreatePointLightMesh;
  45676. private static _CreateSpotLightMesh;
  45677. private static _CreateDirectionalLightMesh;
  45678. }
  45679. }
  45680. declare module "babylonjs/Gizmos/index" {
  45681. export * from "babylonjs/Gizmos/axisDragGizmo";
  45682. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45683. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45684. export * from "babylonjs/Gizmos/gizmo";
  45685. export * from "babylonjs/Gizmos/gizmoManager";
  45686. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45687. export * from "babylonjs/Gizmos/positionGizmo";
  45688. export * from "babylonjs/Gizmos/rotationGizmo";
  45689. export * from "babylonjs/Gizmos/scaleGizmo";
  45690. export * from "babylonjs/Gizmos/lightGizmo";
  45691. }
  45692. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45693. /** @hidden */
  45694. export var backgroundFragmentDeclaration: {
  45695. name: string;
  45696. shader: string;
  45697. };
  45698. }
  45699. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45700. /** @hidden */
  45701. export var backgroundUboDeclaration: {
  45702. name: string;
  45703. shader: string;
  45704. };
  45705. }
  45706. declare module "babylonjs/Shaders/background.fragment" {
  45707. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45708. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45709. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45710. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45711. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45712. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45713. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45714. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45715. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45716. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45717. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45718. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45719. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45720. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45721. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45722. /** @hidden */
  45723. export var backgroundPixelShader: {
  45724. name: string;
  45725. shader: string;
  45726. };
  45727. }
  45728. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45729. /** @hidden */
  45730. export var backgroundVertexDeclaration: {
  45731. name: string;
  45732. shader: string;
  45733. };
  45734. }
  45735. declare module "babylonjs/Shaders/background.vertex" {
  45736. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45737. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45738. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45739. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45740. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45741. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45742. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45743. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45744. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45745. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45746. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45747. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45748. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45749. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45750. /** @hidden */
  45751. export var backgroundVertexShader: {
  45752. name: string;
  45753. shader: string;
  45754. };
  45755. }
  45756. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45757. import { Nullable, int, float } from "babylonjs/types";
  45758. import { Scene } from "babylonjs/scene";
  45759. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45760. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45762. import { Mesh } from "babylonjs/Meshes/mesh";
  45763. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45764. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45765. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45766. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45767. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45768. import "babylonjs/Shaders/background.fragment";
  45769. import "babylonjs/Shaders/background.vertex";
  45770. /**
  45771. * Background material used to create an efficient environement around your scene.
  45772. */
  45773. export class BackgroundMaterial extends PushMaterial {
  45774. /**
  45775. * Standard reflectance value at parallel view angle.
  45776. */
  45777. static StandardReflectance0: number;
  45778. /**
  45779. * Standard reflectance value at grazing angle.
  45780. */
  45781. static StandardReflectance90: number;
  45782. protected _primaryColor: Color3;
  45783. /**
  45784. * Key light Color (multiply against the environement texture)
  45785. */
  45786. primaryColor: Color3;
  45787. protected __perceptualColor: Nullable<Color3>;
  45788. /**
  45789. * Experimental Internal Use Only.
  45790. *
  45791. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45792. * This acts as a helper to set the primary color to a more "human friendly" value.
  45793. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45794. * output color as close as possible from the chosen value.
  45795. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45796. * part of lighting setup.)
  45797. */
  45798. _perceptualColor: Nullable<Color3>;
  45799. protected _primaryColorShadowLevel: float;
  45800. /**
  45801. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45802. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45803. */
  45804. primaryColorShadowLevel: float;
  45805. protected _primaryColorHighlightLevel: float;
  45806. /**
  45807. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45808. * The primary color is used at the level chosen to define what the white area would look.
  45809. */
  45810. primaryColorHighlightLevel: float;
  45811. protected _reflectionTexture: Nullable<BaseTexture>;
  45812. /**
  45813. * Reflection Texture used in the material.
  45814. * Should be author in a specific way for the best result (refer to the documentation).
  45815. */
  45816. reflectionTexture: Nullable<BaseTexture>;
  45817. protected _reflectionBlur: float;
  45818. /**
  45819. * Reflection Texture level of blur.
  45820. *
  45821. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45822. * texture twice.
  45823. */
  45824. reflectionBlur: float;
  45825. protected _diffuseTexture: Nullable<BaseTexture>;
  45826. /**
  45827. * Diffuse Texture used in the material.
  45828. * Should be author in a specific way for the best result (refer to the documentation).
  45829. */
  45830. diffuseTexture: Nullable<BaseTexture>;
  45831. protected _shadowLights: Nullable<IShadowLight[]>;
  45832. /**
  45833. * Specify the list of lights casting shadow on the material.
  45834. * All scene shadow lights will be included if null.
  45835. */
  45836. shadowLights: Nullable<IShadowLight[]>;
  45837. protected _shadowLevel: float;
  45838. /**
  45839. * Helps adjusting the shadow to a softer level if required.
  45840. * 0 means black shadows and 1 means no shadows.
  45841. */
  45842. shadowLevel: float;
  45843. protected _sceneCenter: Vector3;
  45844. /**
  45845. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45846. * It is usually zero but might be interesting to modify according to your setup.
  45847. */
  45848. sceneCenter: Vector3;
  45849. protected _opacityFresnel: boolean;
  45850. /**
  45851. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45852. * This helps ensuring a nice transition when the camera goes under the ground.
  45853. */
  45854. opacityFresnel: boolean;
  45855. protected _reflectionFresnel: boolean;
  45856. /**
  45857. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45858. * This helps adding a mirror texture on the ground.
  45859. */
  45860. reflectionFresnel: boolean;
  45861. protected _reflectionFalloffDistance: number;
  45862. /**
  45863. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45864. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45865. */
  45866. reflectionFalloffDistance: number;
  45867. protected _reflectionAmount: number;
  45868. /**
  45869. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45870. */
  45871. reflectionAmount: number;
  45872. protected _reflectionReflectance0: number;
  45873. /**
  45874. * This specifies the weight of the reflection at grazing angle.
  45875. */
  45876. reflectionReflectance0: number;
  45877. protected _reflectionReflectance90: number;
  45878. /**
  45879. * This specifies the weight of the reflection at a perpendicular point of view.
  45880. */
  45881. reflectionReflectance90: number;
  45882. /**
  45883. * Sets the reflection reflectance fresnel values according to the default standard
  45884. * empirically know to work well :-)
  45885. */
  45886. reflectionStandardFresnelWeight: number;
  45887. protected _useRGBColor: boolean;
  45888. /**
  45889. * Helps to directly use the maps channels instead of their level.
  45890. */
  45891. useRGBColor: boolean;
  45892. protected _enableNoise: boolean;
  45893. /**
  45894. * This helps reducing the banding effect that could occur on the background.
  45895. */
  45896. enableNoise: boolean;
  45897. /**
  45898. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45899. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45900. * Recommended to be keep at 1.0 except for special cases.
  45901. */
  45902. fovMultiplier: number;
  45903. private _fovMultiplier;
  45904. /**
  45905. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45906. */
  45907. useEquirectangularFOV: boolean;
  45908. private _maxSimultaneousLights;
  45909. /**
  45910. * Number of Simultaneous lights allowed on the material.
  45911. */
  45912. maxSimultaneousLights: int;
  45913. /**
  45914. * Default configuration related to image processing available in the Background Material.
  45915. */
  45916. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45917. /**
  45918. * Keep track of the image processing observer to allow dispose and replace.
  45919. */
  45920. private _imageProcessingObserver;
  45921. /**
  45922. * Attaches a new image processing configuration to the PBR Material.
  45923. * @param configuration (if null the scene configuration will be use)
  45924. */
  45925. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45926. /**
  45927. * Gets the image processing configuration used either in this material.
  45928. */
  45929. /**
  45930. * Sets the Default image processing configuration used either in the this material.
  45931. *
  45932. * If sets to null, the scene one is in use.
  45933. */
  45934. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45935. /**
  45936. * Gets wether the color curves effect is enabled.
  45937. */
  45938. /**
  45939. * Sets wether the color curves effect is enabled.
  45940. */
  45941. cameraColorCurvesEnabled: boolean;
  45942. /**
  45943. * Gets wether the color grading effect is enabled.
  45944. */
  45945. /**
  45946. * Gets wether the color grading effect is enabled.
  45947. */
  45948. cameraColorGradingEnabled: boolean;
  45949. /**
  45950. * Gets wether tonemapping is enabled or not.
  45951. */
  45952. /**
  45953. * Sets wether tonemapping is enabled or not
  45954. */
  45955. cameraToneMappingEnabled: boolean;
  45956. /**
  45957. * The camera exposure used on this material.
  45958. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45959. * This corresponds to a photographic exposure.
  45960. */
  45961. /**
  45962. * The camera exposure used on this material.
  45963. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45964. * This corresponds to a photographic exposure.
  45965. */
  45966. cameraExposure: float;
  45967. /**
  45968. * Gets The camera contrast used on this material.
  45969. */
  45970. /**
  45971. * Sets The camera contrast used on this material.
  45972. */
  45973. cameraContrast: float;
  45974. /**
  45975. * Gets the Color Grading 2D Lookup Texture.
  45976. */
  45977. /**
  45978. * Sets the Color Grading 2D Lookup Texture.
  45979. */
  45980. cameraColorGradingTexture: Nullable<BaseTexture>;
  45981. /**
  45982. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45983. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45984. * 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;
  45985. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45986. */
  45987. /**
  45988. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45989. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45990. * 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;
  45991. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45992. */
  45993. cameraColorCurves: Nullable<ColorCurves>;
  45994. /**
  45995. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45996. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45997. */
  45998. switchToBGR: boolean;
  45999. private _renderTargets;
  46000. private _reflectionControls;
  46001. private _white;
  46002. private _primaryShadowColor;
  46003. private _primaryHighlightColor;
  46004. /**
  46005. * Instantiates a Background Material in the given scene
  46006. * @param name The friendly name of the material
  46007. * @param scene The scene to add the material to
  46008. */
  46009. constructor(name: string, scene: Scene);
  46010. /**
  46011. * Gets a boolean indicating that current material needs to register RTT
  46012. */
  46013. readonly hasRenderTargetTextures: boolean;
  46014. /**
  46015. * The entire material has been created in order to prevent overdraw.
  46016. * @returns false
  46017. */
  46018. needAlphaTesting(): boolean;
  46019. /**
  46020. * The entire material has been created in order to prevent overdraw.
  46021. * @returns true if blending is enable
  46022. */
  46023. needAlphaBlending(): boolean;
  46024. /**
  46025. * Checks wether the material is ready to be rendered for a given mesh.
  46026. * @param mesh The mesh to render
  46027. * @param subMesh The submesh to check against
  46028. * @param useInstances Specify wether or not the material is used with instances
  46029. * @returns true if all the dependencies are ready (Textures, Effects...)
  46030. */
  46031. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46032. /**
  46033. * Compute the primary color according to the chosen perceptual color.
  46034. */
  46035. private _computePrimaryColorFromPerceptualColor;
  46036. /**
  46037. * Compute the highlights and shadow colors according to their chosen levels.
  46038. */
  46039. private _computePrimaryColors;
  46040. /**
  46041. * Build the uniform buffer used in the material.
  46042. */
  46043. buildUniformLayout(): void;
  46044. /**
  46045. * Unbind the material.
  46046. */
  46047. unbind(): void;
  46048. /**
  46049. * Bind only the world matrix to the material.
  46050. * @param world The world matrix to bind.
  46051. */
  46052. bindOnlyWorldMatrix(world: Matrix): void;
  46053. /**
  46054. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46055. * @param world The world matrix to bind.
  46056. * @param subMesh The submesh to bind for.
  46057. */
  46058. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46059. /**
  46060. * Dispose the material.
  46061. * @param forceDisposeEffect Force disposal of the associated effect.
  46062. * @param forceDisposeTextures Force disposal of the associated textures.
  46063. */
  46064. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46065. /**
  46066. * Clones the material.
  46067. * @param name The cloned name.
  46068. * @returns The cloned material.
  46069. */
  46070. clone(name: string): BackgroundMaterial;
  46071. /**
  46072. * Serializes the current material to its JSON representation.
  46073. * @returns The JSON representation.
  46074. */
  46075. serialize(): any;
  46076. /**
  46077. * Gets the class name of the material
  46078. * @returns "BackgroundMaterial"
  46079. */
  46080. getClassName(): string;
  46081. /**
  46082. * Parse a JSON input to create back a background material.
  46083. * @param source The JSON data to parse
  46084. * @param scene The scene to create the parsed material in
  46085. * @param rootUrl The root url of the assets the material depends upon
  46086. * @returns the instantiated BackgroundMaterial.
  46087. */
  46088. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46089. }
  46090. }
  46091. declare module "babylonjs/Helpers/environmentHelper" {
  46092. import { Observable } from "babylonjs/Misc/observable";
  46093. import { Nullable } from "babylonjs/types";
  46094. import { Scene } from "babylonjs/scene";
  46095. import { Vector3, Color3 } from "babylonjs/Maths/math";
  46096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46097. import { Mesh } from "babylonjs/Meshes/mesh";
  46098. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46099. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46100. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46101. import "babylonjs/Meshes/Builders/planeBuilder";
  46102. import "babylonjs/Meshes/Builders/boxBuilder";
  46103. /**
  46104. * Represents the different options available during the creation of
  46105. * a Environment helper.
  46106. *
  46107. * This can control the default ground, skybox and image processing setup of your scene.
  46108. */
  46109. export interface IEnvironmentHelperOptions {
  46110. /**
  46111. * Specifies wether or not to create a ground.
  46112. * True by default.
  46113. */
  46114. createGround: boolean;
  46115. /**
  46116. * Specifies the ground size.
  46117. * 15 by default.
  46118. */
  46119. groundSize: number;
  46120. /**
  46121. * The texture used on the ground for the main color.
  46122. * Comes from the BabylonJS CDN by default.
  46123. *
  46124. * Remarks: Can be either a texture or a url.
  46125. */
  46126. groundTexture: string | BaseTexture;
  46127. /**
  46128. * The color mixed in the ground texture by default.
  46129. * BabylonJS clearColor by default.
  46130. */
  46131. groundColor: Color3;
  46132. /**
  46133. * Specifies the ground opacity.
  46134. * 1 by default.
  46135. */
  46136. groundOpacity: number;
  46137. /**
  46138. * Enables the ground to receive shadows.
  46139. * True by default.
  46140. */
  46141. enableGroundShadow: boolean;
  46142. /**
  46143. * Helps preventing the shadow to be fully black on the ground.
  46144. * 0.5 by default.
  46145. */
  46146. groundShadowLevel: number;
  46147. /**
  46148. * Creates a mirror texture attach to the ground.
  46149. * false by default.
  46150. */
  46151. enableGroundMirror: boolean;
  46152. /**
  46153. * Specifies the ground mirror size ratio.
  46154. * 0.3 by default as the default kernel is 64.
  46155. */
  46156. groundMirrorSizeRatio: number;
  46157. /**
  46158. * Specifies the ground mirror blur kernel size.
  46159. * 64 by default.
  46160. */
  46161. groundMirrorBlurKernel: number;
  46162. /**
  46163. * Specifies the ground mirror visibility amount.
  46164. * 1 by default
  46165. */
  46166. groundMirrorAmount: number;
  46167. /**
  46168. * Specifies the ground mirror reflectance weight.
  46169. * This uses the standard weight of the background material to setup the fresnel effect
  46170. * of the mirror.
  46171. * 1 by default.
  46172. */
  46173. groundMirrorFresnelWeight: number;
  46174. /**
  46175. * Specifies the ground mirror Falloff distance.
  46176. * This can helps reducing the size of the reflection.
  46177. * 0 by Default.
  46178. */
  46179. groundMirrorFallOffDistance: number;
  46180. /**
  46181. * Specifies the ground mirror texture type.
  46182. * Unsigned Int by Default.
  46183. */
  46184. groundMirrorTextureType: number;
  46185. /**
  46186. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46187. * the shown objects.
  46188. */
  46189. groundYBias: number;
  46190. /**
  46191. * Specifies wether or not to create a skybox.
  46192. * True by default.
  46193. */
  46194. createSkybox: boolean;
  46195. /**
  46196. * Specifies the skybox size.
  46197. * 20 by default.
  46198. */
  46199. skyboxSize: number;
  46200. /**
  46201. * The texture used on the skybox for the main color.
  46202. * Comes from the BabylonJS CDN by default.
  46203. *
  46204. * Remarks: Can be either a texture or a url.
  46205. */
  46206. skyboxTexture: string | BaseTexture;
  46207. /**
  46208. * The color mixed in the skybox texture by default.
  46209. * BabylonJS clearColor by default.
  46210. */
  46211. skyboxColor: Color3;
  46212. /**
  46213. * The background rotation around the Y axis of the scene.
  46214. * This helps aligning the key lights of your scene with the background.
  46215. * 0 by default.
  46216. */
  46217. backgroundYRotation: number;
  46218. /**
  46219. * Compute automatically the size of the elements to best fit with the scene.
  46220. */
  46221. sizeAuto: boolean;
  46222. /**
  46223. * Default position of the rootMesh if autoSize is not true.
  46224. */
  46225. rootPosition: Vector3;
  46226. /**
  46227. * Sets up the image processing in the scene.
  46228. * true by default.
  46229. */
  46230. setupImageProcessing: boolean;
  46231. /**
  46232. * The texture used as your environment texture in the scene.
  46233. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46234. *
  46235. * Remarks: Can be either a texture or a url.
  46236. */
  46237. environmentTexture: string | BaseTexture;
  46238. /**
  46239. * The value of the exposure to apply to the scene.
  46240. * 0.6 by default if setupImageProcessing is true.
  46241. */
  46242. cameraExposure: number;
  46243. /**
  46244. * The value of the contrast to apply to the scene.
  46245. * 1.6 by default if setupImageProcessing is true.
  46246. */
  46247. cameraContrast: number;
  46248. /**
  46249. * Specifies wether or not tonemapping should be enabled in the scene.
  46250. * true by default if setupImageProcessing is true.
  46251. */
  46252. toneMappingEnabled: boolean;
  46253. }
  46254. /**
  46255. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46256. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46257. * It also helps with the default setup of your imageProcessing configuration.
  46258. */
  46259. export class EnvironmentHelper {
  46260. /**
  46261. * Default ground texture URL.
  46262. */
  46263. private static _groundTextureCDNUrl;
  46264. /**
  46265. * Default skybox texture URL.
  46266. */
  46267. private static _skyboxTextureCDNUrl;
  46268. /**
  46269. * Default environment texture URL.
  46270. */
  46271. private static _environmentTextureCDNUrl;
  46272. /**
  46273. * Creates the default options for the helper.
  46274. */
  46275. private static _getDefaultOptions;
  46276. private _rootMesh;
  46277. /**
  46278. * Gets the root mesh created by the helper.
  46279. */
  46280. readonly rootMesh: Mesh;
  46281. private _skybox;
  46282. /**
  46283. * Gets the skybox created by the helper.
  46284. */
  46285. readonly skybox: Nullable<Mesh>;
  46286. private _skyboxTexture;
  46287. /**
  46288. * Gets the skybox texture created by the helper.
  46289. */
  46290. readonly skyboxTexture: Nullable<BaseTexture>;
  46291. private _skyboxMaterial;
  46292. /**
  46293. * Gets the skybox material created by the helper.
  46294. */
  46295. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46296. private _ground;
  46297. /**
  46298. * Gets the ground mesh created by the helper.
  46299. */
  46300. readonly ground: Nullable<Mesh>;
  46301. private _groundTexture;
  46302. /**
  46303. * Gets the ground texture created by the helper.
  46304. */
  46305. readonly groundTexture: Nullable<BaseTexture>;
  46306. private _groundMirror;
  46307. /**
  46308. * Gets the ground mirror created by the helper.
  46309. */
  46310. readonly groundMirror: Nullable<MirrorTexture>;
  46311. /**
  46312. * Gets the ground mirror render list to helps pushing the meshes
  46313. * you wish in the ground reflection.
  46314. */
  46315. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46316. private _groundMaterial;
  46317. /**
  46318. * Gets the ground material created by the helper.
  46319. */
  46320. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46321. /**
  46322. * Stores the creation options.
  46323. */
  46324. private readonly _scene;
  46325. private _options;
  46326. /**
  46327. * This observable will be notified with any error during the creation of the environment,
  46328. * mainly texture creation errors.
  46329. */
  46330. onErrorObservable: Observable<{
  46331. message?: string;
  46332. exception?: any;
  46333. }>;
  46334. /**
  46335. * constructor
  46336. * @param options Defines the options we want to customize the helper
  46337. * @param scene The scene to add the material to
  46338. */
  46339. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46340. /**
  46341. * Updates the background according to the new options
  46342. * @param options
  46343. */
  46344. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46345. /**
  46346. * Sets the primary color of all the available elements.
  46347. * @param color the main color to affect to the ground and the background
  46348. */
  46349. setMainColor(color: Color3): void;
  46350. /**
  46351. * Setup the image processing according to the specified options.
  46352. */
  46353. private _setupImageProcessing;
  46354. /**
  46355. * Setup the environment texture according to the specified options.
  46356. */
  46357. private _setupEnvironmentTexture;
  46358. /**
  46359. * Setup the background according to the specified options.
  46360. */
  46361. private _setupBackground;
  46362. /**
  46363. * Get the scene sizes according to the setup.
  46364. */
  46365. private _getSceneSize;
  46366. /**
  46367. * Setup the ground according to the specified options.
  46368. */
  46369. private _setupGround;
  46370. /**
  46371. * Setup the ground material according to the specified options.
  46372. */
  46373. private _setupGroundMaterial;
  46374. /**
  46375. * Setup the ground diffuse texture according to the specified options.
  46376. */
  46377. private _setupGroundDiffuseTexture;
  46378. /**
  46379. * Setup the ground mirror texture according to the specified options.
  46380. */
  46381. private _setupGroundMirrorTexture;
  46382. /**
  46383. * Setup the ground to receive the mirror texture.
  46384. */
  46385. private _setupMirrorInGroundMaterial;
  46386. /**
  46387. * Setup the skybox according to the specified options.
  46388. */
  46389. private _setupSkybox;
  46390. /**
  46391. * Setup the skybox material according to the specified options.
  46392. */
  46393. private _setupSkyboxMaterial;
  46394. /**
  46395. * Setup the skybox reflection texture according to the specified options.
  46396. */
  46397. private _setupSkyboxReflectionTexture;
  46398. private _errorHandler;
  46399. /**
  46400. * Dispose all the elements created by the Helper.
  46401. */
  46402. dispose(): void;
  46403. }
  46404. }
  46405. declare module "babylonjs/Helpers/photoDome" {
  46406. import { Observable } from "babylonjs/Misc/observable";
  46407. import { Nullable } from "babylonjs/types";
  46408. import { Scene } from "babylonjs/scene";
  46409. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46410. import { Mesh } from "babylonjs/Meshes/mesh";
  46411. import { Texture } from "babylonjs/Materials/Textures/texture";
  46412. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46413. import "babylonjs/Meshes/Builders/sphereBuilder";
  46414. /**
  46415. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46416. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46417. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46418. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46419. */
  46420. export class PhotoDome extends TransformNode {
  46421. /**
  46422. * Define the image as a Monoscopic panoramic 360 image.
  46423. */
  46424. static readonly MODE_MONOSCOPIC: number;
  46425. /**
  46426. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46427. */
  46428. static readonly MODE_TOPBOTTOM: number;
  46429. /**
  46430. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46431. */
  46432. static readonly MODE_SIDEBYSIDE: number;
  46433. private _useDirectMapping;
  46434. /**
  46435. * The texture being displayed on the sphere
  46436. */
  46437. protected _photoTexture: Texture;
  46438. /**
  46439. * Gets or sets the texture being displayed on the sphere
  46440. */
  46441. photoTexture: Texture;
  46442. /**
  46443. * Observable raised when an error occured while loading the 360 image
  46444. */
  46445. onLoadErrorObservable: Observable<string>;
  46446. /**
  46447. * The skybox material
  46448. */
  46449. protected _material: BackgroundMaterial;
  46450. /**
  46451. * The surface used for the skybox
  46452. */
  46453. protected _mesh: Mesh;
  46454. /**
  46455. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46456. * Also see the options.resolution property.
  46457. */
  46458. fovMultiplier: number;
  46459. private _imageMode;
  46460. /**
  46461. * Gets or set the current video mode for the video. It can be:
  46462. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46463. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46464. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46465. */
  46466. imageMode: number;
  46467. /**
  46468. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46469. * @param name Element's name, child elements will append suffixes for their own names.
  46470. * @param urlsOfPhoto defines the url of the photo to display
  46471. * @param options defines an object containing optional or exposed sub element properties
  46472. * @param onError defines a callback called when an error occured while loading the texture
  46473. */
  46474. constructor(name: string, urlOfPhoto: string, options: {
  46475. resolution?: number;
  46476. size?: number;
  46477. useDirectMapping?: boolean;
  46478. faceForward?: boolean;
  46479. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46480. private _onBeforeCameraRenderObserver;
  46481. private _changeImageMode;
  46482. /**
  46483. * Releases resources associated with this node.
  46484. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46485. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46486. */
  46487. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46488. }
  46489. }
  46490. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46491. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46492. /** @hidden */
  46493. export var rgbdDecodePixelShader: {
  46494. name: string;
  46495. shader: string;
  46496. };
  46497. }
  46498. declare module "babylonjs/Misc/brdfTextureTools" {
  46499. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46500. import { Scene } from "babylonjs/scene";
  46501. import "babylonjs/Shaders/rgbdDecode.fragment";
  46502. /**
  46503. * Class used to host texture specific utilities
  46504. */
  46505. export class BRDFTextureTools {
  46506. /**
  46507. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46508. * @param texture the texture to expand.
  46509. */
  46510. private static _ExpandDefaultBRDFTexture;
  46511. /**
  46512. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46513. * @param scene defines the hosting scene
  46514. * @returns the environment BRDF texture
  46515. */
  46516. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46517. private static _environmentBRDFBase64Texture;
  46518. }
  46519. }
  46520. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46521. import { Nullable } from "babylonjs/types";
  46522. import { IAnimatable } from "babylonjs/Misc/tools";
  46523. import { Color3 } from "babylonjs/Maths/math";
  46524. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46525. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46526. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46527. import { Engine } from "babylonjs/Engines/engine";
  46528. import { Scene } from "babylonjs/scene";
  46529. /**
  46530. * @hidden
  46531. */
  46532. export interface IMaterialClearCoatDefines {
  46533. CLEARCOAT: boolean;
  46534. CLEARCOAT_DEFAULTIOR: boolean;
  46535. CLEARCOAT_TEXTURE: boolean;
  46536. CLEARCOAT_TEXTUREDIRECTUV: number;
  46537. CLEARCOAT_BUMP: boolean;
  46538. CLEARCOAT_BUMPDIRECTUV: number;
  46539. CLEARCOAT_TINT: boolean;
  46540. CLEARCOAT_TINT_TEXTURE: boolean;
  46541. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46542. /** @hidden */
  46543. _areTexturesDirty: boolean;
  46544. }
  46545. /**
  46546. * Define the code related to the clear coat parameters of the pbr material.
  46547. */
  46548. export class PBRClearCoatConfiguration {
  46549. /**
  46550. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46551. * The default fits with a polyurethane material.
  46552. */
  46553. private static readonly _DefaultIndexOfRefraction;
  46554. private _isEnabled;
  46555. /**
  46556. * Defines if the clear coat is enabled in the material.
  46557. */
  46558. isEnabled: boolean;
  46559. /**
  46560. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46561. */
  46562. intensity: number;
  46563. /**
  46564. * Defines the clear coat layer roughness.
  46565. */
  46566. roughness: number;
  46567. private _indexOfRefraction;
  46568. /**
  46569. * Defines the index of refraction of the clear coat.
  46570. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46571. * The default fits with a polyurethane material.
  46572. * Changing the default value is more performance intensive.
  46573. */
  46574. indexOfRefraction: number;
  46575. private _texture;
  46576. /**
  46577. * Stores the clear coat values in a texture.
  46578. */
  46579. texture: Nullable<BaseTexture>;
  46580. private _bumpTexture;
  46581. /**
  46582. * Define the clear coat specific bump texture.
  46583. */
  46584. bumpTexture: Nullable<BaseTexture>;
  46585. private _isTintEnabled;
  46586. /**
  46587. * Defines if the clear coat tint is enabled in the material.
  46588. */
  46589. isTintEnabled: boolean;
  46590. /**
  46591. * Defines the clear coat tint of the material.
  46592. * This is only use if tint is enabled
  46593. */
  46594. tintColor: Color3;
  46595. /**
  46596. * Defines the distance at which the tint color should be found in the
  46597. * clear coat media.
  46598. * This is only use if tint is enabled
  46599. */
  46600. tintColorAtDistance: number;
  46601. /**
  46602. * Defines the clear coat layer thickness.
  46603. * This is only use if tint is enabled
  46604. */
  46605. tintThickness: number;
  46606. private _tintTexture;
  46607. /**
  46608. * Stores the clear tint values in a texture.
  46609. * rgb is tint
  46610. * a is a thickness factor
  46611. */
  46612. tintTexture: Nullable<BaseTexture>;
  46613. /** @hidden */
  46614. private _internalMarkAllSubMeshesAsTexturesDirty;
  46615. /** @hidden */
  46616. _markAllSubMeshesAsTexturesDirty(): void;
  46617. /**
  46618. * Instantiate a new istance of clear coat configuration.
  46619. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46620. */
  46621. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46622. /**
  46623. * Gets wehter the submesh is ready to be used or not.
  46624. * @param defines the list of "defines" to update.
  46625. * @param scene defines the scene the material belongs to.
  46626. * @param engine defines the engine the material belongs to.
  46627. * @param disableBumpMap defines wether the material disables bump or not.
  46628. * @returns - boolean indicating that the submesh is ready or not.
  46629. */
  46630. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46631. /**
  46632. * Checks to see if a texture is used in the material.
  46633. * @param defines the list of "defines" to update.
  46634. * @param scene defines the scene to the material belongs to.
  46635. */
  46636. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46637. /**
  46638. * Binds the material data.
  46639. * @param uniformBuffer defines the Uniform buffer to fill in.
  46640. * @param scene defines the scene the material belongs to.
  46641. * @param engine defines the engine the material belongs to.
  46642. * @param disableBumpMap defines wether the material disables bump or not.
  46643. * @param isFrozen defines wether the material is frozen or not.
  46644. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46645. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46646. */
  46647. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46648. /**
  46649. * Checks to see if a texture is used in the material.
  46650. * @param texture - Base texture to use.
  46651. * @returns - Boolean specifying if a texture is used in the material.
  46652. */
  46653. hasTexture(texture: BaseTexture): boolean;
  46654. /**
  46655. * Returns an array of the actively used textures.
  46656. * @param activeTextures Array of BaseTextures
  46657. */
  46658. getActiveTextures(activeTextures: BaseTexture[]): void;
  46659. /**
  46660. * Returns the animatable textures.
  46661. * @param animatables Array of animatable textures.
  46662. */
  46663. getAnimatables(animatables: IAnimatable[]): void;
  46664. /**
  46665. * Disposes the resources of the material.
  46666. * @param forceDisposeTextures - Forces the disposal of all textures.
  46667. */
  46668. dispose(forceDisposeTextures?: boolean): void;
  46669. /**
  46670. * Get the current class name of the texture useful for serialization or dynamic coding.
  46671. * @returns "PBRClearCoatConfiguration"
  46672. */
  46673. getClassName(): string;
  46674. /**
  46675. * Add fallbacks to the effect fallbacks list.
  46676. * @param defines defines the Base texture to use.
  46677. * @param fallbacks defines the current fallback list.
  46678. * @param currentRank defines the current fallback rank.
  46679. * @returns the new fallback rank.
  46680. */
  46681. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46682. /**
  46683. * Add the required uniforms to the current list.
  46684. * @param uniforms defines the current uniform list.
  46685. */
  46686. static AddUniforms(uniforms: string[]): void;
  46687. /**
  46688. * Add the required samplers to the current list.
  46689. * @param samplers defines the current sampler list.
  46690. */
  46691. static AddSamplers(samplers: string[]): void;
  46692. /**
  46693. * Add the required uniforms to the current buffer.
  46694. * @param uniformBuffer defines the current uniform buffer.
  46695. */
  46696. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46697. /**
  46698. * Makes a duplicate of the current configuration into another one.
  46699. * @param clearCoatConfiguration define the config where to copy the info
  46700. */
  46701. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46702. /**
  46703. * Serializes this clear coat configuration.
  46704. * @returns - An object with the serialized config.
  46705. */
  46706. serialize(): any;
  46707. /**
  46708. * Parses a anisotropy Configuration from a serialized object.
  46709. * @param source - Serialized object.
  46710. * @param scene Defines the scene we are parsing for
  46711. * @param rootUrl Defines the rootUrl to load from
  46712. */
  46713. parse(source: any, scene: Scene, rootUrl: string): void;
  46714. }
  46715. }
  46716. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46717. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46718. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46720. import { Vector2 } from "babylonjs/Maths/math";
  46721. import { Scene } from "babylonjs/scene";
  46722. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46723. import { IAnimatable } from "babylonjs/Misc/tools";
  46724. import { Nullable } from "babylonjs/types";
  46725. /**
  46726. * @hidden
  46727. */
  46728. export interface IMaterialAnisotropicDefines {
  46729. ANISOTROPIC: boolean;
  46730. ANISOTROPIC_TEXTURE: boolean;
  46731. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46732. MAINUV1: boolean;
  46733. _areTexturesDirty: boolean;
  46734. _needUVs: boolean;
  46735. }
  46736. /**
  46737. * Define the code related to the anisotropic parameters of the pbr material.
  46738. */
  46739. export class PBRAnisotropicConfiguration {
  46740. private _isEnabled;
  46741. /**
  46742. * Defines if the anisotropy is enabled in the material.
  46743. */
  46744. isEnabled: boolean;
  46745. /**
  46746. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46747. */
  46748. intensity: number;
  46749. /**
  46750. * Defines if the effect is along the tangents, bitangents or in between.
  46751. * By default, the effect is "strectching" the highlights along the tangents.
  46752. */
  46753. direction: Vector2;
  46754. private _texture;
  46755. /**
  46756. * Stores the anisotropy values in a texture.
  46757. * rg is direction (like normal from -1 to 1)
  46758. * b is a intensity
  46759. */
  46760. texture: Nullable<BaseTexture>;
  46761. /** @hidden */
  46762. private _internalMarkAllSubMeshesAsTexturesDirty;
  46763. /** @hidden */
  46764. _markAllSubMeshesAsTexturesDirty(): void;
  46765. /**
  46766. * Instantiate a new istance of anisotropy configuration.
  46767. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46768. */
  46769. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46770. /**
  46771. * Specifies that the submesh is ready to be used.
  46772. * @param defines the list of "defines" to update.
  46773. * @param scene defines the scene the material belongs to.
  46774. * @returns - boolean indicating that the submesh is ready or not.
  46775. */
  46776. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46777. /**
  46778. * Checks to see if a texture is used in the material.
  46779. * @param defines the list of "defines" to update.
  46780. * @param mesh the mesh we are preparing the defines for.
  46781. * @param scene defines the scene the material belongs to.
  46782. */
  46783. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46784. /**
  46785. * Binds the material data.
  46786. * @param uniformBuffer defines the Uniform buffer to fill in.
  46787. * @param scene defines the scene the material belongs to.
  46788. * @param isFrozen defines wether the material is frozen or not.
  46789. */
  46790. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46791. /**
  46792. * Checks to see if a texture is used in the material.
  46793. * @param texture - Base texture to use.
  46794. * @returns - Boolean specifying if a texture is used in the material.
  46795. */
  46796. hasTexture(texture: BaseTexture): boolean;
  46797. /**
  46798. * Returns an array of the actively used textures.
  46799. * @param activeTextures Array of BaseTextures
  46800. */
  46801. getActiveTextures(activeTextures: BaseTexture[]): void;
  46802. /**
  46803. * Returns the animatable textures.
  46804. * @param animatables Array of animatable textures.
  46805. */
  46806. getAnimatables(animatables: IAnimatable[]): void;
  46807. /**
  46808. * Disposes the resources of the material.
  46809. * @param forceDisposeTextures - Forces the disposal of all textures.
  46810. */
  46811. dispose(forceDisposeTextures?: boolean): void;
  46812. /**
  46813. * Get the current class name of the texture useful for serialization or dynamic coding.
  46814. * @returns "PBRAnisotropicConfiguration"
  46815. */
  46816. getClassName(): string;
  46817. /**
  46818. * Add fallbacks to the effect fallbacks list.
  46819. * @param defines defines the Base texture to use.
  46820. * @param fallbacks defines the current fallback list.
  46821. * @param currentRank defines the current fallback rank.
  46822. * @returns the new fallback rank.
  46823. */
  46824. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46825. /**
  46826. * Add the required uniforms to the current list.
  46827. * @param uniforms defines the current uniform list.
  46828. */
  46829. static AddUniforms(uniforms: string[]): void;
  46830. /**
  46831. * Add the required uniforms to the current buffer.
  46832. * @param uniformBuffer defines the current uniform buffer.
  46833. */
  46834. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46835. /**
  46836. * Add the required samplers to the current list.
  46837. * @param samplers defines the current sampler list.
  46838. */
  46839. static AddSamplers(samplers: string[]): void;
  46840. /**
  46841. * Makes a duplicate of the current configuration into another one.
  46842. * @param anisotropicConfiguration define the config where to copy the info
  46843. */
  46844. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46845. /**
  46846. * Serializes this anisotropy configuration.
  46847. * @returns - An object with the serialized config.
  46848. */
  46849. serialize(): any;
  46850. /**
  46851. * Parses a anisotropy Configuration from a serialized object.
  46852. * @param source - Serialized object.
  46853. * @param scene Defines the scene we are parsing for
  46854. * @param rootUrl Defines the rootUrl to load from
  46855. */
  46856. parse(source: any, scene: Scene, rootUrl: string): void;
  46857. }
  46858. }
  46859. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46860. import { Scene } from "babylonjs/scene";
  46861. /**
  46862. * @hidden
  46863. */
  46864. export interface IMaterialBRDFDefines {
  46865. BRDF_V_HEIGHT_CORRELATED: boolean;
  46866. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46867. SPHERICAL_HARMONICS: boolean;
  46868. /** @hidden */
  46869. _areMiscDirty: boolean;
  46870. }
  46871. /**
  46872. * Define the code related to the BRDF parameters of the pbr material.
  46873. */
  46874. export class PBRBRDFConfiguration {
  46875. /**
  46876. * Default value used for the energy conservation.
  46877. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46878. */
  46879. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46880. /**
  46881. * Default value used for the Smith Visibility Height Correlated mode.
  46882. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46883. */
  46884. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46885. /**
  46886. * Default value used for the IBL diffuse part.
  46887. * This can help switching back to the polynomials mode globally which is a tiny bit
  46888. * less GPU intensive at the drawback of a lower quality.
  46889. */
  46890. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46891. private _useEnergyConservation;
  46892. /**
  46893. * Defines if the material uses energy conservation.
  46894. */
  46895. useEnergyConservation: boolean;
  46896. private _useSmithVisibilityHeightCorrelated;
  46897. /**
  46898. * LEGACY Mode set to false
  46899. * Defines if the material uses height smith correlated visibility term.
  46900. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46901. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46902. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46903. * Not relying on height correlated will also disable energy conservation.
  46904. */
  46905. useSmithVisibilityHeightCorrelated: boolean;
  46906. private _useSphericalHarmonics;
  46907. /**
  46908. * LEGACY Mode set to false
  46909. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46910. * diffuse part of the IBL.
  46911. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46912. * to the ground truth.
  46913. */
  46914. useSphericalHarmonics: boolean;
  46915. /** @hidden */
  46916. private _internalMarkAllSubMeshesAsMiscDirty;
  46917. /** @hidden */
  46918. _markAllSubMeshesAsMiscDirty(): void;
  46919. /**
  46920. * Instantiate a new istance of clear coat configuration.
  46921. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46922. */
  46923. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46924. /**
  46925. * Checks to see if a texture is used in the material.
  46926. * @param defines the list of "defines" to update.
  46927. */
  46928. prepareDefines(defines: IMaterialBRDFDefines): void;
  46929. /**
  46930. * Get the current class name of the texture useful for serialization or dynamic coding.
  46931. * @returns "PBRClearCoatConfiguration"
  46932. */
  46933. getClassName(): string;
  46934. /**
  46935. * Makes a duplicate of the current configuration into another one.
  46936. * @param brdfConfiguration define the config where to copy the info
  46937. */
  46938. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46939. /**
  46940. * Serializes this BRDF configuration.
  46941. * @returns - An object with the serialized config.
  46942. */
  46943. serialize(): any;
  46944. /**
  46945. * Parses a anisotropy Configuration from a serialized object.
  46946. * @param source - Serialized object.
  46947. * @param scene Defines the scene we are parsing for
  46948. * @param rootUrl Defines the rootUrl to load from
  46949. */
  46950. parse(source: any, scene: Scene, rootUrl: string): void;
  46951. }
  46952. }
  46953. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46954. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46955. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46956. import { Color3 } from "babylonjs/Maths/math";
  46957. import { Scene } from "babylonjs/scene";
  46958. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46959. import { IAnimatable } from "babylonjs/Misc/tools";
  46960. import { Nullable } from "babylonjs/types";
  46961. /**
  46962. * @hidden
  46963. */
  46964. export interface IMaterialSheenDefines {
  46965. SHEEN: boolean;
  46966. SHEEN_TEXTURE: boolean;
  46967. SHEEN_TEXTUREDIRECTUV: number;
  46968. SHEEN_LINKWITHALBEDO: boolean;
  46969. /** @hidden */
  46970. _areTexturesDirty: boolean;
  46971. }
  46972. /**
  46973. * Define the code related to the Sheen parameters of the pbr material.
  46974. */
  46975. export class PBRSheenConfiguration {
  46976. private _isEnabled;
  46977. /**
  46978. * Defines if the material uses sheen.
  46979. */
  46980. isEnabled: boolean;
  46981. private _linkSheenWithAlbedo;
  46982. /**
  46983. * Defines if the sheen is linked to the sheen color.
  46984. */
  46985. linkSheenWithAlbedo: boolean;
  46986. /**
  46987. * Defines the sheen intensity.
  46988. */
  46989. intensity: number;
  46990. /**
  46991. * Defines the sheen color.
  46992. */
  46993. color: Color3;
  46994. private _texture;
  46995. /**
  46996. * Stores the sheen tint values in a texture.
  46997. * rgb is tint
  46998. * a is a intensity
  46999. */
  47000. texture: Nullable<BaseTexture>;
  47001. /** @hidden */
  47002. private _internalMarkAllSubMeshesAsTexturesDirty;
  47003. /** @hidden */
  47004. _markAllSubMeshesAsTexturesDirty(): void;
  47005. /**
  47006. * Instantiate a new istance of clear coat configuration.
  47007. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47008. */
  47009. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47010. /**
  47011. * Specifies that the submesh is ready to be used.
  47012. * @param defines the list of "defines" to update.
  47013. * @param scene defines the scene the material belongs to.
  47014. * @returns - boolean indicating that the submesh is ready or not.
  47015. */
  47016. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47017. /**
  47018. * Checks to see if a texture is used in the material.
  47019. * @param defines the list of "defines" to update.
  47020. * @param scene defines the scene the material belongs to.
  47021. */
  47022. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47023. /**
  47024. * Binds the material data.
  47025. * @param uniformBuffer defines the Uniform buffer to fill in.
  47026. * @param scene defines the scene the material belongs to.
  47027. * @param isFrozen defines wether the material is frozen or not.
  47028. */
  47029. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47030. /**
  47031. * Checks to see if a texture is used in the material.
  47032. * @param texture - Base texture to use.
  47033. * @returns - Boolean specifying if a texture is used in the material.
  47034. */
  47035. hasTexture(texture: BaseTexture): boolean;
  47036. /**
  47037. * Returns an array of the actively used textures.
  47038. * @param activeTextures Array of BaseTextures
  47039. */
  47040. getActiveTextures(activeTextures: BaseTexture[]): void;
  47041. /**
  47042. * Returns the animatable textures.
  47043. * @param animatables Array of animatable textures.
  47044. */
  47045. getAnimatables(animatables: IAnimatable[]): void;
  47046. /**
  47047. * Disposes the resources of the material.
  47048. * @param forceDisposeTextures - Forces the disposal of all textures.
  47049. */
  47050. dispose(forceDisposeTextures?: boolean): void;
  47051. /**
  47052. * Get the current class name of the texture useful for serialization or dynamic coding.
  47053. * @returns "PBRSheenConfiguration"
  47054. */
  47055. getClassName(): string;
  47056. /**
  47057. * Add fallbacks to the effect fallbacks list.
  47058. * @param defines defines the Base texture to use.
  47059. * @param fallbacks defines the current fallback list.
  47060. * @param currentRank defines the current fallback rank.
  47061. * @returns the new fallback rank.
  47062. */
  47063. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47064. /**
  47065. * Add the required uniforms to the current list.
  47066. * @param uniforms defines the current uniform list.
  47067. */
  47068. static AddUniforms(uniforms: string[]): void;
  47069. /**
  47070. * Add the required uniforms to the current buffer.
  47071. * @param uniformBuffer defines the current uniform buffer.
  47072. */
  47073. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47074. /**
  47075. * Add the required samplers to the current list.
  47076. * @param samplers defines the current sampler list.
  47077. */
  47078. static AddSamplers(samplers: string[]): void;
  47079. /**
  47080. * Makes a duplicate of the current configuration into another one.
  47081. * @param sheenConfiguration define the config where to copy the info
  47082. */
  47083. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47084. /**
  47085. * Serializes this BRDF configuration.
  47086. * @returns - An object with the serialized config.
  47087. */
  47088. serialize(): any;
  47089. /**
  47090. * Parses a anisotropy Configuration from a serialized object.
  47091. * @param source - Serialized object.
  47092. * @param scene Defines the scene we are parsing for
  47093. * @param rootUrl Defines the rootUrl to load from
  47094. */
  47095. parse(source: any, scene: Scene, rootUrl: string): void;
  47096. }
  47097. }
  47098. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47099. import { Nullable } from "babylonjs/types";
  47100. import { IAnimatable } from "babylonjs/Misc/tools";
  47101. import { Color3 } from "babylonjs/Maths/math";
  47102. import { SmartArray } from "babylonjs/Misc/smartArray";
  47103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47104. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47105. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47106. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47107. import { Engine } from "babylonjs/Engines/engine";
  47108. import { Scene } from "babylonjs/scene";
  47109. /**
  47110. * @hidden
  47111. */
  47112. export interface IMaterialSubSurfaceDefines {
  47113. SUBSURFACE: boolean;
  47114. SS_REFRACTION: boolean;
  47115. SS_TRANSLUCENCY: boolean;
  47116. SS_SCATERRING: boolean;
  47117. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47118. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47119. SS_REFRACTIONMAP_3D: boolean;
  47120. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47121. SS_LODINREFRACTIONALPHA: boolean;
  47122. SS_GAMMAREFRACTION: boolean;
  47123. SS_RGBDREFRACTION: boolean;
  47124. SS_LINEARSPECULARREFRACTION: boolean;
  47125. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47126. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47127. /** @hidden */
  47128. _areTexturesDirty: boolean;
  47129. }
  47130. /**
  47131. * Define the code related to the sub surface parameters of the pbr material.
  47132. */
  47133. export class PBRSubSurfaceConfiguration {
  47134. private _isRefractionEnabled;
  47135. /**
  47136. * Defines if the refraction is enabled in the material.
  47137. */
  47138. isRefractionEnabled: boolean;
  47139. private _isTranslucencyEnabled;
  47140. /**
  47141. * Defines if the translucency is enabled in the material.
  47142. */
  47143. isTranslucencyEnabled: boolean;
  47144. private _isScatteringEnabled;
  47145. /**
  47146. * Defines the refraction intensity of the material.
  47147. * The refraction when enabled replaces the Diffuse part of the material.
  47148. * The intensity helps transitionning between diffuse and refraction.
  47149. */
  47150. refractionIntensity: number;
  47151. /**
  47152. * Defines the translucency intensity of the material.
  47153. * When translucency has been enabled, this defines how much of the "translucency"
  47154. * is addded to the diffuse part of the material.
  47155. */
  47156. translucencyIntensity: number;
  47157. /**
  47158. * Defines the scattering intensity of the material.
  47159. * When scattering has been enabled, this defines how much of the "scattered light"
  47160. * is addded to the diffuse part of the material.
  47161. */
  47162. scatteringIntensity: number;
  47163. private _thicknessTexture;
  47164. /**
  47165. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47166. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47167. * 0 would mean minimumThickness
  47168. * 1 would mean maximumThickness
  47169. * The other channels might be use as a mask to vary the different effects intensity.
  47170. */
  47171. thicknessTexture: Nullable<BaseTexture>;
  47172. private _refractionTexture;
  47173. /**
  47174. * Defines the texture to use for refraction.
  47175. */
  47176. refractionTexture: Nullable<BaseTexture>;
  47177. private _indexOfRefraction;
  47178. /**
  47179. * Defines the index of refraction used in the material.
  47180. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47181. */
  47182. indexOfRefraction: number;
  47183. private _invertRefractionY;
  47184. /**
  47185. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47186. */
  47187. invertRefractionY: boolean;
  47188. private _linkRefractionWithTransparency;
  47189. /**
  47190. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47191. * Materials half opaque for instance using refraction could benefit from this control.
  47192. */
  47193. linkRefractionWithTransparency: boolean;
  47194. /**
  47195. * Defines the minimum thickness stored in the thickness map.
  47196. * If no thickness map is defined, this value will be used to simulate thickness.
  47197. */
  47198. minimumThickness: number;
  47199. /**
  47200. * Defines the maximum thickness stored in the thickness map.
  47201. */
  47202. maximumThickness: number;
  47203. /**
  47204. * Defines the volume tint of the material.
  47205. * This is used for both translucency and scattering.
  47206. */
  47207. tintColor: Color3;
  47208. /**
  47209. * Defines the distance at which the tint color should be found in the media.
  47210. * This is used for refraction only.
  47211. */
  47212. tintColorAtDistance: number;
  47213. /**
  47214. * Defines how far each channel transmit through the media.
  47215. * It is defined as a color to simplify it selection.
  47216. */
  47217. diffusionDistance: Color3;
  47218. private _useMaskFromThicknessTexture;
  47219. /**
  47220. * Stores the intensity of the different subsurface effects in the thickness texture.
  47221. * * the green channel is the translucency intensity.
  47222. * * the blue channel is the scattering intensity.
  47223. * * the alpha channel is the refraction intensity.
  47224. */
  47225. useMaskFromThicknessTexture: boolean;
  47226. /** @hidden */
  47227. private _internalMarkAllSubMeshesAsTexturesDirty;
  47228. /** @hidden */
  47229. _markAllSubMeshesAsTexturesDirty(): void;
  47230. /**
  47231. * Instantiate a new istance of sub surface configuration.
  47232. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47233. */
  47234. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47235. /**
  47236. * Gets wehter the submesh is ready to be used or not.
  47237. * @param defines the list of "defines" to update.
  47238. * @param scene defines the scene the material belongs to.
  47239. * @returns - boolean indicating that the submesh is ready or not.
  47240. */
  47241. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47242. /**
  47243. * Checks to see if a texture is used in the material.
  47244. * @param defines the list of "defines" to update.
  47245. * @param scene defines the scene to the material belongs to.
  47246. */
  47247. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47248. /**
  47249. * Binds the material data.
  47250. * @param uniformBuffer defines the Uniform buffer to fill in.
  47251. * @param scene defines the scene the material belongs to.
  47252. * @param engine defines the engine the material belongs to.
  47253. * @param isFrozen defines wether the material is frozen or not.
  47254. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47255. */
  47256. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47257. /**
  47258. * Unbinds the material from the mesh.
  47259. * @param activeEffect defines the effect that should be unbound from.
  47260. * @returns true if unbound, otherwise false
  47261. */
  47262. unbind(activeEffect: Effect): boolean;
  47263. /**
  47264. * Returns the texture used for refraction or null if none is used.
  47265. * @param scene defines the scene the material belongs to.
  47266. * @returns - Refraction texture if present. If no refraction texture and refraction
  47267. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47268. */
  47269. private _getRefractionTexture;
  47270. /**
  47271. * Returns true if alpha blending should be disabled.
  47272. */
  47273. readonly disableAlphaBlending: boolean;
  47274. /**
  47275. * Fills the list of render target textures.
  47276. * @param renderTargets the list of render targets to update
  47277. */
  47278. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47279. /**
  47280. * Checks to see if a texture is used in the material.
  47281. * @param texture - Base texture to use.
  47282. * @returns - Boolean specifying if a texture is used in the material.
  47283. */
  47284. hasTexture(texture: BaseTexture): boolean;
  47285. /**
  47286. * Gets a boolean indicating that current material needs to register RTT
  47287. * @returns true if this uses a render target otherwise false.
  47288. */
  47289. hasRenderTargetTextures(): boolean;
  47290. /**
  47291. * Returns an array of the actively used textures.
  47292. * @param activeTextures Array of BaseTextures
  47293. */
  47294. getActiveTextures(activeTextures: BaseTexture[]): void;
  47295. /**
  47296. * Returns the animatable textures.
  47297. * @param animatables Array of animatable textures.
  47298. */
  47299. getAnimatables(animatables: IAnimatable[]): void;
  47300. /**
  47301. * Disposes the resources of the material.
  47302. * @param forceDisposeTextures - Forces the disposal of all textures.
  47303. */
  47304. dispose(forceDisposeTextures?: boolean): void;
  47305. /**
  47306. * Get the current class name of the texture useful for serialization or dynamic coding.
  47307. * @returns "PBRSubSurfaceConfiguration"
  47308. */
  47309. getClassName(): string;
  47310. /**
  47311. * Add fallbacks to the effect fallbacks list.
  47312. * @param defines defines the Base texture to use.
  47313. * @param fallbacks defines the current fallback list.
  47314. * @param currentRank defines the current fallback rank.
  47315. * @returns the new fallback rank.
  47316. */
  47317. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47318. /**
  47319. * Add the required uniforms to the current list.
  47320. * @param uniforms defines the current uniform list.
  47321. */
  47322. static AddUniforms(uniforms: string[]): void;
  47323. /**
  47324. * Add the required samplers to the current list.
  47325. * @param samplers defines the current sampler list.
  47326. */
  47327. static AddSamplers(samplers: string[]): void;
  47328. /**
  47329. * Add the required uniforms to the current buffer.
  47330. * @param uniformBuffer defines the current uniform buffer.
  47331. */
  47332. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47333. /**
  47334. * Makes a duplicate of the current configuration into another one.
  47335. * @param configuration define the config where to copy the info
  47336. */
  47337. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47338. /**
  47339. * Serializes this Sub Surface configuration.
  47340. * @returns - An object with the serialized config.
  47341. */
  47342. serialize(): any;
  47343. /**
  47344. * Parses a anisotropy Configuration from a serialized object.
  47345. * @param source - Serialized object.
  47346. * @param scene Defines the scene we are parsing for
  47347. * @param rootUrl Defines the rootUrl to load from
  47348. */
  47349. parse(source: any, scene: Scene, rootUrl: string): void;
  47350. }
  47351. }
  47352. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47353. /** @hidden */
  47354. export var pbrFragmentDeclaration: {
  47355. name: string;
  47356. shader: string;
  47357. };
  47358. }
  47359. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47360. /** @hidden */
  47361. export var pbrUboDeclaration: {
  47362. name: string;
  47363. shader: string;
  47364. };
  47365. }
  47366. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47367. /** @hidden */
  47368. export var pbrFragmentExtraDeclaration: {
  47369. name: string;
  47370. shader: string;
  47371. };
  47372. }
  47373. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47374. /** @hidden */
  47375. export var pbrFragmentSamplersDeclaration: {
  47376. name: string;
  47377. shader: string;
  47378. };
  47379. }
  47380. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47381. /** @hidden */
  47382. export var pbrHelperFunctions: {
  47383. name: string;
  47384. shader: string;
  47385. };
  47386. }
  47387. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47388. /** @hidden */
  47389. export var harmonicsFunctions: {
  47390. name: string;
  47391. shader: string;
  47392. };
  47393. }
  47394. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47395. /** @hidden */
  47396. export var pbrDirectLightingSetupFunctions: {
  47397. name: string;
  47398. shader: string;
  47399. };
  47400. }
  47401. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47402. /** @hidden */
  47403. export var pbrDirectLightingFalloffFunctions: {
  47404. name: string;
  47405. shader: string;
  47406. };
  47407. }
  47408. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47409. /** @hidden */
  47410. export var pbrBRDFFunctions: {
  47411. name: string;
  47412. shader: string;
  47413. };
  47414. }
  47415. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47416. /** @hidden */
  47417. export var pbrDirectLightingFunctions: {
  47418. name: string;
  47419. shader: string;
  47420. };
  47421. }
  47422. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47423. /** @hidden */
  47424. export var pbrIBLFunctions: {
  47425. name: string;
  47426. shader: string;
  47427. };
  47428. }
  47429. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47430. /** @hidden */
  47431. export var pbrDebug: {
  47432. name: string;
  47433. shader: string;
  47434. };
  47435. }
  47436. declare module "babylonjs/Shaders/pbr.fragment" {
  47437. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47438. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47439. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47440. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47441. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47442. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47443. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47444. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47445. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47446. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47447. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47448. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47449. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47450. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47451. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47452. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47453. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47454. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47455. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47456. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47457. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47458. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47459. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47460. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47461. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47462. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47463. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47464. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47465. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47466. /** @hidden */
  47467. export var pbrPixelShader: {
  47468. name: string;
  47469. shader: string;
  47470. };
  47471. }
  47472. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47473. /** @hidden */
  47474. export var pbrVertexDeclaration: {
  47475. name: string;
  47476. shader: string;
  47477. };
  47478. }
  47479. declare module "babylonjs/Shaders/pbr.vertex" {
  47480. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47481. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47482. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47483. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47484. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47485. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47486. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47487. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47488. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47489. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47490. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47491. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47492. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47493. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47494. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47495. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47496. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47497. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47498. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47499. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47500. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47501. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47502. /** @hidden */
  47503. export var pbrVertexShader: {
  47504. name: string;
  47505. shader: string;
  47506. };
  47507. }
  47508. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47509. import { IAnimatable } from "babylonjs/Misc/tools";
  47510. import { Nullable } from "babylonjs/types";
  47511. import { Scene } from "babylonjs/scene";
  47512. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47513. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47515. import { Mesh } from "babylonjs/Meshes/mesh";
  47516. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47517. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47518. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47519. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47520. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47521. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47522. import { Material } from "babylonjs/Materials/material";
  47523. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47524. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47525. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47526. import "babylonjs/Shaders/pbr.fragment";
  47527. import "babylonjs/Shaders/pbr.vertex";
  47528. /**
  47529. * Manages the defines for the PBR Material.
  47530. * @hidden
  47531. */
  47532. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47533. PBR: boolean;
  47534. MAINUV1: boolean;
  47535. MAINUV2: boolean;
  47536. UV1: boolean;
  47537. UV2: boolean;
  47538. ALBEDO: boolean;
  47539. ALBEDODIRECTUV: number;
  47540. VERTEXCOLOR: boolean;
  47541. AMBIENT: boolean;
  47542. AMBIENTDIRECTUV: number;
  47543. AMBIENTINGRAYSCALE: boolean;
  47544. OPACITY: boolean;
  47545. VERTEXALPHA: boolean;
  47546. OPACITYDIRECTUV: number;
  47547. OPACITYRGB: boolean;
  47548. ALPHATEST: boolean;
  47549. DEPTHPREPASS: boolean;
  47550. ALPHABLEND: boolean;
  47551. ALPHAFROMALBEDO: boolean;
  47552. ALPHATESTVALUE: string;
  47553. SPECULAROVERALPHA: boolean;
  47554. RADIANCEOVERALPHA: boolean;
  47555. ALPHAFRESNEL: boolean;
  47556. LINEARALPHAFRESNEL: boolean;
  47557. PREMULTIPLYALPHA: boolean;
  47558. EMISSIVE: boolean;
  47559. EMISSIVEDIRECTUV: number;
  47560. REFLECTIVITY: boolean;
  47561. REFLECTIVITYDIRECTUV: number;
  47562. SPECULARTERM: boolean;
  47563. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47564. MICROSURFACEAUTOMATIC: boolean;
  47565. LODBASEDMICROSFURACE: boolean;
  47566. MICROSURFACEMAP: boolean;
  47567. MICROSURFACEMAPDIRECTUV: number;
  47568. METALLICWORKFLOW: boolean;
  47569. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47570. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47571. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47572. AOSTOREINMETALMAPRED: boolean;
  47573. ENVIRONMENTBRDF: boolean;
  47574. ENVIRONMENTBRDF_RGBD: boolean;
  47575. NORMAL: boolean;
  47576. TANGENT: boolean;
  47577. BUMP: boolean;
  47578. BUMPDIRECTUV: number;
  47579. OBJECTSPACE_NORMALMAP: boolean;
  47580. PARALLAX: boolean;
  47581. PARALLAXOCCLUSION: boolean;
  47582. NORMALXYSCALE: boolean;
  47583. LIGHTMAP: boolean;
  47584. LIGHTMAPDIRECTUV: number;
  47585. USELIGHTMAPASSHADOWMAP: boolean;
  47586. GAMMALIGHTMAP: boolean;
  47587. REFLECTION: boolean;
  47588. REFLECTIONMAP_3D: boolean;
  47589. REFLECTIONMAP_SPHERICAL: boolean;
  47590. REFLECTIONMAP_PLANAR: boolean;
  47591. REFLECTIONMAP_CUBIC: boolean;
  47592. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47593. REFLECTIONMAP_PROJECTION: boolean;
  47594. REFLECTIONMAP_SKYBOX: boolean;
  47595. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47596. REFLECTIONMAP_EXPLICIT: boolean;
  47597. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47598. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47599. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47600. INVERTCUBICMAP: boolean;
  47601. USESPHERICALFROMREFLECTIONMAP: boolean;
  47602. USEIRRADIANCEMAP: boolean;
  47603. SPHERICAL_HARMONICS: boolean;
  47604. USESPHERICALINVERTEX: boolean;
  47605. REFLECTIONMAP_OPPOSITEZ: boolean;
  47606. LODINREFLECTIONALPHA: boolean;
  47607. GAMMAREFLECTION: boolean;
  47608. RGBDREFLECTION: boolean;
  47609. LINEARSPECULARREFLECTION: boolean;
  47610. RADIANCEOCCLUSION: boolean;
  47611. HORIZONOCCLUSION: boolean;
  47612. INSTANCES: boolean;
  47613. NUM_BONE_INFLUENCERS: number;
  47614. BonesPerMesh: number;
  47615. BONETEXTURE: boolean;
  47616. NONUNIFORMSCALING: boolean;
  47617. MORPHTARGETS: boolean;
  47618. MORPHTARGETS_NORMAL: boolean;
  47619. MORPHTARGETS_TANGENT: boolean;
  47620. MORPHTARGETS_UV: boolean;
  47621. NUM_MORPH_INFLUENCERS: number;
  47622. IMAGEPROCESSING: boolean;
  47623. VIGNETTE: boolean;
  47624. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47625. VIGNETTEBLENDMODEOPAQUE: boolean;
  47626. TONEMAPPING: boolean;
  47627. TONEMAPPING_ACES: boolean;
  47628. CONTRAST: boolean;
  47629. COLORCURVES: boolean;
  47630. COLORGRADING: boolean;
  47631. COLORGRADING3D: boolean;
  47632. SAMPLER3DGREENDEPTH: boolean;
  47633. SAMPLER3DBGRMAP: boolean;
  47634. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47635. EXPOSURE: boolean;
  47636. MULTIVIEW: boolean;
  47637. USEPHYSICALLIGHTFALLOFF: boolean;
  47638. USEGLTFLIGHTFALLOFF: boolean;
  47639. TWOSIDEDLIGHTING: boolean;
  47640. SHADOWFLOAT: boolean;
  47641. CLIPPLANE: boolean;
  47642. CLIPPLANE2: boolean;
  47643. CLIPPLANE3: boolean;
  47644. CLIPPLANE4: boolean;
  47645. POINTSIZE: boolean;
  47646. FOG: boolean;
  47647. LOGARITHMICDEPTH: boolean;
  47648. FORCENORMALFORWARD: boolean;
  47649. SPECULARAA: boolean;
  47650. CLEARCOAT: boolean;
  47651. CLEARCOAT_DEFAULTIOR: boolean;
  47652. CLEARCOAT_TEXTURE: boolean;
  47653. CLEARCOAT_TEXTUREDIRECTUV: number;
  47654. CLEARCOAT_BUMP: boolean;
  47655. CLEARCOAT_BUMPDIRECTUV: number;
  47656. CLEARCOAT_TINT: boolean;
  47657. CLEARCOAT_TINT_TEXTURE: boolean;
  47658. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47659. ANISOTROPIC: boolean;
  47660. ANISOTROPIC_TEXTURE: boolean;
  47661. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47662. BRDF_V_HEIGHT_CORRELATED: boolean;
  47663. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47664. SHEEN: boolean;
  47665. SHEEN_TEXTURE: boolean;
  47666. SHEEN_TEXTUREDIRECTUV: number;
  47667. SHEEN_LINKWITHALBEDO: boolean;
  47668. SUBSURFACE: boolean;
  47669. SS_REFRACTION: boolean;
  47670. SS_TRANSLUCENCY: boolean;
  47671. SS_SCATERRING: boolean;
  47672. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47673. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47674. SS_REFRACTIONMAP_3D: boolean;
  47675. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47676. SS_LODINREFRACTIONALPHA: boolean;
  47677. SS_GAMMAREFRACTION: boolean;
  47678. SS_RGBDREFRACTION: boolean;
  47679. SS_LINEARSPECULARREFRACTION: boolean;
  47680. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47681. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47682. UNLIT: boolean;
  47683. DEBUGMODE: number;
  47684. /**
  47685. * Initializes the PBR Material defines.
  47686. */
  47687. constructor();
  47688. /**
  47689. * Resets the PBR Material defines.
  47690. */
  47691. reset(): void;
  47692. }
  47693. /**
  47694. * The Physically based material base class of BJS.
  47695. *
  47696. * This offers the main features of a standard PBR material.
  47697. * For more information, please refer to the documentation :
  47698. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47699. */
  47700. export abstract class PBRBaseMaterial extends PushMaterial {
  47701. /**
  47702. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47703. */
  47704. static readonly PBRMATERIAL_OPAQUE: number;
  47705. /**
  47706. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47707. */
  47708. static readonly PBRMATERIAL_ALPHATEST: number;
  47709. /**
  47710. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47711. */
  47712. static readonly PBRMATERIAL_ALPHABLEND: number;
  47713. /**
  47714. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47715. * They are also discarded below the alpha cutoff threshold to improve performances.
  47716. */
  47717. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47718. /**
  47719. * Defines the default value of how much AO map is occluding the analytical lights
  47720. * (point spot...).
  47721. */
  47722. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47723. /**
  47724. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47725. */
  47726. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47727. /**
  47728. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47729. * to enhance interoperability with other engines.
  47730. */
  47731. static readonly LIGHTFALLOFF_GLTF: number;
  47732. /**
  47733. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47734. * to enhance interoperability with other materials.
  47735. */
  47736. static readonly LIGHTFALLOFF_STANDARD: number;
  47737. /**
  47738. * Intensity of the direct lights e.g. the four lights available in your scene.
  47739. * This impacts both the direct diffuse and specular highlights.
  47740. */
  47741. protected _directIntensity: number;
  47742. /**
  47743. * Intensity of the emissive part of the material.
  47744. * This helps controlling the emissive effect without modifying the emissive color.
  47745. */
  47746. protected _emissiveIntensity: number;
  47747. /**
  47748. * Intensity of the environment e.g. how much the environment will light the object
  47749. * either through harmonics for rough material or through the refelction for shiny ones.
  47750. */
  47751. protected _environmentIntensity: number;
  47752. /**
  47753. * This is a special control allowing the reduction of the specular highlights coming from the
  47754. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47755. */
  47756. protected _specularIntensity: number;
  47757. /**
  47758. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47759. */
  47760. private _lightingInfos;
  47761. /**
  47762. * Debug Control allowing disabling the bump map on this material.
  47763. */
  47764. protected _disableBumpMap: boolean;
  47765. /**
  47766. * AKA Diffuse Texture in standard nomenclature.
  47767. */
  47768. protected _albedoTexture: Nullable<BaseTexture>;
  47769. /**
  47770. * AKA Occlusion Texture in other nomenclature.
  47771. */
  47772. protected _ambientTexture: Nullable<BaseTexture>;
  47773. /**
  47774. * AKA Occlusion Texture Intensity in other nomenclature.
  47775. */
  47776. protected _ambientTextureStrength: number;
  47777. /**
  47778. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47779. * 1 means it completely occludes it
  47780. * 0 mean it has no impact
  47781. */
  47782. protected _ambientTextureImpactOnAnalyticalLights: number;
  47783. /**
  47784. * Stores the alpha values in a texture.
  47785. */
  47786. protected _opacityTexture: Nullable<BaseTexture>;
  47787. /**
  47788. * Stores the reflection values in a texture.
  47789. */
  47790. protected _reflectionTexture: Nullable<BaseTexture>;
  47791. /**
  47792. * Stores the emissive values in a texture.
  47793. */
  47794. protected _emissiveTexture: Nullable<BaseTexture>;
  47795. /**
  47796. * AKA Specular texture in other nomenclature.
  47797. */
  47798. protected _reflectivityTexture: Nullable<BaseTexture>;
  47799. /**
  47800. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47801. */
  47802. protected _metallicTexture: Nullable<BaseTexture>;
  47803. /**
  47804. * Specifies the metallic scalar of the metallic/roughness workflow.
  47805. * Can also be used to scale the metalness values of the metallic texture.
  47806. */
  47807. protected _metallic: Nullable<number>;
  47808. /**
  47809. * Specifies the roughness scalar of the metallic/roughness workflow.
  47810. * Can also be used to scale the roughness values of the metallic texture.
  47811. */
  47812. protected _roughness: Nullable<number>;
  47813. /**
  47814. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47815. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47816. */
  47817. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47818. /**
  47819. * Stores surface normal data used to displace a mesh in a texture.
  47820. */
  47821. protected _bumpTexture: Nullable<BaseTexture>;
  47822. /**
  47823. * Stores the pre-calculated light information of a mesh in a texture.
  47824. */
  47825. protected _lightmapTexture: Nullable<BaseTexture>;
  47826. /**
  47827. * The color of a material in ambient lighting.
  47828. */
  47829. protected _ambientColor: Color3;
  47830. /**
  47831. * AKA Diffuse Color in other nomenclature.
  47832. */
  47833. protected _albedoColor: Color3;
  47834. /**
  47835. * AKA Specular Color in other nomenclature.
  47836. */
  47837. protected _reflectivityColor: Color3;
  47838. /**
  47839. * The color applied when light is reflected from a material.
  47840. */
  47841. protected _reflectionColor: Color3;
  47842. /**
  47843. * The color applied when light is emitted from a material.
  47844. */
  47845. protected _emissiveColor: Color3;
  47846. /**
  47847. * AKA Glossiness in other nomenclature.
  47848. */
  47849. protected _microSurface: number;
  47850. /**
  47851. * Specifies that the material will use the light map as a show map.
  47852. */
  47853. protected _useLightmapAsShadowmap: boolean;
  47854. /**
  47855. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47856. * makes the reflect vector face the model (under horizon).
  47857. */
  47858. protected _useHorizonOcclusion: boolean;
  47859. /**
  47860. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47861. * too much the area relying on ambient texture to define their ambient occlusion.
  47862. */
  47863. protected _useRadianceOcclusion: boolean;
  47864. /**
  47865. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47866. */
  47867. protected _useAlphaFromAlbedoTexture: boolean;
  47868. /**
  47869. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47870. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47871. */
  47872. protected _useSpecularOverAlpha: boolean;
  47873. /**
  47874. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47875. */
  47876. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47877. /**
  47878. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47879. */
  47880. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47881. /**
  47882. * Specifies if the metallic texture contains the roughness information in its green channel.
  47883. */
  47884. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47885. /**
  47886. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47887. */
  47888. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47889. /**
  47890. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47891. */
  47892. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47893. /**
  47894. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47895. */
  47896. protected _useAmbientInGrayScale: boolean;
  47897. /**
  47898. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47899. * The material will try to infer what glossiness each pixel should be.
  47900. */
  47901. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47902. /**
  47903. * Defines the falloff type used in this material.
  47904. * It by default is Physical.
  47905. */
  47906. protected _lightFalloff: number;
  47907. /**
  47908. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47909. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47910. */
  47911. protected _useRadianceOverAlpha: boolean;
  47912. /**
  47913. * Allows using an object space normal map (instead of tangent space).
  47914. */
  47915. protected _useObjectSpaceNormalMap: boolean;
  47916. /**
  47917. * Allows using the bump map in parallax mode.
  47918. */
  47919. protected _useParallax: boolean;
  47920. /**
  47921. * Allows using the bump map in parallax occlusion mode.
  47922. */
  47923. protected _useParallaxOcclusion: boolean;
  47924. /**
  47925. * Controls the scale bias of the parallax mode.
  47926. */
  47927. protected _parallaxScaleBias: number;
  47928. /**
  47929. * If sets to true, disables all the lights affecting the material.
  47930. */
  47931. protected _disableLighting: boolean;
  47932. /**
  47933. * Number of Simultaneous lights allowed on the material.
  47934. */
  47935. protected _maxSimultaneousLights: number;
  47936. /**
  47937. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47938. */
  47939. protected _invertNormalMapX: boolean;
  47940. /**
  47941. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47942. */
  47943. protected _invertNormalMapY: boolean;
  47944. /**
  47945. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47946. */
  47947. protected _twoSidedLighting: boolean;
  47948. /**
  47949. * Defines the alpha limits in alpha test mode.
  47950. */
  47951. protected _alphaCutOff: number;
  47952. /**
  47953. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47954. */
  47955. protected _forceAlphaTest: boolean;
  47956. /**
  47957. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47958. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47959. */
  47960. protected _useAlphaFresnel: boolean;
  47961. /**
  47962. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47963. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47964. */
  47965. protected _useLinearAlphaFresnel: boolean;
  47966. /**
  47967. * The transparency mode of the material.
  47968. */
  47969. protected _transparencyMode: Nullable<number>;
  47970. /**
  47971. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47972. * from cos thetav and roughness:
  47973. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47974. */
  47975. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47976. /**
  47977. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47978. */
  47979. protected _forceIrradianceInFragment: boolean;
  47980. /**
  47981. * Force normal to face away from face.
  47982. */
  47983. protected _forceNormalForward: boolean;
  47984. /**
  47985. * Enables specular anti aliasing in the PBR shader.
  47986. * It will both interacts on the Geometry for analytical and IBL lighting.
  47987. * It also prefilter the roughness map based on the bump values.
  47988. */
  47989. protected _enableSpecularAntiAliasing: boolean;
  47990. /**
  47991. * Default configuration related to image processing available in the PBR Material.
  47992. */
  47993. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47994. /**
  47995. * Keep track of the image processing observer to allow dispose and replace.
  47996. */
  47997. private _imageProcessingObserver;
  47998. /**
  47999. * Attaches a new image processing configuration to the PBR Material.
  48000. * @param configuration
  48001. */
  48002. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48003. /**
  48004. * Stores the available render targets.
  48005. */
  48006. private _renderTargets;
  48007. /**
  48008. * Sets the global ambient color for the material used in lighting calculations.
  48009. */
  48010. private _globalAmbientColor;
  48011. /**
  48012. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48013. */
  48014. private _useLogarithmicDepth;
  48015. /**
  48016. * If set to true, no lighting calculations will be applied.
  48017. */
  48018. private _unlit;
  48019. private _debugMode;
  48020. /**
  48021. * @hidden
  48022. * This is reserved for the inspector.
  48023. * Defines the material debug mode.
  48024. * It helps seeing only some components of the material while troubleshooting.
  48025. */
  48026. debugMode: number;
  48027. /**
  48028. * @hidden
  48029. * This is reserved for the inspector.
  48030. * Specify from where on screen the debug mode should start.
  48031. * The value goes from -1 (full screen) to 1 (not visible)
  48032. * It helps with side by side comparison against the final render
  48033. * This defaults to -1
  48034. */
  48035. private debugLimit;
  48036. /**
  48037. * @hidden
  48038. * This is reserved for the inspector.
  48039. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48040. * You can use the factor to better multiply the final value.
  48041. */
  48042. private debugFactor;
  48043. /**
  48044. * Defines the clear coat layer parameters for the material.
  48045. */
  48046. readonly clearCoat: PBRClearCoatConfiguration;
  48047. /**
  48048. * Defines the anisotropic parameters for the material.
  48049. */
  48050. readonly anisotropy: PBRAnisotropicConfiguration;
  48051. /**
  48052. * Defines the BRDF parameters for the material.
  48053. */
  48054. readonly brdf: PBRBRDFConfiguration;
  48055. /**
  48056. * Defines the Sheen parameters for the material.
  48057. */
  48058. readonly sheen: PBRSheenConfiguration;
  48059. /**
  48060. * Defines the SubSurface parameters for the material.
  48061. */
  48062. readonly subSurface: PBRSubSurfaceConfiguration;
  48063. /**
  48064. * Custom callback helping to override the default shader used in the material.
  48065. */
  48066. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48067. /**
  48068. * Instantiates a new PBRMaterial instance.
  48069. *
  48070. * @param name The material name
  48071. * @param scene The scene the material will be use in.
  48072. */
  48073. constructor(name: string, scene: Scene);
  48074. /**
  48075. * Gets a boolean indicating that current material needs to register RTT
  48076. */
  48077. readonly hasRenderTargetTextures: boolean;
  48078. /**
  48079. * Gets the name of the material class.
  48080. */
  48081. getClassName(): string;
  48082. /**
  48083. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48084. */
  48085. /**
  48086. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48087. */
  48088. useLogarithmicDepth: boolean;
  48089. /**
  48090. * Gets the current transparency mode.
  48091. */
  48092. /**
  48093. * Sets the transparency mode of the material.
  48094. *
  48095. * | Value | Type | Description |
  48096. * | ----- | ----------------------------------- | ----------- |
  48097. * | 0 | OPAQUE | |
  48098. * | 1 | ALPHATEST | |
  48099. * | 2 | ALPHABLEND | |
  48100. * | 3 | ALPHATESTANDBLEND | |
  48101. *
  48102. */
  48103. transparencyMode: Nullable<number>;
  48104. /**
  48105. * Returns true if alpha blending should be disabled.
  48106. */
  48107. private readonly _disableAlphaBlending;
  48108. /**
  48109. * Specifies whether or not this material should be rendered in alpha blend mode.
  48110. */
  48111. needAlphaBlending(): boolean;
  48112. /**
  48113. * Specifies if the mesh will require alpha blending.
  48114. * @param mesh - BJS mesh.
  48115. */
  48116. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48117. /**
  48118. * Specifies whether or not this material should be rendered in alpha test mode.
  48119. */
  48120. needAlphaTesting(): boolean;
  48121. /**
  48122. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48123. */
  48124. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48125. /**
  48126. * Gets the texture used for the alpha test.
  48127. */
  48128. getAlphaTestTexture(): Nullable<BaseTexture>;
  48129. /**
  48130. * Specifies that the submesh is ready to be used.
  48131. * @param mesh - BJS mesh.
  48132. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48133. * @param useInstances - Specifies that instances should be used.
  48134. * @returns - boolean indicating that the submesh is ready or not.
  48135. */
  48136. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48137. /**
  48138. * Specifies if the material uses metallic roughness workflow.
  48139. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48140. */
  48141. isMetallicWorkflow(): boolean;
  48142. private _prepareEffect;
  48143. private _prepareDefines;
  48144. /**
  48145. * Force shader compilation
  48146. */
  48147. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48148. clipPlane: boolean;
  48149. }>): void;
  48150. /**
  48151. * Initializes the uniform buffer layout for the shader.
  48152. */
  48153. buildUniformLayout(): void;
  48154. /**
  48155. * Unbinds the material from the mesh
  48156. */
  48157. unbind(): void;
  48158. /**
  48159. * Binds the submesh data.
  48160. * @param world - The world matrix.
  48161. * @param mesh - The BJS mesh.
  48162. * @param subMesh - A submesh of the BJS mesh.
  48163. */
  48164. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48165. /**
  48166. * Returns the animatable textures.
  48167. * @returns - Array of animatable textures.
  48168. */
  48169. getAnimatables(): IAnimatable[];
  48170. /**
  48171. * Returns the texture used for reflections.
  48172. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48173. */
  48174. private _getReflectionTexture;
  48175. /**
  48176. * Returns an array of the actively used textures.
  48177. * @returns - Array of BaseTextures
  48178. */
  48179. getActiveTextures(): BaseTexture[];
  48180. /**
  48181. * Checks to see if a texture is used in the material.
  48182. * @param texture - Base texture to use.
  48183. * @returns - Boolean specifying if a texture is used in the material.
  48184. */
  48185. hasTexture(texture: BaseTexture): boolean;
  48186. /**
  48187. * Disposes the resources of the material.
  48188. * @param forceDisposeEffect - Forces the disposal of effects.
  48189. * @param forceDisposeTextures - Forces the disposal of all textures.
  48190. */
  48191. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48192. }
  48193. }
  48194. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48195. import { Nullable } from "babylonjs/types";
  48196. import { Scene } from "babylonjs/scene";
  48197. import { Color3 } from "babylonjs/Maths/math";
  48198. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48199. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48201. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48202. /**
  48203. * The Physically based material of BJS.
  48204. *
  48205. * This offers the main features of a standard PBR material.
  48206. * For more information, please refer to the documentation :
  48207. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48208. */
  48209. export class PBRMaterial extends PBRBaseMaterial {
  48210. /**
  48211. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48212. */
  48213. static readonly PBRMATERIAL_OPAQUE: number;
  48214. /**
  48215. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48216. */
  48217. static readonly PBRMATERIAL_ALPHATEST: number;
  48218. /**
  48219. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48220. */
  48221. static readonly PBRMATERIAL_ALPHABLEND: number;
  48222. /**
  48223. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48224. * They are also discarded below the alpha cutoff threshold to improve performances.
  48225. */
  48226. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48227. /**
  48228. * Defines the default value of how much AO map is occluding the analytical lights
  48229. * (point spot...).
  48230. */
  48231. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48232. /**
  48233. * Intensity of the direct lights e.g. the four lights available in your scene.
  48234. * This impacts both the direct diffuse and specular highlights.
  48235. */
  48236. directIntensity: number;
  48237. /**
  48238. * Intensity of the emissive part of the material.
  48239. * This helps controlling the emissive effect without modifying the emissive color.
  48240. */
  48241. emissiveIntensity: number;
  48242. /**
  48243. * Intensity of the environment e.g. how much the environment will light the object
  48244. * either through harmonics for rough material or through the refelction for shiny ones.
  48245. */
  48246. environmentIntensity: number;
  48247. /**
  48248. * This is a special control allowing the reduction of the specular highlights coming from the
  48249. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48250. */
  48251. specularIntensity: number;
  48252. /**
  48253. * Debug Control allowing disabling the bump map on this material.
  48254. */
  48255. disableBumpMap: boolean;
  48256. /**
  48257. * AKA Diffuse Texture in standard nomenclature.
  48258. */
  48259. albedoTexture: BaseTexture;
  48260. /**
  48261. * AKA Occlusion Texture in other nomenclature.
  48262. */
  48263. ambientTexture: BaseTexture;
  48264. /**
  48265. * AKA Occlusion Texture Intensity in other nomenclature.
  48266. */
  48267. ambientTextureStrength: number;
  48268. /**
  48269. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48270. * 1 means it completely occludes it
  48271. * 0 mean it has no impact
  48272. */
  48273. ambientTextureImpactOnAnalyticalLights: number;
  48274. /**
  48275. * Stores the alpha values in a texture.
  48276. */
  48277. opacityTexture: BaseTexture;
  48278. /**
  48279. * Stores the reflection values in a texture.
  48280. */
  48281. reflectionTexture: Nullable<BaseTexture>;
  48282. /**
  48283. * Stores the emissive values in a texture.
  48284. */
  48285. emissiveTexture: BaseTexture;
  48286. /**
  48287. * AKA Specular texture in other nomenclature.
  48288. */
  48289. reflectivityTexture: BaseTexture;
  48290. /**
  48291. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48292. */
  48293. metallicTexture: BaseTexture;
  48294. /**
  48295. * Specifies the metallic scalar of the metallic/roughness workflow.
  48296. * Can also be used to scale the metalness values of the metallic texture.
  48297. */
  48298. metallic: Nullable<number>;
  48299. /**
  48300. * Specifies the roughness scalar of the metallic/roughness workflow.
  48301. * Can also be used to scale the roughness values of the metallic texture.
  48302. */
  48303. roughness: Nullable<number>;
  48304. /**
  48305. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48306. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48307. */
  48308. microSurfaceTexture: BaseTexture;
  48309. /**
  48310. * Stores surface normal data used to displace a mesh in a texture.
  48311. */
  48312. bumpTexture: BaseTexture;
  48313. /**
  48314. * Stores the pre-calculated light information of a mesh in a texture.
  48315. */
  48316. lightmapTexture: BaseTexture;
  48317. /**
  48318. * Stores the refracted light information in a texture.
  48319. */
  48320. refractionTexture: Nullable<BaseTexture>;
  48321. /**
  48322. * The color of a material in ambient lighting.
  48323. */
  48324. ambientColor: Color3;
  48325. /**
  48326. * AKA Diffuse Color in other nomenclature.
  48327. */
  48328. albedoColor: Color3;
  48329. /**
  48330. * AKA Specular Color in other nomenclature.
  48331. */
  48332. reflectivityColor: Color3;
  48333. /**
  48334. * The color reflected from the material.
  48335. */
  48336. reflectionColor: Color3;
  48337. /**
  48338. * The color emitted from the material.
  48339. */
  48340. emissiveColor: Color3;
  48341. /**
  48342. * AKA Glossiness in other nomenclature.
  48343. */
  48344. microSurface: number;
  48345. /**
  48346. * source material index of refraction (IOR)' / 'destination material IOR.
  48347. */
  48348. indexOfRefraction: number;
  48349. /**
  48350. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48351. */
  48352. invertRefractionY: boolean;
  48353. /**
  48354. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48355. * Materials half opaque for instance using refraction could benefit from this control.
  48356. */
  48357. linkRefractionWithTransparency: boolean;
  48358. /**
  48359. * If true, the light map contains occlusion information instead of lighting info.
  48360. */
  48361. useLightmapAsShadowmap: boolean;
  48362. /**
  48363. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48364. */
  48365. useAlphaFromAlbedoTexture: boolean;
  48366. /**
  48367. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48368. */
  48369. forceAlphaTest: boolean;
  48370. /**
  48371. * Defines the alpha limits in alpha test mode.
  48372. */
  48373. alphaCutOff: number;
  48374. /**
  48375. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48376. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48377. */
  48378. useSpecularOverAlpha: boolean;
  48379. /**
  48380. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48381. */
  48382. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48383. /**
  48384. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48385. */
  48386. useRoughnessFromMetallicTextureAlpha: boolean;
  48387. /**
  48388. * Specifies if the metallic texture contains the roughness information in its green channel.
  48389. */
  48390. useRoughnessFromMetallicTextureGreen: boolean;
  48391. /**
  48392. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48393. */
  48394. useMetallnessFromMetallicTextureBlue: boolean;
  48395. /**
  48396. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48397. */
  48398. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48399. /**
  48400. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48401. */
  48402. useAmbientInGrayScale: boolean;
  48403. /**
  48404. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48405. * The material will try to infer what glossiness each pixel should be.
  48406. */
  48407. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48408. /**
  48409. * BJS is using an harcoded light falloff based on a manually sets up range.
  48410. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48411. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48412. */
  48413. /**
  48414. * BJS is using an harcoded light falloff based on a manually sets up range.
  48415. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48416. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48417. */
  48418. usePhysicalLightFalloff: boolean;
  48419. /**
  48420. * In order to support the falloff compatibility with gltf, a special mode has been added
  48421. * to reproduce the gltf light falloff.
  48422. */
  48423. /**
  48424. * In order to support the falloff compatibility with gltf, a special mode has been added
  48425. * to reproduce the gltf light falloff.
  48426. */
  48427. useGLTFLightFalloff: boolean;
  48428. /**
  48429. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48430. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48431. */
  48432. useRadianceOverAlpha: boolean;
  48433. /**
  48434. * Allows using an object space normal map (instead of tangent space).
  48435. */
  48436. useObjectSpaceNormalMap: boolean;
  48437. /**
  48438. * Allows using the bump map in parallax mode.
  48439. */
  48440. useParallax: boolean;
  48441. /**
  48442. * Allows using the bump map in parallax occlusion mode.
  48443. */
  48444. useParallaxOcclusion: boolean;
  48445. /**
  48446. * Controls the scale bias of the parallax mode.
  48447. */
  48448. parallaxScaleBias: number;
  48449. /**
  48450. * If sets to true, disables all the lights affecting the material.
  48451. */
  48452. disableLighting: boolean;
  48453. /**
  48454. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48455. */
  48456. forceIrradianceInFragment: boolean;
  48457. /**
  48458. * Number of Simultaneous lights allowed on the material.
  48459. */
  48460. maxSimultaneousLights: number;
  48461. /**
  48462. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48463. */
  48464. invertNormalMapX: boolean;
  48465. /**
  48466. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48467. */
  48468. invertNormalMapY: boolean;
  48469. /**
  48470. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48471. */
  48472. twoSidedLighting: boolean;
  48473. /**
  48474. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48475. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48476. */
  48477. useAlphaFresnel: boolean;
  48478. /**
  48479. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48480. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48481. */
  48482. useLinearAlphaFresnel: boolean;
  48483. /**
  48484. * Let user defines the brdf lookup texture used for IBL.
  48485. * A default 8bit version is embedded but you could point at :
  48486. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48487. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48488. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48489. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48490. */
  48491. environmentBRDFTexture: Nullable<BaseTexture>;
  48492. /**
  48493. * Force normal to face away from face.
  48494. */
  48495. forceNormalForward: boolean;
  48496. /**
  48497. * Enables specular anti aliasing in the PBR shader.
  48498. * It will both interacts on the Geometry for analytical and IBL lighting.
  48499. * It also prefilter the roughness map based on the bump values.
  48500. */
  48501. enableSpecularAntiAliasing: boolean;
  48502. /**
  48503. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48504. * makes the reflect vector face the model (under horizon).
  48505. */
  48506. useHorizonOcclusion: boolean;
  48507. /**
  48508. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48509. * too much the area relying on ambient texture to define their ambient occlusion.
  48510. */
  48511. useRadianceOcclusion: boolean;
  48512. /**
  48513. * If set to true, no lighting calculations will be applied.
  48514. */
  48515. unlit: boolean;
  48516. /**
  48517. * Gets the image processing configuration used either in this material.
  48518. */
  48519. /**
  48520. * Sets the Default image processing configuration used either in the this material.
  48521. *
  48522. * If sets to null, the scene one is in use.
  48523. */
  48524. imageProcessingConfiguration: ImageProcessingConfiguration;
  48525. /**
  48526. * Gets wether the color curves effect is enabled.
  48527. */
  48528. /**
  48529. * Sets wether the color curves effect is enabled.
  48530. */
  48531. cameraColorCurvesEnabled: boolean;
  48532. /**
  48533. * Gets wether the color grading effect is enabled.
  48534. */
  48535. /**
  48536. * Gets wether the color grading effect is enabled.
  48537. */
  48538. cameraColorGradingEnabled: boolean;
  48539. /**
  48540. * Gets wether tonemapping is enabled or not.
  48541. */
  48542. /**
  48543. * Sets wether tonemapping is enabled or not
  48544. */
  48545. cameraToneMappingEnabled: boolean;
  48546. /**
  48547. * The camera exposure used on this material.
  48548. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48549. * This corresponds to a photographic exposure.
  48550. */
  48551. /**
  48552. * The camera exposure used on this material.
  48553. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48554. * This corresponds to a photographic exposure.
  48555. */
  48556. cameraExposure: number;
  48557. /**
  48558. * Gets The camera contrast used on this material.
  48559. */
  48560. /**
  48561. * Sets The camera contrast used on this material.
  48562. */
  48563. cameraContrast: number;
  48564. /**
  48565. * Gets the Color Grading 2D Lookup Texture.
  48566. */
  48567. /**
  48568. * Sets the Color Grading 2D Lookup Texture.
  48569. */
  48570. cameraColorGradingTexture: Nullable<BaseTexture>;
  48571. /**
  48572. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48573. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48574. * 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;
  48575. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48576. */
  48577. /**
  48578. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48579. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48580. * 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;
  48581. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48582. */
  48583. cameraColorCurves: Nullable<ColorCurves>;
  48584. /**
  48585. * Instantiates a new PBRMaterial instance.
  48586. *
  48587. * @param name The material name
  48588. * @param scene The scene the material will be use in.
  48589. */
  48590. constructor(name: string, scene: Scene);
  48591. /**
  48592. * Returns the name of this material class.
  48593. */
  48594. getClassName(): string;
  48595. /**
  48596. * Makes a duplicate of the current material.
  48597. * @param name - name to use for the new material.
  48598. */
  48599. clone(name: string): PBRMaterial;
  48600. /**
  48601. * Serializes this PBR Material.
  48602. * @returns - An object with the serialized material.
  48603. */
  48604. serialize(): any;
  48605. /**
  48606. * Parses a PBR Material from a serialized object.
  48607. * @param source - Serialized object.
  48608. * @param scene - BJS scene instance.
  48609. * @param rootUrl - url for the scene object
  48610. * @returns - PBRMaterial
  48611. */
  48612. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48613. }
  48614. }
  48615. declare module "babylonjs/Misc/dds" {
  48616. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48617. import { Engine } from "babylonjs/Engines/engine";
  48618. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48619. import { Nullable } from "babylonjs/types";
  48620. import { Scene } from "babylonjs/scene";
  48621. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48622. /**
  48623. * Direct draw surface info
  48624. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48625. */
  48626. export interface DDSInfo {
  48627. /**
  48628. * Width of the texture
  48629. */
  48630. width: number;
  48631. /**
  48632. * Width of the texture
  48633. */
  48634. height: number;
  48635. /**
  48636. * Number of Mipmaps for the texture
  48637. * @see https://en.wikipedia.org/wiki/Mipmap
  48638. */
  48639. mipmapCount: number;
  48640. /**
  48641. * If the textures format is a known fourCC format
  48642. * @see https://www.fourcc.org/
  48643. */
  48644. isFourCC: boolean;
  48645. /**
  48646. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48647. */
  48648. isRGB: boolean;
  48649. /**
  48650. * If the texture is a lumincance format
  48651. */
  48652. isLuminance: boolean;
  48653. /**
  48654. * If this is a cube texture
  48655. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48656. */
  48657. isCube: boolean;
  48658. /**
  48659. * If the texture is a compressed format eg. FOURCC_DXT1
  48660. */
  48661. isCompressed: boolean;
  48662. /**
  48663. * The dxgiFormat of the texture
  48664. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48665. */
  48666. dxgiFormat: number;
  48667. /**
  48668. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48669. */
  48670. textureType: number;
  48671. /**
  48672. * Sphericle polynomial created for the dds texture
  48673. */
  48674. sphericalPolynomial?: SphericalPolynomial;
  48675. }
  48676. /**
  48677. * Class used to provide DDS decompression tools
  48678. */
  48679. export class DDSTools {
  48680. /**
  48681. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48682. */
  48683. static StoreLODInAlphaChannel: boolean;
  48684. /**
  48685. * Gets DDS information from an array buffer
  48686. * @param arrayBuffer defines the array buffer to read data from
  48687. * @returns the DDS information
  48688. */
  48689. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48690. private static _FloatView;
  48691. private static _Int32View;
  48692. private static _ToHalfFloat;
  48693. private static _FromHalfFloat;
  48694. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48695. private static _GetHalfFloatRGBAArrayBuffer;
  48696. private static _GetFloatRGBAArrayBuffer;
  48697. private static _GetFloatAsUIntRGBAArrayBuffer;
  48698. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48699. private static _GetRGBAArrayBuffer;
  48700. private static _ExtractLongWordOrder;
  48701. private static _GetRGBArrayBuffer;
  48702. private static _GetLuminanceArrayBuffer;
  48703. /**
  48704. * Uploads DDS Levels to a Babylon Texture
  48705. * @hidden
  48706. */
  48707. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48708. }
  48709. module "babylonjs/Engines/engine" {
  48710. interface Engine {
  48711. /**
  48712. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48713. * @param rootUrl defines the url where the file to load is located
  48714. * @param scene defines the current scene
  48715. * @param lodScale defines scale to apply to the mip map selection
  48716. * @param lodOffset defines offset to apply to the mip map selection
  48717. * @param onLoad defines an optional callback raised when the texture is loaded
  48718. * @param onError defines an optional callback raised if there is an issue to load the texture
  48719. * @param format defines the format of the data
  48720. * @param forcedExtension defines the extension to use to pick the right loader
  48721. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48722. * @returns the cube texture as an InternalTexture
  48723. */
  48724. 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;
  48725. }
  48726. }
  48727. }
  48728. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48729. import { Nullable } from "babylonjs/types";
  48730. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48731. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48732. /**
  48733. * Implementation of the DDS Texture Loader.
  48734. * @hidden
  48735. */
  48736. export class _DDSTextureLoader implements IInternalTextureLoader {
  48737. /**
  48738. * Defines wether the loader supports cascade loading the different faces.
  48739. */
  48740. readonly supportCascades: boolean;
  48741. /**
  48742. * This returns if the loader support the current file information.
  48743. * @param extension defines the file extension of the file being loaded
  48744. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48745. * @param fallback defines the fallback internal texture if any
  48746. * @param isBase64 defines whether the texture is encoded as a base64
  48747. * @param isBuffer defines whether the texture data are stored as a buffer
  48748. * @returns true if the loader can load the specified file
  48749. */
  48750. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48751. /**
  48752. * Transform the url before loading if required.
  48753. * @param rootUrl the url of the texture
  48754. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48755. * @returns the transformed texture
  48756. */
  48757. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48758. /**
  48759. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48760. * @param rootUrl the url of the texture
  48761. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48762. * @returns the fallback texture
  48763. */
  48764. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48765. /**
  48766. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48767. * @param data contains the texture data
  48768. * @param texture defines the BabylonJS internal texture
  48769. * @param createPolynomials will be true if polynomials have been requested
  48770. * @param onLoad defines the callback to trigger once the texture is ready
  48771. * @param onError defines the callback to trigger in case of error
  48772. */
  48773. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48774. /**
  48775. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48776. * @param data contains the texture data
  48777. * @param texture defines the BabylonJS internal texture
  48778. * @param callback defines the method to call once ready to upload
  48779. */
  48780. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48781. }
  48782. }
  48783. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48784. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48785. /** @hidden */
  48786. export var rgbdEncodePixelShader: {
  48787. name: string;
  48788. shader: string;
  48789. };
  48790. }
  48791. declare module "babylonjs/Misc/environmentTextureTools" {
  48792. import { Nullable } from "babylonjs/types";
  48793. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48794. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48795. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48796. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48797. import "babylonjs/Shaders/rgbdEncode.fragment";
  48798. import "babylonjs/Shaders/rgbdDecode.fragment";
  48799. /**
  48800. * Raw texture data and descriptor sufficient for WebGL texture upload
  48801. */
  48802. export interface EnvironmentTextureInfo {
  48803. /**
  48804. * Version of the environment map
  48805. */
  48806. version: number;
  48807. /**
  48808. * Width of image
  48809. */
  48810. width: number;
  48811. /**
  48812. * Irradiance information stored in the file.
  48813. */
  48814. irradiance: any;
  48815. /**
  48816. * Specular information stored in the file.
  48817. */
  48818. specular: any;
  48819. }
  48820. /**
  48821. * Sets of helpers addressing the serialization and deserialization of environment texture
  48822. * stored in a BabylonJS env file.
  48823. * Those files are usually stored as .env files.
  48824. */
  48825. export class EnvironmentTextureTools {
  48826. /**
  48827. * Magic number identifying the env file.
  48828. */
  48829. private static _MagicBytes;
  48830. /**
  48831. * Gets the environment info from an env file.
  48832. * @param data The array buffer containing the .env bytes.
  48833. * @returns the environment file info (the json header) if successfully parsed.
  48834. */
  48835. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48836. /**
  48837. * Creates an environment texture from a loaded cube texture.
  48838. * @param texture defines the cube texture to convert in env file
  48839. * @return a promise containing the environment data if succesfull.
  48840. */
  48841. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48842. /**
  48843. * Creates a JSON representation of the spherical data.
  48844. * @param texture defines the texture containing the polynomials
  48845. * @return the JSON representation of the spherical info
  48846. */
  48847. private static _CreateEnvTextureIrradiance;
  48848. /**
  48849. * Uploads the texture info contained in the env file to the GPU.
  48850. * @param texture defines the internal texture to upload to
  48851. * @param arrayBuffer defines the buffer cotaining the data to load
  48852. * @param info defines the texture info retrieved through the GetEnvInfo method
  48853. * @returns a promise
  48854. */
  48855. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48856. /**
  48857. * Uploads the levels of image data to the GPU.
  48858. * @param texture defines the internal texture to upload to
  48859. * @param imageData defines the array buffer views of image data [mipmap][face]
  48860. * @returns a promise
  48861. */
  48862. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48863. /**
  48864. * Uploads spherical polynomials information to the texture.
  48865. * @param texture defines the texture we are trying to upload the information to
  48866. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48867. */
  48868. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48869. /** @hidden */
  48870. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48871. }
  48872. }
  48873. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48874. import { Nullable } from "babylonjs/types";
  48875. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48876. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48877. /**
  48878. * Implementation of the ENV Texture Loader.
  48879. * @hidden
  48880. */
  48881. export class _ENVTextureLoader implements IInternalTextureLoader {
  48882. /**
  48883. * Defines wether the loader supports cascade loading the different faces.
  48884. */
  48885. readonly supportCascades: boolean;
  48886. /**
  48887. * This returns if the loader support the current file information.
  48888. * @param extension defines the file extension of the file being loaded
  48889. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48890. * @param fallback defines the fallback internal texture if any
  48891. * @param isBase64 defines whether the texture is encoded as a base64
  48892. * @param isBuffer defines whether the texture data are stored as a buffer
  48893. * @returns true if the loader can load the specified file
  48894. */
  48895. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48896. /**
  48897. * Transform the url before loading if required.
  48898. * @param rootUrl the url of the texture
  48899. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48900. * @returns the transformed texture
  48901. */
  48902. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48903. /**
  48904. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48905. * @param rootUrl the url of the texture
  48906. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48907. * @returns the fallback texture
  48908. */
  48909. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48910. /**
  48911. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48912. * @param data contains the texture data
  48913. * @param texture defines the BabylonJS internal texture
  48914. * @param createPolynomials will be true if polynomials have been requested
  48915. * @param onLoad defines the callback to trigger once the texture is ready
  48916. * @param onError defines the callback to trigger in case of error
  48917. */
  48918. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48919. /**
  48920. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48921. * @param data contains the texture data
  48922. * @param texture defines the BabylonJS internal texture
  48923. * @param callback defines the method to call once ready to upload
  48924. */
  48925. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48926. }
  48927. }
  48928. declare module "babylonjs/Misc/khronosTextureContainer" {
  48929. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48930. /**
  48931. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48932. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48933. */
  48934. export class KhronosTextureContainer {
  48935. /** contents of the KTX container file */
  48936. arrayBuffer: any;
  48937. private static HEADER_LEN;
  48938. private static COMPRESSED_2D;
  48939. private static COMPRESSED_3D;
  48940. private static TEX_2D;
  48941. private static TEX_3D;
  48942. /**
  48943. * Gets the openGL type
  48944. */
  48945. glType: number;
  48946. /**
  48947. * Gets the openGL type size
  48948. */
  48949. glTypeSize: number;
  48950. /**
  48951. * Gets the openGL format
  48952. */
  48953. glFormat: number;
  48954. /**
  48955. * Gets the openGL internal format
  48956. */
  48957. glInternalFormat: number;
  48958. /**
  48959. * Gets the base internal format
  48960. */
  48961. glBaseInternalFormat: number;
  48962. /**
  48963. * Gets image width in pixel
  48964. */
  48965. pixelWidth: number;
  48966. /**
  48967. * Gets image height in pixel
  48968. */
  48969. pixelHeight: number;
  48970. /**
  48971. * Gets image depth in pixels
  48972. */
  48973. pixelDepth: number;
  48974. /**
  48975. * Gets the number of array elements
  48976. */
  48977. numberOfArrayElements: number;
  48978. /**
  48979. * Gets the number of faces
  48980. */
  48981. numberOfFaces: number;
  48982. /**
  48983. * Gets the number of mipmap levels
  48984. */
  48985. numberOfMipmapLevels: number;
  48986. /**
  48987. * Gets the bytes of key value data
  48988. */
  48989. bytesOfKeyValueData: number;
  48990. /**
  48991. * Gets the load type
  48992. */
  48993. loadType: number;
  48994. /**
  48995. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48996. */
  48997. isInvalid: boolean;
  48998. /**
  48999. * Creates a new KhronosTextureContainer
  49000. * @param arrayBuffer contents of the KTX container file
  49001. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49002. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49003. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49004. */
  49005. constructor(
  49006. /** contents of the KTX container file */
  49007. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49008. /**
  49009. * Uploads KTX content to a Babylon Texture.
  49010. * It is assumed that the texture has already been created & is currently bound
  49011. * @hidden
  49012. */
  49013. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49014. private _upload2DCompressedLevels;
  49015. }
  49016. }
  49017. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49018. import { Nullable } from "babylonjs/types";
  49019. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49020. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49021. /**
  49022. * Implementation of the KTX Texture Loader.
  49023. * @hidden
  49024. */
  49025. export class _KTXTextureLoader implements IInternalTextureLoader {
  49026. /**
  49027. * Defines wether the loader supports cascade loading the different faces.
  49028. */
  49029. readonly supportCascades: boolean;
  49030. /**
  49031. * This returns if the loader support the current file information.
  49032. * @param extension defines the file extension of the file being loaded
  49033. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49034. * @param fallback defines the fallback internal texture if any
  49035. * @param isBase64 defines whether the texture is encoded as a base64
  49036. * @param isBuffer defines whether the texture data are stored as a buffer
  49037. * @returns true if the loader can load the specified file
  49038. */
  49039. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49040. /**
  49041. * Transform the url before loading if required.
  49042. * @param rootUrl the url of the texture
  49043. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49044. * @returns the transformed texture
  49045. */
  49046. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49047. /**
  49048. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49049. * @param rootUrl the url of the texture
  49050. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49051. * @returns the fallback texture
  49052. */
  49053. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49054. /**
  49055. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49056. * @param data contains the texture data
  49057. * @param texture defines the BabylonJS internal texture
  49058. * @param createPolynomials will be true if polynomials have been requested
  49059. * @param onLoad defines the callback to trigger once the texture is ready
  49060. * @param onError defines the callback to trigger in case of error
  49061. */
  49062. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49063. /**
  49064. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49065. * @param data contains the texture data
  49066. * @param texture defines the BabylonJS internal texture
  49067. * @param callback defines the method to call once ready to upload
  49068. */
  49069. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49070. }
  49071. }
  49072. declare module "babylonjs/Helpers/sceneHelpers" {
  49073. import { Nullable } from "babylonjs/types";
  49074. import { Mesh } from "babylonjs/Meshes/mesh";
  49075. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49076. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49077. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49078. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49079. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49080. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49081. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49082. import "babylonjs/Meshes/Builders/boxBuilder";
  49083. /** @hidden */
  49084. export var _forceSceneHelpersToBundle: boolean;
  49085. module "babylonjs/scene" {
  49086. interface Scene {
  49087. /**
  49088. * Creates a default light for the scene.
  49089. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49090. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49091. */
  49092. createDefaultLight(replace?: boolean): void;
  49093. /**
  49094. * Creates a default camera for the scene.
  49095. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49096. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49097. * @param replace has default false, when true replaces the active camera in the scene
  49098. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49099. */
  49100. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49101. /**
  49102. * Creates a default camera and a default light.
  49103. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49104. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49105. * @param replace has the default false, when true replaces the active camera/light in the scene
  49106. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49107. */
  49108. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49109. /**
  49110. * Creates a new sky box
  49111. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49112. * @param environmentTexture defines the texture to use as environment texture
  49113. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49114. * @param scale defines the overall scale of the skybox
  49115. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49116. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49117. * @returns a new mesh holding the sky box
  49118. */
  49119. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49120. /**
  49121. * Creates a new environment
  49122. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49123. * @param options defines the options you can use to configure the environment
  49124. * @returns the new EnvironmentHelper
  49125. */
  49126. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49127. /**
  49128. * Creates a new VREXperienceHelper
  49129. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49130. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49131. * @returns a new VREXperienceHelper
  49132. */
  49133. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49134. /**
  49135. * Creates a new XREXperienceHelper
  49136. * @see http://doc.babylonjs.com/how_to/webxr
  49137. * @returns a promise for a new XREXperienceHelper
  49138. */
  49139. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  49140. }
  49141. }
  49142. }
  49143. declare module "babylonjs/Helpers/videoDome" {
  49144. import { Scene } from "babylonjs/scene";
  49145. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49146. import { Mesh } from "babylonjs/Meshes/mesh";
  49147. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49148. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49149. import "babylonjs/Meshes/Builders/sphereBuilder";
  49150. /**
  49151. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49152. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49153. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49154. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49155. */
  49156. export class VideoDome extends TransformNode {
  49157. /**
  49158. * Define the video source as a Monoscopic panoramic 360 video.
  49159. */
  49160. static readonly MODE_MONOSCOPIC: number;
  49161. /**
  49162. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49163. */
  49164. static readonly MODE_TOPBOTTOM: number;
  49165. /**
  49166. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49167. */
  49168. static readonly MODE_SIDEBYSIDE: number;
  49169. private _useDirectMapping;
  49170. /**
  49171. * The video texture being displayed on the sphere
  49172. */
  49173. protected _videoTexture: VideoTexture;
  49174. /**
  49175. * Gets the video texture being displayed on the sphere
  49176. */
  49177. readonly videoTexture: VideoTexture;
  49178. /**
  49179. * The skybox material
  49180. */
  49181. protected _material: BackgroundMaterial;
  49182. /**
  49183. * The surface used for the skybox
  49184. */
  49185. protected _mesh: Mesh;
  49186. /**
  49187. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49188. * Also see the options.resolution property.
  49189. */
  49190. fovMultiplier: number;
  49191. private _videoMode;
  49192. /**
  49193. * Gets or set the current video mode for the video. It can be:
  49194. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49195. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49196. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49197. */
  49198. videoMode: number;
  49199. /**
  49200. * Oberserver used in Stereoscopic VR Mode.
  49201. */
  49202. private _onBeforeCameraRenderObserver;
  49203. /**
  49204. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49205. * @param name Element's name, child elements will append suffixes for their own names.
  49206. * @param urlsOrVideo defines the url(s) or the video element to use
  49207. * @param options An object containing optional or exposed sub element properties
  49208. */
  49209. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49210. resolution?: number;
  49211. clickToPlay?: boolean;
  49212. autoPlay?: boolean;
  49213. loop?: boolean;
  49214. size?: number;
  49215. poster?: string;
  49216. faceForward?: boolean;
  49217. useDirectMapping?: boolean;
  49218. }, scene: Scene);
  49219. private _changeVideoMode;
  49220. /**
  49221. * Releases resources associated with this node.
  49222. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49223. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49224. */
  49225. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49226. }
  49227. }
  49228. declare module "babylonjs/Helpers/index" {
  49229. export * from "babylonjs/Helpers/environmentHelper";
  49230. export * from "babylonjs/Helpers/photoDome";
  49231. export * from "babylonjs/Helpers/sceneHelpers";
  49232. export * from "babylonjs/Helpers/videoDome";
  49233. }
  49234. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49235. import { PerfCounter } from "babylonjs/Misc/tools";
  49236. import { IDisposable } from "babylonjs/scene";
  49237. import { Engine } from "babylonjs/Engines/engine";
  49238. /**
  49239. * This class can be used to get instrumentation data from a Babylon engine
  49240. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49241. */
  49242. export class EngineInstrumentation implements IDisposable {
  49243. /**
  49244. * Define the instrumented engine.
  49245. */
  49246. engine: Engine;
  49247. private _captureGPUFrameTime;
  49248. private _gpuFrameTimeToken;
  49249. private _gpuFrameTime;
  49250. private _captureShaderCompilationTime;
  49251. private _shaderCompilationTime;
  49252. private _onBeginFrameObserver;
  49253. private _onEndFrameObserver;
  49254. private _onBeforeShaderCompilationObserver;
  49255. private _onAfterShaderCompilationObserver;
  49256. /**
  49257. * Gets the perf counter used for GPU frame time
  49258. */
  49259. readonly gpuFrameTimeCounter: PerfCounter;
  49260. /**
  49261. * Gets the GPU frame time capture status
  49262. */
  49263. /**
  49264. * Enable or disable the GPU frame time capture
  49265. */
  49266. captureGPUFrameTime: boolean;
  49267. /**
  49268. * Gets the perf counter used for shader compilation time
  49269. */
  49270. readonly shaderCompilationTimeCounter: PerfCounter;
  49271. /**
  49272. * Gets the shader compilation time capture status
  49273. */
  49274. /**
  49275. * Enable or disable the shader compilation time capture
  49276. */
  49277. captureShaderCompilationTime: boolean;
  49278. /**
  49279. * Instantiates a new engine instrumentation.
  49280. * This class can be used to get instrumentation data from a Babylon engine
  49281. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49282. * @param engine Defines the engine to instrument
  49283. */
  49284. constructor(
  49285. /**
  49286. * Define the instrumented engine.
  49287. */
  49288. engine: Engine);
  49289. /**
  49290. * Dispose and release associated resources.
  49291. */
  49292. dispose(): void;
  49293. }
  49294. }
  49295. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49296. import { PerfCounter } from "babylonjs/Misc/tools";
  49297. import { Scene, IDisposable } from "babylonjs/scene";
  49298. /**
  49299. * This class can be used to get instrumentation data from a Babylon engine
  49300. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49301. */
  49302. export class SceneInstrumentation implements IDisposable {
  49303. /**
  49304. * Defines the scene to instrument
  49305. */
  49306. scene: Scene;
  49307. private _captureActiveMeshesEvaluationTime;
  49308. private _activeMeshesEvaluationTime;
  49309. private _captureRenderTargetsRenderTime;
  49310. private _renderTargetsRenderTime;
  49311. private _captureFrameTime;
  49312. private _frameTime;
  49313. private _captureRenderTime;
  49314. private _renderTime;
  49315. private _captureInterFrameTime;
  49316. private _interFrameTime;
  49317. private _captureParticlesRenderTime;
  49318. private _particlesRenderTime;
  49319. private _captureSpritesRenderTime;
  49320. private _spritesRenderTime;
  49321. private _capturePhysicsTime;
  49322. private _physicsTime;
  49323. private _captureAnimationsTime;
  49324. private _animationsTime;
  49325. private _captureCameraRenderTime;
  49326. private _cameraRenderTime;
  49327. private _onBeforeActiveMeshesEvaluationObserver;
  49328. private _onAfterActiveMeshesEvaluationObserver;
  49329. private _onBeforeRenderTargetsRenderObserver;
  49330. private _onAfterRenderTargetsRenderObserver;
  49331. private _onAfterRenderObserver;
  49332. private _onBeforeDrawPhaseObserver;
  49333. private _onAfterDrawPhaseObserver;
  49334. private _onBeforeAnimationsObserver;
  49335. private _onBeforeParticlesRenderingObserver;
  49336. private _onAfterParticlesRenderingObserver;
  49337. private _onBeforeSpritesRenderingObserver;
  49338. private _onAfterSpritesRenderingObserver;
  49339. private _onBeforePhysicsObserver;
  49340. private _onAfterPhysicsObserver;
  49341. private _onAfterAnimationsObserver;
  49342. private _onBeforeCameraRenderObserver;
  49343. private _onAfterCameraRenderObserver;
  49344. /**
  49345. * Gets the perf counter used for active meshes evaluation time
  49346. */
  49347. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49348. /**
  49349. * Gets the active meshes evaluation time capture status
  49350. */
  49351. /**
  49352. * Enable or disable the active meshes evaluation time capture
  49353. */
  49354. captureActiveMeshesEvaluationTime: boolean;
  49355. /**
  49356. * Gets the perf counter used for render targets render time
  49357. */
  49358. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49359. /**
  49360. * Gets the render targets render time capture status
  49361. */
  49362. /**
  49363. * Enable or disable the render targets render time capture
  49364. */
  49365. captureRenderTargetsRenderTime: boolean;
  49366. /**
  49367. * Gets the perf counter used for particles render time
  49368. */
  49369. readonly particlesRenderTimeCounter: PerfCounter;
  49370. /**
  49371. * Gets the particles render time capture status
  49372. */
  49373. /**
  49374. * Enable or disable the particles render time capture
  49375. */
  49376. captureParticlesRenderTime: boolean;
  49377. /**
  49378. * Gets the perf counter used for sprites render time
  49379. */
  49380. readonly spritesRenderTimeCounter: PerfCounter;
  49381. /**
  49382. * Gets the sprites render time capture status
  49383. */
  49384. /**
  49385. * Enable or disable the sprites render time capture
  49386. */
  49387. captureSpritesRenderTime: boolean;
  49388. /**
  49389. * Gets the perf counter used for physics time
  49390. */
  49391. readonly physicsTimeCounter: PerfCounter;
  49392. /**
  49393. * Gets the physics time capture status
  49394. */
  49395. /**
  49396. * Enable or disable the physics time capture
  49397. */
  49398. capturePhysicsTime: boolean;
  49399. /**
  49400. * Gets the perf counter used for animations time
  49401. */
  49402. readonly animationsTimeCounter: PerfCounter;
  49403. /**
  49404. * Gets the animations time capture status
  49405. */
  49406. /**
  49407. * Enable or disable the animations time capture
  49408. */
  49409. captureAnimationsTime: boolean;
  49410. /**
  49411. * Gets the perf counter used for frame time capture
  49412. */
  49413. readonly frameTimeCounter: PerfCounter;
  49414. /**
  49415. * Gets the frame time capture status
  49416. */
  49417. /**
  49418. * Enable or disable the frame time capture
  49419. */
  49420. captureFrameTime: boolean;
  49421. /**
  49422. * Gets the perf counter used for inter-frames time capture
  49423. */
  49424. readonly interFrameTimeCounter: PerfCounter;
  49425. /**
  49426. * Gets the inter-frames time capture status
  49427. */
  49428. /**
  49429. * Enable or disable the inter-frames time capture
  49430. */
  49431. captureInterFrameTime: boolean;
  49432. /**
  49433. * Gets the perf counter used for render time capture
  49434. */
  49435. readonly renderTimeCounter: PerfCounter;
  49436. /**
  49437. * Gets the render time capture status
  49438. */
  49439. /**
  49440. * Enable or disable the render time capture
  49441. */
  49442. captureRenderTime: boolean;
  49443. /**
  49444. * Gets the perf counter used for camera render time capture
  49445. */
  49446. readonly cameraRenderTimeCounter: PerfCounter;
  49447. /**
  49448. * Gets the camera render time capture status
  49449. */
  49450. /**
  49451. * Enable or disable the camera render time capture
  49452. */
  49453. captureCameraRenderTime: boolean;
  49454. /**
  49455. * Gets the perf counter used for draw calls
  49456. */
  49457. readonly drawCallsCounter: PerfCounter;
  49458. /**
  49459. * Instantiates a new scene instrumentation.
  49460. * This class can be used to get instrumentation data from a Babylon engine
  49461. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49462. * @param scene Defines the scene to instrument
  49463. */
  49464. constructor(
  49465. /**
  49466. * Defines the scene to instrument
  49467. */
  49468. scene: Scene);
  49469. /**
  49470. * Dispose and release associated resources.
  49471. */
  49472. dispose(): void;
  49473. }
  49474. }
  49475. declare module "babylonjs/Instrumentation/index" {
  49476. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49477. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49478. export * from "babylonjs/Instrumentation/timeToken";
  49479. }
  49480. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49481. /** @hidden */
  49482. export var glowMapGenerationPixelShader: {
  49483. name: string;
  49484. shader: string;
  49485. };
  49486. }
  49487. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49488. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49489. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49490. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49491. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49492. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49493. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49494. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49495. /** @hidden */
  49496. export var glowMapGenerationVertexShader: {
  49497. name: string;
  49498. shader: string;
  49499. };
  49500. }
  49501. declare module "babylonjs/Layers/effectLayer" {
  49502. import { Observable } from "babylonjs/Misc/observable";
  49503. import { Nullable } from "babylonjs/types";
  49504. import { Camera } from "babylonjs/Cameras/camera";
  49505. import { Scene } from "babylonjs/scene";
  49506. import { Color4, ISize } from "babylonjs/Maths/math";
  49507. import { Engine } from "babylonjs/Engines/engine";
  49508. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49510. import { Mesh } from "babylonjs/Meshes/mesh";
  49511. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49512. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49513. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49514. import { Effect } from "babylonjs/Materials/effect";
  49515. import { Material } from "babylonjs/Materials/material";
  49516. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49517. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49518. /**
  49519. * Effect layer options. This helps customizing the behaviour
  49520. * of the effect layer.
  49521. */
  49522. export interface IEffectLayerOptions {
  49523. /**
  49524. * Multiplication factor apply to the canvas size to compute the render target size
  49525. * used to generated the objects (the smaller the faster).
  49526. */
  49527. mainTextureRatio: number;
  49528. /**
  49529. * Enforces a fixed size texture to ensure effect stability across devices.
  49530. */
  49531. mainTextureFixedSize?: number;
  49532. /**
  49533. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49534. */
  49535. alphaBlendingMode: number;
  49536. /**
  49537. * The camera attached to the layer.
  49538. */
  49539. camera: Nullable<Camera>;
  49540. /**
  49541. * The rendering group to draw the layer in.
  49542. */
  49543. renderingGroupId: number;
  49544. }
  49545. /**
  49546. * The effect layer Helps adding post process effect blended with the main pass.
  49547. *
  49548. * This can be for instance use to generate glow or higlight effects on the scene.
  49549. *
  49550. * The effect layer class can not be used directly and is intented to inherited from to be
  49551. * customized per effects.
  49552. */
  49553. export abstract class EffectLayer {
  49554. private _vertexBuffers;
  49555. private _indexBuffer;
  49556. private _cachedDefines;
  49557. private _effectLayerMapGenerationEffect;
  49558. private _effectLayerOptions;
  49559. private _mergeEffect;
  49560. protected _scene: Scene;
  49561. protected _engine: Engine;
  49562. protected _maxSize: number;
  49563. protected _mainTextureDesiredSize: ISize;
  49564. protected _mainTexture: RenderTargetTexture;
  49565. protected _shouldRender: boolean;
  49566. protected _postProcesses: PostProcess[];
  49567. protected _textures: BaseTexture[];
  49568. protected _emissiveTextureAndColor: {
  49569. texture: Nullable<BaseTexture>;
  49570. color: Color4;
  49571. };
  49572. /**
  49573. * The name of the layer
  49574. */
  49575. name: string;
  49576. /**
  49577. * The clear color of the texture used to generate the glow map.
  49578. */
  49579. neutralColor: Color4;
  49580. /**
  49581. * Specifies wether the highlight layer is enabled or not.
  49582. */
  49583. isEnabled: boolean;
  49584. /**
  49585. * Gets the camera attached to the layer.
  49586. */
  49587. readonly camera: Nullable<Camera>;
  49588. /**
  49589. * Gets the rendering group id the layer should render in.
  49590. */
  49591. renderingGroupId: number;
  49592. /**
  49593. * An event triggered when the effect layer has been disposed.
  49594. */
  49595. onDisposeObservable: Observable<EffectLayer>;
  49596. /**
  49597. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49598. */
  49599. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49600. /**
  49601. * An event triggered when the generated texture is being merged in the scene.
  49602. */
  49603. onBeforeComposeObservable: Observable<EffectLayer>;
  49604. /**
  49605. * An event triggered when the generated texture has been merged in the scene.
  49606. */
  49607. onAfterComposeObservable: Observable<EffectLayer>;
  49608. /**
  49609. * An event triggered when the efffect layer changes its size.
  49610. */
  49611. onSizeChangedObservable: Observable<EffectLayer>;
  49612. /** @hidden */
  49613. static _SceneComponentInitialization: (scene: Scene) => void;
  49614. /**
  49615. * Instantiates a new effect Layer and references it in the scene.
  49616. * @param name The name of the layer
  49617. * @param scene The scene to use the layer in
  49618. */
  49619. constructor(
  49620. /** The Friendly of the effect in the scene */
  49621. name: string, scene: Scene);
  49622. /**
  49623. * Get the effect name of the layer.
  49624. * @return The effect name
  49625. */
  49626. abstract getEffectName(): string;
  49627. /**
  49628. * Checks for the readiness of the element composing the layer.
  49629. * @param subMesh the mesh to check for
  49630. * @param useInstances specify wether or not to use instances to render the mesh
  49631. * @return true if ready otherwise, false
  49632. */
  49633. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49634. /**
  49635. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49636. * @returns true if the effect requires stencil during the main canvas render pass.
  49637. */
  49638. abstract needStencil(): boolean;
  49639. /**
  49640. * Create the merge effect. This is the shader use to blit the information back
  49641. * to the main canvas at the end of the scene rendering.
  49642. * @returns The effect containing the shader used to merge the effect on the main canvas
  49643. */
  49644. protected abstract _createMergeEffect(): Effect;
  49645. /**
  49646. * Creates the render target textures and post processes used in the effect layer.
  49647. */
  49648. protected abstract _createTextureAndPostProcesses(): void;
  49649. /**
  49650. * Implementation specific of rendering the generating effect on the main canvas.
  49651. * @param effect The effect used to render through
  49652. */
  49653. protected abstract _internalRender(effect: Effect): void;
  49654. /**
  49655. * Sets the required values for both the emissive texture and and the main color.
  49656. */
  49657. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49658. /**
  49659. * Free any resources and references associated to a mesh.
  49660. * Internal use
  49661. * @param mesh The mesh to free.
  49662. */
  49663. abstract _disposeMesh(mesh: Mesh): void;
  49664. /**
  49665. * Serializes this layer (Glow or Highlight for example)
  49666. * @returns a serialized layer object
  49667. */
  49668. abstract serialize?(): any;
  49669. /**
  49670. * Initializes the effect layer with the required options.
  49671. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49672. */
  49673. protected _init(options: Partial<IEffectLayerOptions>): void;
  49674. /**
  49675. * Generates the index buffer of the full screen quad blending to the main canvas.
  49676. */
  49677. private _generateIndexBuffer;
  49678. /**
  49679. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49680. */
  49681. private _generateVertexBuffer;
  49682. /**
  49683. * Sets the main texture desired size which is the closest power of two
  49684. * of the engine canvas size.
  49685. */
  49686. private _setMainTextureSize;
  49687. /**
  49688. * Creates the main texture for the effect layer.
  49689. */
  49690. protected _createMainTexture(): void;
  49691. /**
  49692. * Adds specific effects defines.
  49693. * @param defines The defines to add specifics to.
  49694. */
  49695. protected _addCustomEffectDefines(defines: string[]): void;
  49696. /**
  49697. * Checks for the readiness of the element composing the layer.
  49698. * @param subMesh the mesh to check for
  49699. * @param useInstances specify wether or not to use instances to render the mesh
  49700. * @param emissiveTexture the associated emissive texture used to generate the glow
  49701. * @return true if ready otherwise, false
  49702. */
  49703. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49704. /**
  49705. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49706. */
  49707. render(): void;
  49708. /**
  49709. * Determine if a given mesh will be used in the current effect.
  49710. * @param mesh mesh to test
  49711. * @returns true if the mesh will be used
  49712. */
  49713. hasMesh(mesh: AbstractMesh): boolean;
  49714. /**
  49715. * Returns true if the layer contains information to display, otherwise false.
  49716. * @returns true if the glow layer should be rendered
  49717. */
  49718. shouldRender(): boolean;
  49719. /**
  49720. * Returns true if the mesh should render, otherwise false.
  49721. * @param mesh The mesh to render
  49722. * @returns true if it should render otherwise false
  49723. */
  49724. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49725. /**
  49726. * Returns true if the mesh can be rendered, otherwise false.
  49727. * @param mesh The mesh to render
  49728. * @param material The material used on the mesh
  49729. * @returns true if it can be rendered otherwise false
  49730. */
  49731. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49732. /**
  49733. * Returns true if the mesh should render, otherwise false.
  49734. * @param mesh The mesh to render
  49735. * @returns true if it should render otherwise false
  49736. */
  49737. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49738. /**
  49739. * Renders the submesh passed in parameter to the generation map.
  49740. */
  49741. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49742. /**
  49743. * Rebuild the required buffers.
  49744. * @hidden Internal use only.
  49745. */
  49746. _rebuild(): void;
  49747. /**
  49748. * Dispose only the render target textures and post process.
  49749. */
  49750. private _disposeTextureAndPostProcesses;
  49751. /**
  49752. * Dispose the highlight layer and free resources.
  49753. */
  49754. dispose(): void;
  49755. /**
  49756. * Gets the class name of the effect layer
  49757. * @returns the string with the class name of the effect layer
  49758. */
  49759. getClassName(): string;
  49760. /**
  49761. * Creates an effect layer from parsed effect layer data
  49762. * @param parsedEffectLayer defines effect layer data
  49763. * @param scene defines the current scene
  49764. * @param rootUrl defines the root URL containing the effect layer information
  49765. * @returns a parsed effect Layer
  49766. */
  49767. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49768. }
  49769. }
  49770. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49771. import { Scene } from "babylonjs/scene";
  49772. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49773. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49774. import { AbstractScene } from "babylonjs/abstractScene";
  49775. module "babylonjs/abstractScene" {
  49776. interface AbstractScene {
  49777. /**
  49778. * The list of effect layers (highlights/glow) added to the scene
  49779. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49780. * @see http://doc.babylonjs.com/how_to/glow_layer
  49781. */
  49782. effectLayers: Array<EffectLayer>;
  49783. /**
  49784. * Removes the given effect layer from this scene.
  49785. * @param toRemove defines the effect layer to remove
  49786. * @returns the index of the removed effect layer
  49787. */
  49788. removeEffectLayer(toRemove: EffectLayer): number;
  49789. /**
  49790. * Adds the given effect layer to this scene
  49791. * @param newEffectLayer defines the effect layer to add
  49792. */
  49793. addEffectLayer(newEffectLayer: EffectLayer): void;
  49794. }
  49795. }
  49796. /**
  49797. * Defines the layer scene component responsible to manage any effect layers
  49798. * in a given scene.
  49799. */
  49800. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49801. /**
  49802. * The component name helpfull to identify the component in the list of scene components.
  49803. */
  49804. readonly name: string;
  49805. /**
  49806. * The scene the component belongs to.
  49807. */
  49808. scene: Scene;
  49809. private _engine;
  49810. private _renderEffects;
  49811. private _needStencil;
  49812. private _previousStencilState;
  49813. /**
  49814. * Creates a new instance of the component for the given scene
  49815. * @param scene Defines the scene to register the component in
  49816. */
  49817. constructor(scene: Scene);
  49818. /**
  49819. * Registers the component in a given scene
  49820. */
  49821. register(): void;
  49822. /**
  49823. * Rebuilds the elements related to this component in case of
  49824. * context lost for instance.
  49825. */
  49826. rebuild(): void;
  49827. /**
  49828. * Serializes the component data to the specified json object
  49829. * @param serializationObject The object to serialize to
  49830. */
  49831. serialize(serializationObject: any): void;
  49832. /**
  49833. * Adds all the elements from the container to the scene
  49834. * @param container the container holding the elements
  49835. */
  49836. addFromContainer(container: AbstractScene): void;
  49837. /**
  49838. * Removes all the elements in the container from the scene
  49839. * @param container contains the elements to remove
  49840. * @param dispose if the removed element should be disposed (default: false)
  49841. */
  49842. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49843. /**
  49844. * Disposes the component and the associated ressources.
  49845. */
  49846. dispose(): void;
  49847. private _isReadyForMesh;
  49848. private _renderMainTexture;
  49849. private _setStencil;
  49850. private _setStencilBack;
  49851. private _draw;
  49852. private _drawCamera;
  49853. private _drawRenderingGroup;
  49854. }
  49855. }
  49856. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49857. /** @hidden */
  49858. export var glowMapMergePixelShader: {
  49859. name: string;
  49860. shader: string;
  49861. };
  49862. }
  49863. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49864. /** @hidden */
  49865. export var glowMapMergeVertexShader: {
  49866. name: string;
  49867. shader: string;
  49868. };
  49869. }
  49870. declare module "babylonjs/Layers/glowLayer" {
  49871. import { Nullable } from "babylonjs/types";
  49872. import { Camera } from "babylonjs/Cameras/camera";
  49873. import { Scene } from "babylonjs/scene";
  49874. import { Color4 } from "babylonjs/Maths/math";
  49875. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49877. import { Mesh } from "babylonjs/Meshes/mesh";
  49878. import { Texture } from "babylonjs/Materials/Textures/texture";
  49879. import { Effect } from "babylonjs/Materials/effect";
  49880. import { Material } from "babylonjs/Materials/material";
  49881. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49882. import "babylonjs/Shaders/glowMapMerge.fragment";
  49883. import "babylonjs/Shaders/glowMapMerge.vertex";
  49884. import "babylonjs/Layers/effectLayerSceneComponent";
  49885. module "babylonjs/abstractScene" {
  49886. interface AbstractScene {
  49887. /**
  49888. * Return a the first highlight layer of the scene with a given name.
  49889. * @param name The name of the highlight layer to look for.
  49890. * @return The highlight layer if found otherwise null.
  49891. */
  49892. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49893. }
  49894. }
  49895. /**
  49896. * Glow layer options. This helps customizing the behaviour
  49897. * of the glow layer.
  49898. */
  49899. export interface IGlowLayerOptions {
  49900. /**
  49901. * Multiplication factor apply to the canvas size to compute the render target size
  49902. * used to generated the glowing objects (the smaller the faster).
  49903. */
  49904. mainTextureRatio: number;
  49905. /**
  49906. * Enforces a fixed size texture to ensure resize independant blur.
  49907. */
  49908. mainTextureFixedSize?: number;
  49909. /**
  49910. * How big is the kernel of the blur texture.
  49911. */
  49912. blurKernelSize: number;
  49913. /**
  49914. * The camera attached to the layer.
  49915. */
  49916. camera: Nullable<Camera>;
  49917. /**
  49918. * Enable MSAA by chosing the number of samples.
  49919. */
  49920. mainTextureSamples?: number;
  49921. /**
  49922. * The rendering group to draw the layer in.
  49923. */
  49924. renderingGroupId: number;
  49925. }
  49926. /**
  49927. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49928. *
  49929. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49930. * glowy meshes to your scene.
  49931. *
  49932. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49933. */
  49934. export class GlowLayer extends EffectLayer {
  49935. /**
  49936. * Effect Name of the layer.
  49937. */
  49938. static readonly EffectName: string;
  49939. /**
  49940. * The default blur kernel size used for the glow.
  49941. */
  49942. static DefaultBlurKernelSize: number;
  49943. /**
  49944. * The default texture size ratio used for the glow.
  49945. */
  49946. static DefaultTextureRatio: number;
  49947. /**
  49948. * Sets the kernel size of the blur.
  49949. */
  49950. /**
  49951. * Gets the kernel size of the blur.
  49952. */
  49953. blurKernelSize: number;
  49954. /**
  49955. * Sets the glow intensity.
  49956. */
  49957. /**
  49958. * Gets the glow intensity.
  49959. */
  49960. intensity: number;
  49961. private _options;
  49962. private _intensity;
  49963. private _horizontalBlurPostprocess1;
  49964. private _verticalBlurPostprocess1;
  49965. private _horizontalBlurPostprocess2;
  49966. private _verticalBlurPostprocess2;
  49967. private _blurTexture1;
  49968. private _blurTexture2;
  49969. private _postProcesses1;
  49970. private _postProcesses2;
  49971. private _includedOnlyMeshes;
  49972. private _excludedMeshes;
  49973. /**
  49974. * Callback used to let the user override the color selection on a per mesh basis
  49975. */
  49976. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49977. /**
  49978. * Callback used to let the user override the texture selection on a per mesh basis
  49979. */
  49980. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49981. /**
  49982. * Instantiates a new glow Layer and references it to the scene.
  49983. * @param name The name of the layer
  49984. * @param scene The scene to use the layer in
  49985. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49986. */
  49987. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49988. /**
  49989. * Get the effect name of the layer.
  49990. * @return The effect name
  49991. */
  49992. getEffectName(): string;
  49993. /**
  49994. * Create the merge effect. This is the shader use to blit the information back
  49995. * to the main canvas at the end of the scene rendering.
  49996. */
  49997. protected _createMergeEffect(): Effect;
  49998. /**
  49999. * Creates the render target textures and post processes used in the glow layer.
  50000. */
  50001. protected _createTextureAndPostProcesses(): void;
  50002. /**
  50003. * Checks for the readiness of the element composing the layer.
  50004. * @param subMesh the mesh to check for
  50005. * @param useInstances specify wether or not to use instances to render the mesh
  50006. * @param emissiveTexture the associated emissive texture used to generate the glow
  50007. * @return true if ready otherwise, false
  50008. */
  50009. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50010. /**
  50011. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50012. */
  50013. needStencil(): boolean;
  50014. /**
  50015. * Returns true if the mesh can be rendered, otherwise false.
  50016. * @param mesh The mesh to render
  50017. * @param material The material used on the mesh
  50018. * @returns true if it can be rendered otherwise false
  50019. */
  50020. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50021. /**
  50022. * Implementation specific of rendering the generating effect on the main canvas.
  50023. * @param effect The effect used to render through
  50024. */
  50025. protected _internalRender(effect: Effect): void;
  50026. /**
  50027. * Sets the required values for both the emissive texture and and the main color.
  50028. */
  50029. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50030. /**
  50031. * Returns true if the mesh should render, otherwise false.
  50032. * @param mesh The mesh to render
  50033. * @returns true if it should render otherwise false
  50034. */
  50035. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50036. /**
  50037. * Adds specific effects defines.
  50038. * @param defines The defines to add specifics to.
  50039. */
  50040. protected _addCustomEffectDefines(defines: string[]): void;
  50041. /**
  50042. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50043. * @param mesh The mesh to exclude from the glow layer
  50044. */
  50045. addExcludedMesh(mesh: Mesh): void;
  50046. /**
  50047. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50048. * @param mesh The mesh to remove
  50049. */
  50050. removeExcludedMesh(mesh: Mesh): void;
  50051. /**
  50052. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50053. * @param mesh The mesh to include in the glow layer
  50054. */
  50055. addIncludedOnlyMesh(mesh: Mesh): void;
  50056. /**
  50057. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50058. * @param mesh The mesh to remove
  50059. */
  50060. removeIncludedOnlyMesh(mesh: Mesh): void;
  50061. /**
  50062. * Determine if a given mesh will be used in the glow layer
  50063. * @param mesh The mesh to test
  50064. * @returns true if the mesh will be highlighted by the current glow layer
  50065. */
  50066. hasMesh(mesh: AbstractMesh): boolean;
  50067. /**
  50068. * Free any resources and references associated to a mesh.
  50069. * Internal use
  50070. * @param mesh The mesh to free.
  50071. * @hidden
  50072. */
  50073. _disposeMesh(mesh: Mesh): void;
  50074. /**
  50075. * Gets the class name of the effect layer
  50076. * @returns the string with the class name of the effect layer
  50077. */
  50078. getClassName(): string;
  50079. /**
  50080. * Serializes this glow layer
  50081. * @returns a serialized glow layer object
  50082. */
  50083. serialize(): any;
  50084. /**
  50085. * Creates a Glow Layer from parsed glow layer data
  50086. * @param parsedGlowLayer defines glow layer data
  50087. * @param scene defines the current scene
  50088. * @param rootUrl defines the root URL containing the glow layer information
  50089. * @returns a parsed Glow Layer
  50090. */
  50091. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50092. }
  50093. }
  50094. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50095. /** @hidden */
  50096. export var glowBlurPostProcessPixelShader: {
  50097. name: string;
  50098. shader: string;
  50099. };
  50100. }
  50101. declare module "babylonjs/Layers/highlightLayer" {
  50102. import { Observable } from "babylonjs/Misc/observable";
  50103. import { Nullable } from "babylonjs/types";
  50104. import { Camera } from "babylonjs/Cameras/camera";
  50105. import { Scene } from "babylonjs/scene";
  50106. import { Color3, Color4 } from "babylonjs/Maths/math";
  50107. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50109. import { Mesh } from "babylonjs/Meshes/mesh";
  50110. import { Effect } from "babylonjs/Materials/effect";
  50111. import { Material } from "babylonjs/Materials/material";
  50112. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50113. import "babylonjs/Shaders/glowMapMerge.fragment";
  50114. import "babylonjs/Shaders/glowMapMerge.vertex";
  50115. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50116. module "babylonjs/abstractScene" {
  50117. interface AbstractScene {
  50118. /**
  50119. * Return a the first highlight layer of the scene with a given name.
  50120. * @param name The name of the highlight layer to look for.
  50121. * @return The highlight layer if found otherwise null.
  50122. */
  50123. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50124. }
  50125. }
  50126. /**
  50127. * Highlight layer options. This helps customizing the behaviour
  50128. * of the highlight layer.
  50129. */
  50130. export interface IHighlightLayerOptions {
  50131. /**
  50132. * Multiplication factor apply to the canvas size to compute the render target size
  50133. * used to generated the glowing objects (the smaller the faster).
  50134. */
  50135. mainTextureRatio: number;
  50136. /**
  50137. * Enforces a fixed size texture to ensure resize independant blur.
  50138. */
  50139. mainTextureFixedSize?: number;
  50140. /**
  50141. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50142. * of the picture to blur (the smaller the faster).
  50143. */
  50144. blurTextureSizeRatio: number;
  50145. /**
  50146. * How big in texel of the blur texture is the vertical blur.
  50147. */
  50148. blurVerticalSize: number;
  50149. /**
  50150. * How big in texel of the blur texture is the horizontal blur.
  50151. */
  50152. blurHorizontalSize: number;
  50153. /**
  50154. * Alpha blending mode used to apply the blur. Default is combine.
  50155. */
  50156. alphaBlendingMode: number;
  50157. /**
  50158. * The camera attached to the layer.
  50159. */
  50160. camera: Nullable<Camera>;
  50161. /**
  50162. * Should we display highlight as a solid stroke?
  50163. */
  50164. isStroke?: boolean;
  50165. /**
  50166. * The rendering group to draw the layer in.
  50167. */
  50168. renderingGroupId: number;
  50169. }
  50170. /**
  50171. * The highlight layer Helps adding a glow effect around a mesh.
  50172. *
  50173. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50174. * glowy meshes to your scene.
  50175. *
  50176. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50177. */
  50178. export class HighlightLayer extends EffectLayer {
  50179. name: string;
  50180. /**
  50181. * Effect Name of the highlight layer.
  50182. */
  50183. static readonly EffectName: string;
  50184. /**
  50185. * The neutral color used during the preparation of the glow effect.
  50186. * This is black by default as the blend operation is a blend operation.
  50187. */
  50188. static NeutralColor: Color4;
  50189. /**
  50190. * Stencil value used for glowing meshes.
  50191. */
  50192. static GlowingMeshStencilReference: number;
  50193. /**
  50194. * Stencil value used for the other meshes in the scene.
  50195. */
  50196. static NormalMeshStencilReference: number;
  50197. /**
  50198. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50199. */
  50200. innerGlow: boolean;
  50201. /**
  50202. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50203. */
  50204. outerGlow: boolean;
  50205. /**
  50206. * Specifies the horizontal size of the blur.
  50207. */
  50208. /**
  50209. * Gets the horizontal size of the blur.
  50210. */
  50211. blurHorizontalSize: number;
  50212. /**
  50213. * Specifies the vertical size of the blur.
  50214. */
  50215. /**
  50216. * Gets the vertical size of the blur.
  50217. */
  50218. blurVerticalSize: number;
  50219. /**
  50220. * An event triggered when the highlight layer is being blurred.
  50221. */
  50222. onBeforeBlurObservable: Observable<HighlightLayer>;
  50223. /**
  50224. * An event triggered when the highlight layer has been blurred.
  50225. */
  50226. onAfterBlurObservable: Observable<HighlightLayer>;
  50227. private _instanceGlowingMeshStencilReference;
  50228. private _options;
  50229. private _downSamplePostprocess;
  50230. private _horizontalBlurPostprocess;
  50231. private _verticalBlurPostprocess;
  50232. private _blurTexture;
  50233. private _meshes;
  50234. private _excludedMeshes;
  50235. /**
  50236. * Instantiates a new highlight Layer and references it to the scene..
  50237. * @param name The name of the layer
  50238. * @param scene The scene to use the layer in
  50239. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50240. */
  50241. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50242. /**
  50243. * Get the effect name of the layer.
  50244. * @return The effect name
  50245. */
  50246. getEffectName(): string;
  50247. /**
  50248. * Create the merge effect. This is the shader use to blit the information back
  50249. * to the main canvas at the end of the scene rendering.
  50250. */
  50251. protected _createMergeEffect(): Effect;
  50252. /**
  50253. * Creates the render target textures and post processes used in the highlight layer.
  50254. */
  50255. protected _createTextureAndPostProcesses(): void;
  50256. /**
  50257. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50258. */
  50259. needStencil(): boolean;
  50260. /**
  50261. * Checks for the readiness of the element composing the layer.
  50262. * @param subMesh the mesh to check for
  50263. * @param useInstances specify wether or not to use instances to render the mesh
  50264. * @param emissiveTexture the associated emissive texture used to generate the glow
  50265. * @return true if ready otherwise, false
  50266. */
  50267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50268. /**
  50269. * Implementation specific of rendering the generating effect on the main canvas.
  50270. * @param effect The effect used to render through
  50271. */
  50272. protected _internalRender(effect: Effect): void;
  50273. /**
  50274. * Returns true if the layer contains information to display, otherwise false.
  50275. */
  50276. shouldRender(): boolean;
  50277. /**
  50278. * Returns true if the mesh should render, otherwise false.
  50279. * @param mesh The mesh to render
  50280. * @returns true if it should render otherwise false
  50281. */
  50282. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50283. /**
  50284. * Sets the required values for both the emissive texture and and the main color.
  50285. */
  50286. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50287. /**
  50288. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50289. * @param mesh The mesh to exclude from the highlight layer
  50290. */
  50291. addExcludedMesh(mesh: Mesh): void;
  50292. /**
  50293. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50294. * @param mesh The mesh to highlight
  50295. */
  50296. removeExcludedMesh(mesh: Mesh): void;
  50297. /**
  50298. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50299. * @param mesh mesh to test
  50300. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50301. */
  50302. hasMesh(mesh: AbstractMesh): boolean;
  50303. /**
  50304. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50305. * @param mesh The mesh to highlight
  50306. * @param color The color of the highlight
  50307. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50308. */
  50309. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50310. /**
  50311. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50312. * @param mesh The mesh to highlight
  50313. */
  50314. removeMesh(mesh: Mesh): void;
  50315. /**
  50316. * Force the stencil to the normal expected value for none glowing parts
  50317. */
  50318. private _defaultStencilReference;
  50319. /**
  50320. * Free any resources and references associated to a mesh.
  50321. * Internal use
  50322. * @param mesh The mesh to free.
  50323. * @hidden
  50324. */
  50325. _disposeMesh(mesh: Mesh): void;
  50326. /**
  50327. * Dispose the highlight layer and free resources.
  50328. */
  50329. dispose(): void;
  50330. /**
  50331. * Gets the class name of the effect layer
  50332. * @returns the string with the class name of the effect layer
  50333. */
  50334. getClassName(): string;
  50335. /**
  50336. * Serializes this Highlight layer
  50337. * @returns a serialized Highlight layer object
  50338. */
  50339. serialize(): any;
  50340. /**
  50341. * Creates a Highlight layer from parsed Highlight layer data
  50342. * @param parsedHightlightLayer defines the Highlight layer data
  50343. * @param scene defines the current scene
  50344. * @param rootUrl defines the root URL containing the Highlight layer information
  50345. * @returns a parsed Highlight layer
  50346. */
  50347. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50348. }
  50349. }
  50350. declare module "babylonjs/Layers/layerSceneComponent" {
  50351. import { Scene } from "babylonjs/scene";
  50352. import { ISceneComponent } from "babylonjs/sceneComponent";
  50353. import { Layer } from "babylonjs/Layers/layer";
  50354. import { AbstractScene } from "babylonjs/abstractScene";
  50355. module "babylonjs/abstractScene" {
  50356. interface AbstractScene {
  50357. /**
  50358. * The list of layers (background and foreground) of the scene
  50359. */
  50360. layers: Array<Layer>;
  50361. }
  50362. }
  50363. /**
  50364. * Defines the layer scene component responsible to manage any layers
  50365. * in a given scene.
  50366. */
  50367. export class LayerSceneComponent implements ISceneComponent {
  50368. /**
  50369. * The component name helpfull to identify the component in the list of scene components.
  50370. */
  50371. readonly name: string;
  50372. /**
  50373. * The scene the component belongs to.
  50374. */
  50375. scene: Scene;
  50376. private _engine;
  50377. /**
  50378. * Creates a new instance of the component for the given scene
  50379. * @param scene Defines the scene to register the component in
  50380. */
  50381. constructor(scene: Scene);
  50382. /**
  50383. * Registers the component in a given scene
  50384. */
  50385. register(): void;
  50386. /**
  50387. * Rebuilds the elements related to this component in case of
  50388. * context lost for instance.
  50389. */
  50390. rebuild(): void;
  50391. /**
  50392. * Disposes the component and the associated ressources.
  50393. */
  50394. dispose(): void;
  50395. private _draw;
  50396. private _drawCameraPredicate;
  50397. private _drawCameraBackground;
  50398. private _drawCameraForeground;
  50399. private _drawRenderTargetPredicate;
  50400. private _drawRenderTargetBackground;
  50401. private _drawRenderTargetForeground;
  50402. /**
  50403. * Adds all the elements from the container to the scene
  50404. * @param container the container holding the elements
  50405. */
  50406. addFromContainer(container: AbstractScene): void;
  50407. /**
  50408. * Removes all the elements in the container from the scene
  50409. * @param container contains the elements to remove
  50410. * @param dispose if the removed element should be disposed (default: false)
  50411. */
  50412. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50413. }
  50414. }
  50415. declare module "babylonjs/Shaders/layer.fragment" {
  50416. /** @hidden */
  50417. export var layerPixelShader: {
  50418. name: string;
  50419. shader: string;
  50420. };
  50421. }
  50422. declare module "babylonjs/Shaders/layer.vertex" {
  50423. /** @hidden */
  50424. export var layerVertexShader: {
  50425. name: string;
  50426. shader: string;
  50427. };
  50428. }
  50429. declare module "babylonjs/Layers/layer" {
  50430. import { Observable } from "babylonjs/Misc/observable";
  50431. import { Nullable } from "babylonjs/types";
  50432. import { Scene } from "babylonjs/scene";
  50433. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50434. import { Texture } from "babylonjs/Materials/Textures/texture";
  50435. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50436. import "babylonjs/Shaders/layer.fragment";
  50437. import "babylonjs/Shaders/layer.vertex";
  50438. /**
  50439. * This represents a full screen 2d layer.
  50440. * This can be useful to display a picture in the background of your scene for instance.
  50441. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50442. */
  50443. export class Layer {
  50444. /**
  50445. * Define the name of the layer.
  50446. */
  50447. name: string;
  50448. /**
  50449. * Define the texture the layer should display.
  50450. */
  50451. texture: Nullable<Texture>;
  50452. /**
  50453. * Is the layer in background or foreground.
  50454. */
  50455. isBackground: boolean;
  50456. /**
  50457. * Define the color of the layer (instead of texture).
  50458. */
  50459. color: Color4;
  50460. /**
  50461. * Define the scale of the layer in order to zoom in out of the texture.
  50462. */
  50463. scale: Vector2;
  50464. /**
  50465. * Define an offset for the layer in order to shift the texture.
  50466. */
  50467. offset: Vector2;
  50468. /**
  50469. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50470. */
  50471. alphaBlendingMode: number;
  50472. /**
  50473. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50474. * Alpha test will not mix with the background color in case of transparency.
  50475. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50476. */
  50477. alphaTest: boolean;
  50478. /**
  50479. * Define a mask to restrict the layer to only some of the scene cameras.
  50480. */
  50481. layerMask: number;
  50482. /**
  50483. * Define the list of render target the layer is visible into.
  50484. */
  50485. renderTargetTextures: RenderTargetTexture[];
  50486. /**
  50487. * Define if the layer is only used in renderTarget or if it also
  50488. * renders in the main frame buffer of the canvas.
  50489. */
  50490. renderOnlyInRenderTargetTextures: boolean;
  50491. private _scene;
  50492. private _vertexBuffers;
  50493. private _indexBuffer;
  50494. private _effect;
  50495. private _alphaTestEffect;
  50496. /**
  50497. * An event triggered when the layer is disposed.
  50498. */
  50499. onDisposeObservable: Observable<Layer>;
  50500. private _onDisposeObserver;
  50501. /**
  50502. * Back compatibility with callback before the onDisposeObservable existed.
  50503. * The set callback will be triggered when the layer has been disposed.
  50504. */
  50505. onDispose: () => void;
  50506. /**
  50507. * An event triggered before rendering the scene
  50508. */
  50509. onBeforeRenderObservable: Observable<Layer>;
  50510. private _onBeforeRenderObserver;
  50511. /**
  50512. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50513. * The set callback will be triggered just before rendering the layer.
  50514. */
  50515. onBeforeRender: () => void;
  50516. /**
  50517. * An event triggered after rendering the scene
  50518. */
  50519. onAfterRenderObservable: Observable<Layer>;
  50520. private _onAfterRenderObserver;
  50521. /**
  50522. * Back compatibility with callback before the onAfterRenderObservable existed.
  50523. * The set callback will be triggered just after rendering the layer.
  50524. */
  50525. onAfterRender: () => void;
  50526. /**
  50527. * Instantiates a new layer.
  50528. * This represents a full screen 2d layer.
  50529. * This can be useful to display a picture in the background of your scene for instance.
  50530. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50531. * @param name Define the name of the layer in the scene
  50532. * @param imgUrl Define the url of the texture to display in the layer
  50533. * @param scene Define the scene the layer belongs to
  50534. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50535. * @param color Defines a color for the layer
  50536. */
  50537. constructor(
  50538. /**
  50539. * Define the name of the layer.
  50540. */
  50541. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50542. private _createIndexBuffer;
  50543. /** @hidden */
  50544. _rebuild(): void;
  50545. /**
  50546. * Renders the layer in the scene.
  50547. */
  50548. render(): void;
  50549. /**
  50550. * Disposes and releases the associated ressources.
  50551. */
  50552. dispose(): void;
  50553. }
  50554. }
  50555. declare module "babylonjs/Layers/index" {
  50556. export * from "babylonjs/Layers/effectLayer";
  50557. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50558. export * from "babylonjs/Layers/glowLayer";
  50559. export * from "babylonjs/Layers/highlightLayer";
  50560. export * from "babylonjs/Layers/layer";
  50561. export * from "babylonjs/Layers/layerSceneComponent";
  50562. }
  50563. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50564. /** @hidden */
  50565. export var lensFlarePixelShader: {
  50566. name: string;
  50567. shader: string;
  50568. };
  50569. }
  50570. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50571. /** @hidden */
  50572. export var lensFlareVertexShader: {
  50573. name: string;
  50574. shader: string;
  50575. };
  50576. }
  50577. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50578. import { Scene } from "babylonjs/scene";
  50579. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50581. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50582. import "babylonjs/Shaders/lensFlare.fragment";
  50583. import "babylonjs/Shaders/lensFlare.vertex";
  50584. /**
  50585. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50586. * It is usually composed of several `lensFlare`.
  50587. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50588. */
  50589. export class LensFlareSystem {
  50590. /**
  50591. * Define the name of the lens flare system
  50592. */
  50593. name: string;
  50594. /**
  50595. * List of lens flares used in this system.
  50596. */
  50597. lensFlares: LensFlare[];
  50598. /**
  50599. * Define a limit from the border the lens flare can be visible.
  50600. */
  50601. borderLimit: number;
  50602. /**
  50603. * Define a viewport border we do not want to see the lens flare in.
  50604. */
  50605. viewportBorder: number;
  50606. /**
  50607. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50608. */
  50609. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50610. /**
  50611. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50612. */
  50613. layerMask: number;
  50614. /**
  50615. * Define the id of the lens flare system in the scene.
  50616. * (equal to name by default)
  50617. */
  50618. id: string;
  50619. private _scene;
  50620. private _emitter;
  50621. private _vertexBuffers;
  50622. private _indexBuffer;
  50623. private _effect;
  50624. private _positionX;
  50625. private _positionY;
  50626. private _isEnabled;
  50627. /** @hidden */
  50628. static _SceneComponentInitialization: (scene: Scene) => void;
  50629. /**
  50630. * Instantiates a lens flare system.
  50631. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50632. * It is usually composed of several `lensFlare`.
  50633. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50634. * @param name Define the name of the lens flare system in the scene
  50635. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50636. * @param scene Define the scene the lens flare system belongs to
  50637. */
  50638. constructor(
  50639. /**
  50640. * Define the name of the lens flare system
  50641. */
  50642. name: string, emitter: any, scene: Scene);
  50643. /**
  50644. * Define if the lens flare system is enabled.
  50645. */
  50646. isEnabled: boolean;
  50647. /**
  50648. * Get the scene the effects belongs to.
  50649. * @returns the scene holding the lens flare system
  50650. */
  50651. getScene(): Scene;
  50652. /**
  50653. * Get the emitter of the lens flare system.
  50654. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50655. * @returns the emitter of the lens flare system
  50656. */
  50657. getEmitter(): any;
  50658. /**
  50659. * Set the emitter of the lens flare system.
  50660. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50661. * @param newEmitter Define the new emitter of the system
  50662. */
  50663. setEmitter(newEmitter: any): void;
  50664. /**
  50665. * Get the lens flare system emitter position.
  50666. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50667. * @returns the position
  50668. */
  50669. getEmitterPosition(): Vector3;
  50670. /**
  50671. * @hidden
  50672. */
  50673. computeEffectivePosition(globalViewport: Viewport): boolean;
  50674. /** @hidden */
  50675. _isVisible(): boolean;
  50676. /**
  50677. * @hidden
  50678. */
  50679. render(): boolean;
  50680. /**
  50681. * Dispose and release the lens flare with its associated resources.
  50682. */
  50683. dispose(): void;
  50684. /**
  50685. * Parse a lens flare system from a JSON repressentation
  50686. * @param parsedLensFlareSystem Define the JSON to parse
  50687. * @param scene Define the scene the parsed system should be instantiated in
  50688. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50689. * @returns the parsed system
  50690. */
  50691. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50692. /**
  50693. * Serialize the current Lens Flare System into a JSON representation.
  50694. * @returns the serialized JSON
  50695. */
  50696. serialize(): any;
  50697. }
  50698. }
  50699. declare module "babylonjs/LensFlares/lensFlare" {
  50700. import { Nullable } from "babylonjs/types";
  50701. import { Color3 } from "babylonjs/Maths/math";
  50702. import { Texture } from "babylonjs/Materials/Textures/texture";
  50703. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50704. /**
  50705. * This represents one of the lens effect in a `lensFlareSystem`.
  50706. * It controls one of the indiviual texture used in the effect.
  50707. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50708. */
  50709. export class LensFlare {
  50710. /**
  50711. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50712. */
  50713. size: number;
  50714. /**
  50715. * 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.
  50716. */
  50717. position: number;
  50718. /**
  50719. * Define the lens color.
  50720. */
  50721. color: Color3;
  50722. /**
  50723. * Define the lens texture.
  50724. */
  50725. texture: Nullable<Texture>;
  50726. /**
  50727. * Define the alpha mode to render this particular lens.
  50728. */
  50729. alphaMode: number;
  50730. private _system;
  50731. /**
  50732. * Creates a new Lens Flare.
  50733. * This represents one of the lens effect in a `lensFlareSystem`.
  50734. * It controls one of the indiviual texture used in the effect.
  50735. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50736. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50737. * @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.
  50738. * @param color Define the lens color
  50739. * @param imgUrl Define the lens texture url
  50740. * @param system Define the `lensFlareSystem` this flare is part of
  50741. * @returns The newly created Lens Flare
  50742. */
  50743. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50744. /**
  50745. * Instantiates a new Lens Flare.
  50746. * This represents one of the lens effect in a `lensFlareSystem`.
  50747. * It controls one of the indiviual texture used in the effect.
  50748. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50749. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50750. * @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.
  50751. * @param color Define the lens color
  50752. * @param imgUrl Define the lens texture url
  50753. * @param system Define the `lensFlareSystem` this flare is part of
  50754. */
  50755. constructor(
  50756. /**
  50757. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50758. */
  50759. size: number,
  50760. /**
  50761. * 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.
  50762. */
  50763. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50764. /**
  50765. * Dispose and release the lens flare with its associated resources.
  50766. */
  50767. dispose(): void;
  50768. }
  50769. }
  50770. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50771. import { Nullable } from "babylonjs/types";
  50772. import { Scene } from "babylonjs/scene";
  50773. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50774. import { AbstractScene } from "babylonjs/abstractScene";
  50775. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50776. module "babylonjs/abstractScene" {
  50777. interface AbstractScene {
  50778. /**
  50779. * The list of lens flare system added to the scene
  50780. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50781. */
  50782. lensFlareSystems: Array<LensFlareSystem>;
  50783. /**
  50784. * Removes the given lens flare system from this scene.
  50785. * @param toRemove The lens flare system to remove
  50786. * @returns The index of the removed lens flare system
  50787. */
  50788. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50789. /**
  50790. * Adds the given lens flare system to this scene
  50791. * @param newLensFlareSystem The lens flare system to add
  50792. */
  50793. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50794. /**
  50795. * Gets a lens flare system using its name
  50796. * @param name defines the name to look for
  50797. * @returns the lens flare system or null if not found
  50798. */
  50799. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50800. /**
  50801. * Gets a lens flare system using its id
  50802. * @param id defines the id to look for
  50803. * @returns the lens flare system or null if not found
  50804. */
  50805. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50806. }
  50807. }
  50808. /**
  50809. * Defines the lens flare scene component responsible to manage any lens flares
  50810. * in a given scene.
  50811. */
  50812. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50813. /**
  50814. * The component name helpfull to identify the component in the list of scene components.
  50815. */
  50816. readonly name: string;
  50817. /**
  50818. * The scene the component belongs to.
  50819. */
  50820. scene: Scene;
  50821. /**
  50822. * Creates a new instance of the component for the given scene
  50823. * @param scene Defines the scene to register the component in
  50824. */
  50825. constructor(scene: Scene);
  50826. /**
  50827. * Registers the component in a given scene
  50828. */
  50829. register(): void;
  50830. /**
  50831. * Rebuilds the elements related to this component in case of
  50832. * context lost for instance.
  50833. */
  50834. rebuild(): void;
  50835. /**
  50836. * Adds all the elements from the container to the scene
  50837. * @param container the container holding the elements
  50838. */
  50839. addFromContainer(container: AbstractScene): void;
  50840. /**
  50841. * Removes all the elements in the container from the scene
  50842. * @param container contains the elements to remove
  50843. * @param dispose if the removed element should be disposed (default: false)
  50844. */
  50845. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50846. /**
  50847. * Serializes the component data to the specified json object
  50848. * @param serializationObject The object to serialize to
  50849. */
  50850. serialize(serializationObject: any): void;
  50851. /**
  50852. * Disposes the component and the associated ressources.
  50853. */
  50854. dispose(): void;
  50855. private _draw;
  50856. }
  50857. }
  50858. declare module "babylonjs/LensFlares/index" {
  50859. export * from "babylonjs/LensFlares/lensFlare";
  50860. export * from "babylonjs/LensFlares/lensFlareSystem";
  50861. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50862. }
  50863. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50864. import { Scene } from "babylonjs/scene";
  50865. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50866. import { AbstractScene } from "babylonjs/abstractScene";
  50867. /**
  50868. * Defines the shadow generator component responsible to manage any shadow generators
  50869. * in a given scene.
  50870. */
  50871. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50872. /**
  50873. * The component name helpfull to identify the component in the list of scene components.
  50874. */
  50875. readonly name: string;
  50876. /**
  50877. * The scene the component belongs to.
  50878. */
  50879. scene: Scene;
  50880. /**
  50881. * Creates a new instance of the component for the given scene
  50882. * @param scene Defines the scene to register the component in
  50883. */
  50884. constructor(scene: Scene);
  50885. /**
  50886. * Registers the component in a given scene
  50887. */
  50888. register(): void;
  50889. /**
  50890. * Rebuilds the elements related to this component in case of
  50891. * context lost for instance.
  50892. */
  50893. rebuild(): void;
  50894. /**
  50895. * Serializes the component data to the specified json object
  50896. * @param serializationObject The object to serialize to
  50897. */
  50898. serialize(serializationObject: any): void;
  50899. /**
  50900. * Adds all the elements from the container to the scene
  50901. * @param container the container holding the elements
  50902. */
  50903. addFromContainer(container: AbstractScene): void;
  50904. /**
  50905. * Removes all the elements in the container from the scene
  50906. * @param container contains the elements to remove
  50907. * @param dispose if the removed element should be disposed (default: false)
  50908. */
  50909. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50910. /**
  50911. * Rebuilds the elements related to this component in case of
  50912. * context lost for instance.
  50913. */
  50914. dispose(): void;
  50915. private _gatherRenderTargets;
  50916. }
  50917. }
  50918. declare module "babylonjs/Lights/Shadows/index" {
  50919. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50920. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50921. }
  50922. declare module "babylonjs/Lights/pointLight" {
  50923. import { Scene } from "babylonjs/scene";
  50924. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50926. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50927. import { Effect } from "babylonjs/Materials/effect";
  50928. /**
  50929. * A point light is a light defined by an unique point in world space.
  50930. * The light is emitted in every direction from this point.
  50931. * A good example of a point light is a standard light bulb.
  50932. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50933. */
  50934. export class PointLight extends ShadowLight {
  50935. private _shadowAngle;
  50936. /**
  50937. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50938. * This specifies what angle the shadow will use to be created.
  50939. *
  50940. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50941. */
  50942. /**
  50943. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50944. * This specifies what angle the shadow will use to be created.
  50945. *
  50946. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50947. */
  50948. shadowAngle: number;
  50949. /**
  50950. * Gets the direction if it has been set.
  50951. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50952. */
  50953. /**
  50954. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50955. */
  50956. direction: Vector3;
  50957. /**
  50958. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50959. * A PointLight emits the light in every direction.
  50960. * It can cast shadows.
  50961. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50962. * ```javascript
  50963. * var pointLight = new PointLight("pl", camera.position, scene);
  50964. * ```
  50965. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50966. * @param name The light friendly name
  50967. * @param position The position of the point light in the scene
  50968. * @param scene The scene the lights belongs to
  50969. */
  50970. constructor(name: string, position: Vector3, scene: Scene);
  50971. /**
  50972. * Returns the string "PointLight"
  50973. * @returns the class name
  50974. */
  50975. getClassName(): string;
  50976. /**
  50977. * Returns the integer 0.
  50978. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50979. */
  50980. getTypeID(): number;
  50981. /**
  50982. * Specifies wether or not the shadowmap should be a cube texture.
  50983. * @returns true if the shadowmap needs to be a cube texture.
  50984. */
  50985. needCube(): boolean;
  50986. /**
  50987. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50988. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50989. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50990. */
  50991. getShadowDirection(faceIndex?: number): Vector3;
  50992. /**
  50993. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50994. * - fov = PI / 2
  50995. * - aspect ratio : 1.0
  50996. * - z-near and far equal to the active camera minZ and maxZ.
  50997. * Returns the PointLight.
  50998. */
  50999. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51000. protected _buildUniformLayout(): void;
  51001. /**
  51002. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51003. * @param effect The effect to update
  51004. * @param lightIndex The index of the light in the effect to update
  51005. * @returns The point light
  51006. */
  51007. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51008. /**
  51009. * Prepares the list of defines specific to the light type.
  51010. * @param defines the list of defines
  51011. * @param lightIndex defines the index of the light for the effect
  51012. */
  51013. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51014. }
  51015. }
  51016. declare module "babylonjs/Lights/index" {
  51017. export * from "babylonjs/Lights/light";
  51018. export * from "babylonjs/Lights/shadowLight";
  51019. export * from "babylonjs/Lights/Shadows/index";
  51020. export * from "babylonjs/Lights/directionalLight";
  51021. export * from "babylonjs/Lights/hemisphericLight";
  51022. export * from "babylonjs/Lights/pointLight";
  51023. export * from "babylonjs/Lights/spotLight";
  51024. }
  51025. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51026. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51027. /**
  51028. * Header information of HDR texture files.
  51029. */
  51030. export interface HDRInfo {
  51031. /**
  51032. * The height of the texture in pixels.
  51033. */
  51034. height: number;
  51035. /**
  51036. * The width of the texture in pixels.
  51037. */
  51038. width: number;
  51039. /**
  51040. * The index of the beginning of the data in the binary file.
  51041. */
  51042. dataPosition: number;
  51043. }
  51044. /**
  51045. * This groups tools to convert HDR texture to native colors array.
  51046. */
  51047. export class HDRTools {
  51048. private static Ldexp;
  51049. private static Rgbe2float;
  51050. private static readStringLine;
  51051. /**
  51052. * Reads header information from an RGBE texture stored in a native array.
  51053. * More information on this format are available here:
  51054. * https://en.wikipedia.org/wiki/RGBE_image_format
  51055. *
  51056. * @param uint8array The binary file stored in native array.
  51057. * @return The header information.
  51058. */
  51059. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51060. /**
  51061. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51062. * This RGBE texture needs to store the information as a panorama.
  51063. *
  51064. * More information on this format are available here:
  51065. * https://en.wikipedia.org/wiki/RGBE_image_format
  51066. *
  51067. * @param buffer The binary file stored in an array buffer.
  51068. * @param size The expected size of the extracted cubemap.
  51069. * @return The Cube Map information.
  51070. */
  51071. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51072. /**
  51073. * Returns the pixels data extracted from an RGBE texture.
  51074. * This pixels will be stored left to right up to down in the R G B order in one array.
  51075. *
  51076. * More information on this format are available here:
  51077. * https://en.wikipedia.org/wiki/RGBE_image_format
  51078. *
  51079. * @param uint8array The binary file stored in an array buffer.
  51080. * @param hdrInfo The header information of the file.
  51081. * @return The pixels data in RGB right to left up to down order.
  51082. */
  51083. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51084. private static RGBE_ReadPixels_RLE;
  51085. }
  51086. }
  51087. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51088. import { Nullable } from "babylonjs/types";
  51089. import { Scene } from "babylonjs/scene";
  51090. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  51091. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51092. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51093. /**
  51094. * This represents a texture coming from an HDR input.
  51095. *
  51096. * The only supported format is currently panorama picture stored in RGBE format.
  51097. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51098. */
  51099. export class HDRCubeTexture extends BaseTexture {
  51100. private static _facesMapping;
  51101. private _generateHarmonics;
  51102. private _noMipmap;
  51103. private _textureMatrix;
  51104. private _size;
  51105. private _onLoad;
  51106. private _onError;
  51107. /**
  51108. * The texture URL.
  51109. */
  51110. url: string;
  51111. /**
  51112. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51113. */
  51114. coordinatesMode: number;
  51115. protected _isBlocking: boolean;
  51116. /**
  51117. * Sets wether or not the texture is blocking during loading.
  51118. */
  51119. /**
  51120. * Gets wether or not the texture is blocking during loading.
  51121. */
  51122. isBlocking: boolean;
  51123. protected _rotationY: number;
  51124. /**
  51125. * Sets texture matrix rotation angle around Y axis in radians.
  51126. */
  51127. /**
  51128. * Gets texture matrix rotation angle around Y axis radians.
  51129. */
  51130. rotationY: number;
  51131. /**
  51132. * Gets or sets the center of the bounding box associated with the cube texture
  51133. * It must define where the camera used to render the texture was set
  51134. */
  51135. boundingBoxPosition: Vector3;
  51136. private _boundingBoxSize;
  51137. /**
  51138. * Gets or sets the size of the bounding box associated with the cube texture
  51139. * When defined, the cubemap will switch to local mode
  51140. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51141. * @example https://www.babylonjs-playground.com/#RNASML
  51142. */
  51143. boundingBoxSize: Vector3;
  51144. /**
  51145. * Instantiates an HDRTexture from the following parameters.
  51146. *
  51147. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51148. * @param scene The scene the texture will be used in
  51149. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51150. * @param noMipmap Forces to not generate the mipmap if true
  51151. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51152. * @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)
  51153. * @param reserved Reserved flag for internal use.
  51154. */
  51155. 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>);
  51156. /**
  51157. * Get the current class name of the texture useful for serialization or dynamic coding.
  51158. * @returns "HDRCubeTexture"
  51159. */
  51160. getClassName(): string;
  51161. /**
  51162. * Occurs when the file is raw .hdr file.
  51163. */
  51164. private loadTexture;
  51165. clone(): HDRCubeTexture;
  51166. delayLoad(): void;
  51167. /**
  51168. * Get the texture reflection matrix used to rotate/transform the reflection.
  51169. * @returns the reflection matrix
  51170. */
  51171. getReflectionTextureMatrix(): Matrix;
  51172. /**
  51173. * Set the texture reflection matrix used to rotate/transform the reflection.
  51174. * @param value Define the reflection matrix to set
  51175. */
  51176. setReflectionTextureMatrix(value: Matrix): void;
  51177. /**
  51178. * Parses a JSON representation of an HDR Texture in order to create the texture
  51179. * @param parsedTexture Define the JSON representation
  51180. * @param scene Define the scene the texture should be created in
  51181. * @param rootUrl Define the root url in case we need to load relative dependencies
  51182. * @returns the newly created texture after parsing
  51183. */
  51184. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51185. serialize(): any;
  51186. }
  51187. }
  51188. declare module "babylonjs/Physics/physicsEngine" {
  51189. import { Nullable } from "babylonjs/types";
  51190. import { Vector3 } from "babylonjs/Maths/math";
  51191. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51192. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51193. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51194. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51195. /**
  51196. * Class used to control physics engine
  51197. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51198. */
  51199. export class PhysicsEngine implements IPhysicsEngine {
  51200. private _physicsPlugin;
  51201. /**
  51202. * Global value used to control the smallest number supported by the simulation
  51203. */
  51204. static Epsilon: number;
  51205. private _impostors;
  51206. private _joints;
  51207. /**
  51208. * Gets the gravity vector used by the simulation
  51209. */
  51210. gravity: Vector3;
  51211. /**
  51212. * Factory used to create the default physics plugin.
  51213. * @returns The default physics plugin
  51214. */
  51215. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51216. /**
  51217. * Creates a new Physics Engine
  51218. * @param gravity defines the gravity vector used by the simulation
  51219. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51220. */
  51221. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51222. /**
  51223. * Sets the gravity vector used by the simulation
  51224. * @param gravity defines the gravity vector to use
  51225. */
  51226. setGravity(gravity: Vector3): void;
  51227. /**
  51228. * Set the time step of the physics engine.
  51229. * Default is 1/60.
  51230. * To slow it down, enter 1/600 for example.
  51231. * To speed it up, 1/30
  51232. * @param newTimeStep defines the new timestep to apply to this world.
  51233. */
  51234. setTimeStep(newTimeStep?: number): void;
  51235. /**
  51236. * Get the time step of the physics engine.
  51237. * @returns the current time step
  51238. */
  51239. getTimeStep(): number;
  51240. /**
  51241. * Release all resources
  51242. */
  51243. dispose(): void;
  51244. /**
  51245. * Gets the name of the current physics plugin
  51246. * @returns the name of the plugin
  51247. */
  51248. getPhysicsPluginName(): string;
  51249. /**
  51250. * Adding a new impostor for the impostor tracking.
  51251. * This will be done by the impostor itself.
  51252. * @param impostor the impostor to add
  51253. */
  51254. addImpostor(impostor: PhysicsImpostor): void;
  51255. /**
  51256. * Remove an impostor from the engine.
  51257. * This impostor and its mesh will not longer be updated by the physics engine.
  51258. * @param impostor the impostor to remove
  51259. */
  51260. removeImpostor(impostor: PhysicsImpostor): void;
  51261. /**
  51262. * Add a joint to the physics engine
  51263. * @param mainImpostor defines the main impostor to which the joint is added.
  51264. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51265. * @param joint defines the joint that will connect both impostors.
  51266. */
  51267. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51268. /**
  51269. * Removes a joint from the simulation
  51270. * @param mainImpostor defines the impostor used with the joint
  51271. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51272. * @param joint defines the joint to remove
  51273. */
  51274. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51275. /**
  51276. * Called by the scene. No need to call it.
  51277. * @param delta defines the timespam between frames
  51278. */
  51279. _step(delta: number): void;
  51280. /**
  51281. * Gets the current plugin used to run the simulation
  51282. * @returns current plugin
  51283. */
  51284. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51285. /**
  51286. * Gets the list of physic impostors
  51287. * @returns an array of PhysicsImpostor
  51288. */
  51289. getImpostors(): Array<PhysicsImpostor>;
  51290. /**
  51291. * Gets the impostor for a physics enabled object
  51292. * @param object defines the object impersonated by the impostor
  51293. * @returns the PhysicsImpostor or null if not found
  51294. */
  51295. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51296. /**
  51297. * Gets the impostor for a physics body object
  51298. * @param body defines physics body used by the impostor
  51299. * @returns the PhysicsImpostor or null if not found
  51300. */
  51301. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51302. /**
  51303. * Does a raycast in the physics world
  51304. * @param from when should the ray start?
  51305. * @param to when should the ray end?
  51306. * @returns PhysicsRaycastResult
  51307. */
  51308. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51309. }
  51310. }
  51311. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51312. import { Nullable } from "babylonjs/types";
  51313. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51315. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51316. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51317. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51318. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51319. /** @hidden */
  51320. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51321. private _useDeltaForWorldStep;
  51322. world: any;
  51323. name: string;
  51324. private _physicsMaterials;
  51325. private _fixedTimeStep;
  51326. private _cannonRaycastResult;
  51327. private _raycastResult;
  51328. private _physicsBodysToRemoveAfterStep;
  51329. BJSCANNON: any;
  51330. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51331. setGravity(gravity: Vector3): void;
  51332. setTimeStep(timeStep: number): void;
  51333. getTimeStep(): number;
  51334. executeStep(delta: number): void;
  51335. private _removeMarkedPhysicsBodiesFromWorld;
  51336. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51337. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51338. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51339. private _processChildMeshes;
  51340. removePhysicsBody(impostor: PhysicsImpostor): void;
  51341. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51342. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51343. private _addMaterial;
  51344. private _checkWithEpsilon;
  51345. private _createShape;
  51346. private _createHeightmap;
  51347. private _minus90X;
  51348. private _plus90X;
  51349. private _tmpPosition;
  51350. private _tmpDeltaPosition;
  51351. private _tmpUnityRotation;
  51352. private _updatePhysicsBodyTransformation;
  51353. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51354. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51355. isSupported(): boolean;
  51356. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51357. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51358. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51359. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51360. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51361. getBodyMass(impostor: PhysicsImpostor): number;
  51362. getBodyFriction(impostor: PhysicsImpostor): number;
  51363. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51364. getBodyRestitution(impostor: PhysicsImpostor): number;
  51365. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51366. sleepBody(impostor: PhysicsImpostor): void;
  51367. wakeUpBody(impostor: PhysicsImpostor): void;
  51368. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51369. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51370. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51371. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51372. getRadius(impostor: PhysicsImpostor): number;
  51373. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51374. dispose(): void;
  51375. private _extendNamespace;
  51376. /**
  51377. * Does a raycast in the physics world
  51378. * @param from when should the ray start?
  51379. * @param to when should the ray end?
  51380. * @returns PhysicsRaycastResult
  51381. */
  51382. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51383. }
  51384. }
  51385. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51386. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51387. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51388. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51390. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51391. import { Nullable } from "babylonjs/types";
  51392. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51393. /** @hidden */
  51394. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51395. world: any;
  51396. name: string;
  51397. BJSOIMO: any;
  51398. private _raycastResult;
  51399. constructor(iterations?: number, oimoInjection?: any);
  51400. setGravity(gravity: Vector3): void;
  51401. setTimeStep(timeStep: number): void;
  51402. getTimeStep(): number;
  51403. private _tmpImpostorsArray;
  51404. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51405. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51406. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51407. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51408. private _tmpPositionVector;
  51409. removePhysicsBody(impostor: PhysicsImpostor): void;
  51410. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51411. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51412. isSupported(): boolean;
  51413. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51414. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51415. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51416. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51417. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51418. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51419. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51420. getBodyMass(impostor: PhysicsImpostor): number;
  51421. getBodyFriction(impostor: PhysicsImpostor): number;
  51422. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51423. getBodyRestitution(impostor: PhysicsImpostor): number;
  51424. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51425. sleepBody(impostor: PhysicsImpostor): void;
  51426. wakeUpBody(impostor: PhysicsImpostor): void;
  51427. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51428. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51429. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51430. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51431. getRadius(impostor: PhysicsImpostor): number;
  51432. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51433. dispose(): void;
  51434. /**
  51435. * Does a raycast in the physics world
  51436. * @param from when should the ray start?
  51437. * @param to when should the ray end?
  51438. * @returns PhysicsRaycastResult
  51439. */
  51440. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51441. }
  51442. }
  51443. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51444. import { Nullable } from "babylonjs/types";
  51445. import { Scene } from "babylonjs/scene";
  51446. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51447. import { Mesh } from "babylonjs/Meshes/mesh";
  51448. /**
  51449. * Class containing static functions to help procedurally build meshes
  51450. */
  51451. export class RibbonBuilder {
  51452. /**
  51453. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51454. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51455. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51456. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51457. * * 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
  51458. * * 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
  51459. * * 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
  51460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51461. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51462. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51463. * * 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
  51464. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51465. * * 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
  51466. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51468. * @param name defines the name of the mesh
  51469. * @param options defines the options used to create the mesh
  51470. * @param scene defines the hosting scene
  51471. * @returns the ribbon mesh
  51472. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51473. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51474. */
  51475. static CreateRibbon(name: string, options: {
  51476. pathArray: Vector3[][];
  51477. closeArray?: boolean;
  51478. closePath?: boolean;
  51479. offset?: number;
  51480. updatable?: boolean;
  51481. sideOrientation?: number;
  51482. frontUVs?: Vector4;
  51483. backUVs?: Vector4;
  51484. instance?: Mesh;
  51485. invertUV?: boolean;
  51486. uvs?: Vector2[];
  51487. colors?: Color4[];
  51488. }, scene?: Nullable<Scene>): Mesh;
  51489. }
  51490. }
  51491. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51492. import { Nullable } from "babylonjs/types";
  51493. import { Scene } from "babylonjs/scene";
  51494. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51495. import { Mesh } from "babylonjs/Meshes/mesh";
  51496. /**
  51497. * Class containing static functions to help procedurally build meshes
  51498. */
  51499. export class ShapeBuilder {
  51500. /**
  51501. * 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.
  51502. * * 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.
  51503. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51504. * * 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.
  51505. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51506. * * 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
  51507. * * 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
  51508. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51511. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51513. * @param name defines the name of the mesh
  51514. * @param options defines the options used to create the mesh
  51515. * @param scene defines the hosting scene
  51516. * @returns the extruded shape mesh
  51517. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51519. */
  51520. static ExtrudeShape(name: string, options: {
  51521. shape: Vector3[];
  51522. path: Vector3[];
  51523. scale?: number;
  51524. rotation?: number;
  51525. cap?: number;
  51526. updatable?: boolean;
  51527. sideOrientation?: number;
  51528. frontUVs?: Vector4;
  51529. backUVs?: Vector4;
  51530. instance?: Mesh;
  51531. invertUV?: boolean;
  51532. }, scene?: Nullable<Scene>): Mesh;
  51533. /**
  51534. * Creates an custom extruded shape mesh.
  51535. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51536. * * 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.
  51537. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51538. * * 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
  51539. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51540. * * 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
  51541. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51542. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51543. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51544. * * 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
  51545. * * 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
  51546. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51549. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51551. * @param name defines the name of the mesh
  51552. * @param options defines the options used to create the mesh
  51553. * @param scene defines the hosting scene
  51554. * @returns the custom extruded shape mesh
  51555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51556. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51557. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51558. */
  51559. static ExtrudeShapeCustom(name: string, options: {
  51560. shape: Vector3[];
  51561. path: Vector3[];
  51562. scaleFunction?: any;
  51563. rotationFunction?: any;
  51564. ribbonCloseArray?: boolean;
  51565. ribbonClosePath?: boolean;
  51566. cap?: number;
  51567. updatable?: boolean;
  51568. sideOrientation?: number;
  51569. frontUVs?: Vector4;
  51570. backUVs?: Vector4;
  51571. instance?: Mesh;
  51572. invertUV?: boolean;
  51573. }, scene?: Nullable<Scene>): Mesh;
  51574. private static _ExtrudeShapeGeneric;
  51575. }
  51576. }
  51577. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51578. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51579. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51580. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51581. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51582. import { Nullable } from "babylonjs/types";
  51583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51584. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51585. /**
  51586. * AmmoJS Physics plugin
  51587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51588. * @see https://github.com/kripken/ammo.js/
  51589. */
  51590. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51591. private _useDeltaForWorldStep;
  51592. /**
  51593. * Reference to the Ammo library
  51594. */
  51595. bjsAMMO: any;
  51596. /**
  51597. * Created ammoJS world which physics bodies are added to
  51598. */
  51599. world: any;
  51600. /**
  51601. * Name of the plugin
  51602. */
  51603. name: string;
  51604. private _timeStep;
  51605. private _fixedTimeStep;
  51606. private _maxSteps;
  51607. private _tmpQuaternion;
  51608. private _tmpAmmoTransform;
  51609. private _tmpAmmoQuaternion;
  51610. private _tmpAmmoConcreteContactResultCallback;
  51611. private _collisionConfiguration;
  51612. private _dispatcher;
  51613. private _overlappingPairCache;
  51614. private _solver;
  51615. private _softBodySolver;
  51616. private _tmpAmmoVectorA;
  51617. private _tmpAmmoVectorB;
  51618. private _tmpAmmoVectorC;
  51619. private _tmpAmmoVectorD;
  51620. private _tmpContactCallbackResult;
  51621. private _tmpAmmoVectorRCA;
  51622. private _tmpAmmoVectorRCB;
  51623. private _raycastResult;
  51624. private static readonly DISABLE_COLLISION_FLAG;
  51625. private static readonly KINEMATIC_FLAG;
  51626. private static readonly DISABLE_DEACTIVATION_FLAG;
  51627. /**
  51628. * Initializes the ammoJS plugin
  51629. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51630. * @param ammoInjection can be used to inject your own ammo reference
  51631. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51632. */
  51633. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51634. /**
  51635. * Sets the gravity of the physics world (m/(s^2))
  51636. * @param gravity Gravity to set
  51637. */
  51638. setGravity(gravity: Vector3): void;
  51639. /**
  51640. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51641. * @param timeStep timestep to use in seconds
  51642. */
  51643. setTimeStep(timeStep: number): void;
  51644. /**
  51645. * 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)
  51646. * @param fixedTimeStep fixedTimeStep to use in seconds
  51647. */
  51648. setFixedTimeStep(fixedTimeStep: number): void;
  51649. /**
  51650. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51651. * @param maxSteps the maximum number of steps by the physics engine per frame
  51652. */
  51653. setMaxSteps(maxSteps: number): void;
  51654. /**
  51655. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51656. * @returns the current timestep in seconds
  51657. */
  51658. getTimeStep(): number;
  51659. private _isImpostorInContact;
  51660. private _isImpostorPairInContact;
  51661. private _stepSimulation;
  51662. /**
  51663. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51664. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51665. * After the step the babylon meshes are set to the position of the physics imposters
  51666. * @param delta amount of time to step forward
  51667. * @param impostors array of imposters to update before/after the step
  51668. */
  51669. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51670. /**
  51671. * Update babylon mesh to match physics world object
  51672. * @param impostor imposter to match
  51673. */
  51674. private _afterSoftStep;
  51675. /**
  51676. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51677. * @param impostor imposter to match
  51678. */
  51679. private _ropeStep;
  51680. /**
  51681. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51682. * @param impostor imposter to match
  51683. */
  51684. private _softbodyOrClothStep;
  51685. private _tmpVector;
  51686. private _tmpMatrix;
  51687. /**
  51688. * Applies an impulse on the imposter
  51689. * @param impostor imposter to apply impulse to
  51690. * @param force amount of force to be applied to the imposter
  51691. * @param contactPoint the location to apply the impulse on the imposter
  51692. */
  51693. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51694. /**
  51695. * Applies a force on the imposter
  51696. * @param impostor imposter to apply force
  51697. * @param force amount of force to be applied to the imposter
  51698. * @param contactPoint the location to apply the force on the imposter
  51699. */
  51700. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51701. /**
  51702. * Creates a physics body using the plugin
  51703. * @param impostor the imposter to create the physics body on
  51704. */
  51705. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51706. /**
  51707. * Removes the physics body from the imposter and disposes of the body's memory
  51708. * @param impostor imposter to remove the physics body from
  51709. */
  51710. removePhysicsBody(impostor: PhysicsImpostor): void;
  51711. /**
  51712. * Generates a joint
  51713. * @param impostorJoint the imposter joint to create the joint with
  51714. */
  51715. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51716. /**
  51717. * Removes a joint
  51718. * @param impostorJoint the imposter joint to remove the joint from
  51719. */
  51720. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51721. private _addMeshVerts;
  51722. /**
  51723. * Initialise the soft body vertices to match its object's (mesh) vertices
  51724. * Softbody vertices (nodes) are in world space and to match this
  51725. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51726. * @param impostor to create the softbody for
  51727. */
  51728. private _softVertexData;
  51729. /**
  51730. * Create an impostor's soft body
  51731. * @param impostor to create the softbody for
  51732. */
  51733. private _createSoftbody;
  51734. /**
  51735. * Create cloth for an impostor
  51736. * @param impostor to create the softbody for
  51737. */
  51738. private _createCloth;
  51739. /**
  51740. * Create rope for an impostor
  51741. * @param impostor to create the softbody for
  51742. */
  51743. private _createRope;
  51744. private _addHullVerts;
  51745. private _createShape;
  51746. /**
  51747. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51748. * @param impostor imposter containing the physics body and babylon object
  51749. */
  51750. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51751. /**
  51752. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51753. * @param impostor imposter containing the physics body and babylon object
  51754. * @param newPosition new position
  51755. * @param newRotation new rotation
  51756. */
  51757. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51758. /**
  51759. * If this plugin is supported
  51760. * @returns true if its supported
  51761. */
  51762. isSupported(): boolean;
  51763. /**
  51764. * Sets the linear velocity of the physics body
  51765. * @param impostor imposter to set the velocity on
  51766. * @param velocity velocity to set
  51767. */
  51768. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51769. /**
  51770. * Sets the angular velocity of the physics body
  51771. * @param impostor imposter to set the velocity on
  51772. * @param velocity velocity to set
  51773. */
  51774. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51775. /**
  51776. * gets the linear velocity
  51777. * @param impostor imposter to get linear velocity from
  51778. * @returns linear velocity
  51779. */
  51780. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51781. /**
  51782. * gets the angular velocity
  51783. * @param impostor imposter to get angular velocity from
  51784. * @returns angular velocity
  51785. */
  51786. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51787. /**
  51788. * Sets the mass of physics body
  51789. * @param impostor imposter to set the mass on
  51790. * @param mass mass to set
  51791. */
  51792. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51793. /**
  51794. * Gets the mass of the physics body
  51795. * @param impostor imposter to get the mass from
  51796. * @returns mass
  51797. */
  51798. getBodyMass(impostor: PhysicsImpostor): number;
  51799. /**
  51800. * Gets friction of the impostor
  51801. * @param impostor impostor to get friction from
  51802. * @returns friction value
  51803. */
  51804. getBodyFriction(impostor: PhysicsImpostor): number;
  51805. /**
  51806. * Sets friction of the impostor
  51807. * @param impostor impostor to set friction on
  51808. * @param friction friction value
  51809. */
  51810. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51811. /**
  51812. * Gets restitution of the impostor
  51813. * @param impostor impostor to get restitution from
  51814. * @returns restitution value
  51815. */
  51816. getBodyRestitution(impostor: PhysicsImpostor): number;
  51817. /**
  51818. * Sets resitution of the impostor
  51819. * @param impostor impostor to set resitution on
  51820. * @param restitution resitution value
  51821. */
  51822. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51823. /**
  51824. * Gets pressure inside the impostor
  51825. * @param impostor impostor to get pressure from
  51826. * @returns pressure value
  51827. */
  51828. getBodyPressure(impostor: PhysicsImpostor): number;
  51829. /**
  51830. * Sets pressure inside a soft body impostor
  51831. * Cloth and rope must remain 0 pressure
  51832. * @param impostor impostor to set pressure on
  51833. * @param pressure pressure value
  51834. */
  51835. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51836. /**
  51837. * Gets stiffness of the impostor
  51838. * @param impostor impostor to get stiffness from
  51839. * @returns pressure value
  51840. */
  51841. getBodyStiffness(impostor: PhysicsImpostor): number;
  51842. /**
  51843. * Sets stiffness of the impostor
  51844. * @param impostor impostor to set stiffness on
  51845. * @param stiffness stiffness value from 0 to 1
  51846. */
  51847. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51848. /**
  51849. * Gets velocityIterations of the impostor
  51850. * @param impostor impostor to get velocity iterations from
  51851. * @returns velocityIterations value
  51852. */
  51853. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51854. /**
  51855. * Sets velocityIterations of the impostor
  51856. * @param impostor impostor to set velocity iterations on
  51857. * @param velocityIterations velocityIterations value
  51858. */
  51859. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51860. /**
  51861. * Gets positionIterations of the impostor
  51862. * @param impostor impostor to get position iterations from
  51863. * @returns positionIterations value
  51864. */
  51865. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51866. /**
  51867. * Sets positionIterations of the impostor
  51868. * @param impostor impostor to set position on
  51869. * @param positionIterations positionIterations value
  51870. */
  51871. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51872. /**
  51873. * Append an anchor to a cloth object
  51874. * @param impostor is the cloth impostor to add anchor to
  51875. * @param otherImpostor is the rigid impostor to anchor to
  51876. * @param width ratio across width from 0 to 1
  51877. * @param height ratio up height from 0 to 1
  51878. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51879. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51880. */
  51881. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51882. /**
  51883. * Append an hook to a rope object
  51884. * @param impostor is the rope impostor to add hook to
  51885. * @param otherImpostor is the rigid impostor to hook to
  51886. * @param length ratio along the rope from 0 to 1
  51887. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51888. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51889. */
  51890. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51891. /**
  51892. * Sleeps the physics body and stops it from being active
  51893. * @param impostor impostor to sleep
  51894. */
  51895. sleepBody(impostor: PhysicsImpostor): void;
  51896. /**
  51897. * Activates the physics body
  51898. * @param impostor impostor to activate
  51899. */
  51900. wakeUpBody(impostor: PhysicsImpostor): void;
  51901. /**
  51902. * Updates the distance parameters of the joint
  51903. * @param joint joint to update
  51904. * @param maxDistance maximum distance of the joint
  51905. * @param minDistance minimum distance of the joint
  51906. */
  51907. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51908. /**
  51909. * Sets a motor on the joint
  51910. * @param joint joint to set motor on
  51911. * @param speed speed of the motor
  51912. * @param maxForce maximum force of the motor
  51913. * @param motorIndex index of the motor
  51914. */
  51915. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51916. /**
  51917. * Sets the motors limit
  51918. * @param joint joint to set limit on
  51919. * @param upperLimit upper limit
  51920. * @param lowerLimit lower limit
  51921. */
  51922. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51923. /**
  51924. * Syncs the position and rotation of a mesh with the impostor
  51925. * @param mesh mesh to sync
  51926. * @param impostor impostor to update the mesh with
  51927. */
  51928. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51929. /**
  51930. * Gets the radius of the impostor
  51931. * @param impostor impostor to get radius from
  51932. * @returns the radius
  51933. */
  51934. getRadius(impostor: PhysicsImpostor): number;
  51935. /**
  51936. * Gets the box size of the impostor
  51937. * @param impostor impostor to get box size from
  51938. * @param result the resulting box size
  51939. */
  51940. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51941. /**
  51942. * Disposes of the impostor
  51943. */
  51944. dispose(): void;
  51945. /**
  51946. * Does a raycast in the physics world
  51947. * @param from when should the ray start?
  51948. * @param to when should the ray end?
  51949. * @returns PhysicsRaycastResult
  51950. */
  51951. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51952. }
  51953. }
  51954. declare module "babylonjs/Probes/reflectionProbe" {
  51955. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51956. import { Vector3 } from "babylonjs/Maths/math";
  51957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51958. import { Nullable } from "babylonjs/types";
  51959. import { Scene } from "babylonjs/scene";
  51960. module "babylonjs/abstractScene" {
  51961. interface AbstractScene {
  51962. /**
  51963. * The list of reflection probes added to the scene
  51964. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51965. */
  51966. reflectionProbes: Array<ReflectionProbe>;
  51967. /**
  51968. * Removes the given reflection probe from this scene.
  51969. * @param toRemove The reflection probe to remove
  51970. * @returns The index of the removed reflection probe
  51971. */
  51972. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51973. /**
  51974. * Adds the given reflection probe to this scene.
  51975. * @param newReflectionProbe The reflection probe to add
  51976. */
  51977. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51978. }
  51979. }
  51980. /**
  51981. * Class used to generate realtime reflection / refraction cube textures
  51982. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51983. */
  51984. export class ReflectionProbe {
  51985. /** defines the name of the probe */
  51986. name: string;
  51987. private _scene;
  51988. private _renderTargetTexture;
  51989. private _projectionMatrix;
  51990. private _viewMatrix;
  51991. private _target;
  51992. private _add;
  51993. private _attachedMesh;
  51994. private _invertYAxis;
  51995. /** Gets or sets probe position (center of the cube map) */
  51996. position: Vector3;
  51997. /**
  51998. * Creates a new reflection probe
  51999. * @param name defines the name of the probe
  52000. * @param size defines the texture resolution (for each face)
  52001. * @param scene defines the hosting scene
  52002. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52003. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52004. */
  52005. constructor(
  52006. /** defines the name of the probe */
  52007. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52008. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52009. samples: number;
  52010. /** Gets or sets the refresh rate to use (on every frame by default) */
  52011. refreshRate: number;
  52012. /**
  52013. * Gets the hosting scene
  52014. * @returns a Scene
  52015. */
  52016. getScene(): Scene;
  52017. /** Gets the internal CubeTexture used to render to */
  52018. readonly cubeTexture: RenderTargetTexture;
  52019. /** Gets the list of meshes to render */
  52020. readonly renderList: Nullable<AbstractMesh[]>;
  52021. /**
  52022. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52023. * @param mesh defines the mesh to attach to
  52024. */
  52025. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52026. /**
  52027. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52028. * @param renderingGroupId The rendering group id corresponding to its index
  52029. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52030. */
  52031. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52032. /**
  52033. * Clean all associated resources
  52034. */
  52035. dispose(): void;
  52036. /**
  52037. * Converts the reflection probe information to a readable string for debug purpose.
  52038. * @param fullDetails Supports for multiple levels of logging within scene loading
  52039. * @returns the human readable reflection probe info
  52040. */
  52041. toString(fullDetails?: boolean): string;
  52042. /**
  52043. * Get the class name of the relfection probe.
  52044. * @returns "ReflectionProbe"
  52045. */
  52046. getClassName(): string;
  52047. /**
  52048. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52049. * @returns The JSON representation of the texture
  52050. */
  52051. serialize(): any;
  52052. /**
  52053. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52054. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52055. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52056. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52057. * @returns The parsed reflection probe if successful
  52058. */
  52059. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52060. }
  52061. }
  52062. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52063. /** @hidden */
  52064. export var _BabylonLoaderRegistered: boolean;
  52065. }
  52066. declare module "babylonjs/Loading/Plugins/index" {
  52067. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52068. }
  52069. declare module "babylonjs/Loading/index" {
  52070. export * from "babylonjs/Loading/loadingScreen";
  52071. export * from "babylonjs/Loading/Plugins/index";
  52072. export * from "babylonjs/Loading/sceneLoader";
  52073. export * from "babylonjs/Loading/sceneLoaderFlags";
  52074. }
  52075. declare module "babylonjs/Materials/Background/index" {
  52076. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52077. }
  52078. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52079. import { Scene } from "babylonjs/scene";
  52080. import { Color3 } from "babylonjs/Maths/math";
  52081. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52083. /**
  52084. * The Physically based simple base material of BJS.
  52085. *
  52086. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52087. * It is used as the base class for both the specGloss and metalRough conventions.
  52088. */
  52089. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52090. /**
  52091. * Number of Simultaneous lights allowed on the material.
  52092. */
  52093. maxSimultaneousLights: number;
  52094. /**
  52095. * If sets to true, disables all the lights affecting the material.
  52096. */
  52097. disableLighting: boolean;
  52098. /**
  52099. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52100. */
  52101. environmentTexture: BaseTexture;
  52102. /**
  52103. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52104. */
  52105. invertNormalMapX: boolean;
  52106. /**
  52107. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52108. */
  52109. invertNormalMapY: boolean;
  52110. /**
  52111. * Normal map used in the model.
  52112. */
  52113. normalTexture: BaseTexture;
  52114. /**
  52115. * Emissivie color used to self-illuminate the model.
  52116. */
  52117. emissiveColor: Color3;
  52118. /**
  52119. * Emissivie texture used to self-illuminate the model.
  52120. */
  52121. emissiveTexture: BaseTexture;
  52122. /**
  52123. * Occlusion Channel Strenght.
  52124. */
  52125. occlusionStrength: number;
  52126. /**
  52127. * Occlusion Texture of the material (adding extra occlusion effects).
  52128. */
  52129. occlusionTexture: BaseTexture;
  52130. /**
  52131. * Defines the alpha limits in alpha test mode.
  52132. */
  52133. alphaCutOff: number;
  52134. /**
  52135. * Gets the current double sided mode.
  52136. */
  52137. /**
  52138. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52139. */
  52140. doubleSided: boolean;
  52141. /**
  52142. * Stores the pre-calculated light information of a mesh in a texture.
  52143. */
  52144. lightmapTexture: BaseTexture;
  52145. /**
  52146. * If true, the light map contains occlusion information instead of lighting info.
  52147. */
  52148. useLightmapAsShadowmap: boolean;
  52149. /**
  52150. * Instantiates a new PBRMaterial instance.
  52151. *
  52152. * @param name The material name
  52153. * @param scene The scene the material will be use in.
  52154. */
  52155. constructor(name: string, scene: Scene);
  52156. getClassName(): string;
  52157. }
  52158. }
  52159. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52160. import { Scene } from "babylonjs/scene";
  52161. import { Color3 } from "babylonjs/Maths/math";
  52162. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52163. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52164. /**
  52165. * The PBR material of BJS following the metal roughness convention.
  52166. *
  52167. * This fits to the PBR convention in the GLTF definition:
  52168. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52169. */
  52170. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52171. /**
  52172. * The base color has two different interpretations depending on the value of metalness.
  52173. * When the material is a metal, the base color is the specific measured reflectance value
  52174. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52175. * of the material.
  52176. */
  52177. baseColor: Color3;
  52178. /**
  52179. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52180. * well as opacity information in the alpha channel.
  52181. */
  52182. baseTexture: BaseTexture;
  52183. /**
  52184. * Specifies the metallic scalar value of the material.
  52185. * Can also be used to scale the metalness values of the metallic texture.
  52186. */
  52187. metallic: number;
  52188. /**
  52189. * Specifies the roughness scalar value of the material.
  52190. * Can also be used to scale the roughness values of the metallic texture.
  52191. */
  52192. roughness: number;
  52193. /**
  52194. * Texture containing both the metallic value in the B channel and the
  52195. * roughness value in the G channel to keep better precision.
  52196. */
  52197. metallicRoughnessTexture: BaseTexture;
  52198. /**
  52199. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52200. *
  52201. * @param name The material name
  52202. * @param scene The scene the material will be use in.
  52203. */
  52204. constructor(name: string, scene: Scene);
  52205. /**
  52206. * Return the currrent class name of the material.
  52207. */
  52208. getClassName(): string;
  52209. /**
  52210. * Makes a duplicate of the current material.
  52211. * @param name - name to use for the new material.
  52212. */
  52213. clone(name: string): PBRMetallicRoughnessMaterial;
  52214. /**
  52215. * Serialize the material to a parsable JSON object.
  52216. */
  52217. serialize(): any;
  52218. /**
  52219. * Parses a JSON object correponding to the serialize function.
  52220. */
  52221. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52222. }
  52223. }
  52224. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52225. import { Scene } from "babylonjs/scene";
  52226. import { Color3 } from "babylonjs/Maths/math";
  52227. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52228. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52229. /**
  52230. * The PBR material of BJS following the specular glossiness convention.
  52231. *
  52232. * This fits to the PBR convention in the GLTF definition:
  52233. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52234. */
  52235. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52236. /**
  52237. * Specifies the diffuse color of the material.
  52238. */
  52239. diffuseColor: Color3;
  52240. /**
  52241. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52242. * channel.
  52243. */
  52244. diffuseTexture: BaseTexture;
  52245. /**
  52246. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52247. */
  52248. specularColor: Color3;
  52249. /**
  52250. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52251. */
  52252. glossiness: number;
  52253. /**
  52254. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52255. */
  52256. specularGlossinessTexture: BaseTexture;
  52257. /**
  52258. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52259. *
  52260. * @param name The material name
  52261. * @param scene The scene the material will be use in.
  52262. */
  52263. constructor(name: string, scene: Scene);
  52264. /**
  52265. * Return the currrent class name of the material.
  52266. */
  52267. getClassName(): string;
  52268. /**
  52269. * Makes a duplicate of the current material.
  52270. * @param name - name to use for the new material.
  52271. */
  52272. clone(name: string): PBRSpecularGlossinessMaterial;
  52273. /**
  52274. * Serialize the material to a parsable JSON object.
  52275. */
  52276. serialize(): any;
  52277. /**
  52278. * Parses a JSON object correponding to the serialize function.
  52279. */
  52280. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52281. }
  52282. }
  52283. declare module "babylonjs/Materials/PBR/index" {
  52284. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52285. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52286. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52287. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52288. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52289. }
  52290. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52291. import { Nullable } from "babylonjs/types";
  52292. import { Scene } from "babylonjs/scene";
  52293. import { Matrix } from "babylonjs/Maths/math";
  52294. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52295. /**
  52296. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52297. * It can help converting any input color in a desired output one. This can then be used to create effects
  52298. * from sepia, black and white to sixties or futuristic rendering...
  52299. *
  52300. * The only supported format is currently 3dl.
  52301. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52302. */
  52303. export class ColorGradingTexture extends BaseTexture {
  52304. /**
  52305. * The current texture matrix. (will always be identity in color grading texture)
  52306. */
  52307. private _textureMatrix;
  52308. /**
  52309. * The texture URL.
  52310. */
  52311. url: string;
  52312. /**
  52313. * Empty line regex stored for GC.
  52314. */
  52315. private static _noneEmptyLineRegex;
  52316. private _engine;
  52317. /**
  52318. * Instantiates a ColorGradingTexture from the following parameters.
  52319. *
  52320. * @param url The location of the color gradind data (currently only supporting 3dl)
  52321. * @param scene The scene the texture will be used in
  52322. */
  52323. constructor(url: string, scene: Scene);
  52324. /**
  52325. * Returns the texture matrix used in most of the material.
  52326. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52327. */
  52328. getTextureMatrix(): Matrix;
  52329. /**
  52330. * Occurs when the file being loaded is a .3dl LUT file.
  52331. */
  52332. private load3dlTexture;
  52333. /**
  52334. * Starts the loading process of the texture.
  52335. */
  52336. private loadTexture;
  52337. /**
  52338. * Clones the color gradind texture.
  52339. */
  52340. clone(): ColorGradingTexture;
  52341. /**
  52342. * Called during delayed load for textures.
  52343. */
  52344. delayLoad(): void;
  52345. /**
  52346. * Parses a color grading texture serialized by Babylon.
  52347. * @param parsedTexture The texture information being parsedTexture
  52348. * @param scene The scene to load the texture in
  52349. * @param rootUrl The root url of the data assets to load
  52350. * @return A color gradind texture
  52351. */
  52352. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52353. /**
  52354. * Serializes the LUT texture to json format.
  52355. */
  52356. serialize(): any;
  52357. }
  52358. }
  52359. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52360. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52361. import { Scene } from "babylonjs/scene";
  52362. import { Nullable } from "babylonjs/types";
  52363. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52364. /**
  52365. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52366. */
  52367. export class EquiRectangularCubeTexture extends BaseTexture {
  52368. /** The six faces of the cube. */
  52369. private static _FacesMapping;
  52370. private _noMipmap;
  52371. private _onLoad;
  52372. private _onError;
  52373. /** The size of the cubemap. */
  52374. private _size;
  52375. /** The buffer of the image. */
  52376. private _buffer;
  52377. /** The width of the input image. */
  52378. private _width;
  52379. /** The height of the input image. */
  52380. private _height;
  52381. /** The URL to the image. */
  52382. url: string;
  52383. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52384. coordinatesMode: number;
  52385. /**
  52386. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52387. * @param url The location of the image
  52388. * @param scene The scene the texture will be used in
  52389. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52390. * @param noMipmap Forces to not generate the mipmap if true
  52391. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52392. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52393. * @param onLoad — defines a callback called when texture is loaded
  52394. * @param onError — defines a callback called if there is an error
  52395. */
  52396. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52397. /**
  52398. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52399. */
  52400. private loadImage;
  52401. /**
  52402. * Convert the image buffer into a cubemap and create a CubeTexture.
  52403. */
  52404. private loadTexture;
  52405. /**
  52406. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52407. * @param buffer The ArrayBuffer that should be converted.
  52408. * @returns The buffer as Float32Array.
  52409. */
  52410. private getFloat32ArrayFromArrayBuffer;
  52411. /**
  52412. * Get the current class name of the texture useful for serialization or dynamic coding.
  52413. * @returns "EquiRectangularCubeTexture"
  52414. */
  52415. getClassName(): string;
  52416. /**
  52417. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52418. * @returns A clone of the current EquiRectangularCubeTexture.
  52419. */
  52420. clone(): EquiRectangularCubeTexture;
  52421. }
  52422. }
  52423. declare module "babylonjs/Misc/tga" {
  52424. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52425. /**
  52426. * Based on jsTGALoader - Javascript loader for TGA file
  52427. * By Vincent Thibault
  52428. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52429. */
  52430. export class TGATools {
  52431. private static _TYPE_INDEXED;
  52432. private static _TYPE_RGB;
  52433. private static _TYPE_GREY;
  52434. private static _TYPE_RLE_INDEXED;
  52435. private static _TYPE_RLE_RGB;
  52436. private static _TYPE_RLE_GREY;
  52437. private static _ORIGIN_MASK;
  52438. private static _ORIGIN_SHIFT;
  52439. private static _ORIGIN_BL;
  52440. private static _ORIGIN_BR;
  52441. private static _ORIGIN_UL;
  52442. private static _ORIGIN_UR;
  52443. /**
  52444. * Gets the header of a TGA file
  52445. * @param data defines the TGA data
  52446. * @returns the header
  52447. */
  52448. static GetTGAHeader(data: Uint8Array): any;
  52449. /**
  52450. * Uploads TGA content to a Babylon Texture
  52451. * @hidden
  52452. */
  52453. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52454. /** @hidden */
  52455. 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;
  52456. /** @hidden */
  52457. 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;
  52458. /** @hidden */
  52459. 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;
  52460. /** @hidden */
  52461. 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;
  52462. /** @hidden */
  52463. 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;
  52464. /** @hidden */
  52465. 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;
  52466. }
  52467. }
  52468. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52469. import { Nullable } from "babylonjs/types";
  52470. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52471. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52472. /**
  52473. * Implementation of the TGA Texture Loader.
  52474. * @hidden
  52475. */
  52476. export class _TGATextureLoader implements IInternalTextureLoader {
  52477. /**
  52478. * Defines wether the loader supports cascade loading the different faces.
  52479. */
  52480. readonly supportCascades: boolean;
  52481. /**
  52482. * This returns if the loader support the current file information.
  52483. * @param extension defines the file extension of the file being loaded
  52484. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52485. * @param fallback defines the fallback internal texture if any
  52486. * @param isBase64 defines whether the texture is encoded as a base64
  52487. * @param isBuffer defines whether the texture data are stored as a buffer
  52488. * @returns true if the loader can load the specified file
  52489. */
  52490. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52491. /**
  52492. * Transform the url before loading if required.
  52493. * @param rootUrl the url of the texture
  52494. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52495. * @returns the transformed texture
  52496. */
  52497. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52498. /**
  52499. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52500. * @param rootUrl the url of the texture
  52501. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52502. * @returns the fallback texture
  52503. */
  52504. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52505. /**
  52506. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52507. * @param data contains the texture data
  52508. * @param texture defines the BabylonJS internal texture
  52509. * @param createPolynomials will be true if polynomials have been requested
  52510. * @param onLoad defines the callback to trigger once the texture is ready
  52511. * @param onError defines the callback to trigger in case of error
  52512. */
  52513. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52514. /**
  52515. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52516. * @param data contains the texture data
  52517. * @param texture defines the BabylonJS internal texture
  52518. * @param callback defines the method to call once ready to upload
  52519. */
  52520. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52521. }
  52522. }
  52523. declare module "babylonjs/Misc/basis" {
  52524. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52525. /**
  52526. * Info about the .basis files
  52527. */
  52528. class BasisFileInfo {
  52529. /**
  52530. * If the file has alpha
  52531. */
  52532. hasAlpha: boolean;
  52533. /**
  52534. * Info about each image of the basis file
  52535. */
  52536. images: Array<{
  52537. levels: Array<{
  52538. width: number;
  52539. height: number;
  52540. transcodedPixels: ArrayBufferView;
  52541. }>;
  52542. }>;
  52543. }
  52544. /**
  52545. * Result of transcoding a basis file
  52546. */
  52547. class TranscodeResult {
  52548. /**
  52549. * Info about the .basis file
  52550. */
  52551. fileInfo: BasisFileInfo;
  52552. /**
  52553. * Format to use when loading the file
  52554. */
  52555. format: number;
  52556. }
  52557. /**
  52558. * Configuration options for the Basis transcoder
  52559. */
  52560. export class BasisTranscodeConfiguration {
  52561. /**
  52562. * Supported compression formats used to determine the supported output format of the transcoder
  52563. */
  52564. supportedCompressionFormats?: {
  52565. /**
  52566. * etc1 compression format
  52567. */
  52568. etc1?: boolean;
  52569. /**
  52570. * s3tc compression format
  52571. */
  52572. s3tc?: boolean;
  52573. /**
  52574. * pvrtc compression format
  52575. */
  52576. pvrtc?: boolean;
  52577. /**
  52578. * etc2 compression format
  52579. */
  52580. etc2?: boolean;
  52581. };
  52582. /**
  52583. * If mipmap levels should be loaded for transcoded images (Default: true)
  52584. */
  52585. loadMipmapLevels?: boolean;
  52586. /**
  52587. * Index of a single image to load (Default: all images)
  52588. */
  52589. loadSingleImage?: number;
  52590. }
  52591. /**
  52592. * Used to load .Basis files
  52593. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52594. */
  52595. export class BasisTools {
  52596. private static _IgnoreSupportedFormats;
  52597. /**
  52598. * URL to use when loading the basis transcoder
  52599. */
  52600. static JSModuleURL: string;
  52601. /**
  52602. * URL to use when loading the wasm module for the transcoder
  52603. */
  52604. static WasmModuleURL: string;
  52605. /**
  52606. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52607. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52608. * @returns internal format corresponding to the Basis format
  52609. */
  52610. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52611. private static _WorkerPromise;
  52612. private static _Worker;
  52613. private static _actionId;
  52614. private static _CreateWorkerAsync;
  52615. /**
  52616. * Transcodes a loaded image file to compressed pixel data
  52617. * @param imageData image data to transcode
  52618. * @param config configuration options for the transcoding
  52619. * @returns a promise resulting in the transcoded image
  52620. */
  52621. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52622. /**
  52623. * Loads a texture from the transcode result
  52624. * @param texture texture load to
  52625. * @param transcodeResult the result of transcoding the basis file to load from
  52626. */
  52627. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52628. }
  52629. }
  52630. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  52631. import { Nullable } from "babylonjs/types";
  52632. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52633. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52634. /**
  52635. * Loader for .basis file format
  52636. */
  52637. export class _BasisTextureLoader implements IInternalTextureLoader {
  52638. /**
  52639. * Defines whether the loader supports cascade loading the different faces.
  52640. */
  52641. readonly supportCascades: boolean;
  52642. /**
  52643. * This returns if the loader support the current file information.
  52644. * @param extension defines the file extension of the file being loaded
  52645. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52646. * @param fallback defines the fallback internal texture if any
  52647. * @param isBase64 defines whether the texture is encoded as a base64
  52648. * @param isBuffer defines whether the texture data are stored as a buffer
  52649. * @returns true if the loader can load the specified file
  52650. */
  52651. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52652. /**
  52653. * Transform the url before loading if required.
  52654. * @param rootUrl the url of the texture
  52655. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52656. * @returns the transformed texture
  52657. */
  52658. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52659. /**
  52660. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52661. * @param rootUrl the url of the texture
  52662. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52663. * @returns the fallback texture
  52664. */
  52665. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52666. /**
  52667. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52668. * @param data contains the texture data
  52669. * @param texture defines the BabylonJS internal texture
  52670. * @param createPolynomials will be true if polynomials have been requested
  52671. * @param onLoad defines the callback to trigger once the texture is ready
  52672. * @param onError defines the callback to trigger in case of error
  52673. */
  52674. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52675. /**
  52676. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52677. * @param data contains the texture data
  52678. * @param texture defines the BabylonJS internal texture
  52679. * @param callback defines the method to call once ready to upload
  52680. */
  52681. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52682. }
  52683. }
  52684. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52685. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52686. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52687. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52688. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52689. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  52690. }
  52691. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52692. import { Scene } from "babylonjs/scene";
  52693. import { Texture } from "babylonjs/Materials/Textures/texture";
  52694. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52695. /**
  52696. * 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.
  52697. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52698. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52699. */
  52700. export class CustomProceduralTexture extends ProceduralTexture {
  52701. private _animate;
  52702. private _time;
  52703. private _config;
  52704. private _texturePath;
  52705. /**
  52706. * Instantiates a new Custom Procedural Texture.
  52707. * 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.
  52708. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52709. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52710. * @param name Define the name of the texture
  52711. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52712. * @param size Define the size of the texture to create
  52713. * @param scene Define the scene the texture belongs to
  52714. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52715. * @param generateMipMaps Define if the texture should creates mip maps or not
  52716. */
  52717. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52718. private _loadJson;
  52719. /**
  52720. * Is the texture ready to be used ? (rendered at least once)
  52721. * @returns true if ready, otherwise, false.
  52722. */
  52723. isReady(): boolean;
  52724. /**
  52725. * Render the texture to its associated render target.
  52726. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52727. */
  52728. render(useCameraPostProcess?: boolean): void;
  52729. /**
  52730. * Update the list of dependant textures samplers in the shader.
  52731. */
  52732. updateTextures(): void;
  52733. /**
  52734. * Update the uniform values of the procedural texture in the shader.
  52735. */
  52736. updateShaderUniforms(): void;
  52737. /**
  52738. * Define if the texture animates or not.
  52739. */
  52740. animate: boolean;
  52741. }
  52742. }
  52743. declare module "babylonjs/Shaders/noise.fragment" {
  52744. /** @hidden */
  52745. export var noisePixelShader: {
  52746. name: string;
  52747. shader: string;
  52748. };
  52749. }
  52750. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52751. import { Nullable } from "babylonjs/types";
  52752. import { Scene } from "babylonjs/scene";
  52753. import { Texture } from "babylonjs/Materials/Textures/texture";
  52754. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52755. import "babylonjs/Shaders/noise.fragment";
  52756. /**
  52757. * Class used to generate noise procedural textures
  52758. */
  52759. export class NoiseProceduralTexture extends ProceduralTexture {
  52760. private _time;
  52761. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52762. brightness: number;
  52763. /** Defines the number of octaves to process */
  52764. octaves: number;
  52765. /** Defines the level of persistence (0.8 by default) */
  52766. persistence: number;
  52767. /** Gets or sets animation speed factor (default is 1) */
  52768. animationSpeedFactor: number;
  52769. /**
  52770. * Creates a new NoiseProceduralTexture
  52771. * @param name defines the name fo the texture
  52772. * @param size defines the size of the texture (default is 256)
  52773. * @param scene defines the hosting scene
  52774. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52775. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52776. */
  52777. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52778. private _updateShaderUniforms;
  52779. protected _getDefines(): string;
  52780. /** Generate the current state of the procedural texture */
  52781. render(useCameraPostProcess?: boolean): void;
  52782. /**
  52783. * Serializes this noise procedural texture
  52784. * @returns a serialized noise procedural texture object
  52785. */
  52786. serialize(): any;
  52787. /**
  52788. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52789. * @param parsedTexture defines parsed texture data
  52790. * @param scene defines the current scene
  52791. * @param rootUrl defines the root URL containing noise procedural texture information
  52792. * @returns a parsed NoiseProceduralTexture
  52793. */
  52794. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52795. }
  52796. }
  52797. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52798. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52799. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52800. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52801. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52802. }
  52803. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52804. import { Nullable } from "babylonjs/types";
  52805. import { Scene } from "babylonjs/scene";
  52806. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52807. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52808. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52809. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52810. /**
  52811. * Raw cube texture where the raw buffers are passed in
  52812. */
  52813. export class RawCubeTexture extends CubeTexture {
  52814. /**
  52815. * Creates a cube texture where the raw buffers are passed in.
  52816. * @param scene defines the scene the texture is attached to
  52817. * @param data defines the array of data to use to create each face
  52818. * @param size defines the size of the textures
  52819. * @param format defines the format of the data
  52820. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52821. * @param generateMipMaps defines if the engine should generate the mip levels
  52822. * @param invertY defines if data must be stored with Y axis inverted
  52823. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52824. * @param compression defines the compression used (null by default)
  52825. */
  52826. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52827. /**
  52828. * Updates the raw cube texture.
  52829. * @param data defines the data to store
  52830. * @param format defines the data format
  52831. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52832. * @param invertY defines if data must be stored with Y axis inverted
  52833. * @param compression defines the compression used (null by default)
  52834. * @param level defines which level of the texture to update
  52835. */
  52836. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52837. /**
  52838. * Updates a raw cube texture with RGBD encoded data.
  52839. * @param data defines the array of data [mipmap][face] to use to create each face
  52840. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52841. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52842. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52843. * @returns a promsie that resolves when the operation is complete
  52844. */
  52845. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52846. /**
  52847. * Clones the raw cube texture.
  52848. * @return a new cube texture
  52849. */
  52850. clone(): CubeTexture;
  52851. /** @hidden */
  52852. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52853. }
  52854. }
  52855. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52856. import { Scene } from "babylonjs/scene";
  52857. import { Texture } from "babylonjs/Materials/Textures/texture";
  52858. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52859. /**
  52860. * Class used to store 3D textures containing user data
  52861. */
  52862. export class RawTexture3D extends Texture {
  52863. /** Gets or sets the texture format to use */
  52864. format: number;
  52865. private _engine;
  52866. /**
  52867. * Create a new RawTexture3D
  52868. * @param data defines the data of the texture
  52869. * @param width defines the width of the texture
  52870. * @param height defines the height of the texture
  52871. * @param depth defines the depth of the texture
  52872. * @param format defines the texture format to use
  52873. * @param scene defines the hosting scene
  52874. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52875. * @param invertY defines if texture must be stored with Y axis inverted
  52876. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52877. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52878. */
  52879. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52880. /** Gets or sets the texture format to use */
  52881. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52882. /**
  52883. * Update the texture with new data
  52884. * @param data defines the data to store in the texture
  52885. */
  52886. update(data: ArrayBufferView): void;
  52887. }
  52888. }
  52889. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52890. import { Scene } from "babylonjs/scene";
  52891. import { Plane } from "babylonjs/Maths/math";
  52892. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52893. /**
  52894. * Creates a refraction texture used by refraction channel of the standard material.
  52895. * It is like a mirror but to see through a material.
  52896. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52897. */
  52898. export class RefractionTexture extends RenderTargetTexture {
  52899. /**
  52900. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52901. * 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.
  52902. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52903. */
  52904. refractionPlane: Plane;
  52905. /**
  52906. * Define how deep under the surface we should see.
  52907. */
  52908. depth: number;
  52909. /**
  52910. * Creates a refraction texture used by refraction channel of the standard material.
  52911. * It is like a mirror but to see through a material.
  52912. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52913. * @param name Define the texture name
  52914. * @param size Define the size of the underlying texture
  52915. * @param scene Define the scene the refraction belongs to
  52916. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52917. */
  52918. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52919. /**
  52920. * Clone the refraction texture.
  52921. * @returns the cloned texture
  52922. */
  52923. clone(): RefractionTexture;
  52924. /**
  52925. * Serialize the texture to a JSON representation you could use in Parse later on
  52926. * @returns the serialized JSON representation
  52927. */
  52928. serialize(): any;
  52929. }
  52930. }
  52931. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52932. import { Nullable } from "babylonjs/types";
  52933. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52934. import { Matrix } from "babylonjs/Maths/math";
  52935. import { Engine } from "babylonjs/Engines/engine";
  52936. import { Scene } from "babylonjs/scene";
  52937. /**
  52938. * Defines the options related to the creation of an HtmlElementTexture
  52939. */
  52940. export interface IHtmlElementTextureOptions {
  52941. /**
  52942. * Defines wether mip maps should be created or not.
  52943. */
  52944. generateMipMaps?: boolean;
  52945. /**
  52946. * Defines the sampling mode of the texture.
  52947. */
  52948. samplingMode?: number;
  52949. /**
  52950. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52951. */
  52952. engine: Nullable<Engine>;
  52953. /**
  52954. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52955. */
  52956. scene: Nullable<Scene>;
  52957. }
  52958. /**
  52959. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52960. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52961. * is automatically managed.
  52962. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52963. * in your application.
  52964. *
  52965. * As the update is not automatic, you need to call them manually.
  52966. */
  52967. export class HtmlElementTexture extends BaseTexture {
  52968. /**
  52969. * The texture URL.
  52970. */
  52971. element: HTMLVideoElement | HTMLCanvasElement;
  52972. private static readonly DefaultOptions;
  52973. private _textureMatrix;
  52974. private _engine;
  52975. private _isVideo;
  52976. private _generateMipMaps;
  52977. private _samplingMode;
  52978. /**
  52979. * Instantiates a HtmlElementTexture from the following parameters.
  52980. *
  52981. * @param name Defines the name of the texture
  52982. * @param element Defines the video or canvas the texture is filled with
  52983. * @param options Defines the other none mandatory texture creation options
  52984. */
  52985. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52986. private _createInternalTexture;
  52987. /**
  52988. * Returns the texture matrix used in most of the material.
  52989. */
  52990. getTextureMatrix(): Matrix;
  52991. /**
  52992. * Updates the content of the texture.
  52993. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52994. */
  52995. update(invertY?: Nullable<boolean>): void;
  52996. }
  52997. }
  52998. declare module "babylonjs/Materials/Textures/index" {
  52999. export * from "babylonjs/Materials/Textures/baseTexture";
  53000. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53001. export * from "babylonjs/Materials/Textures/cubeTexture";
  53002. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53003. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53004. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53005. export * from "babylonjs/Materials/Textures/internalTexture";
  53006. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  53007. export * from "babylonjs/Materials/Textures/Loaders/index";
  53008. export * from "babylonjs/Materials/Textures/mirrorTexture";
  53009. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  53010. export * from "babylonjs/Materials/Textures/Procedurals/index";
  53011. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  53012. export * from "babylonjs/Materials/Textures/rawTexture";
  53013. export * from "babylonjs/Materials/Textures/rawTexture3D";
  53014. export * from "babylonjs/Materials/Textures/refractionTexture";
  53015. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53016. export * from "babylonjs/Materials/Textures/texture";
  53017. export * from "babylonjs/Materials/Textures/videoTexture";
  53018. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53019. }
  53020. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53021. /**
  53022. * Enum used to define the target of a block
  53023. */
  53024. export enum NodeMaterialBlockTargets {
  53025. /** Vertex shader */
  53026. Vertex = 1,
  53027. /** Fragment shader */
  53028. Fragment = 2,
  53029. /** Vertex and Fragment */
  53030. VertexAndFragment = 3
  53031. }
  53032. }
  53033. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53034. /**
  53035. * Defines the kind of connection point for node based material
  53036. */
  53037. export enum NodeMaterialBlockConnectionPointTypes {
  53038. /** Float */
  53039. Float = 1,
  53040. /** Int */
  53041. Int = 2,
  53042. /** Vector2 */
  53043. Vector2 = 4,
  53044. /** Vector3 */
  53045. Vector3 = 8,
  53046. /** Vector4 */
  53047. Vector4 = 16,
  53048. /** Color3 */
  53049. Color3 = 32,
  53050. /** Color4 */
  53051. Color4 = 64,
  53052. /** Matrix */
  53053. Matrix = 128,
  53054. /** Vector3 or Color3 */
  53055. Vector3OrColor3 = 40,
  53056. /** Vector3 or Vector4 */
  53057. Vector3OrVector4 = 24,
  53058. /** Vector4 or Color4 */
  53059. Vector4OrColor4 = 80,
  53060. /** Color3 or Color4 */
  53061. Color3OrColor4 = 96,
  53062. /** Vector2 or Color3 or Color4 */
  53063. Vector2OrColor3OrColor4 = 100,
  53064. /** Vector3 or Color3 or Color4 or Vector4 */
  53065. Vector3OrColor3OrVector4OrColor4 = 120,
  53066. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  53067. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  53068. /** Detect type based on connection */
  53069. AutoDetect = 1024,
  53070. /** Output type that will be defined by input type */
  53071. BasedOnInput = 2048
  53072. }
  53073. }
  53074. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53075. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53076. /**
  53077. * Root class for all node material optimizers
  53078. */
  53079. export class NodeMaterialOptimizer {
  53080. /**
  53081. * Function used to optimize a NodeMaterial graph
  53082. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53083. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53084. */
  53085. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53086. }
  53087. }
  53088. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  53089. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53090. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53091. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53092. /**
  53093. * Block used to transform a vector4 with a matrix
  53094. */
  53095. export class Vector4TransformBlock extends NodeMaterialBlock {
  53096. /**
  53097. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53098. */
  53099. complementW: number;
  53100. /**
  53101. * Creates a new Vector4TransformBlock
  53102. * @param name defines the block name
  53103. */
  53104. constructor(name: string);
  53105. /**
  53106. * Gets the current class name
  53107. * @returns the class name
  53108. */
  53109. getClassName(): string;
  53110. /**
  53111. * Gets the vector input
  53112. */
  53113. readonly vector: NodeMaterialConnectionPoint;
  53114. /**
  53115. * Gets the output component
  53116. */
  53117. readonly output: NodeMaterialConnectionPoint;
  53118. /**
  53119. * Gets the matrix transform input
  53120. */
  53121. readonly transform: NodeMaterialConnectionPoint;
  53122. protected _buildBlock(state: NodeMaterialBuildState): this;
  53123. }
  53124. }
  53125. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53126. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53127. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53128. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53129. /**
  53130. * Block used to output the vertex position
  53131. */
  53132. export class VertexOutputBlock extends NodeMaterialBlock {
  53133. /**
  53134. * Creates a new VertexOutputBlock
  53135. * @param name defines the block name
  53136. */
  53137. constructor(name: string);
  53138. /**
  53139. * Gets the current class name
  53140. * @returns the class name
  53141. */
  53142. getClassName(): string;
  53143. /**
  53144. * Gets the vector input component
  53145. */
  53146. readonly vector: NodeMaterialConnectionPoint;
  53147. protected _buildBlock(state: NodeMaterialBuildState): this;
  53148. }
  53149. }
  53150. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53151. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53152. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53153. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53154. /**
  53155. * Block used to output the final color
  53156. */
  53157. export class FragmentOutputBlock extends NodeMaterialBlock {
  53158. /**
  53159. * Gets or sets a boolean indicating if this block will output an alpha value
  53160. */
  53161. alphaBlendingEnabled: boolean;
  53162. /**
  53163. * Create a new FragmentOutputBlock
  53164. * @param name defines the block name
  53165. */
  53166. constructor(name: string);
  53167. /**
  53168. * Gets the current class name
  53169. * @returns the class name
  53170. */
  53171. getClassName(): string;
  53172. /**
  53173. * Gets the color input component
  53174. */
  53175. readonly color: NodeMaterialConnectionPoint;
  53176. protected _buildBlock(state: NodeMaterialBuildState): this;
  53177. }
  53178. }
  53179. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53180. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53181. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53182. import { Scene } from "babylonjs/scene";
  53183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53184. import { Matrix } from "babylonjs/Maths/math";
  53185. import { Mesh } from "babylonjs/Meshes/mesh";
  53186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53187. import { Observable } from "babylonjs/Misc/observable";
  53188. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53189. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53190. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53191. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53192. import { Nullable } from "babylonjs/types";
  53193. /**
  53194. * Interface used to configure the node material editor
  53195. */
  53196. export interface INodeMaterialEditorOptions {
  53197. /** Define the URl to load node editor script */
  53198. editorURL?: string;
  53199. }
  53200. /** @hidden */
  53201. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53202. /** BONES */
  53203. NUM_BONE_INFLUENCERS: number;
  53204. BonesPerMesh: number;
  53205. BONETEXTURE: boolean;
  53206. /** MORPH TARGETS */
  53207. MORPHTARGETS: boolean;
  53208. MORPHTARGETS_NORMAL: boolean;
  53209. MORPHTARGETS_TANGENT: boolean;
  53210. MORPHTARGETS_UV: boolean;
  53211. NUM_MORPH_INFLUENCERS: number;
  53212. /** IMAGE PROCESSING */
  53213. IMAGEPROCESSING: boolean;
  53214. VIGNETTE: boolean;
  53215. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53216. VIGNETTEBLENDMODEOPAQUE: boolean;
  53217. TONEMAPPING: boolean;
  53218. TONEMAPPING_ACES: boolean;
  53219. CONTRAST: boolean;
  53220. EXPOSURE: boolean;
  53221. COLORCURVES: boolean;
  53222. COLORGRADING: boolean;
  53223. COLORGRADING3D: boolean;
  53224. SAMPLER3DGREENDEPTH: boolean;
  53225. SAMPLER3DBGRMAP: boolean;
  53226. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53227. constructor();
  53228. setValue(name: string, value: boolean): void;
  53229. }
  53230. /**
  53231. * Class used to configure NodeMaterial
  53232. */
  53233. export interface INodeMaterialOptions {
  53234. /**
  53235. * Defines if blocks should emit comments
  53236. */
  53237. emitComments: boolean;
  53238. }
  53239. /**
  53240. * Class used to create a node based material built by assembling shader blocks
  53241. */
  53242. export class NodeMaterial extends PushMaterial {
  53243. private _options;
  53244. private _vertexCompilationState;
  53245. private _fragmentCompilationState;
  53246. private _sharedData;
  53247. private _buildId;
  53248. private _buildWasSuccessful;
  53249. private _cachedWorldViewMatrix;
  53250. private _cachedWorldViewProjectionMatrix;
  53251. private _optimizers;
  53252. /** Define the URl to load node editor script */
  53253. static EditorURL: string;
  53254. private BJSNODEMATERIALEDITOR;
  53255. /** Get the inspector from bundle or global */
  53256. private _getGlobalNodeMaterialEditor;
  53257. /**
  53258. * Defines the maximum number of lights that can be used in the material
  53259. */
  53260. maxSimultaneousLights: number;
  53261. /**
  53262. * Observable raised when the material is built
  53263. */
  53264. onBuildObservable: Observable<NodeMaterial>;
  53265. /**
  53266. * Gets or sets the root nodes of the material vertex shader
  53267. */
  53268. _vertexOutputNodes: NodeMaterialBlock[];
  53269. /**
  53270. * Gets or sets the root nodes of the material fragment (pixel) shader
  53271. */
  53272. _fragmentOutputNodes: NodeMaterialBlock[];
  53273. /** Gets or sets options to control the node material overall behavior */
  53274. options: INodeMaterialOptions;
  53275. /**
  53276. * Default configuration related to image processing available in the standard Material.
  53277. */
  53278. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53279. /**
  53280. * Gets the image processing configuration used either in this material.
  53281. */
  53282. /**
  53283. * Sets the Default image processing configuration used either in the this material.
  53284. *
  53285. * If sets to null, the scene one is in use.
  53286. */
  53287. imageProcessingConfiguration: ImageProcessingConfiguration;
  53288. /**
  53289. * Create a new node based material
  53290. * @param name defines the material name
  53291. * @param scene defines the hosting scene
  53292. * @param options defines creation option
  53293. */
  53294. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53295. /**
  53296. * Gets the current class name of the material e.g. "NodeMaterial"
  53297. * @returns the class name
  53298. */
  53299. getClassName(): string;
  53300. /**
  53301. * Keep track of the image processing observer to allow dispose and replace.
  53302. */
  53303. private _imageProcessingObserver;
  53304. /**
  53305. * Attaches a new image processing configuration to the Standard Material.
  53306. * @param configuration
  53307. */
  53308. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53309. /**
  53310. * Adds a new optimizer to the list of optimizers
  53311. * @param optimizer defines the optimizers to add
  53312. * @returns the current material
  53313. */
  53314. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53315. /**
  53316. * Remove an optimizer from the list of optimizers
  53317. * @param optimizer defines the optimizers to remove
  53318. * @returns the current material
  53319. */
  53320. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53321. /**
  53322. * Add a new block to the list of output nodes
  53323. * @param node defines the node to add
  53324. * @returns the current material
  53325. */
  53326. addOutputNode(node: NodeMaterialBlock): this;
  53327. /**
  53328. * Remove a block from the list of root nodes
  53329. * @param node defines the node to remove
  53330. * @returns the current material
  53331. */
  53332. removeOutputNode(node: NodeMaterialBlock): this;
  53333. private _addVertexOutputNode;
  53334. private _removeVertexOutputNode;
  53335. private _addFragmentOutputNode;
  53336. private _removeFragmentOutputNode;
  53337. /**
  53338. * Specifies if the material will require alpha blending
  53339. * @returns a boolean specifying if alpha blending is needed
  53340. */
  53341. needAlphaBlending(): boolean;
  53342. /**
  53343. * Specifies if this material should be rendered in alpha test mode
  53344. * @returns a boolean specifying if an alpha test is needed.
  53345. */
  53346. needAlphaTesting(): boolean;
  53347. private _initializeBlock;
  53348. private _resetDualBlocks;
  53349. /**
  53350. * Build the material and generates the inner effect
  53351. * @param verbose defines if the build should log activity
  53352. */
  53353. build(verbose?: boolean): void;
  53354. /**
  53355. * Runs an otpimization phase to try to improve the shader code
  53356. */
  53357. optimize(): void;
  53358. private _prepareDefinesForAttributes;
  53359. /**
  53360. * Get if the submesh is ready to be used and all its information available.
  53361. * Child classes can use it to update shaders
  53362. * @param mesh defines the mesh to check
  53363. * @param subMesh defines which submesh to check
  53364. * @param useInstances specifies that instances should be used
  53365. * @returns a boolean indicating that the submesh is ready or not
  53366. */
  53367. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53368. /**
  53369. * Binds the world matrix to the material
  53370. * @param world defines the world transformation matrix
  53371. */
  53372. bindOnlyWorldMatrix(world: Matrix): void;
  53373. /**
  53374. * Binds the submesh to this material by preparing the effect and shader to draw
  53375. * @param world defines the world transformation matrix
  53376. * @param mesh defines the mesh containing the submesh
  53377. * @param subMesh defines the submesh to bind the material to
  53378. */
  53379. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53380. /**
  53381. * Gets the active textures from the material
  53382. * @returns an array of textures
  53383. */
  53384. getActiveTextures(): BaseTexture[];
  53385. /**
  53386. * Specifies if the material uses a texture
  53387. * @param texture defines the texture to check against the material
  53388. * @returns a boolean specifying if the material uses the texture
  53389. */
  53390. hasTexture(texture: BaseTexture): boolean;
  53391. /**
  53392. * Disposes the material
  53393. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53394. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53395. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53396. */
  53397. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53398. /** Creates the node editor window. */
  53399. private _createNodeEditor;
  53400. /**
  53401. * Launch the node material editor
  53402. * @param config Define the configuration of the editor
  53403. * @return a promise fulfilled when the node editor is visible
  53404. */
  53405. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53406. /**
  53407. * Clear the current material
  53408. */
  53409. clear(): void;
  53410. /**
  53411. * Clear the current material and set it to a default state
  53412. */
  53413. setToDefault(): void;
  53414. }
  53415. }
  53416. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  53417. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53418. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53419. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53420. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53422. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53423. import { Effect } from "babylonjs/Materials/effect";
  53424. import { Mesh } from "babylonjs/Meshes/mesh";
  53425. import { Nullable } from "babylonjs/types";
  53426. /**
  53427. * Block used to read a texture from a sampler
  53428. */
  53429. export class TextureBlock extends NodeMaterialBlock {
  53430. private _defineName;
  53431. private _samplerName;
  53432. private _transformedUVName;
  53433. private _textureTransformName;
  53434. private _textureInfoName;
  53435. private _mainUVName;
  53436. private _mainUVDefineName;
  53437. /**
  53438. * Gets or sets the texture associated with the node
  53439. */
  53440. texture: Nullable<BaseTexture>;
  53441. /**
  53442. * Create a new TextureBlock
  53443. * @param name defines the block name
  53444. */
  53445. constructor(name: string);
  53446. /**
  53447. * Gets the current class name
  53448. * @returns the class name
  53449. */
  53450. getClassName(): string;
  53451. /**
  53452. * Gets the uv input component
  53453. */
  53454. readonly uv: NodeMaterialConnectionPoint;
  53455. /**
  53456. * Gets the output component
  53457. */
  53458. readonly output: NodeMaterialConnectionPoint;
  53459. autoConfigure(): void;
  53460. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53461. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53462. isReady(): boolean;
  53463. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53464. private _injectVertexCode;
  53465. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53466. }
  53467. }
  53468. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  53469. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53470. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53471. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  53472. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  53473. /**
  53474. * Class used to store shared data between 2 NodeMaterialBuildState
  53475. */
  53476. export class NodeMaterialBuildStateSharedData {
  53477. /**
  53478. * Gets the list of emitted varyings
  53479. */
  53480. varyings: string[];
  53481. /**
  53482. * Gets the varying declaration string
  53483. */
  53484. varyingDeclaration: string;
  53485. /**
  53486. * Input blocks
  53487. */
  53488. inputBlocks: InputBlock[];
  53489. /**
  53490. * Input blocks
  53491. */
  53492. textureBlocks: TextureBlock[];
  53493. /**
  53494. * Bindable blocks (Blocks that need to set data to the effect)
  53495. */
  53496. bindableBlocks: NodeMaterialBlock[];
  53497. /**
  53498. * List of blocks that can provide a compilation fallback
  53499. */
  53500. blocksWithFallbacks: NodeMaterialBlock[];
  53501. /**
  53502. * List of blocks that can provide a define update
  53503. */
  53504. blocksWithDefines: NodeMaterialBlock[];
  53505. /**
  53506. * List of blocks that can provide a repeatable content
  53507. */
  53508. repeatableContentBlocks: NodeMaterialBlock[];
  53509. /**
  53510. * List of blocks that can provide a dynamic list of uniforms
  53511. */
  53512. dynamicUniformBlocks: NodeMaterialBlock[];
  53513. /**
  53514. * List of blocks that can block the isReady function for the material
  53515. */
  53516. blockingBlocks: NodeMaterialBlock[];
  53517. /**
  53518. * Build Id used to avoid multiple recompilations
  53519. */
  53520. buildId: number;
  53521. /** List of emitted variables */
  53522. variableNames: {
  53523. [key: string]: number;
  53524. };
  53525. /** List of emitted defines */
  53526. defineNames: {
  53527. [key: string]: number;
  53528. };
  53529. /** Should emit comments? */
  53530. emitComments: boolean;
  53531. /** Emit build activity */
  53532. verbose: boolean;
  53533. /**
  53534. * Gets the compilation hints emitted at compilation time
  53535. */
  53536. hints: {
  53537. needWorldViewMatrix: boolean;
  53538. needWorldViewProjectionMatrix: boolean;
  53539. needAlphaBlending: boolean;
  53540. needAlphaTesting: boolean;
  53541. };
  53542. /**
  53543. * List of compilation checks
  53544. */
  53545. checks: {
  53546. emitVertex: boolean;
  53547. emitFragment: boolean;
  53548. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53549. };
  53550. /** Creates a new shared data */
  53551. constructor();
  53552. /**
  53553. * Emits console errors and exceptions if there is a failing check
  53554. */
  53555. emitErrors(): void;
  53556. }
  53557. }
  53558. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  53559. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53560. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53561. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  53562. /**
  53563. * Class used to store node based material build state
  53564. */
  53565. export class NodeMaterialBuildState {
  53566. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53567. supportUniformBuffers: boolean;
  53568. /**
  53569. * Gets the list of emitted attributes
  53570. */
  53571. attributes: string[];
  53572. /**
  53573. * Gets the list of emitted uniforms
  53574. */
  53575. uniforms: string[];
  53576. /**
  53577. * Gets the list of emitted uniform buffers
  53578. */
  53579. uniformBuffers: string[];
  53580. /**
  53581. * Gets the list of emitted samplers
  53582. */
  53583. samplers: string[];
  53584. /**
  53585. * Gets the list of emitted functions
  53586. */
  53587. functions: {
  53588. [key: string]: string;
  53589. };
  53590. /**
  53591. * Gets the target of the compilation state
  53592. */
  53593. target: NodeMaterialBlockTargets;
  53594. /**
  53595. * Gets the list of emitted counters
  53596. */
  53597. counters: {
  53598. [key: string]: number;
  53599. };
  53600. /**
  53601. * Shared data between multiple NodeMaterialBuildState instances
  53602. */
  53603. sharedData: NodeMaterialBuildStateSharedData;
  53604. /** @hidden */
  53605. _vertexState: NodeMaterialBuildState;
  53606. /** @hidden */
  53607. _attributeDeclaration: string;
  53608. /** @hidden */
  53609. _uniformDeclaration: string;
  53610. /** @hidden */
  53611. _samplerDeclaration: string;
  53612. /** @hidden */
  53613. _varyingTransfer: string;
  53614. private _repeatableContentAnchorIndex;
  53615. /** @hidden */
  53616. _builtCompilationString: string;
  53617. /**
  53618. * Gets the emitted compilation strings
  53619. */
  53620. compilationString: string;
  53621. /**
  53622. * Finalize the compilation strings
  53623. * @param state defines the current compilation state
  53624. */
  53625. finalize(state: NodeMaterialBuildState): void;
  53626. /** @hidden */
  53627. readonly _repeatableContentAnchor: string;
  53628. /** @hidden */
  53629. _getFreeVariableName(prefix: string): string;
  53630. /** @hidden */
  53631. _getFreeDefineName(prefix: string): string;
  53632. /** @hidden */
  53633. _excludeVariableName(name: string): void;
  53634. /** @hidden */
  53635. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53636. /** @hidden */
  53637. _emitFunction(name: string, code: string, comments: string): void;
  53638. /** @hidden */
  53639. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53640. replaceStrings?: {
  53641. search: RegExp;
  53642. replace: string;
  53643. }[];
  53644. repeatKey?: string;
  53645. }): string;
  53646. /** @hidden */
  53647. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53648. repeatKey?: string;
  53649. removeAttributes?: boolean;
  53650. removeUniforms?: boolean;
  53651. removeVaryings?: boolean;
  53652. removeIfDef?: boolean;
  53653. replaceStrings?: {
  53654. search: RegExp;
  53655. replace: string;
  53656. }[];
  53657. }, storeKey?: string): void;
  53658. /** @hidden */
  53659. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53660. /** @hidden */
  53661. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53662. }
  53663. }
  53664. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53665. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53666. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53667. import { Nullable } from "babylonjs/types";
  53668. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53669. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53670. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53672. import { Mesh } from "babylonjs/Meshes/mesh";
  53673. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53674. /**
  53675. * Defines a block that can be used inside a node based material
  53676. */
  53677. export class NodeMaterialBlock {
  53678. private _buildId;
  53679. private _buildTarget;
  53680. private _target;
  53681. private _isFinalMerger;
  53682. private _isInput;
  53683. /** @hidden */
  53684. _inputs: NodeMaterialConnectionPoint[];
  53685. /** @hidden */
  53686. _outputs: NodeMaterialConnectionPoint[];
  53687. /**
  53688. * Gets or sets the name of the block
  53689. */
  53690. name: string;
  53691. /**
  53692. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53693. */
  53694. readonly isFinalMerger: boolean;
  53695. /**
  53696. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53697. */
  53698. readonly isInput: boolean;
  53699. /**
  53700. * Gets or sets the build Id
  53701. */
  53702. buildId: number;
  53703. /**
  53704. * Gets or sets the target of the block
  53705. */
  53706. target: NodeMaterialBlockTargets;
  53707. /**
  53708. * Gets the list of input points
  53709. */
  53710. readonly inputs: NodeMaterialConnectionPoint[];
  53711. /** Gets the list of output points */
  53712. readonly outputs: NodeMaterialConnectionPoint[];
  53713. /**
  53714. * Find an input by its name
  53715. * @param name defines the name of the input to look for
  53716. * @returns the input or null if not found
  53717. */
  53718. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53719. /**
  53720. * Find an output by its name
  53721. * @param name defines the name of the outputto look for
  53722. * @returns the output or null if not found
  53723. */
  53724. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53725. /**
  53726. * Creates a new NodeMaterialBlock
  53727. * @param name defines the block name
  53728. * @param target defines the target of that block (Vertex by default)
  53729. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53730. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53731. */
  53732. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53733. /**
  53734. * Initialize the block and prepare the context for build
  53735. * @param state defines the state that will be used for the build
  53736. */
  53737. initialize(state: NodeMaterialBuildState): void;
  53738. /**
  53739. * Bind data to effect. Will only be called for blocks with isBindable === true
  53740. * @param effect defines the effect to bind data to
  53741. * @param nodeMaterial defines the hosting NodeMaterial
  53742. * @param mesh defines the mesh that will be rendered
  53743. */
  53744. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53745. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53746. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53747. protected _writeFloat(value: number): string;
  53748. /**
  53749. * Gets the current class name e.g. "NodeMaterialBlock"
  53750. * @returns the class name
  53751. */
  53752. getClassName(): string;
  53753. /**
  53754. * Register a new input. Must be called inside a block constructor
  53755. * @param name defines the connection point name
  53756. * @param type defines the connection point type
  53757. * @param isOptional defines a boolean indicating that this input can be omitted
  53758. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53759. * @returns the current block
  53760. */
  53761. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53762. /**
  53763. * Register a new output. Must be called inside a block constructor
  53764. * @param name defines the connection point name
  53765. * @param type defines the connection point type
  53766. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53767. * @returns the current block
  53768. */
  53769. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53770. /**
  53771. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53772. * @param forOutput defines an optional connection point to check compatibility with
  53773. * @returns the first available input or null
  53774. */
  53775. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53776. /**
  53777. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53778. * @param forBlock defines an optional block to check compatibility with
  53779. * @returns the first available input or null
  53780. */
  53781. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53782. /**
  53783. * Connect current block with another block
  53784. * @param other defines the block to connect with
  53785. * @param options define the various options to help pick the right connections
  53786. * @returns the current block
  53787. */
  53788. connectTo(other: NodeMaterialBlock, options?: {
  53789. input?: string;
  53790. output?: string;
  53791. outputSwizzle?: string;
  53792. }): this | undefined;
  53793. protected _buildBlock(state: NodeMaterialBuildState): void;
  53794. /**
  53795. * Add uniforms, samplers and uniform buffers at compilation time
  53796. * @param state defines the state to update
  53797. * @param nodeMaterial defines the node material requesting the update
  53798. * @param defines defines the material defines to update
  53799. */
  53800. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53801. /**
  53802. * Add potential fallbacks if shader compilation fails
  53803. * @param mesh defines the mesh to be rendered
  53804. * @param fallbacks defines the current prioritized list of fallbacks
  53805. */
  53806. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53807. /**
  53808. * Update defines for shader compilation
  53809. * @param mesh defines the mesh to be rendered
  53810. * @param nodeMaterial defines the node material requesting the update
  53811. * @param defines defines the material defines to update
  53812. * @param useInstances specifies that instances should be used
  53813. */
  53814. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53815. /**
  53816. * Initialize defines for shader compilation
  53817. * @param mesh defines the mesh to be rendered
  53818. * @param nodeMaterial defines the node material requesting the update
  53819. * @param defines defines the material defines to be prepared
  53820. * @param useInstances specifies that instances should be used
  53821. */
  53822. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53823. /**
  53824. * Lets the block try to connect some inputs automatically
  53825. */
  53826. autoConfigure(): void;
  53827. /**
  53828. * Function called when a block is declared as repeatable content generator
  53829. * @param vertexShaderState defines the current compilation state for the vertex shader
  53830. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53831. * @param mesh defines the mesh to be rendered
  53832. * @param defines defines the material defines to update
  53833. */
  53834. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53835. /**
  53836. * Checks if the block is ready
  53837. * @param mesh defines the mesh to be rendered
  53838. * @param nodeMaterial defines the node material requesting the update
  53839. * @param defines defines the material defines to update
  53840. * @param useInstances specifies that instances should be used
  53841. * @returns true if the block is ready
  53842. */
  53843. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53844. private _processBuild;
  53845. /**
  53846. * Compile the current node and generate the shader code
  53847. * @param state defines the current compilation state (uniforms, samplers, current string)
  53848. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  53849. * @returns true if already built
  53850. */
  53851. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  53852. }
  53853. }
  53854. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  53855. /**
  53856. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53857. */
  53858. export enum NodeMaterialBlockConnectionPointMode {
  53859. /** Value is an uniform */
  53860. Uniform = 0,
  53861. /** Value is a mesh attribute */
  53862. Attribute = 1,
  53863. /** Value is a varying between vertex and fragment shaders */
  53864. Varying = 2,
  53865. /** Mode is undefined */
  53866. Undefined = 3
  53867. }
  53868. }
  53869. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  53870. /**
  53871. * Enum used to define well known values e.g. values automatically provided by the system
  53872. */
  53873. export enum NodeMaterialWellKnownValues {
  53874. /** World */
  53875. World = 1,
  53876. /** View */
  53877. View = 2,
  53878. /** Projection */
  53879. Projection = 3,
  53880. /** ViewProjection */
  53881. ViewProjection = 4,
  53882. /** WorldView */
  53883. WorldView = 5,
  53884. /** WorldViewProjection */
  53885. WorldViewProjection = 6,
  53886. /** CameraPosition */
  53887. CameraPosition = 7,
  53888. /** Fog Color */
  53889. FogColor = 8
  53890. }
  53891. }
  53892. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  53893. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53894. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53895. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53896. import { Nullable } from "babylonjs/types";
  53897. import { Effect } from "babylonjs/Materials/effect";
  53898. import { Matrix } from "babylonjs/Maths/math";
  53899. import { Scene } from "babylonjs/scene";
  53900. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53902. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53903. /**
  53904. * Block used to expose an input value
  53905. */
  53906. export class InputBlock extends NodeMaterialBlock {
  53907. private _mode;
  53908. private _associatedVariableName;
  53909. private _storedValue;
  53910. private _valueCallback;
  53911. private _type;
  53912. /** @hidden */
  53913. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53914. /**
  53915. * Gets or sets the connection point type (default is float)
  53916. */
  53917. readonly type: NodeMaterialBlockConnectionPointTypes;
  53918. /**
  53919. * Creates a new InputBlock
  53920. * @param name defines the block name
  53921. * @param target defines the target of that block (Vertex by default)
  53922. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53923. */
  53924. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53925. /**
  53926. * Gets the output component
  53927. */
  53928. readonly output: NodeMaterialConnectionPoint;
  53929. /**
  53930. * Set the source of this connection point to a vertex attribute
  53931. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53932. * @returns the current connection point
  53933. */
  53934. setAsAttribute(attributeName?: string): InputBlock;
  53935. /**
  53936. * Set the source of this connection point to a well known value
  53937. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53938. * @returns the current connection point
  53939. */
  53940. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  53941. /**
  53942. * Gets or sets the value of that point.
  53943. * Please note that this value will be ignored if valueCallback is defined
  53944. */
  53945. value: any;
  53946. /**
  53947. * Gets or sets a callback used to get the value of that point.
  53948. * Please note that setting this value will force the connection point to ignore the value property
  53949. */
  53950. valueCallback: () => any;
  53951. /**
  53952. * Gets or sets the associated variable name in the shader
  53953. */
  53954. associatedVariableName: string;
  53955. /**
  53956. * Gets a boolean indicating that this connection point not defined yet
  53957. */
  53958. readonly isUndefined: boolean;
  53959. /**
  53960. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53961. * In this case the connection point name must be the name of the uniform to use.
  53962. * Can only be set on inputs
  53963. */
  53964. isUniform: boolean;
  53965. /**
  53966. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53967. * In this case the connection point name must be the name of the attribute to use
  53968. * Can only be set on inputs
  53969. */
  53970. isAttribute: boolean;
  53971. /**
  53972. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53973. * Can only be set on exit points
  53974. */
  53975. isVarying: boolean;
  53976. /**
  53977. * Gets a boolean indicating that the current connection point is a well known value
  53978. */
  53979. readonly isWellKnownValue: boolean;
  53980. /**
  53981. * Gets or sets the current well known value or null if not defined as well know value
  53982. */
  53983. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53984. /**
  53985. * Gets the current class name
  53986. * @returns the class name
  53987. */
  53988. getClassName(): string;
  53989. private _emitDefine;
  53990. /**
  53991. * Set the input block to its default value (based on its type)
  53992. */
  53993. setDefaultValue(): void;
  53994. private _emit;
  53995. /** @hidden */
  53996. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53997. /** @hidden */
  53998. _transmit(effect: Effect, scene: Scene): void;
  53999. protected _buildBlock(state: NodeMaterialBuildState): void;
  54000. }
  54001. }
  54002. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  54003. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54004. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54005. import { Nullable } from "babylonjs/types";
  54006. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54007. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54008. /**
  54009. * Defines a connection point for a block
  54010. */
  54011. export class NodeMaterialConnectionPoint {
  54012. /** @hidden */
  54013. _ownerBlock: NodeMaterialBlock;
  54014. /** @hidden */
  54015. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54016. private _endpoints;
  54017. private _associatedVariableName;
  54018. /** @hidden */
  54019. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54020. private _type;
  54021. /** @hidden */
  54022. _enforceAssociatedVariableName: boolean;
  54023. /**
  54024. * Gets or sets the associated variable name in the shader
  54025. */
  54026. associatedVariableName: string;
  54027. /**
  54028. * Gets or sets the connection point type (default is float)
  54029. */
  54030. type: NodeMaterialBlockConnectionPointTypes;
  54031. /**
  54032. * Gets or sets the connection point name
  54033. */
  54034. name: string;
  54035. /**
  54036. * Gets or sets the swizzle to apply to this connection point when reading or writing
  54037. */
  54038. swizzle: string;
  54039. /**
  54040. * Gets or sets a boolean indicating that this connection point can be omitted
  54041. */
  54042. isOptional: boolean;
  54043. /**
  54044. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54045. */
  54046. define: string;
  54047. /** Gets or sets the target of that connection point */
  54048. target: NodeMaterialBlockTargets;
  54049. /**
  54050. * Gets a boolean indicating that the current point is connected
  54051. */
  54052. readonly isConnected: boolean;
  54053. /**
  54054. * Gets a boolean indicating that the current point is connected to an input block
  54055. */
  54056. readonly isConnectedToInput: boolean;
  54057. /**
  54058. * Gets a the connected input block (if any)
  54059. */
  54060. readonly connectInputBlock: Nullable<InputBlock>;
  54061. /** Get the other side of the connection (if any) */
  54062. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54063. /** Get the block that owns this connection point */
  54064. readonly ownerBlock: NodeMaterialBlock;
  54065. /** Get the block connected on the other side of this connection (if any) */
  54066. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54067. /** Get the block connected on the endpoints of this connection (if any) */
  54068. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54069. /** Gets the list of connected endpoints */
  54070. readonly endpoints: NodeMaterialConnectionPoint[];
  54071. /**
  54072. * Creates a new connection point
  54073. * @param name defines the connection point name
  54074. * @param ownerBlock defines the block hosting this connection point
  54075. */
  54076. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54077. /**
  54078. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54079. * @returns the class name
  54080. */
  54081. getClassName(): string;
  54082. private _getTypeLength;
  54083. /**
  54084. * Gets an boolean indicating if the current point can be connected to another point
  54085. * @param connectionPoint defines the other connection point
  54086. * @returns true if the connection is possible
  54087. */
  54088. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54089. /**
  54090. * Connect this point to another connection point
  54091. * @param connectionPoint defines the other connection point
  54092. * @returns the current connection point
  54093. */
  54094. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54095. /**
  54096. * Disconnect this point from one of his endpoint
  54097. * @param endpoint defines the other connection point
  54098. * @returns the current connection point
  54099. */
  54100. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54101. }
  54102. }
  54103. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  54104. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54105. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54107. import { Mesh } from "babylonjs/Meshes/mesh";
  54108. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54109. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54110. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54111. /**
  54112. * Block used to add support for vertex skinning (bones)
  54113. */
  54114. export class BonesBlock extends NodeMaterialBlock {
  54115. /**
  54116. * Creates a new BonesBlock
  54117. * @param name defines the block name
  54118. */
  54119. constructor(name: string);
  54120. /**
  54121. * Initialize the block and prepare the context for build
  54122. * @param state defines the state that will be used for the build
  54123. */
  54124. initialize(state: NodeMaterialBuildState): void;
  54125. /**
  54126. * Gets the current class name
  54127. * @returns the class name
  54128. */
  54129. getClassName(): string;
  54130. /**
  54131. * Gets the matrix indices input component
  54132. */
  54133. readonly matricesIndices: NodeMaterialConnectionPoint;
  54134. /**
  54135. * Gets the matrix weights input component
  54136. */
  54137. readonly matricesWeights: NodeMaterialConnectionPoint;
  54138. /**
  54139. * Gets the extra matrix indices input component
  54140. */
  54141. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54142. /**
  54143. * Gets the extra matrix weights input component
  54144. */
  54145. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54146. /**
  54147. * Gets the world input component
  54148. */
  54149. readonly world: NodeMaterialConnectionPoint;
  54150. /**
  54151. * Gets the output component
  54152. */
  54153. readonly output: NodeMaterialConnectionPoint;
  54154. autoConfigure(): void;
  54155. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54156. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54157. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54158. protected _buildBlock(state: NodeMaterialBuildState): this;
  54159. }
  54160. }
  54161. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  54162. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54163. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54164. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54166. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54167. /**
  54168. * Block used to add support for instances
  54169. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54170. */
  54171. export class InstancesBlock extends NodeMaterialBlock {
  54172. /**
  54173. * Creates a new InstancesBlock
  54174. * @param name defines the block name
  54175. */
  54176. constructor(name: string);
  54177. /**
  54178. * Gets the current class name
  54179. * @returns the class name
  54180. */
  54181. getClassName(): string;
  54182. /**
  54183. * Gets the first world row input component
  54184. */
  54185. readonly world0: NodeMaterialConnectionPoint;
  54186. /**
  54187. * Gets the second world row input component
  54188. */
  54189. readonly world1: NodeMaterialConnectionPoint;
  54190. /**
  54191. * Gets the third world row input component
  54192. */
  54193. readonly world2: NodeMaterialConnectionPoint;
  54194. /**
  54195. * Gets the forth world row input component
  54196. */
  54197. readonly world3: NodeMaterialConnectionPoint;
  54198. /**
  54199. * Gets the world input component
  54200. */
  54201. readonly world: NodeMaterialConnectionPoint;
  54202. /**
  54203. * Gets the output component
  54204. */
  54205. readonly output: NodeMaterialConnectionPoint;
  54206. autoConfigure(): void;
  54207. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54208. protected _buildBlock(state: NodeMaterialBuildState): this;
  54209. }
  54210. }
  54211. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  54212. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54213. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54214. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54216. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54217. import { Effect } from "babylonjs/Materials/effect";
  54218. import { Mesh } from "babylonjs/Meshes/mesh";
  54219. /**
  54220. * Block used to add morph targets support to vertex shader
  54221. */
  54222. export class MorphTargetsBlock extends NodeMaterialBlock {
  54223. private _repeatableContentAnchor;
  54224. private _repeatebleContentGenerated;
  54225. /**
  54226. * Create a new MorphTargetsBlock
  54227. * @param name defines the block name
  54228. */
  54229. constructor(name: string);
  54230. /**
  54231. * Gets the current class name
  54232. * @returns the class name
  54233. */
  54234. getClassName(): string;
  54235. /**
  54236. * Gets the position input component
  54237. */
  54238. readonly position: NodeMaterialConnectionPoint;
  54239. /**
  54240. * Gets the normal input component
  54241. */
  54242. readonly normal: NodeMaterialConnectionPoint;
  54243. /**
  54244. * Gets the tangent input component
  54245. */
  54246. readonly tangent: NodeMaterialConnectionPoint;
  54247. /**
  54248. * Gets the tangent input component
  54249. */
  54250. readonly uv: NodeMaterialConnectionPoint;
  54251. /**
  54252. * Gets the position output component
  54253. */
  54254. readonly positionOutput: NodeMaterialConnectionPoint;
  54255. /**
  54256. * Gets the normal output component
  54257. */
  54258. readonly normalOutput: NodeMaterialConnectionPoint;
  54259. /**
  54260. * Gets the tangent output component
  54261. */
  54262. readonly tangentOutput: NodeMaterialConnectionPoint;
  54263. /**
  54264. * Gets the tangent output component
  54265. */
  54266. readonly uvOutput: NodeMaterialConnectionPoint;
  54267. initialize(state: NodeMaterialBuildState): void;
  54268. autoConfigure(): void;
  54269. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54270. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54271. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54272. protected _buildBlock(state: NodeMaterialBuildState): this;
  54273. }
  54274. }
  54275. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54276. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54277. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54278. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54279. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54280. }
  54281. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54282. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54283. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54284. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54285. /**
  54286. * Block used to add an alpha test in the fragment shader
  54287. */
  54288. export class AlphaTestBlock extends NodeMaterialBlock {
  54289. /**
  54290. * Gets or sets the alpha value where alpha testing happens
  54291. */
  54292. alphaCutOff: number;
  54293. /**
  54294. * Create a new AlphaTestBlock
  54295. * @param name defines the block name
  54296. */
  54297. constructor(name: string);
  54298. /**
  54299. * Gets the current class name
  54300. * @returns the class name
  54301. */
  54302. getClassName(): string;
  54303. /**
  54304. * Gets the color input component
  54305. */
  54306. readonly color: NodeMaterialConnectionPoint;
  54307. protected _buildBlock(state: NodeMaterialBuildState): this;
  54308. }
  54309. }
  54310. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  54311. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54312. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54313. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54314. /**
  54315. * Block used to create a Color4 out of 4 inputs (one for each component)
  54316. */
  54317. export class RGBAMergerBlock extends NodeMaterialBlock {
  54318. /**
  54319. * Create a new RGBAMergerBlock
  54320. * @param name defines the block name
  54321. */
  54322. constructor(name: string);
  54323. /**
  54324. * Gets the current class name
  54325. * @returns the class name
  54326. */
  54327. getClassName(): string;
  54328. /**
  54329. * Gets the R input component
  54330. */
  54331. readonly r: NodeMaterialConnectionPoint;
  54332. /**
  54333. * Gets the G input component
  54334. */
  54335. readonly g: NodeMaterialConnectionPoint;
  54336. /**
  54337. * Gets the B input component
  54338. */
  54339. readonly b: NodeMaterialConnectionPoint;
  54340. /**
  54341. * Gets the RGB input component
  54342. */
  54343. readonly rgb: NodeMaterialConnectionPoint;
  54344. /**
  54345. * Gets the R input component
  54346. */
  54347. readonly a: NodeMaterialConnectionPoint;
  54348. /**
  54349. * Gets the output component
  54350. */
  54351. readonly output: NodeMaterialConnectionPoint;
  54352. protected _buildBlock(state: NodeMaterialBuildState): this;
  54353. }
  54354. }
  54355. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  54356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54357. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54358. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54359. /**
  54360. * Block used to create a Color3 out of 3 inputs (one for each component)
  54361. */
  54362. export class RGBMergerBlock extends NodeMaterialBlock {
  54363. /**
  54364. * Create a new RGBMergerBlock
  54365. * @param name defines the block name
  54366. */
  54367. constructor(name: string);
  54368. /**
  54369. * Gets the current class name
  54370. * @returns the class name
  54371. */
  54372. getClassName(): string;
  54373. /**
  54374. * Gets the R component input
  54375. */
  54376. readonly r: NodeMaterialConnectionPoint;
  54377. /**
  54378. * Gets the G component input
  54379. */
  54380. readonly g: NodeMaterialConnectionPoint;
  54381. /**
  54382. * Gets the B component input
  54383. */
  54384. readonly b: NodeMaterialConnectionPoint;
  54385. /**
  54386. * Gets the output component
  54387. */
  54388. readonly output: NodeMaterialConnectionPoint;
  54389. protected _buildBlock(state: NodeMaterialBuildState): this;
  54390. }
  54391. }
  54392. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  54393. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54394. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54395. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54396. /**
  54397. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  54398. */
  54399. export class RGBASplitterBlock extends NodeMaterialBlock {
  54400. /**
  54401. * Create a new RGBASplitterBlock
  54402. * @param name defines the block name
  54403. */
  54404. constructor(name: string);
  54405. /**
  54406. * Gets the current class name
  54407. * @returns the class name
  54408. */
  54409. getClassName(): string;
  54410. /**
  54411. * Gets the input component
  54412. */
  54413. readonly input: NodeMaterialConnectionPoint;
  54414. protected _buildBlock(state: NodeMaterialBuildState): this;
  54415. }
  54416. }
  54417. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  54418. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54419. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54420. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54421. /**
  54422. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  54423. */
  54424. export class RGBSplitterBlock extends NodeMaterialBlock {
  54425. /**
  54426. * Create a new RGBSplitterBlock
  54427. * @param name defines the block name
  54428. */
  54429. constructor(name: string);
  54430. /**
  54431. * Gets the current class name
  54432. * @returns the class name
  54433. */
  54434. getClassName(): string;
  54435. /**
  54436. * Gets the input component
  54437. */
  54438. readonly input: NodeMaterialConnectionPoint;
  54439. protected _buildBlock(state: NodeMaterialBuildState): this;
  54440. }
  54441. }
  54442. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  54443. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54444. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54445. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54447. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54448. import { Effect } from "babylonjs/Materials/effect";
  54449. import { Mesh } from "babylonjs/Meshes/mesh";
  54450. /**
  54451. * Block used to add image processing support to fragment shader
  54452. */
  54453. export class ImageProcessingBlock extends NodeMaterialBlock {
  54454. /**
  54455. * Create a new ImageProcessingBlock
  54456. * @param name defines the block name
  54457. */
  54458. constructor(name: string);
  54459. /**
  54460. * Gets the current class name
  54461. * @returns the class name
  54462. */
  54463. getClassName(): string;
  54464. /**
  54465. * Gets the color input component
  54466. */
  54467. readonly color: NodeMaterialConnectionPoint;
  54468. /**
  54469. * Gets the output component
  54470. */
  54471. readonly output: NodeMaterialConnectionPoint;
  54472. /**
  54473. * Initialize the block and prepare the context for build
  54474. * @param state defines the state that will be used for the build
  54475. */
  54476. initialize(state: NodeMaterialBuildState): void;
  54477. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54478. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54479. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54480. protected _buildBlock(state: NodeMaterialBuildState): this;
  54481. }
  54482. }
  54483. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  54484. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  54485. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  54486. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  54487. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  54488. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  54489. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  54490. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  54491. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  54492. }
  54493. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  54494. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54495. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54496. import { Mesh } from "babylonjs/Meshes/mesh";
  54497. import { Effect } from "babylonjs/Materials/effect";
  54498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54500. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54501. /**
  54502. * Block used to add support for scene fog
  54503. */
  54504. export class FogBlock extends NodeMaterialBlock {
  54505. private _fogDistanceName;
  54506. private _fogParameters;
  54507. /**
  54508. * Create a new FogBlock
  54509. * @param name defines the block name
  54510. */
  54511. constructor(name: string);
  54512. /**
  54513. * Gets the current class name
  54514. * @returns the class name
  54515. */
  54516. getClassName(): string;
  54517. /**
  54518. * Gets the world position input component
  54519. */
  54520. readonly worldPosition: NodeMaterialConnectionPoint;
  54521. /**
  54522. * Gets the view input component
  54523. */
  54524. readonly view: NodeMaterialConnectionPoint;
  54525. /**
  54526. * Gets the color input component
  54527. */
  54528. readonly color: NodeMaterialConnectionPoint;
  54529. /**
  54530. * Gets the fog color input component
  54531. */
  54532. readonly fogColor: NodeMaterialConnectionPoint;
  54533. /**
  54534. * Gets the output component
  54535. */
  54536. readonly output: NodeMaterialConnectionPoint;
  54537. autoConfigure(): void;
  54538. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54539. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54540. protected _buildBlock(state: NodeMaterialBuildState): this;
  54541. }
  54542. }
  54543. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  54544. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54545. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54546. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54548. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54549. import { Effect } from "babylonjs/Materials/effect";
  54550. import { Mesh } from "babylonjs/Meshes/mesh";
  54551. import { Light } from "babylonjs/Lights/light";
  54552. import { Nullable } from "babylonjs/types";
  54553. /**
  54554. * Block used to add light in the fragment shader
  54555. */
  54556. export class LightBlock extends NodeMaterialBlock {
  54557. private _lightId;
  54558. /**
  54559. * Gets or sets the light associated with this block
  54560. */
  54561. light: Nullable<Light>;
  54562. /**
  54563. * Create a new LightBlock
  54564. * @param name defines the block name
  54565. */
  54566. constructor(name: string);
  54567. /**
  54568. * Gets the current class name
  54569. * @returns the class name
  54570. */
  54571. getClassName(): string;
  54572. /**
  54573. * Gets the world position input component
  54574. */
  54575. readonly worldPosition: NodeMaterialConnectionPoint;
  54576. /**
  54577. * Gets the world normal input component
  54578. */
  54579. readonly worldNormal: NodeMaterialConnectionPoint;
  54580. /**
  54581. * Gets the camera (or eye) position component
  54582. */
  54583. readonly cameraPosition: NodeMaterialConnectionPoint;
  54584. /**
  54585. * Gets the diffuse output component
  54586. */
  54587. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54588. /**
  54589. * Gets the specular output component
  54590. */
  54591. readonly specularOutput: NodeMaterialConnectionPoint;
  54592. autoConfigure(): void;
  54593. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54594. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54595. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54596. private _injectVertexCode;
  54597. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54598. }
  54599. }
  54600. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  54601. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  54602. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  54603. }
  54604. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  54605. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54606. }
  54607. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  54608. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54609. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54610. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54611. /**
  54612. * Block used to multiply 2 values
  54613. */
  54614. export class MultiplyBlock extends NodeMaterialBlock {
  54615. /**
  54616. * Creates a new MultiplyBlock
  54617. * @param name defines the block name
  54618. */
  54619. constructor(name: string);
  54620. /**
  54621. * Gets the current class name
  54622. * @returns the class name
  54623. */
  54624. getClassName(): string;
  54625. /**
  54626. * Gets the left operand input component
  54627. */
  54628. readonly left: NodeMaterialConnectionPoint;
  54629. /**
  54630. * Gets the right operand input component
  54631. */
  54632. readonly right: NodeMaterialConnectionPoint;
  54633. /**
  54634. * Gets the output component
  54635. */
  54636. readonly output: NodeMaterialConnectionPoint;
  54637. protected _buildBlock(state: NodeMaterialBuildState): this;
  54638. }
  54639. }
  54640. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  54641. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54642. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54643. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54644. /**
  54645. * Block used to add 2 vector4
  54646. */
  54647. export class AddBlock extends NodeMaterialBlock {
  54648. /**
  54649. * Creates a new AddBlock
  54650. * @param name defines the block name
  54651. */
  54652. constructor(name: string);
  54653. /**
  54654. * Gets the current class name
  54655. * @returns the class name
  54656. */
  54657. getClassName(): string;
  54658. /**
  54659. * Gets the left operand input component
  54660. */
  54661. readonly left: NodeMaterialConnectionPoint;
  54662. /**
  54663. * Gets the right operand input component
  54664. */
  54665. readonly right: NodeMaterialConnectionPoint;
  54666. /**
  54667. * Gets the output component
  54668. */
  54669. readonly output: NodeMaterialConnectionPoint;
  54670. protected _buildBlock(state: NodeMaterialBuildState): this;
  54671. }
  54672. }
  54673. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  54674. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54675. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54676. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54677. /**
  54678. * Block used to clamp a float
  54679. */
  54680. export class ClampBlock extends NodeMaterialBlock {
  54681. /** Gets or sets the minimum range */
  54682. minimum: number;
  54683. /** Gets or sets the maximum range */
  54684. maximum: number;
  54685. /**
  54686. * Creates a new ClampBlock
  54687. * @param name defines the block name
  54688. */
  54689. constructor(name: string);
  54690. /**
  54691. * Gets the current class name
  54692. * @returns the class name
  54693. */
  54694. getClassName(): string;
  54695. /**
  54696. * Gets the value input component
  54697. */
  54698. readonly value: NodeMaterialConnectionPoint;
  54699. /**
  54700. * Gets the output component
  54701. */
  54702. readonly output: NodeMaterialConnectionPoint;
  54703. protected _buildBlock(state: NodeMaterialBuildState): this;
  54704. }
  54705. }
  54706. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  54707. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54708. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54709. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54710. /**
  54711. * Block used to transform a vector2 with a matrix
  54712. */
  54713. export class Vector2TransformBlock extends NodeMaterialBlock {
  54714. /**
  54715. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54716. */
  54717. complementZ: number;
  54718. /**
  54719. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54720. */
  54721. complementW: number;
  54722. /**
  54723. * Creates a new Vector2TransformBlock
  54724. * @param name defines the block name
  54725. */
  54726. constructor(name: string);
  54727. /**
  54728. * Gets the vector input
  54729. */
  54730. readonly vector: NodeMaterialConnectionPoint;
  54731. /**
  54732. * Gets the matrix transform input
  54733. */
  54734. readonly transform: NodeMaterialConnectionPoint;
  54735. /**
  54736. * Gets the output component
  54737. */
  54738. readonly output: NodeMaterialConnectionPoint;
  54739. /**
  54740. * Gets the current class name
  54741. * @returns the class name
  54742. */
  54743. getClassName(): string;
  54744. protected _buildBlock(state: NodeMaterialBuildState): this;
  54745. }
  54746. }
  54747. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54748. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54750. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54751. /**
  54752. * Block used to transform a vector3 with a matrix
  54753. */
  54754. export class Vector3TransformBlock extends NodeMaterialBlock {
  54755. /**
  54756. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54757. */
  54758. complement: number;
  54759. /**
  54760. * Creates a new Vector3TransformBlock
  54761. * @param name defines the block name
  54762. */
  54763. constructor(name: string);
  54764. /**
  54765. * Gets the vector input
  54766. */
  54767. readonly vector: NodeMaterialConnectionPoint;
  54768. /**
  54769. * Gets the matrix transform input
  54770. */
  54771. readonly transform: NodeMaterialConnectionPoint;
  54772. /**
  54773. * Gets the output component
  54774. */
  54775. readonly output: NodeMaterialConnectionPoint;
  54776. /**
  54777. * Gets the current class name
  54778. * @returns the class name
  54779. */
  54780. getClassName(): string;
  54781. protected _buildBlock(state: NodeMaterialBuildState): this;
  54782. }
  54783. }
  54784. declare module "babylonjs/Materials/Node/Blocks/index" {
  54785. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  54786. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  54787. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  54788. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  54789. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  54790. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  54791. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  54792. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  54793. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54794. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54795. }
  54796. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54797. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54798. }
  54799. declare module "babylonjs/Materials/Node/index" {
  54800. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54801. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54802. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54803. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54804. export * from "babylonjs/Materials/Node/nodeMaterial";
  54805. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54806. export * from "babylonjs/Materials/Node/Blocks/index";
  54807. export * from "babylonjs/Materials/Node/Optimizers/index";
  54808. }
  54809. declare module "babylonjs/Materials/effectRenderer" {
  54810. import { Nullable } from "babylonjs/types";
  54811. import { Texture } from "babylonjs/Materials/Textures/texture";
  54812. import { Engine } from "babylonjs/Engines/engine";
  54813. import { Observable } from "babylonjs/Misc/observable";
  54814. import { Effect } from "babylonjs/Materials/effect";
  54815. /**
  54816. * Helper class to render one or more effects
  54817. */
  54818. export class EffectRenderer {
  54819. private engine;
  54820. private static _Vertices;
  54821. private static _Indices;
  54822. private _vertexBuffers;
  54823. private _indexBuffer;
  54824. private _ringBufferIndex;
  54825. private _ringScreenBuffer;
  54826. private _getNextFrameBuffer;
  54827. /**
  54828. * Creates an effect renderer
  54829. * @param engine the engine to use for rendering
  54830. */
  54831. constructor(engine: Engine);
  54832. /**
  54833. * renders one or more effects to a specified texture
  54834. * @param effectWrappers list of effects to renderer
  54835. * @param outputTexture texture to draw to, if null it will render to the screen
  54836. */
  54837. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54838. /**
  54839. * Disposes of the effect renderer
  54840. */
  54841. dispose(): void;
  54842. }
  54843. /**
  54844. * Options to create an EffectWrapper
  54845. */
  54846. interface EffectWrapperCreationOptions {
  54847. /**
  54848. * Engine to use to create the effect
  54849. */
  54850. engine: Engine;
  54851. /**
  54852. * Fragment shader for the effect
  54853. */
  54854. fragmentShader: string;
  54855. /**
  54856. * Attributes to use in the shader
  54857. */
  54858. attributeNames: Array<string>;
  54859. /**
  54860. * Uniforms to use in the shader
  54861. */
  54862. uniformNames: Array<string>;
  54863. /**
  54864. * Texture sampler names to use in the shader
  54865. */
  54866. samplerNames: Array<string>;
  54867. }
  54868. /**
  54869. * Wraps an effect to be used for rendering
  54870. */
  54871. export class EffectWrapper {
  54872. /**
  54873. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54874. */
  54875. onApplyObservable: Observable<{}>;
  54876. /**
  54877. * The underlying effect
  54878. */
  54879. effect: Effect;
  54880. /**
  54881. * Creates an effect to be renderer
  54882. * @param creationOptions options to create the effect
  54883. */
  54884. constructor(creationOptions: EffectWrapperCreationOptions);
  54885. /**
  54886. * Disposes of the effect wrapper
  54887. */
  54888. dispose(): void;
  54889. }
  54890. }
  54891. declare module "babylonjs/Materials/index" {
  54892. export * from "babylonjs/Materials/Background/index";
  54893. export * from "babylonjs/Materials/colorCurves";
  54894. export * from "babylonjs/Materials/effect";
  54895. export * from "babylonjs/Materials/fresnelParameters";
  54896. export * from "babylonjs/Materials/imageProcessingConfiguration";
  54897. export * from "babylonjs/Materials/material";
  54898. export * from "babylonjs/Materials/materialDefines";
  54899. export * from "babylonjs/Materials/materialHelper";
  54900. export * from "babylonjs/Materials/multiMaterial";
  54901. export * from "babylonjs/Materials/PBR/index";
  54902. export * from "babylonjs/Materials/pushMaterial";
  54903. export * from "babylonjs/Materials/shaderMaterial";
  54904. export * from "babylonjs/Materials/standardMaterial";
  54905. export * from "babylonjs/Materials/Textures/index";
  54906. export * from "babylonjs/Materials/uniformBuffer";
  54907. export * from "babylonjs/Materials/materialFlags";
  54908. export * from "babylonjs/Materials/Node/index";
  54909. export * from "babylonjs/Materials/effectRenderer";
  54910. }
  54911. declare module "babylonjs/Maths/index" {
  54912. export * from "babylonjs/Maths/math.scalar";
  54913. export * from "babylonjs/Maths/math";
  54914. export * from "babylonjs/Maths/sphericalPolynomial";
  54915. }
  54916. declare module "babylonjs/Misc/workerPool" {
  54917. import { IDisposable } from "babylonjs/scene";
  54918. /**
  54919. * Helper class to push actions to a pool of workers.
  54920. */
  54921. export class WorkerPool implements IDisposable {
  54922. private _workerInfos;
  54923. private _pendingActions;
  54924. /**
  54925. * Constructor
  54926. * @param workers Array of workers to use for actions
  54927. */
  54928. constructor(workers: Array<Worker>);
  54929. /**
  54930. * Terminates all workers and clears any pending actions.
  54931. */
  54932. dispose(): void;
  54933. /**
  54934. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54935. * pended until a worker has completed its action.
  54936. * @param action The action to perform. Call onComplete when the action is complete.
  54937. */
  54938. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54939. private _execute;
  54940. }
  54941. }
  54942. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  54943. import { IDisposable } from "babylonjs/scene";
  54944. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54945. /**
  54946. * Configuration for Draco compression
  54947. */
  54948. export interface IDracoCompressionConfiguration {
  54949. /**
  54950. * Configuration for the decoder.
  54951. */
  54952. decoder: {
  54953. /**
  54954. * The url to the WebAssembly module.
  54955. */
  54956. wasmUrl?: string;
  54957. /**
  54958. * The url to the WebAssembly binary.
  54959. */
  54960. wasmBinaryUrl?: string;
  54961. /**
  54962. * The url to the fallback JavaScript module.
  54963. */
  54964. fallbackUrl?: string;
  54965. };
  54966. }
  54967. /**
  54968. * Draco compression (https://google.github.io/draco/)
  54969. *
  54970. * This class wraps the Draco module.
  54971. *
  54972. * **Encoder**
  54973. *
  54974. * The encoder is not currently implemented.
  54975. *
  54976. * **Decoder**
  54977. *
  54978. * 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.
  54979. *
  54980. * To update the configuration, use the following code:
  54981. * ```javascript
  54982. * DracoCompression.Configuration = {
  54983. * decoder: {
  54984. * wasmUrl: "<url to the WebAssembly library>",
  54985. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54986. * fallbackUrl: "<url to the fallback JavaScript library>",
  54987. * }
  54988. * };
  54989. * ```
  54990. *
  54991. * 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.
  54992. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54993. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54994. *
  54995. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54996. * ```javascript
  54997. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54998. * ```
  54999. *
  55000. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55001. */
  55002. export class DracoCompression implements IDisposable {
  55003. private _workerPoolPromise?;
  55004. private _decoderModulePromise?;
  55005. /**
  55006. * The configuration. Defaults to the following urls:
  55007. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55008. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55009. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55010. */
  55011. static Configuration: IDracoCompressionConfiguration;
  55012. /**
  55013. * Returns true if the decoder configuration is available.
  55014. */
  55015. static readonly DecoderAvailable: boolean;
  55016. /**
  55017. * Default number of workers to create when creating the draco compression object.
  55018. */
  55019. static DefaultNumWorkers: number;
  55020. private static GetDefaultNumWorkers;
  55021. private static _Default;
  55022. /**
  55023. * Default instance for the draco compression object.
  55024. */
  55025. static readonly Default: DracoCompression;
  55026. /**
  55027. * Constructor
  55028. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55029. */
  55030. constructor(numWorkers?: number);
  55031. /**
  55032. * Stop all async operations and release resources.
  55033. */
  55034. dispose(): void;
  55035. /**
  55036. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55037. * @returns a promise that resolves when ready
  55038. */
  55039. whenReadyAsync(): Promise<void>;
  55040. /**
  55041. * Decode Draco compressed mesh data to vertex data.
  55042. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55043. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55044. * @returns A promise that resolves with the decoded vertex data
  55045. */
  55046. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55047. [kind: string]: number;
  55048. }): Promise<VertexData>;
  55049. }
  55050. }
  55051. declare module "babylonjs/Meshes/Compression/index" {
  55052. export * from "babylonjs/Meshes/Compression/dracoCompression";
  55053. }
  55054. declare module "babylonjs/Meshes/csg" {
  55055. import { Nullable } from "babylonjs/types";
  55056. import { Scene } from "babylonjs/scene";
  55057. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  55058. import { Mesh } from "babylonjs/Meshes/mesh";
  55059. import { Material } from "babylonjs/Materials/material";
  55060. /**
  55061. * Class for building Constructive Solid Geometry
  55062. */
  55063. export class CSG {
  55064. private polygons;
  55065. /**
  55066. * The world matrix
  55067. */
  55068. matrix: Matrix;
  55069. /**
  55070. * Stores the position
  55071. */
  55072. position: Vector3;
  55073. /**
  55074. * Stores the rotation
  55075. */
  55076. rotation: Vector3;
  55077. /**
  55078. * Stores the rotation quaternion
  55079. */
  55080. rotationQuaternion: Nullable<Quaternion>;
  55081. /**
  55082. * Stores the scaling vector
  55083. */
  55084. scaling: Vector3;
  55085. /**
  55086. * Convert the Mesh to CSG
  55087. * @param mesh The Mesh to convert to CSG
  55088. * @returns A new CSG from the Mesh
  55089. */
  55090. static FromMesh(mesh: Mesh): CSG;
  55091. /**
  55092. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55093. * @param polygons Polygons used to construct a CSG solid
  55094. */
  55095. private static FromPolygons;
  55096. /**
  55097. * Clones, or makes a deep copy, of the CSG
  55098. * @returns A new CSG
  55099. */
  55100. clone(): CSG;
  55101. /**
  55102. * Unions this CSG with another CSG
  55103. * @param csg The CSG to union against this CSG
  55104. * @returns The unioned CSG
  55105. */
  55106. union(csg: CSG): CSG;
  55107. /**
  55108. * Unions this CSG with another CSG in place
  55109. * @param csg The CSG to union against this CSG
  55110. */
  55111. unionInPlace(csg: CSG): void;
  55112. /**
  55113. * Subtracts this CSG with another CSG
  55114. * @param csg The CSG to subtract against this CSG
  55115. * @returns A new CSG
  55116. */
  55117. subtract(csg: CSG): CSG;
  55118. /**
  55119. * Subtracts this CSG with another CSG in place
  55120. * @param csg The CSG to subtact against this CSG
  55121. */
  55122. subtractInPlace(csg: CSG): void;
  55123. /**
  55124. * Intersect this CSG with another CSG
  55125. * @param csg The CSG to intersect against this CSG
  55126. * @returns A new CSG
  55127. */
  55128. intersect(csg: CSG): CSG;
  55129. /**
  55130. * Intersects this CSG with another CSG in place
  55131. * @param csg The CSG to intersect against this CSG
  55132. */
  55133. intersectInPlace(csg: CSG): void;
  55134. /**
  55135. * Return a new CSG solid with solid and empty space switched. This solid is
  55136. * not modified.
  55137. * @returns A new CSG solid with solid and empty space switched
  55138. */
  55139. inverse(): CSG;
  55140. /**
  55141. * Inverses the CSG in place
  55142. */
  55143. inverseInPlace(): void;
  55144. /**
  55145. * This is used to keep meshes transformations so they can be restored
  55146. * when we build back a Babylon Mesh
  55147. * NB : All CSG operations are performed in world coordinates
  55148. * @param csg The CSG to copy the transform attributes from
  55149. * @returns This CSG
  55150. */
  55151. copyTransformAttributes(csg: CSG): CSG;
  55152. /**
  55153. * Build Raw mesh from CSG
  55154. * Coordinates here are in world space
  55155. * @param name The name of the mesh geometry
  55156. * @param scene The Scene
  55157. * @param keepSubMeshes Specifies if the submeshes should be kept
  55158. * @returns A new Mesh
  55159. */
  55160. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  55161. /**
  55162. * Build Mesh from CSG taking material and transforms into account
  55163. * @param name The name of the Mesh
  55164. * @param material The material of the Mesh
  55165. * @param scene The Scene
  55166. * @param keepSubMeshes Specifies if submeshes should be kept
  55167. * @returns The new Mesh
  55168. */
  55169. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  55170. }
  55171. }
  55172. declare module "babylonjs/Meshes/trailMesh" {
  55173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55174. import { Mesh } from "babylonjs/Meshes/mesh";
  55175. import { Scene } from "babylonjs/scene";
  55176. /**
  55177. * Class used to create a trail following a mesh
  55178. */
  55179. export class TrailMesh extends Mesh {
  55180. private _generator;
  55181. private _autoStart;
  55182. private _running;
  55183. private _diameter;
  55184. private _length;
  55185. private _sectionPolygonPointsCount;
  55186. private _sectionVectors;
  55187. private _sectionNormalVectors;
  55188. private _beforeRenderObserver;
  55189. /**
  55190. * @constructor
  55191. * @param name The value used by scene.getMeshByName() to do a lookup.
  55192. * @param generator The mesh to generate a trail.
  55193. * @param scene The scene to add this mesh to.
  55194. * @param diameter Diameter of trailing mesh. Default is 1.
  55195. * @param length Length of trailing mesh. Default is 60.
  55196. * @param autoStart Automatically start trailing mesh. Default true.
  55197. */
  55198. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55199. /**
  55200. * "TrailMesh"
  55201. * @returns "TrailMesh"
  55202. */
  55203. getClassName(): string;
  55204. private _createMesh;
  55205. /**
  55206. * Start trailing mesh.
  55207. */
  55208. start(): void;
  55209. /**
  55210. * Stop trailing mesh.
  55211. */
  55212. stop(): void;
  55213. /**
  55214. * Update trailing mesh geometry.
  55215. */
  55216. update(): void;
  55217. /**
  55218. * Returns a new TrailMesh object.
  55219. * @param name is a string, the name given to the new mesh
  55220. * @param newGenerator use new generator object for cloned trail mesh
  55221. * @returns a new mesh
  55222. */
  55223. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55224. /**
  55225. * Serializes this trail mesh
  55226. * @param serializationObject object to write serialization to
  55227. */
  55228. serialize(serializationObject: any): void;
  55229. /**
  55230. * Parses a serialized trail mesh
  55231. * @param parsedMesh the serialized mesh
  55232. * @param scene the scene to create the trail mesh in
  55233. * @returns the created trail mesh
  55234. */
  55235. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55236. }
  55237. }
  55238. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  55239. import { Nullable } from "babylonjs/types";
  55240. import { Scene } from "babylonjs/scene";
  55241. import { Vector4, Color4 } from "babylonjs/Maths/math";
  55242. import { Mesh } from "babylonjs/Meshes/mesh";
  55243. /**
  55244. * Class containing static functions to help procedurally build meshes
  55245. */
  55246. export class TiledBoxBuilder {
  55247. /**
  55248. * Creates a box mesh
  55249. * 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)
  55250. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55252. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55254. * @param name defines the name of the mesh
  55255. * @param options defines the options used to create the mesh
  55256. * @param scene defines the hosting scene
  55257. * @returns the box mesh
  55258. */
  55259. static CreateTiledBox(name: string, options: {
  55260. pattern?: number;
  55261. width?: number;
  55262. height?: number;
  55263. depth?: number;
  55264. tileSize?: number;
  55265. tileWidth?: number;
  55266. tileHeight?: number;
  55267. alignHorizontal?: number;
  55268. alignVertical?: number;
  55269. faceUV?: Vector4[];
  55270. faceColors?: Color4[];
  55271. sideOrientation?: number;
  55272. updatable?: boolean;
  55273. }, scene?: Nullable<Scene>): Mesh;
  55274. }
  55275. }
  55276. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  55277. import { Vector4 } from "babylonjs/Maths/math";
  55278. import { Mesh } from "babylonjs/Meshes/mesh";
  55279. /**
  55280. * Class containing static functions to help procedurally build meshes
  55281. */
  55282. export class TorusKnotBuilder {
  55283. /**
  55284. * Creates a torus knot mesh
  55285. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55286. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55287. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55288. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55290. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55292. * @param name defines the name of the mesh
  55293. * @param options defines the options used to create the mesh
  55294. * @param scene defines the hosting scene
  55295. * @returns the torus knot mesh
  55296. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55297. */
  55298. static CreateTorusKnot(name: string, options: {
  55299. radius?: number;
  55300. tube?: number;
  55301. radialSegments?: number;
  55302. tubularSegments?: number;
  55303. p?: number;
  55304. q?: number;
  55305. updatable?: boolean;
  55306. sideOrientation?: number;
  55307. frontUVs?: Vector4;
  55308. backUVs?: Vector4;
  55309. }, scene: any): Mesh;
  55310. }
  55311. }
  55312. declare module "babylonjs/Meshes/polygonMesh" {
  55313. import { Scene } from "babylonjs/scene";
  55314. import { Vector2, Path2 } from "babylonjs/Maths/math";
  55315. import { Mesh } from "babylonjs/Meshes/mesh";
  55316. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55317. /**
  55318. * Polygon
  55319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55320. */
  55321. export class Polygon {
  55322. /**
  55323. * Creates a rectangle
  55324. * @param xmin bottom X coord
  55325. * @param ymin bottom Y coord
  55326. * @param xmax top X coord
  55327. * @param ymax top Y coord
  55328. * @returns points that make the resulting rectation
  55329. */
  55330. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55331. /**
  55332. * Creates a circle
  55333. * @param radius radius of circle
  55334. * @param cx scale in x
  55335. * @param cy scale in y
  55336. * @param numberOfSides number of sides that make up the circle
  55337. * @returns points that make the resulting circle
  55338. */
  55339. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55340. /**
  55341. * Creates a polygon from input string
  55342. * @param input Input polygon data
  55343. * @returns the parsed points
  55344. */
  55345. static Parse(input: string): Vector2[];
  55346. /**
  55347. * Starts building a polygon from x and y coordinates
  55348. * @param x x coordinate
  55349. * @param y y coordinate
  55350. * @returns the started path2
  55351. */
  55352. static StartingAt(x: number, y: number): Path2;
  55353. }
  55354. /**
  55355. * Builds a polygon
  55356. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55357. */
  55358. export class PolygonMeshBuilder {
  55359. private _points;
  55360. private _outlinepoints;
  55361. private _holes;
  55362. private _name;
  55363. private _scene;
  55364. private _epoints;
  55365. private _eholes;
  55366. private _addToepoint;
  55367. /**
  55368. * Babylon reference to the earcut plugin.
  55369. */
  55370. bjsEarcut: any;
  55371. /**
  55372. * Creates a PolygonMeshBuilder
  55373. * @param name name of the builder
  55374. * @param contours Path of the polygon
  55375. * @param scene scene to add to when creating the mesh
  55376. * @param earcutInjection can be used to inject your own earcut reference
  55377. */
  55378. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55379. /**
  55380. * Adds a whole within the polygon
  55381. * @param hole Array of points defining the hole
  55382. * @returns this
  55383. */
  55384. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55385. /**
  55386. * Creates the polygon
  55387. * @param updatable If the mesh should be updatable
  55388. * @param depth The depth of the mesh created
  55389. * @returns the created mesh
  55390. */
  55391. build(updatable?: boolean, depth?: number): Mesh;
  55392. /**
  55393. * Creates the polygon
  55394. * @param depth The depth of the mesh created
  55395. * @returns the created VertexData
  55396. */
  55397. buildVertexData(depth?: number): VertexData;
  55398. /**
  55399. * Adds a side to the polygon
  55400. * @param positions points that make the polygon
  55401. * @param normals normals of the polygon
  55402. * @param uvs uvs of the polygon
  55403. * @param indices indices of the polygon
  55404. * @param bounds bounds of the polygon
  55405. * @param points points of the polygon
  55406. * @param depth depth of the polygon
  55407. * @param flip flip of the polygon
  55408. */
  55409. private addSide;
  55410. }
  55411. }
  55412. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  55413. import { Scene } from "babylonjs/scene";
  55414. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  55415. import { Mesh } from "babylonjs/Meshes/mesh";
  55416. import { Nullable } from "babylonjs/types";
  55417. /**
  55418. * Class containing static functions to help procedurally build meshes
  55419. */
  55420. export class PolygonBuilder {
  55421. /**
  55422. * Creates a polygon mesh
  55423. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55424. * * 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
  55425. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55428. * * Remember you can only change the shape positions, not their number when updating a polygon
  55429. * @param name defines the name of the mesh
  55430. * @param options defines the options used to create the mesh
  55431. * @param scene defines the hosting scene
  55432. * @param earcutInjection can be used to inject your own earcut reference
  55433. * @returns the polygon mesh
  55434. */
  55435. static CreatePolygon(name: string, options: {
  55436. shape: Vector3[];
  55437. holes?: Vector3[][];
  55438. depth?: number;
  55439. faceUV?: Vector4[];
  55440. faceColors?: Color4[];
  55441. updatable?: boolean;
  55442. sideOrientation?: number;
  55443. frontUVs?: Vector4;
  55444. backUVs?: Vector4;
  55445. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55446. /**
  55447. * Creates an extruded polygon mesh, with depth in the Y direction.
  55448. * * 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)
  55449. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55450. * @param name defines the name of the mesh
  55451. * @param options defines the options used to create the mesh
  55452. * @param scene defines the hosting scene
  55453. * @param earcutInjection can be used to inject your own earcut reference
  55454. * @returns the polygon mesh
  55455. */
  55456. static ExtrudePolygon(name: string, options: {
  55457. shape: Vector3[];
  55458. holes?: Vector3[][];
  55459. depth?: number;
  55460. faceUV?: Vector4[];
  55461. faceColors?: Color4[];
  55462. updatable?: boolean;
  55463. sideOrientation?: number;
  55464. frontUVs?: Vector4;
  55465. backUVs?: Vector4;
  55466. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55467. }
  55468. }
  55469. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  55470. import { Scene } from "babylonjs/scene";
  55471. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55472. import { Mesh } from "babylonjs/Meshes/mesh";
  55473. import { Nullable } from "babylonjs/types";
  55474. /**
  55475. * Class containing static functions to help procedurally build meshes
  55476. */
  55477. export class LatheBuilder {
  55478. /**
  55479. * Creates lathe mesh.
  55480. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55481. * * 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
  55482. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55483. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55484. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55485. * * 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
  55486. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55487. * * 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
  55488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55490. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55492. * @param name defines the name of the mesh
  55493. * @param options defines the options used to create the mesh
  55494. * @param scene defines the hosting scene
  55495. * @returns the lathe mesh
  55496. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55497. */
  55498. static CreateLathe(name: string, options: {
  55499. shape: Vector3[];
  55500. radius?: number;
  55501. tessellation?: number;
  55502. clip?: number;
  55503. arc?: number;
  55504. closed?: boolean;
  55505. updatable?: boolean;
  55506. sideOrientation?: number;
  55507. frontUVs?: Vector4;
  55508. backUVs?: Vector4;
  55509. cap?: number;
  55510. invertUV?: boolean;
  55511. }, scene?: Nullable<Scene>): Mesh;
  55512. }
  55513. }
  55514. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  55515. import { Nullable } from "babylonjs/types";
  55516. import { Scene } from "babylonjs/scene";
  55517. import { Vector4 } from "babylonjs/Maths/math";
  55518. import { Mesh } from "babylonjs/Meshes/mesh";
  55519. /**
  55520. * Class containing static functions to help procedurally build meshes
  55521. */
  55522. export class TiledPlaneBuilder {
  55523. /**
  55524. * Creates a tiled plane mesh
  55525. * * The parameter `pattern` will, depending on value, do nothing or
  55526. * * * flip (reflect about central vertical) alternate tiles across and up
  55527. * * * flip every tile on alternate rows
  55528. * * * rotate (180 degs) alternate tiles across and up
  55529. * * * rotate every tile on alternate rows
  55530. * * * flip and rotate alternate tiles across and up
  55531. * * * flip and rotate every tile on alternate rows
  55532. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55533. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55534. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55535. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55536. * * 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)
  55537. * * 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)
  55538. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55539. * @param name defines the name of the mesh
  55540. * @param options defines the options used to create the mesh
  55541. * @param scene defines the hosting scene
  55542. * @returns the box mesh
  55543. */
  55544. static CreateTiledPlane(name: string, options: {
  55545. pattern?: number;
  55546. tileSize?: number;
  55547. tileWidth?: number;
  55548. tileHeight?: number;
  55549. size?: number;
  55550. width?: number;
  55551. height?: number;
  55552. alignHorizontal?: number;
  55553. alignVertical?: number;
  55554. sideOrientation?: number;
  55555. frontUVs?: Vector4;
  55556. backUVs?: Vector4;
  55557. updatable?: boolean;
  55558. }, scene?: Nullable<Scene>): Mesh;
  55559. }
  55560. }
  55561. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  55562. import { Nullable } from "babylonjs/types";
  55563. import { Scene } from "babylonjs/scene";
  55564. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55565. import { Mesh } from "babylonjs/Meshes/mesh";
  55566. /**
  55567. * Class containing static functions to help procedurally build meshes
  55568. */
  55569. export class TubeBuilder {
  55570. /**
  55571. * Creates a tube mesh.
  55572. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55573. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55574. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55575. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55576. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55577. * * 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)
  55578. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55579. * * 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
  55580. * * 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
  55581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55583. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55585. * @param name defines the name of the mesh
  55586. * @param options defines the options used to create the mesh
  55587. * @param scene defines the hosting scene
  55588. * @returns the tube mesh
  55589. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55590. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55591. */
  55592. static CreateTube(name: string, options: {
  55593. path: Vector3[];
  55594. radius?: number;
  55595. tessellation?: number;
  55596. radiusFunction?: {
  55597. (i: number, distance: number): number;
  55598. };
  55599. cap?: number;
  55600. arc?: number;
  55601. updatable?: boolean;
  55602. sideOrientation?: number;
  55603. frontUVs?: Vector4;
  55604. backUVs?: Vector4;
  55605. instance?: Mesh;
  55606. invertUV?: boolean;
  55607. }, scene?: Nullable<Scene>): Mesh;
  55608. }
  55609. }
  55610. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  55611. import { Scene } from "babylonjs/scene";
  55612. import { Vector4 } from "babylonjs/Maths/math";
  55613. import { Mesh } from "babylonjs/Meshes/mesh";
  55614. import { Nullable } from "babylonjs/types";
  55615. /**
  55616. * Class containing static functions to help procedurally build meshes
  55617. */
  55618. export class IcoSphereBuilder {
  55619. /**
  55620. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55621. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55622. * * 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`)
  55623. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55624. * * 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
  55625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55626. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55628. * @param name defines the name of the mesh
  55629. * @param options defines the options used to create the mesh
  55630. * @param scene defines the hosting scene
  55631. * @returns the icosahedron mesh
  55632. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55633. */
  55634. static CreateIcoSphere(name: string, options: {
  55635. radius?: number;
  55636. radiusX?: number;
  55637. radiusY?: number;
  55638. radiusZ?: number;
  55639. flat?: boolean;
  55640. subdivisions?: number;
  55641. sideOrientation?: number;
  55642. frontUVs?: Vector4;
  55643. backUVs?: Vector4;
  55644. updatable?: boolean;
  55645. }, scene?: Nullable<Scene>): Mesh;
  55646. }
  55647. }
  55648. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  55649. import { Vector3 } from "babylonjs/Maths/math";
  55650. import { Mesh } from "babylonjs/Meshes/mesh";
  55651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55652. /**
  55653. * Class containing static functions to help procedurally build meshes
  55654. */
  55655. export class DecalBuilder {
  55656. /**
  55657. * Creates a decal mesh.
  55658. * 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
  55659. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55660. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55661. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55662. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55663. * @param name defines the name of the mesh
  55664. * @param sourceMesh defines the mesh where the decal must be applied
  55665. * @param options defines the options used to create the mesh
  55666. * @param scene defines the hosting scene
  55667. * @returns the decal mesh
  55668. * @see https://doc.babylonjs.com/how_to/decals
  55669. */
  55670. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55671. position?: Vector3;
  55672. normal?: Vector3;
  55673. size?: Vector3;
  55674. angle?: number;
  55675. }): Mesh;
  55676. }
  55677. }
  55678. declare module "babylonjs/Meshes/meshBuilder" {
  55679. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  55680. import { Nullable } from "babylonjs/types";
  55681. import { Scene } from "babylonjs/scene";
  55682. import { Mesh } from "babylonjs/Meshes/mesh";
  55683. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  55684. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55686. /**
  55687. * Class containing static functions to help procedurally build meshes
  55688. */
  55689. export class MeshBuilder {
  55690. /**
  55691. * Creates a box mesh
  55692. * * The parameter `size` sets the size (float) of each box side (default 1)
  55693. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55694. * * 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)
  55695. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55699. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55700. * @param name defines the name of the mesh
  55701. * @param options defines the options used to create the mesh
  55702. * @param scene defines the hosting scene
  55703. * @returns the box mesh
  55704. */
  55705. static CreateBox(name: string, options: {
  55706. size?: number;
  55707. width?: number;
  55708. height?: number;
  55709. depth?: number;
  55710. faceUV?: Vector4[];
  55711. faceColors?: Color4[];
  55712. sideOrientation?: number;
  55713. frontUVs?: Vector4;
  55714. backUVs?: Vector4;
  55715. updatable?: boolean;
  55716. }, scene?: Nullable<Scene>): Mesh;
  55717. /**
  55718. * Creates a tiled box mesh
  55719. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55721. * @param name defines the name of the mesh
  55722. * @param options defines the options used to create the mesh
  55723. * @param scene defines the hosting scene
  55724. * @returns the tiled box mesh
  55725. */
  55726. static CreateTiledBox(name: string, options: {
  55727. pattern?: number;
  55728. size?: number;
  55729. width?: number;
  55730. height?: number;
  55731. depth: number;
  55732. tileSize?: number;
  55733. tileWidth?: number;
  55734. tileHeight?: number;
  55735. faceUV?: Vector4[];
  55736. faceColors?: Color4[];
  55737. alignHorizontal?: number;
  55738. alignVertical?: number;
  55739. sideOrientation?: number;
  55740. updatable?: boolean;
  55741. }, scene?: Nullable<Scene>): Mesh;
  55742. /**
  55743. * Creates a sphere mesh
  55744. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55745. * * 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`)
  55746. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55747. * * 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
  55748. * * 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)
  55749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55750. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55752. * @param name defines the name of the mesh
  55753. * @param options defines the options used to create the mesh
  55754. * @param scene defines the hosting scene
  55755. * @returns the sphere mesh
  55756. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55757. */
  55758. static CreateSphere(name: string, options: {
  55759. segments?: number;
  55760. diameter?: number;
  55761. diameterX?: number;
  55762. diameterY?: number;
  55763. diameterZ?: number;
  55764. arc?: number;
  55765. slice?: number;
  55766. sideOrientation?: number;
  55767. frontUVs?: Vector4;
  55768. backUVs?: Vector4;
  55769. updatable?: boolean;
  55770. }, scene?: Nullable<Scene>): Mesh;
  55771. /**
  55772. * Creates a plane polygonal mesh. By default, this is a disc
  55773. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55774. * * 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
  55775. * * 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
  55776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55777. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55779. * @param name defines the name of the mesh
  55780. * @param options defines the options used to create the mesh
  55781. * @param scene defines the hosting scene
  55782. * @returns the plane polygonal mesh
  55783. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55784. */
  55785. static CreateDisc(name: string, options: {
  55786. radius?: number;
  55787. tessellation?: number;
  55788. arc?: number;
  55789. updatable?: boolean;
  55790. sideOrientation?: number;
  55791. frontUVs?: Vector4;
  55792. backUVs?: Vector4;
  55793. }, scene?: Nullable<Scene>): Mesh;
  55794. /**
  55795. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55796. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55797. * * 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`)
  55798. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55799. * * 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
  55800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55801. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55803. * @param name defines the name of the mesh
  55804. * @param options defines the options used to create the mesh
  55805. * @param scene defines the hosting scene
  55806. * @returns the icosahedron mesh
  55807. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55808. */
  55809. static CreateIcoSphere(name: string, options: {
  55810. radius?: number;
  55811. radiusX?: number;
  55812. radiusY?: number;
  55813. radiusZ?: number;
  55814. flat?: boolean;
  55815. subdivisions?: number;
  55816. sideOrientation?: number;
  55817. frontUVs?: Vector4;
  55818. backUVs?: Vector4;
  55819. updatable?: boolean;
  55820. }, scene?: Nullable<Scene>): Mesh;
  55821. /**
  55822. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55823. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55824. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55825. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55826. * * 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
  55827. * * 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
  55828. * * 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
  55829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55831. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55832. * * 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
  55833. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55834. * * 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
  55835. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55837. * @param name defines the name of the mesh
  55838. * @param options defines the options used to create the mesh
  55839. * @param scene defines the hosting scene
  55840. * @returns the ribbon mesh
  55841. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55842. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55843. */
  55844. static CreateRibbon(name: string, options: {
  55845. pathArray: Vector3[][];
  55846. closeArray?: boolean;
  55847. closePath?: boolean;
  55848. offset?: number;
  55849. updatable?: boolean;
  55850. sideOrientation?: number;
  55851. frontUVs?: Vector4;
  55852. backUVs?: Vector4;
  55853. instance?: Mesh;
  55854. invertUV?: boolean;
  55855. uvs?: Vector2[];
  55856. colors?: Color4[];
  55857. }, scene?: Nullable<Scene>): Mesh;
  55858. /**
  55859. * Creates a cylinder or a cone mesh
  55860. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55861. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55862. * * 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.
  55863. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55864. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55865. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55866. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55867. * * 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).
  55868. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55869. * * 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).
  55870. * * 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
  55871. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55872. * * 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
  55873. * * 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.
  55874. * * If `enclose` is false, a ring surface is one element.
  55875. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55876. * * 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
  55877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55880. * @param name defines the name of the mesh
  55881. * @param options defines the options used to create the mesh
  55882. * @param scene defines the hosting scene
  55883. * @returns the cylinder mesh
  55884. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55885. */
  55886. static CreateCylinder(name: string, options: {
  55887. height?: number;
  55888. diameterTop?: number;
  55889. diameterBottom?: number;
  55890. diameter?: number;
  55891. tessellation?: number;
  55892. subdivisions?: number;
  55893. arc?: number;
  55894. faceColors?: Color4[];
  55895. faceUV?: Vector4[];
  55896. updatable?: boolean;
  55897. hasRings?: boolean;
  55898. enclose?: boolean;
  55899. cap?: number;
  55900. sideOrientation?: number;
  55901. frontUVs?: Vector4;
  55902. backUVs?: Vector4;
  55903. }, scene?: Nullable<Scene>): Mesh;
  55904. /**
  55905. * Creates a torus mesh
  55906. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55907. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55908. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55912. * @param name defines the name of the mesh
  55913. * @param options defines the options used to create the mesh
  55914. * @param scene defines the hosting scene
  55915. * @returns the torus mesh
  55916. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55917. */
  55918. static CreateTorus(name: string, options: {
  55919. diameter?: number;
  55920. thickness?: number;
  55921. tessellation?: number;
  55922. updatable?: boolean;
  55923. sideOrientation?: number;
  55924. frontUVs?: Vector4;
  55925. backUVs?: Vector4;
  55926. }, scene?: Nullable<Scene>): Mesh;
  55927. /**
  55928. * Creates a torus knot mesh
  55929. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55930. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55931. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55932. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55936. * @param name defines the name of the mesh
  55937. * @param options defines the options used to create the mesh
  55938. * @param scene defines the hosting scene
  55939. * @returns the torus knot mesh
  55940. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55941. */
  55942. static CreateTorusKnot(name: string, options: {
  55943. radius?: number;
  55944. tube?: number;
  55945. radialSegments?: number;
  55946. tubularSegments?: number;
  55947. p?: number;
  55948. q?: number;
  55949. updatable?: boolean;
  55950. sideOrientation?: number;
  55951. frontUVs?: Vector4;
  55952. backUVs?: Vector4;
  55953. }, scene?: Nullable<Scene>): Mesh;
  55954. /**
  55955. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55956. * * 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
  55957. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55958. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55959. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55960. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55961. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55962. * * 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
  55963. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55965. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55966. * @param name defines the name of the new line system
  55967. * @param options defines the options used to create the line system
  55968. * @param scene defines the hosting scene
  55969. * @returns a new line system mesh
  55970. */
  55971. static CreateLineSystem(name: string, options: {
  55972. lines: Vector3[][];
  55973. updatable?: boolean;
  55974. instance?: Nullable<LinesMesh>;
  55975. colors?: Nullable<Color4[][]>;
  55976. useVertexAlpha?: boolean;
  55977. }, scene: Nullable<Scene>): LinesMesh;
  55978. /**
  55979. * Creates a line mesh
  55980. * 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
  55981. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55982. * * The parameter `points` is an array successive Vector3
  55983. * * 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
  55984. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55985. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55986. * * When updating an instance, remember that only point positions can change, not the number of points
  55987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55989. * @param name defines the name of the new line system
  55990. * @param options defines the options used to create the line system
  55991. * @param scene defines the hosting scene
  55992. * @returns a new line mesh
  55993. */
  55994. static CreateLines(name: string, options: {
  55995. points: Vector3[];
  55996. updatable?: boolean;
  55997. instance?: Nullable<LinesMesh>;
  55998. colors?: Color4[];
  55999. useVertexAlpha?: boolean;
  56000. }, scene?: Nullable<Scene>): LinesMesh;
  56001. /**
  56002. * Creates a dashed line mesh
  56003. * * 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
  56004. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56005. * * The parameter `points` is an array successive Vector3
  56006. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56007. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56008. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56009. * * 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
  56010. * * When updating an instance, remember that only point positions can change, not the number of points
  56011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56012. * @param name defines the name of the mesh
  56013. * @param options defines the options used to create the mesh
  56014. * @param scene defines the hosting scene
  56015. * @returns the dashed line mesh
  56016. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56017. */
  56018. static CreateDashedLines(name: string, options: {
  56019. points: Vector3[];
  56020. dashSize?: number;
  56021. gapSize?: number;
  56022. dashNb?: number;
  56023. updatable?: boolean;
  56024. instance?: LinesMesh;
  56025. }, scene?: Nullable<Scene>): LinesMesh;
  56026. /**
  56027. * 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.
  56028. * * 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.
  56029. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56030. * * 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.
  56031. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56032. * * 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
  56033. * * 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
  56034. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56037. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56039. * @param name defines the name of the mesh
  56040. * @param options defines the options used to create the mesh
  56041. * @param scene defines the hosting scene
  56042. * @returns the extruded shape mesh
  56043. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56044. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56045. */
  56046. static ExtrudeShape(name: string, options: {
  56047. shape: Vector3[];
  56048. path: Vector3[];
  56049. scale?: number;
  56050. rotation?: number;
  56051. cap?: number;
  56052. updatable?: boolean;
  56053. sideOrientation?: number;
  56054. frontUVs?: Vector4;
  56055. backUVs?: Vector4;
  56056. instance?: Mesh;
  56057. invertUV?: boolean;
  56058. }, scene?: Nullable<Scene>): Mesh;
  56059. /**
  56060. * Creates an custom extruded shape mesh.
  56061. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56062. * * 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.
  56063. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56064. * * 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
  56065. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56066. * * 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
  56067. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56068. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56069. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56070. * * 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
  56071. * * 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
  56072. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56074. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56075. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56077. * @param name defines the name of the mesh
  56078. * @param options defines the options used to create the mesh
  56079. * @param scene defines the hosting scene
  56080. * @returns the custom extruded shape mesh
  56081. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56082. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56084. */
  56085. static ExtrudeShapeCustom(name: string, options: {
  56086. shape: Vector3[];
  56087. path: Vector3[];
  56088. scaleFunction?: any;
  56089. rotationFunction?: any;
  56090. ribbonCloseArray?: boolean;
  56091. ribbonClosePath?: boolean;
  56092. cap?: number;
  56093. updatable?: boolean;
  56094. sideOrientation?: number;
  56095. frontUVs?: Vector4;
  56096. backUVs?: Vector4;
  56097. instance?: Mesh;
  56098. invertUV?: boolean;
  56099. }, scene?: Nullable<Scene>): Mesh;
  56100. /**
  56101. * Creates lathe mesh.
  56102. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56103. * * 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
  56104. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56105. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56106. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56107. * * 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
  56108. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56109. * * 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
  56110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56112. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56114. * @param name defines the name of the mesh
  56115. * @param options defines the options used to create the mesh
  56116. * @param scene defines the hosting scene
  56117. * @returns the lathe mesh
  56118. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56119. */
  56120. static CreateLathe(name: string, options: {
  56121. shape: Vector3[];
  56122. radius?: number;
  56123. tessellation?: number;
  56124. clip?: number;
  56125. arc?: number;
  56126. closed?: boolean;
  56127. updatable?: boolean;
  56128. sideOrientation?: number;
  56129. frontUVs?: Vector4;
  56130. backUVs?: Vector4;
  56131. cap?: number;
  56132. invertUV?: boolean;
  56133. }, scene?: Nullable<Scene>): Mesh;
  56134. /**
  56135. * Creates a tiled plane mesh
  56136. * * You can set a limited pattern arrangement with the tiles
  56137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56140. * @param name defines the name of the mesh
  56141. * @param options defines the options used to create the mesh
  56142. * @param scene defines the hosting scene
  56143. * @returns the plane mesh
  56144. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56145. */
  56146. static CreateTiledPlane(name: string, options: {
  56147. pattern?: number;
  56148. tileSize?: number;
  56149. tileWidth?: number;
  56150. tileHeight?: number;
  56151. size?: number;
  56152. width?: number;
  56153. height?: number;
  56154. alignHorizontal?: number;
  56155. alignVertical?: number;
  56156. sideOrientation?: number;
  56157. frontUVs?: Vector4;
  56158. backUVs?: Vector4;
  56159. updatable?: boolean;
  56160. }, scene?: Nullable<Scene>): Mesh;
  56161. /**
  56162. * Creates a plane mesh
  56163. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56164. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56165. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56167. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56169. * @param name defines the name of the mesh
  56170. * @param options defines the options used to create the mesh
  56171. * @param scene defines the hosting scene
  56172. * @returns the plane mesh
  56173. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56174. */
  56175. static CreatePlane(name: string, options: {
  56176. size?: number;
  56177. width?: number;
  56178. height?: number;
  56179. sideOrientation?: number;
  56180. frontUVs?: Vector4;
  56181. backUVs?: Vector4;
  56182. updatable?: boolean;
  56183. sourcePlane?: Plane;
  56184. }, scene?: Nullable<Scene>): Mesh;
  56185. /**
  56186. * Creates a ground mesh
  56187. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56188. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56190. * @param name defines the name of the mesh
  56191. * @param options defines the options used to create the mesh
  56192. * @param scene defines the hosting scene
  56193. * @returns the ground mesh
  56194. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56195. */
  56196. static CreateGround(name: string, options: {
  56197. width?: number;
  56198. height?: number;
  56199. subdivisions?: number;
  56200. subdivisionsX?: number;
  56201. subdivisionsY?: number;
  56202. updatable?: boolean;
  56203. }, scene?: Nullable<Scene>): Mesh;
  56204. /**
  56205. * Creates a tiled ground mesh
  56206. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56207. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56208. * * 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
  56209. * * 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
  56210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56211. * @param name defines the name of the mesh
  56212. * @param options defines the options used to create the mesh
  56213. * @param scene defines the hosting scene
  56214. * @returns the tiled ground mesh
  56215. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56216. */
  56217. static CreateTiledGround(name: string, options: {
  56218. xmin: number;
  56219. zmin: number;
  56220. xmax: number;
  56221. zmax: number;
  56222. subdivisions?: {
  56223. w: number;
  56224. h: number;
  56225. };
  56226. precision?: {
  56227. w: number;
  56228. h: number;
  56229. };
  56230. updatable?: boolean;
  56231. }, scene?: Nullable<Scene>): Mesh;
  56232. /**
  56233. * Creates a ground mesh from a height map
  56234. * * The parameter `url` sets the URL of the height map image resource.
  56235. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56236. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56237. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56238. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56239. * * 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.
  56240. * * 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).
  56241. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56243. * @param name defines the name of the mesh
  56244. * @param url defines the url to the height map
  56245. * @param options defines the options used to create the mesh
  56246. * @param scene defines the hosting scene
  56247. * @returns the ground mesh
  56248. * @see https://doc.babylonjs.com/babylon101/height_map
  56249. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56250. */
  56251. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56252. width?: number;
  56253. height?: number;
  56254. subdivisions?: number;
  56255. minHeight?: number;
  56256. maxHeight?: number;
  56257. colorFilter?: Color3;
  56258. alphaFilter?: number;
  56259. updatable?: boolean;
  56260. onReady?: (mesh: GroundMesh) => void;
  56261. }, scene?: Nullable<Scene>): GroundMesh;
  56262. /**
  56263. * Creates a polygon mesh
  56264. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56265. * * 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
  56266. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56268. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56269. * * Remember you can only change the shape positions, not their number when updating a polygon
  56270. * @param name defines the name of the mesh
  56271. * @param options defines the options used to create the mesh
  56272. * @param scene defines the hosting scene
  56273. * @param earcutInjection can be used to inject your own earcut reference
  56274. * @returns the polygon mesh
  56275. */
  56276. static CreatePolygon(name: string, options: {
  56277. shape: Vector3[];
  56278. holes?: Vector3[][];
  56279. depth?: number;
  56280. faceUV?: Vector4[];
  56281. faceColors?: Color4[];
  56282. updatable?: boolean;
  56283. sideOrientation?: number;
  56284. frontUVs?: Vector4;
  56285. backUVs?: Vector4;
  56286. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56287. /**
  56288. * Creates an extruded polygon mesh, with depth in the Y direction.
  56289. * * 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)
  56290. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56291. * @param name defines the name of the mesh
  56292. * @param options defines the options used to create the mesh
  56293. * @param scene defines the hosting scene
  56294. * @param earcutInjection can be used to inject your own earcut reference
  56295. * @returns the polygon mesh
  56296. */
  56297. static ExtrudePolygon(name: string, options: {
  56298. shape: Vector3[];
  56299. holes?: Vector3[][];
  56300. depth?: number;
  56301. faceUV?: Vector4[];
  56302. faceColors?: Color4[];
  56303. updatable?: boolean;
  56304. sideOrientation?: number;
  56305. frontUVs?: Vector4;
  56306. backUVs?: Vector4;
  56307. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56308. /**
  56309. * Creates a tube mesh.
  56310. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56311. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56312. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56313. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56314. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56315. * * 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)
  56316. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56317. * * 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
  56318. * * 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
  56319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56321. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56323. * @param name defines the name of the mesh
  56324. * @param options defines the options used to create the mesh
  56325. * @param scene defines the hosting scene
  56326. * @returns the tube mesh
  56327. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56328. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56329. */
  56330. static CreateTube(name: string, options: {
  56331. path: Vector3[];
  56332. radius?: number;
  56333. tessellation?: number;
  56334. radiusFunction?: {
  56335. (i: number, distance: number): number;
  56336. };
  56337. cap?: number;
  56338. arc?: number;
  56339. updatable?: boolean;
  56340. sideOrientation?: number;
  56341. frontUVs?: Vector4;
  56342. backUVs?: Vector4;
  56343. instance?: Mesh;
  56344. invertUV?: boolean;
  56345. }, scene?: Nullable<Scene>): Mesh;
  56346. /**
  56347. * Creates a polyhedron mesh
  56348. * * 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
  56349. * * The parameter `size` (positive float, default 1) sets the polygon size
  56350. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56351. * * 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`
  56352. * * 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
  56353. * * 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)`)
  56354. * * 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
  56355. * * 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
  56356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56359. * @param name defines the name of the mesh
  56360. * @param options defines the options used to create the mesh
  56361. * @param scene defines the hosting scene
  56362. * @returns the polyhedron mesh
  56363. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56364. */
  56365. static CreatePolyhedron(name: string, options: {
  56366. type?: number;
  56367. size?: number;
  56368. sizeX?: number;
  56369. sizeY?: number;
  56370. sizeZ?: number;
  56371. custom?: any;
  56372. faceUV?: Vector4[];
  56373. faceColors?: Color4[];
  56374. flat?: boolean;
  56375. updatable?: boolean;
  56376. sideOrientation?: number;
  56377. frontUVs?: Vector4;
  56378. backUVs?: Vector4;
  56379. }, scene?: Nullable<Scene>): Mesh;
  56380. /**
  56381. * Creates a decal mesh.
  56382. * 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
  56383. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56384. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56385. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56386. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56387. * @param name defines the name of the mesh
  56388. * @param sourceMesh defines the mesh where the decal must be applied
  56389. * @param options defines the options used to create the mesh
  56390. * @param scene defines the hosting scene
  56391. * @returns the decal mesh
  56392. * @see https://doc.babylonjs.com/how_to/decals
  56393. */
  56394. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56395. position?: Vector3;
  56396. normal?: Vector3;
  56397. size?: Vector3;
  56398. angle?: number;
  56399. }): Mesh;
  56400. }
  56401. }
  56402. declare module "babylonjs/Meshes/meshSimplification" {
  56403. import { Mesh } from "babylonjs/Meshes/mesh";
  56404. /**
  56405. * A simplifier interface for future simplification implementations
  56406. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56407. */
  56408. export interface ISimplifier {
  56409. /**
  56410. * Simplification of a given mesh according to the given settings.
  56411. * Since this requires computation, it is assumed that the function runs async.
  56412. * @param settings The settings of the simplification, including quality and distance
  56413. * @param successCallback A callback that will be called after the mesh was simplified.
  56414. * @param errorCallback in case of an error, this callback will be called. optional.
  56415. */
  56416. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56417. }
  56418. /**
  56419. * Expected simplification settings.
  56420. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56421. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56422. */
  56423. export interface ISimplificationSettings {
  56424. /**
  56425. * Gets or sets the expected quality
  56426. */
  56427. quality: number;
  56428. /**
  56429. * Gets or sets the distance when this optimized version should be used
  56430. */
  56431. distance: number;
  56432. /**
  56433. * Gets an already optimized mesh
  56434. */
  56435. optimizeMesh?: boolean;
  56436. }
  56437. /**
  56438. * Class used to specify simplification options
  56439. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56440. */
  56441. export class SimplificationSettings implements ISimplificationSettings {
  56442. /** expected quality */
  56443. quality: number;
  56444. /** distance when this optimized version should be used */
  56445. distance: number;
  56446. /** already optimized mesh */
  56447. optimizeMesh?: boolean | undefined;
  56448. /**
  56449. * Creates a SimplificationSettings
  56450. * @param quality expected quality
  56451. * @param distance distance when this optimized version should be used
  56452. * @param optimizeMesh already optimized mesh
  56453. */
  56454. constructor(
  56455. /** expected quality */
  56456. quality: number,
  56457. /** distance when this optimized version should be used */
  56458. distance: number,
  56459. /** already optimized mesh */
  56460. optimizeMesh?: boolean | undefined);
  56461. }
  56462. /**
  56463. * Interface used to define a simplification task
  56464. */
  56465. export interface ISimplificationTask {
  56466. /**
  56467. * Array of settings
  56468. */
  56469. settings: Array<ISimplificationSettings>;
  56470. /**
  56471. * Simplification type
  56472. */
  56473. simplificationType: SimplificationType;
  56474. /**
  56475. * Mesh to simplify
  56476. */
  56477. mesh: Mesh;
  56478. /**
  56479. * Callback called on success
  56480. */
  56481. successCallback?: () => void;
  56482. /**
  56483. * Defines if parallel processing can be used
  56484. */
  56485. parallelProcessing: boolean;
  56486. }
  56487. /**
  56488. * Queue used to order the simplification tasks
  56489. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56490. */
  56491. export class SimplificationQueue {
  56492. private _simplificationArray;
  56493. /**
  56494. * Gets a boolean indicating that the process is still running
  56495. */
  56496. running: boolean;
  56497. /**
  56498. * Creates a new queue
  56499. */
  56500. constructor();
  56501. /**
  56502. * Adds a new simplification task
  56503. * @param task defines a task to add
  56504. */
  56505. addTask(task: ISimplificationTask): void;
  56506. /**
  56507. * Execute next task
  56508. */
  56509. executeNext(): void;
  56510. /**
  56511. * Execute a simplification task
  56512. * @param task defines the task to run
  56513. */
  56514. runSimplification(task: ISimplificationTask): void;
  56515. private getSimplifier;
  56516. }
  56517. /**
  56518. * The implemented types of simplification
  56519. * At the moment only Quadratic Error Decimation is implemented
  56520. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56521. */
  56522. export enum SimplificationType {
  56523. /** Quadratic error decimation */
  56524. QUADRATIC = 0
  56525. }
  56526. }
  56527. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  56528. import { Scene } from "babylonjs/scene";
  56529. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  56530. import { ISceneComponent } from "babylonjs/sceneComponent";
  56531. module "babylonjs/scene" {
  56532. interface Scene {
  56533. /** @hidden (Backing field) */
  56534. _simplificationQueue: SimplificationQueue;
  56535. /**
  56536. * Gets or sets the simplification queue attached to the scene
  56537. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56538. */
  56539. simplificationQueue: SimplificationQueue;
  56540. }
  56541. }
  56542. module "babylonjs/Meshes/mesh" {
  56543. interface Mesh {
  56544. /**
  56545. * Simplify the mesh according to the given array of settings.
  56546. * Function will return immediately and will simplify async
  56547. * @param settings a collection of simplification settings
  56548. * @param parallelProcessing should all levels calculate parallel or one after the other
  56549. * @param simplificationType the type of simplification to run
  56550. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56551. * @returns the current mesh
  56552. */
  56553. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56554. }
  56555. }
  56556. /**
  56557. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56558. * created in a scene
  56559. */
  56560. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56561. /**
  56562. * The component name helpfull to identify the component in the list of scene components.
  56563. */
  56564. readonly name: string;
  56565. /**
  56566. * The scene the component belongs to.
  56567. */
  56568. scene: Scene;
  56569. /**
  56570. * Creates a new instance of the component for the given scene
  56571. * @param scene Defines the scene to register the component in
  56572. */
  56573. constructor(scene: Scene);
  56574. /**
  56575. * Registers the component in a given scene
  56576. */
  56577. register(): void;
  56578. /**
  56579. * Rebuilds the elements related to this component in case of
  56580. * context lost for instance.
  56581. */
  56582. rebuild(): void;
  56583. /**
  56584. * Disposes the component and the associated ressources
  56585. */
  56586. dispose(): void;
  56587. private _beforeCameraUpdate;
  56588. }
  56589. }
  56590. declare module "babylonjs/Meshes/Builders/index" {
  56591. export * from "babylonjs/Meshes/Builders/boxBuilder";
  56592. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  56593. export * from "babylonjs/Meshes/Builders/discBuilder";
  56594. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  56595. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  56596. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  56597. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  56598. export * from "babylonjs/Meshes/Builders/torusBuilder";
  56599. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  56600. export * from "babylonjs/Meshes/Builders/linesBuilder";
  56601. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  56602. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  56603. export * from "babylonjs/Meshes/Builders/latheBuilder";
  56604. export * from "babylonjs/Meshes/Builders/planeBuilder";
  56605. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  56606. export * from "babylonjs/Meshes/Builders/groundBuilder";
  56607. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  56608. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  56609. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  56610. export * from "babylonjs/Meshes/Builders/decalBuilder";
  56611. }
  56612. declare module "babylonjs/Meshes/index" {
  56613. export * from "babylonjs/Meshes/abstractMesh";
  56614. export * from "babylonjs/Meshes/buffer";
  56615. export * from "babylonjs/Meshes/Compression/index";
  56616. export * from "babylonjs/Meshes/csg";
  56617. export * from "babylonjs/Meshes/geometry";
  56618. export * from "babylonjs/Meshes/groundMesh";
  56619. export * from "babylonjs/Meshes/trailMesh";
  56620. export * from "babylonjs/Meshes/instancedMesh";
  56621. export * from "babylonjs/Meshes/linesMesh";
  56622. export * from "babylonjs/Meshes/mesh";
  56623. export * from "babylonjs/Meshes/mesh.vertexData";
  56624. export * from "babylonjs/Meshes/meshBuilder";
  56625. export * from "babylonjs/Meshes/meshSimplification";
  56626. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  56627. export * from "babylonjs/Meshes/polygonMesh";
  56628. export * from "babylonjs/Meshes/subMesh";
  56629. export * from "babylonjs/Meshes/meshLODLevel";
  56630. export * from "babylonjs/Meshes/transformNode";
  56631. export * from "babylonjs/Meshes/Builders/index";
  56632. export * from "babylonjs/Meshes/dataBuffer";
  56633. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  56634. }
  56635. declare module "babylonjs/Morph/index" {
  56636. export * from "babylonjs/Morph/morphTarget";
  56637. export * from "babylonjs/Morph/morphTargetManager";
  56638. }
  56639. declare module "babylonjs/Offline/database" {
  56640. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  56641. /**
  56642. * Class used to enable access to IndexedDB
  56643. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56644. */
  56645. export class Database implements IOfflineProvider {
  56646. private _callbackManifestChecked;
  56647. private _currentSceneUrl;
  56648. private _db;
  56649. private _enableSceneOffline;
  56650. private _enableTexturesOffline;
  56651. private _manifestVersionFound;
  56652. private _mustUpdateRessources;
  56653. private _hasReachedQuota;
  56654. private _isSupported;
  56655. private _idbFactory;
  56656. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56657. private static IsUASupportingBlobStorage;
  56658. /**
  56659. * Gets a boolean indicating if Database storate is enabled (off by default)
  56660. */
  56661. static IDBStorageEnabled: boolean;
  56662. /**
  56663. * Gets a boolean indicating if scene must be saved in the database
  56664. */
  56665. readonly enableSceneOffline: boolean;
  56666. /**
  56667. * Gets a boolean indicating if textures must be saved in the database
  56668. */
  56669. readonly enableTexturesOffline: boolean;
  56670. /**
  56671. * Creates a new Database
  56672. * @param urlToScene defines the url to load the scene
  56673. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56674. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56675. */
  56676. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56677. private static _ParseURL;
  56678. private static _ReturnFullUrlLocation;
  56679. private _checkManifestFile;
  56680. /**
  56681. * Open the database and make it available
  56682. * @param successCallback defines the callback to call on success
  56683. * @param errorCallback defines the callback to call on error
  56684. */
  56685. open(successCallback: () => void, errorCallback: () => void): void;
  56686. /**
  56687. * Loads an image from the database
  56688. * @param url defines the url to load from
  56689. * @param image defines the target DOM image
  56690. */
  56691. loadImage(url: string, image: HTMLImageElement): void;
  56692. private _loadImageFromDBAsync;
  56693. private _saveImageIntoDBAsync;
  56694. private _checkVersionFromDB;
  56695. private _loadVersionFromDBAsync;
  56696. private _saveVersionIntoDBAsync;
  56697. /**
  56698. * Loads a file from database
  56699. * @param url defines the URL to load from
  56700. * @param sceneLoaded defines a callback to call on success
  56701. * @param progressCallBack defines a callback to call when progress changed
  56702. * @param errorCallback defines a callback to call on error
  56703. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56704. */
  56705. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56706. private _loadFileAsync;
  56707. private _saveFileAsync;
  56708. /**
  56709. * Validates if xhr data is correct
  56710. * @param xhr defines the request to validate
  56711. * @param dataType defines the expected data type
  56712. * @returns true if data is correct
  56713. */
  56714. private static _ValidateXHRData;
  56715. }
  56716. }
  56717. declare module "babylonjs/Offline/index" {
  56718. export * from "babylonjs/Offline/database";
  56719. export * from "babylonjs/Offline/IOfflineProvider";
  56720. }
  56721. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  56722. /** @hidden */
  56723. export var gpuUpdateParticlesPixelShader: {
  56724. name: string;
  56725. shader: string;
  56726. };
  56727. }
  56728. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  56729. /** @hidden */
  56730. export var gpuUpdateParticlesVertexShader: {
  56731. name: string;
  56732. shader: string;
  56733. };
  56734. }
  56735. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  56736. /** @hidden */
  56737. export var clipPlaneFragmentDeclaration2: {
  56738. name: string;
  56739. shader: string;
  56740. };
  56741. }
  56742. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  56743. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  56744. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56745. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56746. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56747. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56748. /** @hidden */
  56749. export var gpuRenderParticlesPixelShader: {
  56750. name: string;
  56751. shader: string;
  56752. };
  56753. }
  56754. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  56755. /** @hidden */
  56756. export var clipPlaneVertexDeclaration2: {
  56757. name: string;
  56758. shader: string;
  56759. };
  56760. }
  56761. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  56762. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  56763. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56764. /** @hidden */
  56765. export var gpuRenderParticlesVertexShader: {
  56766. name: string;
  56767. shader: string;
  56768. };
  56769. }
  56770. declare module "babylonjs/Particles/gpuParticleSystem" {
  56771. import { Nullable } from "babylonjs/types";
  56772. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  56773. import { Observable } from "babylonjs/Misc/observable";
  56774. import { Color4, Color3 } from "babylonjs/Maths/math";
  56775. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56776. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  56777. import { Scene, IDisposable } from "babylonjs/scene";
  56778. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  56779. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  56780. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  56781. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  56782. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  56783. /**
  56784. * This represents a GPU particle system in Babylon
  56785. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56786. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56787. */
  56788. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56789. /**
  56790. * The layer mask we are rendering the particles through.
  56791. */
  56792. layerMask: number;
  56793. private _capacity;
  56794. private _activeCount;
  56795. private _currentActiveCount;
  56796. private _accumulatedCount;
  56797. private _renderEffect;
  56798. private _updateEffect;
  56799. private _buffer0;
  56800. private _buffer1;
  56801. private _spriteBuffer;
  56802. private _updateVAO;
  56803. private _renderVAO;
  56804. private _targetIndex;
  56805. private _sourceBuffer;
  56806. private _targetBuffer;
  56807. private _engine;
  56808. private _currentRenderId;
  56809. private _started;
  56810. private _stopped;
  56811. private _timeDelta;
  56812. private _randomTexture;
  56813. private _randomTexture2;
  56814. private _attributesStrideSize;
  56815. private _updateEffectOptions;
  56816. private _randomTextureSize;
  56817. private _actualFrame;
  56818. private readonly _rawTextureWidth;
  56819. /**
  56820. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56821. */
  56822. static readonly IsSupported: boolean;
  56823. /**
  56824. * An event triggered when the system is disposed.
  56825. */
  56826. onDisposeObservable: Observable<GPUParticleSystem>;
  56827. /**
  56828. * Gets the maximum number of particles active at the same time.
  56829. * @returns The max number of active particles.
  56830. */
  56831. getCapacity(): number;
  56832. /**
  56833. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56834. * to override the particles.
  56835. */
  56836. forceDepthWrite: boolean;
  56837. /**
  56838. * Gets or set the number of active particles
  56839. */
  56840. activeParticleCount: number;
  56841. private _preWarmDone;
  56842. /**
  56843. * Is this system ready to be used/rendered
  56844. * @return true if the system is ready
  56845. */
  56846. isReady(): boolean;
  56847. /**
  56848. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56849. * @returns True if it has been started, otherwise false.
  56850. */
  56851. isStarted(): boolean;
  56852. /**
  56853. * Starts the particle system and begins to emit
  56854. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56855. */
  56856. start(delay?: number): void;
  56857. /**
  56858. * Stops the particle system.
  56859. */
  56860. stop(): void;
  56861. /**
  56862. * Remove all active particles
  56863. */
  56864. reset(): void;
  56865. /**
  56866. * Returns the string "GPUParticleSystem"
  56867. * @returns a string containing the class name
  56868. */
  56869. getClassName(): string;
  56870. private _colorGradientsTexture;
  56871. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56872. /**
  56873. * Adds a new color gradient
  56874. * @param gradient defines the gradient to use (between 0 and 1)
  56875. * @param color1 defines the color to affect to the specified gradient
  56876. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56877. * @returns the current particle system
  56878. */
  56879. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56880. /**
  56881. * Remove a specific color gradient
  56882. * @param gradient defines the gradient to remove
  56883. * @returns the current particle system
  56884. */
  56885. removeColorGradient(gradient: number): GPUParticleSystem;
  56886. private _angularSpeedGradientsTexture;
  56887. private _sizeGradientsTexture;
  56888. private _velocityGradientsTexture;
  56889. private _limitVelocityGradientsTexture;
  56890. private _dragGradientsTexture;
  56891. private _addFactorGradient;
  56892. /**
  56893. * Adds a new size gradient
  56894. * @param gradient defines the gradient to use (between 0 and 1)
  56895. * @param factor defines the size factor to affect to the specified gradient
  56896. * @returns the current particle system
  56897. */
  56898. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56899. /**
  56900. * Remove a specific size gradient
  56901. * @param gradient defines the gradient to remove
  56902. * @returns the current particle system
  56903. */
  56904. removeSizeGradient(gradient: number): GPUParticleSystem;
  56905. /**
  56906. * Adds a new angular speed gradient
  56907. * @param gradient defines the gradient to use (between 0 and 1)
  56908. * @param factor defines the angular speed to affect to the specified gradient
  56909. * @returns the current particle system
  56910. */
  56911. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56912. /**
  56913. * Remove a specific angular speed gradient
  56914. * @param gradient defines the gradient to remove
  56915. * @returns the current particle system
  56916. */
  56917. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56918. /**
  56919. * Adds a new velocity gradient
  56920. * @param gradient defines the gradient to use (between 0 and 1)
  56921. * @param factor defines the velocity to affect to the specified gradient
  56922. * @returns the current particle system
  56923. */
  56924. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56925. /**
  56926. * Remove a specific velocity gradient
  56927. * @param gradient defines the gradient to remove
  56928. * @returns the current particle system
  56929. */
  56930. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56931. /**
  56932. * Adds a new limit velocity gradient
  56933. * @param gradient defines the gradient to use (between 0 and 1)
  56934. * @param factor defines the limit velocity value to affect to the specified gradient
  56935. * @returns the current particle system
  56936. */
  56937. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56938. /**
  56939. * Remove a specific limit velocity gradient
  56940. * @param gradient defines the gradient to remove
  56941. * @returns the current particle system
  56942. */
  56943. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56944. /**
  56945. * Adds a new drag gradient
  56946. * @param gradient defines the gradient to use (between 0 and 1)
  56947. * @param factor defines the drag value to affect to the specified gradient
  56948. * @returns the current particle system
  56949. */
  56950. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56951. /**
  56952. * Remove a specific drag gradient
  56953. * @param gradient defines the gradient to remove
  56954. * @returns the current particle system
  56955. */
  56956. removeDragGradient(gradient: number): GPUParticleSystem;
  56957. /**
  56958. * Not supported by GPUParticleSystem
  56959. * @param gradient defines the gradient to use (between 0 and 1)
  56960. * @param factor defines the emit rate value to affect to the specified gradient
  56961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56962. * @returns the current particle system
  56963. */
  56964. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56965. /**
  56966. * Not supported by GPUParticleSystem
  56967. * @param gradient defines the gradient to remove
  56968. * @returns the current particle system
  56969. */
  56970. removeEmitRateGradient(gradient: number): IParticleSystem;
  56971. /**
  56972. * Not supported by GPUParticleSystem
  56973. * @param gradient defines the gradient to use (between 0 and 1)
  56974. * @param factor defines the start size value to affect to the specified gradient
  56975. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56976. * @returns the current particle system
  56977. */
  56978. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56979. /**
  56980. * Not supported by GPUParticleSystem
  56981. * @param gradient defines the gradient to remove
  56982. * @returns the current particle system
  56983. */
  56984. removeStartSizeGradient(gradient: number): IParticleSystem;
  56985. /**
  56986. * Not supported by GPUParticleSystem
  56987. * @param gradient defines the gradient to use (between 0 and 1)
  56988. * @param min defines the color remap minimal range
  56989. * @param max defines the color remap maximal range
  56990. * @returns the current particle system
  56991. */
  56992. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56993. /**
  56994. * Not supported by GPUParticleSystem
  56995. * @param gradient defines the gradient to remove
  56996. * @returns the current particle system
  56997. */
  56998. removeColorRemapGradient(): IParticleSystem;
  56999. /**
  57000. * Not supported by GPUParticleSystem
  57001. * @param gradient defines the gradient to use (between 0 and 1)
  57002. * @param min defines the alpha remap minimal range
  57003. * @param max defines the alpha remap maximal range
  57004. * @returns the current particle system
  57005. */
  57006. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57007. /**
  57008. * Not supported by GPUParticleSystem
  57009. * @param gradient defines the gradient to remove
  57010. * @returns the current particle system
  57011. */
  57012. removeAlphaRemapGradient(): IParticleSystem;
  57013. /**
  57014. * Not supported by GPUParticleSystem
  57015. * @param gradient defines the gradient to use (between 0 and 1)
  57016. * @param color defines the color to affect to the specified gradient
  57017. * @returns the current particle system
  57018. */
  57019. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57020. /**
  57021. * Not supported by GPUParticleSystem
  57022. * @param gradient defines the gradient to remove
  57023. * @returns the current particle system
  57024. */
  57025. removeRampGradient(): IParticleSystem;
  57026. /**
  57027. * Not supported by GPUParticleSystem
  57028. * @returns the list of ramp gradients
  57029. */
  57030. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57031. /**
  57032. * Not supported by GPUParticleSystem
  57033. * Gets or sets a boolean indicating that ramp gradients must be used
  57034. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57035. */
  57036. useRampGradients: boolean;
  57037. /**
  57038. * Not supported by GPUParticleSystem
  57039. * @param gradient defines the gradient to use (between 0 and 1)
  57040. * @param factor defines the life time factor to affect to the specified gradient
  57041. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57042. * @returns the current particle system
  57043. */
  57044. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57045. /**
  57046. * Not supported by GPUParticleSystem
  57047. * @param gradient defines the gradient to remove
  57048. * @returns the current particle system
  57049. */
  57050. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57051. /**
  57052. * Instantiates a GPU particle system.
  57053. * 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.
  57054. * @param name The name of the particle system
  57055. * @param options The options used to create the system
  57056. * @param scene The scene the particle system belongs to
  57057. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57058. */
  57059. constructor(name: string, options: Partial<{
  57060. capacity: number;
  57061. randomTextureSize: number;
  57062. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57063. protected _reset(): void;
  57064. private _createUpdateVAO;
  57065. private _createRenderVAO;
  57066. private _initialize;
  57067. /** @hidden */
  57068. _recreateUpdateEffect(): void;
  57069. /** @hidden */
  57070. _recreateRenderEffect(): void;
  57071. /**
  57072. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57073. * @param preWarm defines if we are in the pre-warmimg phase
  57074. */
  57075. animate(preWarm?: boolean): void;
  57076. private _createFactorGradientTexture;
  57077. private _createSizeGradientTexture;
  57078. private _createAngularSpeedGradientTexture;
  57079. private _createVelocityGradientTexture;
  57080. private _createLimitVelocityGradientTexture;
  57081. private _createDragGradientTexture;
  57082. private _createColorGradientTexture;
  57083. /**
  57084. * Renders the particle system in its current state
  57085. * @param preWarm defines if the system should only update the particles but not render them
  57086. * @returns the current number of particles
  57087. */
  57088. render(preWarm?: boolean): number;
  57089. /**
  57090. * Rebuilds the particle system
  57091. */
  57092. rebuild(): void;
  57093. private _releaseBuffers;
  57094. private _releaseVAOs;
  57095. /**
  57096. * Disposes the particle system and free the associated resources
  57097. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57098. */
  57099. dispose(disposeTexture?: boolean): void;
  57100. /**
  57101. * Clones the particle system.
  57102. * @param name The name of the cloned object
  57103. * @param newEmitter The new emitter to use
  57104. * @returns the cloned particle system
  57105. */
  57106. clone(name: string, newEmitter: any): GPUParticleSystem;
  57107. /**
  57108. * Serializes the particle system to a JSON object.
  57109. * @returns the JSON object
  57110. */
  57111. serialize(): any;
  57112. /**
  57113. * Parses a JSON object to create a GPU particle system.
  57114. * @param parsedParticleSystem The JSON object to parse
  57115. * @param scene The scene to create the particle system in
  57116. * @param rootUrl The root url to use to load external dependencies like texture
  57117. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57118. * @returns the parsed GPU particle system
  57119. */
  57120. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57121. }
  57122. }
  57123. declare module "babylonjs/Particles/particleSystemSet" {
  57124. import { Nullable } from "babylonjs/types";
  57125. import { Color3 } from "babylonjs/Maths/math";
  57126. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57128. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57129. import { Scene, IDisposable } from "babylonjs/scene";
  57130. /**
  57131. * Represents a set of particle systems working together to create a specific effect
  57132. */
  57133. export class ParticleSystemSet implements IDisposable {
  57134. private _emitterCreationOptions;
  57135. private _emitterNode;
  57136. /**
  57137. * Gets the particle system list
  57138. */
  57139. systems: IParticleSystem[];
  57140. /**
  57141. * Gets the emitter node used with this set
  57142. */
  57143. readonly emitterNode: Nullable<TransformNode>;
  57144. /**
  57145. * Creates a new emitter mesh as a sphere
  57146. * @param options defines the options used to create the sphere
  57147. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57148. * @param scene defines the hosting scene
  57149. */
  57150. setEmitterAsSphere(options: {
  57151. diameter: number;
  57152. segments: number;
  57153. color: Color3;
  57154. }, renderingGroupId: number, scene: Scene): void;
  57155. /**
  57156. * Starts all particle systems of the set
  57157. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57158. */
  57159. start(emitter?: AbstractMesh): void;
  57160. /**
  57161. * Release all associated resources
  57162. */
  57163. dispose(): void;
  57164. /**
  57165. * Serialize the set into a JSON compatible object
  57166. * @returns a JSON compatible representation of the set
  57167. */
  57168. serialize(): any;
  57169. /**
  57170. * Parse a new ParticleSystemSet from a serialized source
  57171. * @param data defines a JSON compatible representation of the set
  57172. * @param scene defines the hosting scene
  57173. * @param gpu defines if we want GPU particles or CPU particles
  57174. * @returns a new ParticleSystemSet
  57175. */
  57176. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57177. }
  57178. }
  57179. declare module "babylonjs/Particles/particleHelper" {
  57180. import { Nullable } from "babylonjs/types";
  57181. import { Scene } from "babylonjs/scene";
  57182. import { Vector3 } from "babylonjs/Maths/math";
  57183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57184. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57185. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  57186. /**
  57187. * This class is made for on one-liner static method to help creating particle system set.
  57188. */
  57189. export class ParticleHelper {
  57190. /**
  57191. * Gets or sets base Assets URL
  57192. */
  57193. static BaseAssetsUrl: string;
  57194. /**
  57195. * Create a default particle system that you can tweak
  57196. * @param emitter defines the emitter to use
  57197. * @param capacity defines the system capacity (default is 500 particles)
  57198. * @param scene defines the hosting scene
  57199. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57200. * @returns the new Particle system
  57201. */
  57202. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57203. /**
  57204. * This is the main static method (one-liner) of this helper to create different particle systems
  57205. * @param type This string represents the type to the particle system to create
  57206. * @param scene The scene where the particle system should live
  57207. * @param gpu If the system will use gpu
  57208. * @returns the ParticleSystemSet created
  57209. */
  57210. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57211. /**
  57212. * Static function used to export a particle system to a ParticleSystemSet variable.
  57213. * Please note that the emitter shape is not exported
  57214. * @param systems defines the particle systems to export
  57215. * @returns the created particle system set
  57216. */
  57217. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57218. }
  57219. }
  57220. declare module "babylonjs/Particles/particleSystemComponent" {
  57221. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57222. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  57223. import "babylonjs/Shaders/particles.vertex";
  57224. module "babylonjs/Engines/engine" {
  57225. interface Engine {
  57226. /**
  57227. * Create an effect to use with particle systems.
  57228. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57229. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57230. * @param uniformsNames defines a list of attribute names
  57231. * @param samplers defines an array of string used to represent textures
  57232. * @param defines defines the string containing the defines to use to compile the shaders
  57233. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57234. * @param onCompiled defines a function to call when the effect creation is successful
  57235. * @param onError defines a function to call when the effect creation has failed
  57236. * @returns the new Effect
  57237. */
  57238. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57239. }
  57240. }
  57241. module "babylonjs/Meshes/mesh" {
  57242. interface Mesh {
  57243. /**
  57244. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57245. * @returns an array of IParticleSystem
  57246. */
  57247. getEmittedParticleSystems(): IParticleSystem[];
  57248. /**
  57249. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57250. * @returns an array of IParticleSystem
  57251. */
  57252. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57253. }
  57254. }
  57255. /**
  57256. * @hidden
  57257. */
  57258. export var _IDoNeedToBeInTheBuild: number;
  57259. }
  57260. declare module "babylonjs/Particles/index" {
  57261. export * from "babylonjs/Particles/baseParticleSystem";
  57262. export * from "babylonjs/Particles/EmitterTypes/index";
  57263. export * from "babylonjs/Particles/gpuParticleSystem";
  57264. export * from "babylonjs/Particles/IParticleSystem";
  57265. export * from "babylonjs/Particles/particle";
  57266. export * from "babylonjs/Particles/particleHelper";
  57267. export * from "babylonjs/Particles/particleSystem";
  57268. export * from "babylonjs/Particles/particleSystemComponent";
  57269. export * from "babylonjs/Particles/particleSystemSet";
  57270. export * from "babylonjs/Particles/solidParticle";
  57271. export * from "babylonjs/Particles/solidParticleSystem";
  57272. export * from "babylonjs/Particles/subEmitter";
  57273. }
  57274. declare module "babylonjs/Physics/physicsEngineComponent" {
  57275. import { Nullable } from "babylonjs/types";
  57276. import { Observable, Observer } from "babylonjs/Misc/observable";
  57277. import { Vector3 } from "babylonjs/Maths/math";
  57278. import { Mesh } from "babylonjs/Meshes/mesh";
  57279. import { ISceneComponent } from "babylonjs/sceneComponent";
  57280. import { Scene } from "babylonjs/scene";
  57281. import { Node } from "babylonjs/node";
  57282. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57283. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57284. module "babylonjs/scene" {
  57285. interface Scene {
  57286. /** @hidden (Backing field) */
  57287. _physicsEngine: Nullable<IPhysicsEngine>;
  57288. /**
  57289. * Gets the current physics engine
  57290. * @returns a IPhysicsEngine or null if none attached
  57291. */
  57292. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57293. /**
  57294. * Enables physics to the current scene
  57295. * @param gravity defines the scene's gravity for the physics engine
  57296. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57297. * @return a boolean indicating if the physics engine was initialized
  57298. */
  57299. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57300. /**
  57301. * Disables and disposes the physics engine associated with the scene
  57302. */
  57303. disablePhysicsEngine(): void;
  57304. /**
  57305. * Gets a boolean indicating if there is an active physics engine
  57306. * @returns a boolean indicating if there is an active physics engine
  57307. */
  57308. isPhysicsEnabled(): boolean;
  57309. /**
  57310. * Deletes a physics compound impostor
  57311. * @param compound defines the compound to delete
  57312. */
  57313. deleteCompoundImpostor(compound: any): void;
  57314. /**
  57315. * An event triggered when physic simulation is about to be run
  57316. */
  57317. onBeforePhysicsObservable: Observable<Scene>;
  57318. /**
  57319. * An event triggered when physic simulation has been done
  57320. */
  57321. onAfterPhysicsObservable: Observable<Scene>;
  57322. }
  57323. }
  57324. module "babylonjs/Meshes/abstractMesh" {
  57325. interface AbstractMesh {
  57326. /** @hidden */
  57327. _physicsImpostor: Nullable<PhysicsImpostor>;
  57328. /**
  57329. * Gets or sets impostor used for physic simulation
  57330. * @see http://doc.babylonjs.com/features/physics_engine
  57331. */
  57332. physicsImpostor: Nullable<PhysicsImpostor>;
  57333. /**
  57334. * Gets the current physics impostor
  57335. * @see http://doc.babylonjs.com/features/physics_engine
  57336. * @returns a physics impostor or null
  57337. */
  57338. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57339. /** Apply a physic impulse to the mesh
  57340. * @param force defines the force to apply
  57341. * @param contactPoint defines where to apply the force
  57342. * @returns the current mesh
  57343. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57344. */
  57345. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57346. /**
  57347. * Creates a physic joint between two meshes
  57348. * @param otherMesh defines the other mesh to use
  57349. * @param pivot1 defines the pivot to use on this mesh
  57350. * @param pivot2 defines the pivot to use on the other mesh
  57351. * @param options defines additional options (can be plugin dependent)
  57352. * @returns the current mesh
  57353. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57354. */
  57355. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57356. /** @hidden */
  57357. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57358. }
  57359. }
  57360. /**
  57361. * Defines the physics engine scene component responsible to manage a physics engine
  57362. */
  57363. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57364. /**
  57365. * The component name helpful to identify the component in the list of scene components.
  57366. */
  57367. readonly name: string;
  57368. /**
  57369. * The scene the component belongs to.
  57370. */
  57371. scene: Scene;
  57372. /**
  57373. * Creates a new instance of the component for the given scene
  57374. * @param scene Defines the scene to register the component in
  57375. */
  57376. constructor(scene: Scene);
  57377. /**
  57378. * Registers the component in a given scene
  57379. */
  57380. register(): void;
  57381. /**
  57382. * Rebuilds the elements related to this component in case of
  57383. * context lost for instance.
  57384. */
  57385. rebuild(): void;
  57386. /**
  57387. * Disposes the component and the associated ressources
  57388. */
  57389. dispose(): void;
  57390. }
  57391. }
  57392. declare module "babylonjs/Physics/physicsHelper" {
  57393. import { Nullable } from "babylonjs/types";
  57394. import { Vector3 } from "babylonjs/Maths/math";
  57395. import { Mesh } from "babylonjs/Meshes/mesh";
  57396. import { Scene } from "babylonjs/scene";
  57397. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57398. /**
  57399. * A helper for physics simulations
  57400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57401. */
  57402. export class PhysicsHelper {
  57403. private _scene;
  57404. private _physicsEngine;
  57405. /**
  57406. * Initializes the Physics helper
  57407. * @param scene Babylon.js scene
  57408. */
  57409. constructor(scene: Scene);
  57410. /**
  57411. * Applies a radial explosion impulse
  57412. * @param origin the origin of the explosion
  57413. * @param radiusOrEventOptions the radius or the options of radial explosion
  57414. * @param strength the explosion strength
  57415. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57416. * @returns A physics radial explosion event, or null
  57417. */
  57418. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57419. /**
  57420. * Applies a radial explosion force
  57421. * @param origin the origin of the explosion
  57422. * @param radiusOrEventOptions the radius or the options of radial explosion
  57423. * @param strength the explosion strength
  57424. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57425. * @returns A physics radial explosion event, or null
  57426. */
  57427. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57428. /**
  57429. * Creates a gravitational field
  57430. * @param origin the origin of the explosion
  57431. * @param radiusOrEventOptions the radius or the options of radial explosion
  57432. * @param strength the explosion strength
  57433. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57434. * @returns A physics gravitational field event, or null
  57435. */
  57436. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57437. /**
  57438. * Creates a physics updraft event
  57439. * @param origin the origin of the updraft
  57440. * @param radiusOrEventOptions the radius or the options of the updraft
  57441. * @param strength the strength of the updraft
  57442. * @param height the height of the updraft
  57443. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57444. * @returns A physics updraft event, or null
  57445. */
  57446. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57447. /**
  57448. * Creates a physics vortex event
  57449. * @param origin the of the vortex
  57450. * @param radiusOrEventOptions the radius or the options of the vortex
  57451. * @param strength the strength of the vortex
  57452. * @param height the height of the vortex
  57453. * @returns a Physics vortex event, or null
  57454. * A physics vortex event or null
  57455. */
  57456. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57457. }
  57458. /**
  57459. * Represents a physics radial explosion event
  57460. */
  57461. class PhysicsRadialExplosionEvent {
  57462. private _scene;
  57463. private _options;
  57464. private _sphere;
  57465. private _dataFetched;
  57466. /**
  57467. * Initializes a radial explosioin event
  57468. * @param _scene BabylonJS scene
  57469. * @param _options The options for the vortex event
  57470. */
  57471. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57472. /**
  57473. * Returns the data related to the radial explosion event (sphere).
  57474. * @returns The radial explosion event data
  57475. */
  57476. getData(): PhysicsRadialExplosionEventData;
  57477. /**
  57478. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57479. * @param impostor A physics imposter
  57480. * @param origin the origin of the explosion
  57481. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57482. */
  57483. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57484. /**
  57485. * Triggers affecterd impostors callbacks
  57486. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57487. */
  57488. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57489. /**
  57490. * Disposes the sphere.
  57491. * @param force Specifies if the sphere should be disposed by force
  57492. */
  57493. dispose(force?: boolean): void;
  57494. /*** Helpers ***/
  57495. private _prepareSphere;
  57496. private _intersectsWithSphere;
  57497. }
  57498. /**
  57499. * Represents a gravitational field event
  57500. */
  57501. class PhysicsGravitationalFieldEvent {
  57502. private _physicsHelper;
  57503. private _scene;
  57504. private _origin;
  57505. private _options;
  57506. private _tickCallback;
  57507. private _sphere;
  57508. private _dataFetched;
  57509. /**
  57510. * Initializes the physics gravitational field event
  57511. * @param _physicsHelper A physics helper
  57512. * @param _scene BabylonJS scene
  57513. * @param _origin The origin position of the gravitational field event
  57514. * @param _options The options for the vortex event
  57515. */
  57516. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57517. /**
  57518. * Returns the data related to the gravitational field event (sphere).
  57519. * @returns A gravitational field event
  57520. */
  57521. getData(): PhysicsGravitationalFieldEventData;
  57522. /**
  57523. * Enables the gravitational field.
  57524. */
  57525. enable(): void;
  57526. /**
  57527. * Disables the gravitational field.
  57528. */
  57529. disable(): void;
  57530. /**
  57531. * Disposes the sphere.
  57532. * @param force The force to dispose from the gravitational field event
  57533. */
  57534. dispose(force?: boolean): void;
  57535. private _tick;
  57536. }
  57537. /**
  57538. * Represents a physics updraft event
  57539. */
  57540. class PhysicsUpdraftEvent {
  57541. private _scene;
  57542. private _origin;
  57543. private _options;
  57544. private _physicsEngine;
  57545. private _originTop;
  57546. private _originDirection;
  57547. private _tickCallback;
  57548. private _cylinder;
  57549. private _cylinderPosition;
  57550. private _dataFetched;
  57551. /**
  57552. * Initializes the physics updraft event
  57553. * @param _scene BabylonJS scene
  57554. * @param _origin The origin position of the updraft
  57555. * @param _options The options for the updraft event
  57556. */
  57557. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57558. /**
  57559. * Returns the data related to the updraft event (cylinder).
  57560. * @returns A physics updraft event
  57561. */
  57562. getData(): PhysicsUpdraftEventData;
  57563. /**
  57564. * Enables the updraft.
  57565. */
  57566. enable(): void;
  57567. /**
  57568. * Disables the updraft.
  57569. */
  57570. disable(): void;
  57571. /**
  57572. * Disposes the cylinder.
  57573. * @param force Specifies if the updraft should be disposed by force
  57574. */
  57575. dispose(force?: boolean): void;
  57576. private getImpostorHitData;
  57577. private _tick;
  57578. /*** Helpers ***/
  57579. private _prepareCylinder;
  57580. private _intersectsWithCylinder;
  57581. }
  57582. /**
  57583. * Represents a physics vortex event
  57584. */
  57585. class PhysicsVortexEvent {
  57586. private _scene;
  57587. private _origin;
  57588. private _options;
  57589. private _physicsEngine;
  57590. private _originTop;
  57591. private _tickCallback;
  57592. private _cylinder;
  57593. private _cylinderPosition;
  57594. private _dataFetched;
  57595. /**
  57596. * Initializes the physics vortex event
  57597. * @param _scene The BabylonJS scene
  57598. * @param _origin The origin position of the vortex
  57599. * @param _options The options for the vortex event
  57600. */
  57601. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57602. /**
  57603. * Returns the data related to the vortex event (cylinder).
  57604. * @returns The physics vortex event data
  57605. */
  57606. getData(): PhysicsVortexEventData;
  57607. /**
  57608. * Enables the vortex.
  57609. */
  57610. enable(): void;
  57611. /**
  57612. * Disables the cortex.
  57613. */
  57614. disable(): void;
  57615. /**
  57616. * Disposes the sphere.
  57617. * @param force
  57618. */
  57619. dispose(force?: boolean): void;
  57620. private getImpostorHitData;
  57621. private _tick;
  57622. /*** Helpers ***/
  57623. private _prepareCylinder;
  57624. private _intersectsWithCylinder;
  57625. }
  57626. /**
  57627. * Options fot the radial explosion event
  57628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57629. */
  57630. export class PhysicsRadialExplosionEventOptions {
  57631. /**
  57632. * The radius of the sphere for the radial explosion.
  57633. */
  57634. radius: number;
  57635. /**
  57636. * The strenth of the explosion.
  57637. */
  57638. strength: number;
  57639. /**
  57640. * The strenght of the force in correspondence to the distance of the affected object
  57641. */
  57642. falloff: PhysicsRadialImpulseFalloff;
  57643. /**
  57644. * Sphere options for the radial explosion.
  57645. */
  57646. sphere: {
  57647. segments: number;
  57648. diameter: number;
  57649. };
  57650. /**
  57651. * Sphere options for the radial explosion.
  57652. */
  57653. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57654. }
  57655. /**
  57656. * Options fot the updraft event
  57657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57658. */
  57659. export class PhysicsUpdraftEventOptions {
  57660. /**
  57661. * The radius of the cylinder for the vortex
  57662. */
  57663. radius: number;
  57664. /**
  57665. * The strenth of the updraft.
  57666. */
  57667. strength: number;
  57668. /**
  57669. * The height of the cylinder for the updraft.
  57670. */
  57671. height: number;
  57672. /**
  57673. * The mode for the the updraft.
  57674. */
  57675. updraftMode: PhysicsUpdraftMode;
  57676. }
  57677. /**
  57678. * Options fot the vortex event
  57679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57680. */
  57681. export class PhysicsVortexEventOptions {
  57682. /**
  57683. * The radius of the cylinder for the vortex
  57684. */
  57685. radius: number;
  57686. /**
  57687. * The strenth of the vortex.
  57688. */
  57689. strength: number;
  57690. /**
  57691. * The height of the cylinder for the vortex.
  57692. */
  57693. height: number;
  57694. /**
  57695. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57696. */
  57697. centripetalForceThreshold: number;
  57698. /**
  57699. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57700. */
  57701. centripetalForceMultiplier: number;
  57702. /**
  57703. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57704. */
  57705. centrifugalForceMultiplier: number;
  57706. /**
  57707. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57708. */
  57709. updraftForceMultiplier: number;
  57710. }
  57711. /**
  57712. * The strenght of the force in correspondence to the distance of the affected object
  57713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57714. */
  57715. export enum PhysicsRadialImpulseFalloff {
  57716. /** Defines that impulse is constant in strength across it's whole radius */
  57717. Constant = 0,
  57718. /** Defines that impulse gets weaker if it's further from the origin */
  57719. Linear = 1
  57720. }
  57721. /**
  57722. * The strength of the force in correspondence to the distance of the affected object
  57723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57724. */
  57725. export enum PhysicsUpdraftMode {
  57726. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57727. Center = 0,
  57728. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57729. Perpendicular = 1
  57730. }
  57731. /**
  57732. * Interface for a physics hit data
  57733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57734. */
  57735. export interface PhysicsHitData {
  57736. /**
  57737. * The force applied at the contact point
  57738. */
  57739. force: Vector3;
  57740. /**
  57741. * The contact point
  57742. */
  57743. contactPoint: Vector3;
  57744. /**
  57745. * The distance from the origin to the contact point
  57746. */
  57747. distanceFromOrigin: number;
  57748. }
  57749. /**
  57750. * Interface for radial explosion event data
  57751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57752. */
  57753. export interface PhysicsRadialExplosionEventData {
  57754. /**
  57755. * A sphere used for the radial explosion event
  57756. */
  57757. sphere: Mesh;
  57758. }
  57759. /**
  57760. * Interface for gravitational field event data
  57761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57762. */
  57763. export interface PhysicsGravitationalFieldEventData {
  57764. /**
  57765. * A sphere mesh used for the gravitational field event
  57766. */
  57767. sphere: Mesh;
  57768. }
  57769. /**
  57770. * Interface for updraft event data
  57771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57772. */
  57773. export interface PhysicsUpdraftEventData {
  57774. /**
  57775. * A cylinder used for the updraft event
  57776. */
  57777. cylinder: Mesh;
  57778. }
  57779. /**
  57780. * Interface for vortex event data
  57781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57782. */
  57783. export interface PhysicsVortexEventData {
  57784. /**
  57785. * A cylinder used for the vortex event
  57786. */
  57787. cylinder: Mesh;
  57788. }
  57789. /**
  57790. * Interface for an affected physics impostor
  57791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57792. */
  57793. export interface PhysicsAffectedImpostorWithData {
  57794. /**
  57795. * The impostor affected by the effect
  57796. */
  57797. impostor: PhysicsImpostor;
  57798. /**
  57799. * The data about the hit/horce from the explosion
  57800. */
  57801. hitData: PhysicsHitData;
  57802. }
  57803. }
  57804. declare module "babylonjs/Physics/Plugins/index" {
  57805. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57806. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57807. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57808. }
  57809. declare module "babylonjs/Physics/index" {
  57810. export * from "babylonjs/Physics/IPhysicsEngine";
  57811. export * from "babylonjs/Physics/physicsEngine";
  57812. export * from "babylonjs/Physics/physicsEngineComponent";
  57813. export * from "babylonjs/Physics/physicsHelper";
  57814. export * from "babylonjs/Physics/physicsImpostor";
  57815. export * from "babylonjs/Physics/physicsJoint";
  57816. export * from "babylonjs/Physics/Plugins/index";
  57817. }
  57818. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57819. /** @hidden */
  57820. export var blackAndWhitePixelShader: {
  57821. name: string;
  57822. shader: string;
  57823. };
  57824. }
  57825. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57826. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57827. import { Camera } from "babylonjs/Cameras/camera";
  57828. import { Engine } from "babylonjs/Engines/engine";
  57829. import "babylonjs/Shaders/blackAndWhite.fragment";
  57830. /**
  57831. * Post process used to render in black and white
  57832. */
  57833. export class BlackAndWhitePostProcess extends PostProcess {
  57834. /**
  57835. * Linear about to convert he result to black and white (default: 1)
  57836. */
  57837. degree: number;
  57838. /**
  57839. * Creates a black and white post process
  57840. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57841. * @param name The name of the effect.
  57842. * @param options The required width/height ratio to downsize to before computing the render pass.
  57843. * @param camera The camera to apply the render pass to.
  57844. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57845. * @param engine The engine which the post process will be applied. (default: current engine)
  57846. * @param reusable If the post process can be reused on the same frame. (default: false)
  57847. */
  57848. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57849. }
  57850. }
  57851. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  57852. import { Nullable } from "babylonjs/types";
  57853. import { Camera } from "babylonjs/Cameras/camera";
  57854. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57855. import { Engine } from "babylonjs/Engines/engine";
  57856. /**
  57857. * This represents a set of one or more post processes in Babylon.
  57858. * A post process can be used to apply a shader to a texture after it is rendered.
  57859. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57860. */
  57861. export class PostProcessRenderEffect {
  57862. private _postProcesses;
  57863. private _getPostProcesses;
  57864. private _singleInstance;
  57865. private _cameras;
  57866. private _indicesForCamera;
  57867. /**
  57868. * Name of the effect
  57869. * @hidden
  57870. */
  57871. _name: string;
  57872. /**
  57873. * Instantiates a post process render effect.
  57874. * A post process can be used to apply a shader to a texture after it is rendered.
  57875. * @param engine The engine the effect is tied to
  57876. * @param name The name of the effect
  57877. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57878. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57879. */
  57880. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57881. /**
  57882. * Checks if all the post processes in the effect are supported.
  57883. */
  57884. readonly isSupported: boolean;
  57885. /**
  57886. * Updates the current state of the effect
  57887. * @hidden
  57888. */
  57889. _update(): void;
  57890. /**
  57891. * Attaches the effect on cameras
  57892. * @param cameras The camera to attach to.
  57893. * @hidden
  57894. */
  57895. _attachCameras(cameras: Camera): void;
  57896. /**
  57897. * Attaches the effect on cameras
  57898. * @param cameras The camera to attach to.
  57899. * @hidden
  57900. */
  57901. _attachCameras(cameras: Camera[]): void;
  57902. /**
  57903. * Detaches the effect on cameras
  57904. * @param cameras The camera to detatch from.
  57905. * @hidden
  57906. */
  57907. _detachCameras(cameras: Camera): void;
  57908. /**
  57909. * Detatches the effect on cameras
  57910. * @param cameras The camera to detatch from.
  57911. * @hidden
  57912. */
  57913. _detachCameras(cameras: Camera[]): void;
  57914. /**
  57915. * Enables the effect on given cameras
  57916. * @param cameras The camera to enable.
  57917. * @hidden
  57918. */
  57919. _enable(cameras: Camera): void;
  57920. /**
  57921. * Enables the effect on given cameras
  57922. * @param cameras The camera to enable.
  57923. * @hidden
  57924. */
  57925. _enable(cameras: Nullable<Camera[]>): void;
  57926. /**
  57927. * Disables the effect on the given cameras
  57928. * @param cameras The camera to disable.
  57929. * @hidden
  57930. */
  57931. _disable(cameras: Camera): void;
  57932. /**
  57933. * Disables the effect on the given cameras
  57934. * @param cameras The camera to disable.
  57935. * @hidden
  57936. */
  57937. _disable(cameras: Nullable<Camera[]>): void;
  57938. /**
  57939. * Gets a list of the post processes contained in the effect.
  57940. * @param camera The camera to get the post processes on.
  57941. * @returns The list of the post processes in the effect.
  57942. */
  57943. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57944. }
  57945. }
  57946. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  57947. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57948. /** @hidden */
  57949. export var extractHighlightsPixelShader: {
  57950. name: string;
  57951. shader: string;
  57952. };
  57953. }
  57954. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  57955. import { Nullable } from "babylonjs/types";
  57956. import { Camera } from "babylonjs/Cameras/camera";
  57957. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57958. import { Engine } from "babylonjs/Engines/engine";
  57959. import "babylonjs/Shaders/extractHighlights.fragment";
  57960. /**
  57961. * 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.
  57962. */
  57963. export class ExtractHighlightsPostProcess extends PostProcess {
  57964. /**
  57965. * The luminance threshold, pixels below this value will be set to black.
  57966. */
  57967. threshold: number;
  57968. /** @hidden */
  57969. _exposure: number;
  57970. /**
  57971. * Post process which has the input texture to be used when performing highlight extraction
  57972. * @hidden
  57973. */
  57974. _inputPostProcess: Nullable<PostProcess>;
  57975. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57976. }
  57977. }
  57978. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  57979. /** @hidden */
  57980. export var bloomMergePixelShader: {
  57981. name: string;
  57982. shader: string;
  57983. };
  57984. }
  57985. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  57986. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57987. import { Nullable } from "babylonjs/types";
  57988. import { Engine } from "babylonjs/Engines/engine";
  57989. import { Camera } from "babylonjs/Cameras/camera";
  57990. import "babylonjs/Shaders/bloomMerge.fragment";
  57991. /**
  57992. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57993. */
  57994. export class BloomMergePostProcess extends PostProcess {
  57995. /** Weight of the bloom to be added to the original input. */
  57996. weight: number;
  57997. /**
  57998. * Creates a new instance of @see BloomMergePostProcess
  57999. * @param name The name of the effect.
  58000. * @param originalFromInput Post process which's input will be used for the merge.
  58001. * @param blurred Blurred highlights post process which's output will be used.
  58002. * @param weight Weight of the bloom to be added to the original input.
  58003. * @param options The required width/height ratio to downsize to before computing the render pass.
  58004. * @param camera The camera to apply the render pass to.
  58005. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58006. * @param engine The engine which the post process will be applied. (default: current engine)
  58007. * @param reusable If the post process can be reused on the same frame. (default: false)
  58008. * @param textureType Type of textures used when performing the post process. (default: 0)
  58009. * @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)
  58010. */
  58011. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58012. /** Weight of the bloom to be added to the original input. */
  58013. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58014. }
  58015. }
  58016. declare module "babylonjs/PostProcesses/bloomEffect" {
  58017. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58018. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58019. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  58020. import { Camera } from "babylonjs/Cameras/camera";
  58021. import { Scene } from "babylonjs/scene";
  58022. /**
  58023. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58024. */
  58025. export class BloomEffect extends PostProcessRenderEffect {
  58026. private bloomScale;
  58027. /**
  58028. * @hidden Internal
  58029. */
  58030. _effects: Array<PostProcess>;
  58031. /**
  58032. * @hidden Internal
  58033. */
  58034. _downscale: ExtractHighlightsPostProcess;
  58035. private _blurX;
  58036. private _blurY;
  58037. private _merge;
  58038. /**
  58039. * The luminance threshold to find bright areas of the image to bloom.
  58040. */
  58041. threshold: number;
  58042. /**
  58043. * The strength of the bloom.
  58044. */
  58045. weight: number;
  58046. /**
  58047. * Specifies the size of the bloom blur kernel, relative to the final output size
  58048. */
  58049. kernel: number;
  58050. /**
  58051. * Creates a new instance of @see BloomEffect
  58052. * @param scene The scene the effect belongs to.
  58053. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58054. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58055. * @param bloomWeight The the strength of bloom.
  58056. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58057. * @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)
  58058. */
  58059. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58060. /**
  58061. * Disposes each of the internal effects for a given camera.
  58062. * @param camera The camera to dispose the effect on.
  58063. */
  58064. disposeEffects(camera: Camera): void;
  58065. /**
  58066. * @hidden Internal
  58067. */
  58068. _updateEffects(): void;
  58069. /**
  58070. * Internal
  58071. * @returns if all the contained post processes are ready.
  58072. * @hidden
  58073. */
  58074. _isReady(): boolean;
  58075. }
  58076. }
  58077. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  58078. /** @hidden */
  58079. export var chromaticAberrationPixelShader: {
  58080. name: string;
  58081. shader: string;
  58082. };
  58083. }
  58084. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  58085. import { Vector2 } from "babylonjs/Maths/math";
  58086. import { Nullable } from "babylonjs/types";
  58087. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58088. import { Camera } from "babylonjs/Cameras/camera";
  58089. import { Engine } from "babylonjs/Engines/engine";
  58090. import "babylonjs/Shaders/chromaticAberration.fragment";
  58091. /**
  58092. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58093. */
  58094. export class ChromaticAberrationPostProcess extends PostProcess {
  58095. /**
  58096. * The amount of seperation of rgb channels (default: 30)
  58097. */
  58098. aberrationAmount: number;
  58099. /**
  58100. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58101. */
  58102. radialIntensity: number;
  58103. /**
  58104. * 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))
  58105. */
  58106. direction: Vector2;
  58107. /**
  58108. * 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))
  58109. */
  58110. centerPosition: Vector2;
  58111. /**
  58112. * Creates a new instance ChromaticAberrationPostProcess
  58113. * @param name The name of the effect.
  58114. * @param screenWidth The width of the screen to apply the effect on.
  58115. * @param screenHeight The height of the screen to apply the effect on.
  58116. * @param options The required width/height ratio to downsize to before computing the render pass.
  58117. * @param camera The camera to apply the render pass to.
  58118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58119. * @param engine The engine which the post process will be applied. (default: current engine)
  58120. * @param reusable If the post process can be reused on the same frame. (default: false)
  58121. * @param textureType Type of textures used when performing the post process. (default: 0)
  58122. * @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)
  58123. */
  58124. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58125. }
  58126. }
  58127. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  58128. /** @hidden */
  58129. export var circleOfConfusionPixelShader: {
  58130. name: string;
  58131. shader: string;
  58132. };
  58133. }
  58134. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  58135. import { Nullable } from "babylonjs/types";
  58136. import { Engine } from "babylonjs/Engines/engine";
  58137. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58138. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58139. import { Camera } from "babylonjs/Cameras/camera";
  58140. import "babylonjs/Shaders/circleOfConfusion.fragment";
  58141. /**
  58142. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58143. */
  58144. export class CircleOfConfusionPostProcess extends PostProcess {
  58145. /**
  58146. * 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.
  58147. */
  58148. lensSize: number;
  58149. /**
  58150. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58151. */
  58152. fStop: number;
  58153. /**
  58154. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58155. */
  58156. focusDistance: number;
  58157. /**
  58158. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58159. */
  58160. focalLength: number;
  58161. private _depthTexture;
  58162. /**
  58163. * Creates a new instance CircleOfConfusionPostProcess
  58164. * @param name The name of the effect.
  58165. * @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.
  58166. * @param options The required width/height ratio to downsize to before computing the render pass.
  58167. * @param camera The camera to apply the render pass to.
  58168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58169. * @param engine The engine which the post process will be applied. (default: current engine)
  58170. * @param reusable If the post process can be reused on the same frame. (default: false)
  58171. * @param textureType Type of textures used when performing the post process. (default: 0)
  58172. * @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)
  58173. */
  58174. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58175. /**
  58176. * 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.
  58177. */
  58178. depthTexture: RenderTargetTexture;
  58179. }
  58180. }
  58181. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  58182. /** @hidden */
  58183. export var colorCorrectionPixelShader: {
  58184. name: string;
  58185. shader: string;
  58186. };
  58187. }
  58188. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  58189. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58190. import { Engine } from "babylonjs/Engines/engine";
  58191. import { Camera } from "babylonjs/Cameras/camera";
  58192. import "babylonjs/Shaders/colorCorrection.fragment";
  58193. /**
  58194. *
  58195. * This post-process allows the modification of rendered colors by using
  58196. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58197. *
  58198. * The object needs to be provided an url to a texture containing the color
  58199. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58200. * Use an image editing software to tweak the LUT to match your needs.
  58201. *
  58202. * For an example of a color LUT, see here:
  58203. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58204. * For explanations on color grading, see here:
  58205. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58206. *
  58207. */
  58208. export class ColorCorrectionPostProcess extends PostProcess {
  58209. private _colorTableTexture;
  58210. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58211. }
  58212. }
  58213. declare module "babylonjs/Shaders/convolution.fragment" {
  58214. /** @hidden */
  58215. export var convolutionPixelShader: {
  58216. name: string;
  58217. shader: string;
  58218. };
  58219. }
  58220. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  58221. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58222. import { Nullable } from "babylonjs/types";
  58223. import { Camera } from "babylonjs/Cameras/camera";
  58224. import { Engine } from "babylonjs/Engines/engine";
  58225. import "babylonjs/Shaders/convolution.fragment";
  58226. /**
  58227. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58228. * input texture to perform effects such as edge detection or sharpening
  58229. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58230. */
  58231. export class ConvolutionPostProcess extends PostProcess {
  58232. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58233. kernel: number[];
  58234. /**
  58235. * Creates a new instance ConvolutionPostProcess
  58236. * @param name The name of the effect.
  58237. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58238. * @param options The required width/height ratio to downsize to before computing the render pass.
  58239. * @param camera The camera to apply the render pass to.
  58240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58241. * @param engine The engine which the post process will be applied. (default: current engine)
  58242. * @param reusable If the post process can be reused on the same frame. (default: false)
  58243. * @param textureType Type of textures used when performing the post process. (default: 0)
  58244. */
  58245. constructor(name: string,
  58246. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58247. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58248. /**
  58249. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58250. */
  58251. static EdgeDetect0Kernel: number[];
  58252. /**
  58253. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58254. */
  58255. static EdgeDetect1Kernel: number[];
  58256. /**
  58257. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58258. */
  58259. static EdgeDetect2Kernel: number[];
  58260. /**
  58261. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58262. */
  58263. static SharpenKernel: number[];
  58264. /**
  58265. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58266. */
  58267. static EmbossKernel: number[];
  58268. /**
  58269. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58270. */
  58271. static GaussianKernel: number[];
  58272. }
  58273. }
  58274. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  58275. import { Nullable } from "babylonjs/types";
  58276. import { Vector2 } from "babylonjs/Maths/math";
  58277. import { Camera } from "babylonjs/Cameras/camera";
  58278. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58279. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  58280. import { Engine } from "babylonjs/Engines/engine";
  58281. import { Scene } from "babylonjs/scene";
  58282. /**
  58283. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58284. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58285. * based on samples that have a large difference in distance than the center pixel.
  58286. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58287. */
  58288. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58289. direction: Vector2;
  58290. /**
  58291. * Creates a new instance CircleOfConfusionPostProcess
  58292. * @param name The name of the effect.
  58293. * @param scene The scene the effect belongs to.
  58294. * @param direction The direction the blur should be applied.
  58295. * @param kernel The size of the kernel used to blur.
  58296. * @param options The required width/height ratio to downsize to before computing the render pass.
  58297. * @param camera The camera to apply the render pass to.
  58298. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58299. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58300. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58301. * @param engine The engine which the post process will be applied. (default: current engine)
  58302. * @param reusable If the post process can be reused on the same frame. (default: false)
  58303. * @param textureType Type of textures used when performing the post process. (default: 0)
  58304. * @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)
  58305. */
  58306. 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);
  58307. }
  58308. }
  58309. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  58310. /** @hidden */
  58311. export var depthOfFieldMergePixelShader: {
  58312. name: string;
  58313. shader: string;
  58314. };
  58315. }
  58316. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  58317. import { Nullable } from "babylonjs/types";
  58318. import { Camera } from "babylonjs/Cameras/camera";
  58319. import { Effect } from "babylonjs/Materials/effect";
  58320. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58321. import { Engine } from "babylonjs/Engines/engine";
  58322. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  58323. /**
  58324. * Options to be set when merging outputs from the default pipeline.
  58325. */
  58326. export class DepthOfFieldMergePostProcessOptions {
  58327. /**
  58328. * The original image to merge on top of
  58329. */
  58330. originalFromInput: PostProcess;
  58331. /**
  58332. * Parameters to perform the merge of the depth of field effect
  58333. */
  58334. depthOfField?: {
  58335. circleOfConfusion: PostProcess;
  58336. blurSteps: Array<PostProcess>;
  58337. };
  58338. /**
  58339. * Parameters to perform the merge of bloom effect
  58340. */
  58341. bloom?: {
  58342. blurred: PostProcess;
  58343. weight: number;
  58344. };
  58345. }
  58346. /**
  58347. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58348. */
  58349. export class DepthOfFieldMergePostProcess extends PostProcess {
  58350. private blurSteps;
  58351. /**
  58352. * Creates a new instance of DepthOfFieldMergePostProcess
  58353. * @param name The name of the effect.
  58354. * @param originalFromInput Post process which's input will be used for the merge.
  58355. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58356. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58357. * @param options The required width/height ratio to downsize to before computing the render pass.
  58358. * @param camera The camera to apply the render pass to.
  58359. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58360. * @param engine The engine which the post process will be applied. (default: current engine)
  58361. * @param reusable If the post process can be reused on the same frame. (default: false)
  58362. * @param textureType Type of textures used when performing the post process. (default: 0)
  58363. * @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)
  58364. */
  58365. 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);
  58366. /**
  58367. * Updates the effect with the current post process compile time values and recompiles the shader.
  58368. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58369. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58370. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58371. * @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
  58372. * @param onCompiled Called when the shader has been compiled.
  58373. * @param onError Called if there is an error when compiling a shader.
  58374. */
  58375. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58376. }
  58377. }
  58378. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  58379. import { Nullable } from "babylonjs/types";
  58380. import { Camera } from "babylonjs/Cameras/camera";
  58381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58382. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58383. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58384. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  58385. import { Scene } from "babylonjs/scene";
  58386. /**
  58387. * Specifies the level of max blur that should be applied when using the depth of field effect
  58388. */
  58389. export enum DepthOfFieldEffectBlurLevel {
  58390. /**
  58391. * Subtle blur
  58392. */
  58393. Low = 0,
  58394. /**
  58395. * Medium blur
  58396. */
  58397. Medium = 1,
  58398. /**
  58399. * Large blur
  58400. */
  58401. High = 2
  58402. }
  58403. /**
  58404. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58405. */
  58406. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58407. private _circleOfConfusion;
  58408. /**
  58409. * @hidden Internal, blurs from high to low
  58410. */
  58411. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58412. private _depthOfFieldBlurY;
  58413. private _dofMerge;
  58414. /**
  58415. * @hidden Internal post processes in depth of field effect
  58416. */
  58417. _effects: Array<PostProcess>;
  58418. /**
  58419. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58420. */
  58421. focalLength: number;
  58422. /**
  58423. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58424. */
  58425. fStop: number;
  58426. /**
  58427. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58428. */
  58429. focusDistance: number;
  58430. /**
  58431. * 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.
  58432. */
  58433. lensSize: number;
  58434. /**
  58435. * Creates a new instance DepthOfFieldEffect
  58436. * @param scene The scene the effect belongs to.
  58437. * @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.
  58438. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58439. * @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)
  58440. */
  58441. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58442. /**
  58443. * Get the current class name of the current effet
  58444. * @returns "DepthOfFieldEffect"
  58445. */
  58446. getClassName(): string;
  58447. /**
  58448. * 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.
  58449. */
  58450. depthTexture: RenderTargetTexture;
  58451. /**
  58452. * Disposes each of the internal effects for a given camera.
  58453. * @param camera The camera to dispose the effect on.
  58454. */
  58455. disposeEffects(camera: Camera): void;
  58456. /**
  58457. * @hidden Internal
  58458. */
  58459. _updateEffects(): void;
  58460. /**
  58461. * Internal
  58462. * @returns if all the contained post processes are ready.
  58463. * @hidden
  58464. */
  58465. _isReady(): boolean;
  58466. }
  58467. }
  58468. declare module "babylonjs/Shaders/displayPass.fragment" {
  58469. /** @hidden */
  58470. export var displayPassPixelShader: {
  58471. name: string;
  58472. shader: string;
  58473. };
  58474. }
  58475. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  58476. import { Nullable } from "babylonjs/types";
  58477. import { Camera } from "babylonjs/Cameras/camera";
  58478. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58479. import { Engine } from "babylonjs/Engines/engine";
  58480. import "babylonjs/Shaders/displayPass.fragment";
  58481. /**
  58482. * DisplayPassPostProcess which produces an output the same as it's input
  58483. */
  58484. export class DisplayPassPostProcess extends PostProcess {
  58485. /**
  58486. * Creates the DisplayPassPostProcess
  58487. * @param name The name of the effect.
  58488. * @param options The required width/height ratio to downsize to before computing the render pass.
  58489. * @param camera The camera to apply the render pass to.
  58490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58491. * @param engine The engine which the post process will be applied. (default: current engine)
  58492. * @param reusable If the post process can be reused on the same frame. (default: false)
  58493. */
  58494. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58495. }
  58496. }
  58497. declare module "babylonjs/Shaders/filter.fragment" {
  58498. /** @hidden */
  58499. export var filterPixelShader: {
  58500. name: string;
  58501. shader: string;
  58502. };
  58503. }
  58504. declare module "babylonjs/PostProcesses/filterPostProcess" {
  58505. import { Nullable } from "babylonjs/types";
  58506. import { Matrix } from "babylonjs/Maths/math";
  58507. import { Camera } from "babylonjs/Cameras/camera";
  58508. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58509. import { Engine } from "babylonjs/Engines/engine";
  58510. import "babylonjs/Shaders/filter.fragment";
  58511. /**
  58512. * Applies a kernel filter to the image
  58513. */
  58514. export class FilterPostProcess extends PostProcess {
  58515. /** The matrix to be applied to the image */
  58516. kernelMatrix: Matrix;
  58517. /**
  58518. *
  58519. * @param name The name of the effect.
  58520. * @param kernelMatrix The matrix to be applied to the image
  58521. * @param options The required width/height ratio to downsize to before computing the render pass.
  58522. * @param camera The camera to apply the render pass to.
  58523. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58524. * @param engine The engine which the post process will be applied. (default: current engine)
  58525. * @param reusable If the post process can be reused on the same frame. (default: false)
  58526. */
  58527. constructor(name: string,
  58528. /** The matrix to be applied to the image */
  58529. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58530. }
  58531. }
  58532. declare module "babylonjs/Shaders/fxaa.fragment" {
  58533. /** @hidden */
  58534. export var fxaaPixelShader: {
  58535. name: string;
  58536. shader: string;
  58537. };
  58538. }
  58539. declare module "babylonjs/Shaders/fxaa.vertex" {
  58540. /** @hidden */
  58541. export var fxaaVertexShader: {
  58542. name: string;
  58543. shader: string;
  58544. };
  58545. }
  58546. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  58547. import { Nullable } from "babylonjs/types";
  58548. import { Camera } from "babylonjs/Cameras/camera";
  58549. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58550. import { Engine } from "babylonjs/Engines/engine";
  58551. import "babylonjs/Shaders/fxaa.fragment";
  58552. import "babylonjs/Shaders/fxaa.vertex";
  58553. /**
  58554. * Fxaa post process
  58555. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58556. */
  58557. export class FxaaPostProcess extends PostProcess {
  58558. /** @hidden */
  58559. texelWidth: number;
  58560. /** @hidden */
  58561. texelHeight: number;
  58562. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58563. private _getDefines;
  58564. }
  58565. }
  58566. declare module "babylonjs/Shaders/grain.fragment" {
  58567. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58568. /** @hidden */
  58569. export var grainPixelShader: {
  58570. name: string;
  58571. shader: string;
  58572. };
  58573. }
  58574. declare module "babylonjs/PostProcesses/grainPostProcess" {
  58575. import { Nullable } from "babylonjs/types";
  58576. import { Camera } from "babylonjs/Cameras/camera";
  58577. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58578. import { Engine } from "babylonjs/Engines/engine";
  58579. import "babylonjs/Shaders/grain.fragment";
  58580. /**
  58581. * The GrainPostProcess adds noise to the image at mid luminance levels
  58582. */
  58583. export class GrainPostProcess extends PostProcess {
  58584. /**
  58585. * The intensity of the grain added (default: 30)
  58586. */
  58587. intensity: number;
  58588. /**
  58589. * If the grain should be randomized on every frame
  58590. */
  58591. animated: boolean;
  58592. /**
  58593. * Creates a new instance of @see GrainPostProcess
  58594. * @param name The name of the effect.
  58595. * @param options The required width/height ratio to downsize to before computing the render pass.
  58596. * @param camera The camera to apply the render pass to.
  58597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58598. * @param engine The engine which the post process will be applied. (default: current engine)
  58599. * @param reusable If the post process can be reused on the same frame. (default: false)
  58600. * @param textureType Type of textures used when performing the post process. (default: 0)
  58601. * @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)
  58602. */
  58603. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58604. }
  58605. }
  58606. declare module "babylonjs/Shaders/highlights.fragment" {
  58607. /** @hidden */
  58608. export var highlightsPixelShader: {
  58609. name: string;
  58610. shader: string;
  58611. };
  58612. }
  58613. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  58614. import { Nullable } from "babylonjs/types";
  58615. import { Camera } from "babylonjs/Cameras/camera";
  58616. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58617. import { Engine } from "babylonjs/Engines/engine";
  58618. import "babylonjs/Shaders/highlights.fragment";
  58619. /**
  58620. * Extracts highlights from the image
  58621. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58622. */
  58623. export class HighlightsPostProcess extends PostProcess {
  58624. /**
  58625. * Extracts highlights from the image
  58626. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58627. * @param name The name of the effect.
  58628. * @param options The required width/height ratio to downsize to before computing the render pass.
  58629. * @param camera The camera to apply the render pass to.
  58630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58631. * @param engine The engine which the post process will be applied. (default: current engine)
  58632. * @param reusable If the post process can be reused on the same frame. (default: false)
  58633. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58634. */
  58635. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58636. }
  58637. }
  58638. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  58639. /** @hidden */
  58640. export var mrtFragmentDeclaration: {
  58641. name: string;
  58642. shader: string;
  58643. };
  58644. }
  58645. declare module "babylonjs/Shaders/geometry.fragment" {
  58646. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  58647. /** @hidden */
  58648. export var geometryPixelShader: {
  58649. name: string;
  58650. shader: string;
  58651. };
  58652. }
  58653. declare module "babylonjs/Shaders/geometry.vertex" {
  58654. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58655. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58656. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58657. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58658. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58659. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58660. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58661. /** @hidden */
  58662. export var geometryVertexShader: {
  58663. name: string;
  58664. shader: string;
  58665. };
  58666. }
  58667. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  58668. import { Matrix } from "babylonjs/Maths/math";
  58669. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58670. import { Mesh } from "babylonjs/Meshes/mesh";
  58671. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  58672. import { Effect } from "babylonjs/Materials/effect";
  58673. import { Scene } from "babylonjs/scene";
  58674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58675. import "babylonjs/Shaders/geometry.fragment";
  58676. import "babylonjs/Shaders/geometry.vertex";
  58677. /** @hidden */
  58678. interface ISavedTransformationMatrix {
  58679. world: Matrix;
  58680. viewProjection: Matrix;
  58681. }
  58682. /**
  58683. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58684. */
  58685. export class GeometryBufferRenderer {
  58686. /**
  58687. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58688. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58689. */
  58690. static readonly POSITION_TEXTURE_TYPE: number;
  58691. /**
  58692. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58693. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58694. */
  58695. static readonly VELOCITY_TEXTURE_TYPE: number;
  58696. /**
  58697. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58698. * in order to compute objects velocities when enableVelocity is set to "true"
  58699. * @hidden
  58700. */
  58701. _previousTransformationMatrices: {
  58702. [index: number]: ISavedTransformationMatrix;
  58703. };
  58704. /**
  58705. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58706. * in order to compute objects velocities when enableVelocity is set to "true"
  58707. * @hidden
  58708. */
  58709. _previousBonesTransformationMatrices: {
  58710. [index: number]: Float32Array;
  58711. };
  58712. /**
  58713. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58714. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58715. */
  58716. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58717. private _scene;
  58718. private _multiRenderTarget;
  58719. private _ratio;
  58720. private _enablePosition;
  58721. private _enableVelocity;
  58722. private _positionIndex;
  58723. private _velocityIndex;
  58724. protected _effect: Effect;
  58725. protected _cachedDefines: string;
  58726. /**
  58727. * Set the render list (meshes to be rendered) used in the G buffer.
  58728. */
  58729. renderList: Mesh[];
  58730. /**
  58731. * Gets wether or not G buffer are supported by the running hardware.
  58732. * This requires draw buffer supports
  58733. */
  58734. readonly isSupported: boolean;
  58735. /**
  58736. * Returns the index of the given texture type in the G-Buffer textures array
  58737. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58738. * @returns the index of the given texture type in the G-Buffer textures array
  58739. */
  58740. getTextureIndex(textureType: number): number;
  58741. /**
  58742. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58743. */
  58744. /**
  58745. * Sets whether or not objects positions are enabled for the G buffer.
  58746. */
  58747. enablePosition: boolean;
  58748. /**
  58749. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58750. */
  58751. /**
  58752. * Sets wether or not objects velocities are enabled for the G buffer.
  58753. */
  58754. enableVelocity: boolean;
  58755. /**
  58756. * Gets the scene associated with the buffer.
  58757. */
  58758. readonly scene: Scene;
  58759. /**
  58760. * Gets the ratio used by the buffer during its creation.
  58761. * How big is the buffer related to the main canvas.
  58762. */
  58763. readonly ratio: number;
  58764. /** @hidden */
  58765. static _SceneComponentInitialization: (scene: Scene) => void;
  58766. /**
  58767. * Creates a new G Buffer for the scene
  58768. * @param scene The scene the buffer belongs to
  58769. * @param ratio How big is the buffer related to the main canvas.
  58770. */
  58771. constructor(scene: Scene, ratio?: number);
  58772. /**
  58773. * Checks wether everything is ready to render a submesh to the G buffer.
  58774. * @param subMesh the submesh to check readiness for
  58775. * @param useInstances is the mesh drawn using instance or not
  58776. * @returns true if ready otherwise false
  58777. */
  58778. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58779. /**
  58780. * Gets the current underlying G Buffer.
  58781. * @returns the buffer
  58782. */
  58783. getGBuffer(): MultiRenderTarget;
  58784. /**
  58785. * Gets the number of samples used to render the buffer (anti aliasing).
  58786. */
  58787. /**
  58788. * Sets the number of samples used to render the buffer (anti aliasing).
  58789. */
  58790. samples: number;
  58791. /**
  58792. * Disposes the renderer and frees up associated resources.
  58793. */
  58794. dispose(): void;
  58795. protected _createRenderTargets(): void;
  58796. private _copyBonesTransformationMatrices;
  58797. }
  58798. }
  58799. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  58800. import { Nullable } from "babylonjs/types";
  58801. import { Scene } from "babylonjs/scene";
  58802. import { ISceneComponent } from "babylonjs/sceneComponent";
  58803. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58804. module "babylonjs/scene" {
  58805. interface Scene {
  58806. /** @hidden (Backing field) */
  58807. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58808. /**
  58809. * Gets or Sets the current geometry buffer associated to the scene.
  58810. */
  58811. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58812. /**
  58813. * Enables a GeometryBufferRender and associates it with the scene
  58814. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58815. * @returns the GeometryBufferRenderer
  58816. */
  58817. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58818. /**
  58819. * Disables the GeometryBufferRender associated with the scene
  58820. */
  58821. disableGeometryBufferRenderer(): void;
  58822. }
  58823. }
  58824. /**
  58825. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58826. * in several rendering techniques.
  58827. */
  58828. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58829. /**
  58830. * The component name helpful to identify the component in the list of scene components.
  58831. */
  58832. readonly name: string;
  58833. /**
  58834. * The scene the component belongs to.
  58835. */
  58836. scene: Scene;
  58837. /**
  58838. * Creates a new instance of the component for the given scene
  58839. * @param scene Defines the scene to register the component in
  58840. */
  58841. constructor(scene: Scene);
  58842. /**
  58843. * Registers the component in a given scene
  58844. */
  58845. register(): void;
  58846. /**
  58847. * Rebuilds the elements related to this component in case of
  58848. * context lost for instance.
  58849. */
  58850. rebuild(): void;
  58851. /**
  58852. * Disposes the component and the associated ressources
  58853. */
  58854. dispose(): void;
  58855. private _gatherRenderTargets;
  58856. }
  58857. }
  58858. declare module "babylonjs/Shaders/motionBlur.fragment" {
  58859. /** @hidden */
  58860. export var motionBlurPixelShader: {
  58861. name: string;
  58862. shader: string;
  58863. };
  58864. }
  58865. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  58866. import { Nullable } from "babylonjs/types";
  58867. import { Camera } from "babylonjs/Cameras/camera";
  58868. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58869. import { Scene } from "babylonjs/scene";
  58870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58871. import "babylonjs/Animations/animatable";
  58872. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  58873. import "babylonjs/Shaders/motionBlur.fragment";
  58874. import { Engine } from "babylonjs/Engines/engine";
  58875. /**
  58876. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58877. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58878. * As an example, all you have to do is to create the post-process:
  58879. * var mb = new BABYLON.MotionBlurPostProcess(
  58880. * 'mb', // The name of the effect.
  58881. * scene, // The scene containing the objects to blur according to their velocity.
  58882. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58883. * camera // The camera to apply the render pass to.
  58884. * );
  58885. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58886. */
  58887. export class MotionBlurPostProcess extends PostProcess {
  58888. /**
  58889. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58890. */
  58891. motionStrength: number;
  58892. /**
  58893. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58894. */
  58895. /**
  58896. * Sets the number of iterations to be used for motion blur quality
  58897. */
  58898. motionBlurSamples: number;
  58899. private _motionBlurSamples;
  58900. private _geometryBufferRenderer;
  58901. /**
  58902. * Creates a new instance MotionBlurPostProcess
  58903. * @param name The name of the effect.
  58904. * @param scene The scene containing the objects to blur according to their velocity.
  58905. * @param options The required width/height ratio to downsize to before computing the render pass.
  58906. * @param camera The camera to apply the render pass to.
  58907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58908. * @param engine The engine which the post process will be applied. (default: current engine)
  58909. * @param reusable If the post process can be reused on the same frame. (default: false)
  58910. * @param textureType Type of textures used when performing the post process. (default: 0)
  58911. * @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)
  58912. */
  58913. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58914. /**
  58915. * Excludes the given skinned mesh from computing bones velocities.
  58916. * 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.
  58917. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58918. */
  58919. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58920. /**
  58921. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58922. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58923. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58924. */
  58925. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58926. /**
  58927. * Disposes the post process.
  58928. * @param camera The camera to dispose the post process on.
  58929. */
  58930. dispose(camera?: Camera): void;
  58931. }
  58932. }
  58933. declare module "babylonjs/Shaders/refraction.fragment" {
  58934. /** @hidden */
  58935. export var refractionPixelShader: {
  58936. name: string;
  58937. shader: string;
  58938. };
  58939. }
  58940. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  58941. import { Color3 } from "babylonjs/Maths/math";
  58942. import { Camera } from "babylonjs/Cameras/camera";
  58943. import { Texture } from "babylonjs/Materials/Textures/texture";
  58944. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58945. import { Engine } from "babylonjs/Engines/engine";
  58946. import "babylonjs/Shaders/refraction.fragment";
  58947. /**
  58948. * Post process which applies a refractin texture
  58949. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58950. */
  58951. export class RefractionPostProcess extends PostProcess {
  58952. /** the base color of the refraction (used to taint the rendering) */
  58953. color: Color3;
  58954. /** simulated refraction depth */
  58955. depth: number;
  58956. /** the coefficient of the base color (0 to remove base color tainting) */
  58957. colorLevel: number;
  58958. private _refTexture;
  58959. private _ownRefractionTexture;
  58960. /**
  58961. * Gets or sets the refraction texture
  58962. * Please note that you are responsible for disposing the texture if you set it manually
  58963. */
  58964. refractionTexture: Texture;
  58965. /**
  58966. * Initializes the RefractionPostProcess
  58967. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58968. * @param name The name of the effect.
  58969. * @param refractionTextureUrl Url of the refraction texture to use
  58970. * @param color the base color of the refraction (used to taint the rendering)
  58971. * @param depth simulated refraction depth
  58972. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58973. * @param camera The camera to apply the render pass to.
  58974. * @param options The required width/height ratio to downsize to before computing the render pass.
  58975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58976. * @param engine The engine which the post process will be applied. (default: current engine)
  58977. * @param reusable If the post process can be reused on the same frame. (default: false)
  58978. */
  58979. constructor(name: string, refractionTextureUrl: string,
  58980. /** the base color of the refraction (used to taint the rendering) */
  58981. color: Color3,
  58982. /** simulated refraction depth */
  58983. depth: number,
  58984. /** the coefficient of the base color (0 to remove base color tainting) */
  58985. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58986. /**
  58987. * Disposes of the post process
  58988. * @param camera Camera to dispose post process on
  58989. */
  58990. dispose(camera: Camera): void;
  58991. }
  58992. }
  58993. declare module "babylonjs/Shaders/sharpen.fragment" {
  58994. /** @hidden */
  58995. export var sharpenPixelShader: {
  58996. name: string;
  58997. shader: string;
  58998. };
  58999. }
  59000. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  59001. import { Nullable } from "babylonjs/types";
  59002. import { Camera } from "babylonjs/Cameras/camera";
  59003. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59004. import "babylonjs/Shaders/sharpen.fragment";
  59005. import { Engine } from "babylonjs/Engines/engine";
  59006. /**
  59007. * The SharpenPostProcess applies a sharpen kernel to every pixel
  59008. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59009. */
  59010. export class SharpenPostProcess extends PostProcess {
  59011. /**
  59012. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  59013. */
  59014. colorAmount: number;
  59015. /**
  59016. * How much sharpness should be applied (default: 0.3)
  59017. */
  59018. edgeAmount: number;
  59019. /**
  59020. * Creates a new instance ConvolutionPostProcess
  59021. * @param name The name of the effect.
  59022. * @param options The required width/height ratio to downsize to before computing the render pass.
  59023. * @param camera The camera to apply the render pass to.
  59024. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59025. * @param engine The engine which the post process will be applied. (default: current engine)
  59026. * @param reusable If the post process can be reused on the same frame. (default: false)
  59027. * @param textureType Type of textures used when performing the post process. (default: 0)
  59028. * @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)
  59029. */
  59030. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59031. }
  59032. }
  59033. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  59034. import { Nullable } from "babylonjs/types";
  59035. import { Camera } from "babylonjs/Cameras/camera";
  59036. import { Engine } from "babylonjs/Engines/engine";
  59037. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59038. import { IInspectable } from "babylonjs/Misc/iInspectable";
  59039. /**
  59040. * PostProcessRenderPipeline
  59041. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59042. */
  59043. export class PostProcessRenderPipeline {
  59044. private engine;
  59045. private _renderEffects;
  59046. private _renderEffectsForIsolatedPass;
  59047. /**
  59048. * List of inspectable custom properties (used by the Inspector)
  59049. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  59050. */
  59051. inspectableCustomProperties: IInspectable[];
  59052. /**
  59053. * @hidden
  59054. */
  59055. protected _cameras: Camera[];
  59056. /** @hidden */
  59057. _name: string;
  59058. /**
  59059. * Gets pipeline name
  59060. */
  59061. readonly name: string;
  59062. /**
  59063. * Initializes a PostProcessRenderPipeline
  59064. * @param engine engine to add the pipeline to
  59065. * @param name name of the pipeline
  59066. */
  59067. constructor(engine: Engine, name: string);
  59068. /**
  59069. * Gets the class name
  59070. * @returns "PostProcessRenderPipeline"
  59071. */
  59072. getClassName(): string;
  59073. /**
  59074. * If all the render effects in the pipeline are supported
  59075. */
  59076. readonly isSupported: boolean;
  59077. /**
  59078. * Adds an effect to the pipeline
  59079. * @param renderEffect the effect to add
  59080. */
  59081. addEffect(renderEffect: PostProcessRenderEffect): void;
  59082. /** @hidden */
  59083. _rebuild(): void;
  59084. /** @hidden */
  59085. _enableEffect(renderEffectName: string, cameras: Camera): void;
  59086. /** @hidden */
  59087. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59088. /** @hidden */
  59089. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59090. /** @hidden */
  59091. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59092. /** @hidden */
  59093. _attachCameras(cameras: Camera, unique: boolean): void;
  59094. /** @hidden */
  59095. _attachCameras(cameras: Camera[], unique: boolean): void;
  59096. /** @hidden */
  59097. _detachCameras(cameras: Camera): void;
  59098. /** @hidden */
  59099. _detachCameras(cameras: Nullable<Camera[]>): void;
  59100. /** @hidden */
  59101. _update(): void;
  59102. /** @hidden */
  59103. _reset(): void;
  59104. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59105. /**
  59106. * Disposes of the pipeline
  59107. */
  59108. dispose(): void;
  59109. }
  59110. }
  59111. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  59112. import { Camera } from "babylonjs/Cameras/camera";
  59113. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59114. /**
  59115. * PostProcessRenderPipelineManager class
  59116. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59117. */
  59118. export class PostProcessRenderPipelineManager {
  59119. private _renderPipelines;
  59120. /**
  59121. * Initializes a PostProcessRenderPipelineManager
  59122. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59123. */
  59124. constructor();
  59125. /**
  59126. * Gets the list of supported render pipelines
  59127. */
  59128. readonly supportedPipelines: PostProcessRenderPipeline[];
  59129. /**
  59130. * Adds a pipeline to the manager
  59131. * @param renderPipeline The pipeline to add
  59132. */
  59133. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59134. /**
  59135. * Attaches a camera to the pipeline
  59136. * @param renderPipelineName The name of the pipeline to attach to
  59137. * @param cameras the camera to attach
  59138. * @param unique if the camera can be attached multiple times to the pipeline
  59139. */
  59140. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59141. /**
  59142. * Detaches a camera from the pipeline
  59143. * @param renderPipelineName The name of the pipeline to detach from
  59144. * @param cameras the camera to detach
  59145. */
  59146. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59147. /**
  59148. * Enables an effect by name on a pipeline
  59149. * @param renderPipelineName the name of the pipeline to enable the effect in
  59150. * @param renderEffectName the name of the effect to enable
  59151. * @param cameras the cameras that the effect should be enabled on
  59152. */
  59153. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59154. /**
  59155. * Disables an effect by name on a pipeline
  59156. * @param renderPipelineName the name of the pipeline to disable the effect in
  59157. * @param renderEffectName the name of the effect to disable
  59158. * @param cameras the cameras that the effect should be disabled on
  59159. */
  59160. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59161. /**
  59162. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59163. */
  59164. update(): void;
  59165. /** @hidden */
  59166. _rebuild(): void;
  59167. /**
  59168. * Disposes of the manager and pipelines
  59169. */
  59170. dispose(): void;
  59171. }
  59172. }
  59173. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  59174. import { ISceneComponent } from "babylonjs/sceneComponent";
  59175. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59176. import { Scene } from "babylonjs/scene";
  59177. module "babylonjs/scene" {
  59178. interface Scene {
  59179. /** @hidden (Backing field) */
  59180. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59181. /**
  59182. * Gets the postprocess render pipeline manager
  59183. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59184. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59185. */
  59186. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59187. }
  59188. }
  59189. /**
  59190. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59191. */
  59192. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59193. /**
  59194. * The component name helpfull to identify the component in the list of scene components.
  59195. */
  59196. readonly name: string;
  59197. /**
  59198. * The scene the component belongs to.
  59199. */
  59200. scene: Scene;
  59201. /**
  59202. * Creates a new instance of the component for the given scene
  59203. * @param scene Defines the scene to register the component in
  59204. */
  59205. constructor(scene: Scene);
  59206. /**
  59207. * Registers the component in a given scene
  59208. */
  59209. register(): void;
  59210. /**
  59211. * Rebuilds the elements related to this component in case of
  59212. * context lost for instance.
  59213. */
  59214. rebuild(): void;
  59215. /**
  59216. * Disposes the component and the associated ressources
  59217. */
  59218. dispose(): void;
  59219. private _gatherRenderTargets;
  59220. }
  59221. }
  59222. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  59223. import { Nullable } from "babylonjs/types";
  59224. import { IAnimatable } from "babylonjs/Misc/tools";
  59225. import { Camera } from "babylonjs/Cameras/camera";
  59226. import { IDisposable } from "babylonjs/scene";
  59227. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  59228. import { Scene } from "babylonjs/scene";
  59229. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  59230. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59231. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59232. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  59233. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59234. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59235. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  59236. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59237. import { Animation } from "babylonjs/Animations/animation";
  59238. /**
  59239. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59240. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59241. */
  59242. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59243. private _scene;
  59244. private _camerasToBeAttached;
  59245. /**
  59246. * ID of the sharpen post process,
  59247. */
  59248. private readonly SharpenPostProcessId;
  59249. /**
  59250. * @ignore
  59251. * ID of the image processing post process;
  59252. */
  59253. readonly ImageProcessingPostProcessId: string;
  59254. /**
  59255. * @ignore
  59256. * ID of the Fast Approximate Anti-Aliasing post process;
  59257. */
  59258. readonly FxaaPostProcessId: string;
  59259. /**
  59260. * ID of the chromatic aberration post process,
  59261. */
  59262. private readonly ChromaticAberrationPostProcessId;
  59263. /**
  59264. * ID of the grain post process
  59265. */
  59266. private readonly GrainPostProcessId;
  59267. /**
  59268. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59269. */
  59270. sharpen: SharpenPostProcess;
  59271. private _sharpenEffect;
  59272. private bloom;
  59273. /**
  59274. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59275. */
  59276. depthOfField: DepthOfFieldEffect;
  59277. /**
  59278. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59279. */
  59280. fxaa: FxaaPostProcess;
  59281. /**
  59282. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59283. */
  59284. imageProcessing: ImageProcessingPostProcess;
  59285. /**
  59286. * Chromatic aberration post process which will shift rgb colors in the image
  59287. */
  59288. chromaticAberration: ChromaticAberrationPostProcess;
  59289. private _chromaticAberrationEffect;
  59290. /**
  59291. * Grain post process which add noise to the image
  59292. */
  59293. grain: GrainPostProcess;
  59294. private _grainEffect;
  59295. /**
  59296. * Glow post process which adds a glow to emissive areas of the image
  59297. */
  59298. private _glowLayer;
  59299. /**
  59300. * Animations which can be used to tweak settings over a period of time
  59301. */
  59302. animations: Animation[];
  59303. private _imageProcessingConfigurationObserver;
  59304. private _sharpenEnabled;
  59305. private _bloomEnabled;
  59306. private _depthOfFieldEnabled;
  59307. private _depthOfFieldBlurLevel;
  59308. private _fxaaEnabled;
  59309. private _imageProcessingEnabled;
  59310. private _defaultPipelineTextureType;
  59311. private _bloomScale;
  59312. private _chromaticAberrationEnabled;
  59313. private _grainEnabled;
  59314. private _buildAllowed;
  59315. /**
  59316. * Gets active scene
  59317. */
  59318. readonly scene: Scene;
  59319. /**
  59320. * Enable or disable the sharpen process from the pipeline
  59321. */
  59322. sharpenEnabled: boolean;
  59323. private _resizeObserver;
  59324. private _hardwareScaleLevel;
  59325. private _bloomKernel;
  59326. /**
  59327. * Specifies the size of the bloom blur kernel, relative to the final output size
  59328. */
  59329. bloomKernel: number;
  59330. /**
  59331. * Specifies the weight of the bloom in the final rendering
  59332. */
  59333. private _bloomWeight;
  59334. /**
  59335. * Specifies the luma threshold for the area that will be blurred by the bloom
  59336. */
  59337. private _bloomThreshold;
  59338. private _hdr;
  59339. /**
  59340. * The strength of the bloom.
  59341. */
  59342. bloomWeight: number;
  59343. /**
  59344. * The strength of the bloom.
  59345. */
  59346. bloomThreshold: number;
  59347. /**
  59348. * The scale of the bloom, lower value will provide better performance.
  59349. */
  59350. bloomScale: number;
  59351. /**
  59352. * Enable or disable the bloom from the pipeline
  59353. */
  59354. bloomEnabled: boolean;
  59355. private _rebuildBloom;
  59356. /**
  59357. * If the depth of field is enabled.
  59358. */
  59359. depthOfFieldEnabled: boolean;
  59360. /**
  59361. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59362. */
  59363. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59364. /**
  59365. * If the anti aliasing is enabled.
  59366. */
  59367. fxaaEnabled: boolean;
  59368. private _samples;
  59369. /**
  59370. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59371. */
  59372. samples: number;
  59373. /**
  59374. * If image processing is enabled.
  59375. */
  59376. imageProcessingEnabled: boolean;
  59377. /**
  59378. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59379. */
  59380. glowLayerEnabled: boolean;
  59381. /**
  59382. * Gets the glow layer (or null if not defined)
  59383. */
  59384. readonly glowLayer: Nullable<GlowLayer>;
  59385. /**
  59386. * Enable or disable the chromaticAberration process from the pipeline
  59387. */
  59388. chromaticAberrationEnabled: boolean;
  59389. /**
  59390. * Enable or disable the grain process from the pipeline
  59391. */
  59392. grainEnabled: boolean;
  59393. /**
  59394. * @constructor
  59395. * @param name - The rendering pipeline name (default: "")
  59396. * @param hdr - If high dynamic range textures should be used (default: true)
  59397. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59398. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59399. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59400. */
  59401. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59402. /**
  59403. * Get the class name
  59404. * @returns "DefaultRenderingPipeline"
  59405. */
  59406. getClassName(): string;
  59407. /**
  59408. * Force the compilation of the entire pipeline.
  59409. */
  59410. prepare(): void;
  59411. private _hasCleared;
  59412. private _prevPostProcess;
  59413. private _prevPrevPostProcess;
  59414. private _setAutoClearAndTextureSharing;
  59415. private _depthOfFieldSceneObserver;
  59416. private _buildPipeline;
  59417. private _disposePostProcesses;
  59418. /**
  59419. * Adds a camera to the pipeline
  59420. * @param camera the camera to be added
  59421. */
  59422. addCamera(camera: Camera): void;
  59423. /**
  59424. * Removes a camera from the pipeline
  59425. * @param camera the camera to remove
  59426. */
  59427. removeCamera(camera: Camera): void;
  59428. /**
  59429. * Dispose of the pipeline and stop all post processes
  59430. */
  59431. dispose(): void;
  59432. /**
  59433. * Serialize the rendering pipeline (Used when exporting)
  59434. * @returns the serialized object
  59435. */
  59436. serialize(): any;
  59437. /**
  59438. * Parse the serialized pipeline
  59439. * @param source Source pipeline.
  59440. * @param scene The scene to load the pipeline to.
  59441. * @param rootUrl The URL of the serialized pipeline.
  59442. * @returns An instantiated pipeline from the serialized object.
  59443. */
  59444. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59445. }
  59446. }
  59447. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  59448. /** @hidden */
  59449. export var lensHighlightsPixelShader: {
  59450. name: string;
  59451. shader: string;
  59452. };
  59453. }
  59454. declare module "babylonjs/Shaders/depthOfField.fragment" {
  59455. /** @hidden */
  59456. export var depthOfFieldPixelShader: {
  59457. name: string;
  59458. shader: string;
  59459. };
  59460. }
  59461. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  59462. import { Camera } from "babylonjs/Cameras/camera";
  59463. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59464. import { Scene } from "babylonjs/scene";
  59465. import "babylonjs/Shaders/chromaticAberration.fragment";
  59466. import "babylonjs/Shaders/lensHighlights.fragment";
  59467. import "babylonjs/Shaders/depthOfField.fragment";
  59468. /**
  59469. * BABYLON.JS Chromatic Aberration GLSL Shader
  59470. * Author: Olivier Guyot
  59471. * Separates very slightly R, G and B colors on the edges of the screen
  59472. * Inspired by Francois Tarlier & Martins Upitis
  59473. */
  59474. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59475. /**
  59476. * @ignore
  59477. * The chromatic aberration PostProcess id in the pipeline
  59478. */
  59479. LensChromaticAberrationEffect: string;
  59480. /**
  59481. * @ignore
  59482. * The highlights enhancing PostProcess id in the pipeline
  59483. */
  59484. HighlightsEnhancingEffect: string;
  59485. /**
  59486. * @ignore
  59487. * The depth-of-field PostProcess id in the pipeline
  59488. */
  59489. LensDepthOfFieldEffect: string;
  59490. private _scene;
  59491. private _depthTexture;
  59492. private _grainTexture;
  59493. private _chromaticAberrationPostProcess;
  59494. private _highlightsPostProcess;
  59495. private _depthOfFieldPostProcess;
  59496. private _edgeBlur;
  59497. private _grainAmount;
  59498. private _chromaticAberration;
  59499. private _distortion;
  59500. private _highlightsGain;
  59501. private _highlightsThreshold;
  59502. private _dofDistance;
  59503. private _dofAperture;
  59504. private _dofDarken;
  59505. private _dofPentagon;
  59506. private _blurNoise;
  59507. /**
  59508. * @constructor
  59509. *
  59510. * Effect parameters are as follow:
  59511. * {
  59512. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59513. * edge_blur: number; // from 0 to x (1 for realism)
  59514. * distortion: number; // from 0 to x (1 for realism)
  59515. * grain_amount: number; // from 0 to 1
  59516. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59517. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59518. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59519. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59520. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59521. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59522. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59523. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59524. * }
  59525. * Note: if an effect parameter is unset, effect is disabled
  59526. *
  59527. * @param name The rendering pipeline name
  59528. * @param parameters - An object containing all parameters (see above)
  59529. * @param scene The scene linked to this pipeline
  59530. * @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)
  59531. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59532. */
  59533. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59534. /**
  59535. * Get the class name
  59536. * @returns "LensRenderingPipeline"
  59537. */
  59538. getClassName(): string;
  59539. /**
  59540. * Gets associated scene
  59541. */
  59542. readonly scene: Scene;
  59543. /**
  59544. * Gets or sets the edge blur
  59545. */
  59546. edgeBlur: number;
  59547. /**
  59548. * Gets or sets the grain amount
  59549. */
  59550. grainAmount: number;
  59551. /**
  59552. * Gets or sets the chromatic aberration amount
  59553. */
  59554. chromaticAberration: number;
  59555. /**
  59556. * Gets or sets the depth of field aperture
  59557. */
  59558. dofAperture: number;
  59559. /**
  59560. * Gets or sets the edge distortion
  59561. */
  59562. edgeDistortion: number;
  59563. /**
  59564. * Gets or sets the depth of field distortion
  59565. */
  59566. dofDistortion: number;
  59567. /**
  59568. * Gets or sets the darken out of focus amount
  59569. */
  59570. darkenOutOfFocus: number;
  59571. /**
  59572. * Gets or sets a boolean indicating if blur noise is enabled
  59573. */
  59574. blurNoise: boolean;
  59575. /**
  59576. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59577. */
  59578. pentagonBokeh: boolean;
  59579. /**
  59580. * Gets or sets the highlight grain amount
  59581. */
  59582. highlightsGain: number;
  59583. /**
  59584. * Gets or sets the highlight threshold
  59585. */
  59586. highlightsThreshold: number;
  59587. /**
  59588. * Sets the amount of blur at the edges
  59589. * @param amount blur amount
  59590. */
  59591. setEdgeBlur(amount: number): void;
  59592. /**
  59593. * Sets edge blur to 0
  59594. */
  59595. disableEdgeBlur(): void;
  59596. /**
  59597. * Sets the amout of grain
  59598. * @param amount Amount of grain
  59599. */
  59600. setGrainAmount(amount: number): void;
  59601. /**
  59602. * Set grain amount to 0
  59603. */
  59604. disableGrain(): void;
  59605. /**
  59606. * Sets the chromatic aberration amount
  59607. * @param amount amount of chromatic aberration
  59608. */
  59609. setChromaticAberration(amount: number): void;
  59610. /**
  59611. * Sets chromatic aberration amount to 0
  59612. */
  59613. disableChromaticAberration(): void;
  59614. /**
  59615. * Sets the EdgeDistortion amount
  59616. * @param amount amount of EdgeDistortion
  59617. */
  59618. setEdgeDistortion(amount: number): void;
  59619. /**
  59620. * Sets edge distortion to 0
  59621. */
  59622. disableEdgeDistortion(): void;
  59623. /**
  59624. * Sets the FocusDistance amount
  59625. * @param amount amount of FocusDistance
  59626. */
  59627. setFocusDistance(amount: number): void;
  59628. /**
  59629. * Disables depth of field
  59630. */
  59631. disableDepthOfField(): void;
  59632. /**
  59633. * Sets the Aperture amount
  59634. * @param amount amount of Aperture
  59635. */
  59636. setAperture(amount: number): void;
  59637. /**
  59638. * Sets the DarkenOutOfFocus amount
  59639. * @param amount amount of DarkenOutOfFocus
  59640. */
  59641. setDarkenOutOfFocus(amount: number): void;
  59642. private _pentagonBokehIsEnabled;
  59643. /**
  59644. * Creates a pentagon bokeh effect
  59645. */
  59646. enablePentagonBokeh(): void;
  59647. /**
  59648. * Disables the pentagon bokeh effect
  59649. */
  59650. disablePentagonBokeh(): void;
  59651. /**
  59652. * Enables noise blur
  59653. */
  59654. enableNoiseBlur(): void;
  59655. /**
  59656. * Disables noise blur
  59657. */
  59658. disableNoiseBlur(): void;
  59659. /**
  59660. * Sets the HighlightsGain amount
  59661. * @param amount amount of HighlightsGain
  59662. */
  59663. setHighlightsGain(amount: number): void;
  59664. /**
  59665. * Sets the HighlightsThreshold amount
  59666. * @param amount amount of HighlightsThreshold
  59667. */
  59668. setHighlightsThreshold(amount: number): void;
  59669. /**
  59670. * Disables highlights
  59671. */
  59672. disableHighlights(): void;
  59673. /**
  59674. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59675. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59676. */
  59677. dispose(disableDepthRender?: boolean): void;
  59678. private _createChromaticAberrationPostProcess;
  59679. private _createHighlightsPostProcess;
  59680. private _createDepthOfFieldPostProcess;
  59681. private _createGrainTexture;
  59682. }
  59683. }
  59684. declare module "babylonjs/Shaders/ssao2.fragment" {
  59685. /** @hidden */
  59686. export var ssao2PixelShader: {
  59687. name: string;
  59688. shader: string;
  59689. };
  59690. }
  59691. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  59692. /** @hidden */
  59693. export var ssaoCombinePixelShader: {
  59694. name: string;
  59695. shader: string;
  59696. };
  59697. }
  59698. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  59699. import { Camera } from "babylonjs/Cameras/camera";
  59700. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59701. import { Scene } from "babylonjs/scene";
  59702. import "babylonjs/Shaders/ssao2.fragment";
  59703. import "babylonjs/Shaders/ssaoCombine.fragment";
  59704. /**
  59705. * Render pipeline to produce ssao effect
  59706. */
  59707. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59708. /**
  59709. * @ignore
  59710. * The PassPostProcess id in the pipeline that contains the original scene color
  59711. */
  59712. SSAOOriginalSceneColorEffect: string;
  59713. /**
  59714. * @ignore
  59715. * The SSAO PostProcess id in the pipeline
  59716. */
  59717. SSAORenderEffect: string;
  59718. /**
  59719. * @ignore
  59720. * The horizontal blur PostProcess id in the pipeline
  59721. */
  59722. SSAOBlurHRenderEffect: string;
  59723. /**
  59724. * @ignore
  59725. * The vertical blur PostProcess id in the pipeline
  59726. */
  59727. SSAOBlurVRenderEffect: string;
  59728. /**
  59729. * @ignore
  59730. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59731. */
  59732. SSAOCombineRenderEffect: string;
  59733. /**
  59734. * The output strength of the SSAO post-process. Default value is 1.0.
  59735. */
  59736. totalStrength: number;
  59737. /**
  59738. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59739. */
  59740. maxZ: number;
  59741. /**
  59742. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59743. */
  59744. minZAspect: number;
  59745. private _samples;
  59746. /**
  59747. * Number of samples used for the SSAO calculations. Default value is 8
  59748. */
  59749. samples: number;
  59750. private _textureSamples;
  59751. /**
  59752. * Number of samples to use for antialiasing
  59753. */
  59754. textureSamples: number;
  59755. /**
  59756. * Ratio object used for SSAO ratio and blur ratio
  59757. */
  59758. private _ratio;
  59759. /**
  59760. * Dynamically generated sphere sampler.
  59761. */
  59762. private _sampleSphere;
  59763. /**
  59764. * Blur filter offsets
  59765. */
  59766. private _samplerOffsets;
  59767. private _expensiveBlur;
  59768. /**
  59769. * If bilateral blur should be used
  59770. */
  59771. expensiveBlur: boolean;
  59772. /**
  59773. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59774. */
  59775. radius: number;
  59776. /**
  59777. * The base color of the SSAO post-process
  59778. * The final result is "base + ssao" between [0, 1]
  59779. */
  59780. base: number;
  59781. /**
  59782. * Support test.
  59783. */
  59784. static readonly IsSupported: boolean;
  59785. private _scene;
  59786. private _depthTexture;
  59787. private _normalTexture;
  59788. private _randomTexture;
  59789. private _originalColorPostProcess;
  59790. private _ssaoPostProcess;
  59791. private _blurHPostProcess;
  59792. private _blurVPostProcess;
  59793. private _ssaoCombinePostProcess;
  59794. private _firstUpdate;
  59795. /**
  59796. * Gets active scene
  59797. */
  59798. readonly scene: Scene;
  59799. /**
  59800. * @constructor
  59801. * @param name The rendering pipeline name
  59802. * @param scene The scene linked to this pipeline
  59803. * @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 }
  59804. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59805. */
  59806. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59807. /**
  59808. * Get the class name
  59809. * @returns "SSAO2RenderingPipeline"
  59810. */
  59811. getClassName(): string;
  59812. /**
  59813. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59814. */
  59815. dispose(disableGeometryBufferRenderer?: boolean): void;
  59816. private _createBlurPostProcess;
  59817. /** @hidden */
  59818. _rebuild(): void;
  59819. private _bits;
  59820. private _radicalInverse_VdC;
  59821. private _hammersley;
  59822. private _hemisphereSample_uniform;
  59823. private _generateHemisphere;
  59824. private _createSSAOPostProcess;
  59825. private _createSSAOCombinePostProcess;
  59826. private _createRandomTexture;
  59827. /**
  59828. * Serialize the rendering pipeline (Used when exporting)
  59829. * @returns the serialized object
  59830. */
  59831. serialize(): any;
  59832. /**
  59833. * Parse the serialized pipeline
  59834. * @param source Source pipeline.
  59835. * @param scene The scene to load the pipeline to.
  59836. * @param rootUrl The URL of the serialized pipeline.
  59837. * @returns An instantiated pipeline from the serialized object.
  59838. */
  59839. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59840. }
  59841. }
  59842. declare module "babylonjs/Shaders/ssao.fragment" {
  59843. /** @hidden */
  59844. export var ssaoPixelShader: {
  59845. name: string;
  59846. shader: string;
  59847. };
  59848. }
  59849. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  59850. import { Camera } from "babylonjs/Cameras/camera";
  59851. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59852. import { Scene } from "babylonjs/scene";
  59853. import "babylonjs/Shaders/ssao.fragment";
  59854. import "babylonjs/Shaders/ssaoCombine.fragment";
  59855. /**
  59856. * Render pipeline to produce ssao effect
  59857. */
  59858. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59859. /**
  59860. * @ignore
  59861. * The PassPostProcess id in the pipeline that contains the original scene color
  59862. */
  59863. SSAOOriginalSceneColorEffect: string;
  59864. /**
  59865. * @ignore
  59866. * The SSAO PostProcess id in the pipeline
  59867. */
  59868. SSAORenderEffect: string;
  59869. /**
  59870. * @ignore
  59871. * The horizontal blur PostProcess id in the pipeline
  59872. */
  59873. SSAOBlurHRenderEffect: string;
  59874. /**
  59875. * @ignore
  59876. * The vertical blur PostProcess id in the pipeline
  59877. */
  59878. SSAOBlurVRenderEffect: string;
  59879. /**
  59880. * @ignore
  59881. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59882. */
  59883. SSAOCombineRenderEffect: string;
  59884. /**
  59885. * The output strength of the SSAO post-process. Default value is 1.0.
  59886. */
  59887. totalStrength: number;
  59888. /**
  59889. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59890. */
  59891. radius: number;
  59892. /**
  59893. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59894. * Must not be equal to fallOff and superior to fallOff.
  59895. * Default value is 0.0075
  59896. */
  59897. area: number;
  59898. /**
  59899. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59900. * Must not be equal to area and inferior to area.
  59901. * Default value is 0.000001
  59902. */
  59903. fallOff: number;
  59904. /**
  59905. * The base color of the SSAO post-process
  59906. * The final result is "base + ssao" between [0, 1]
  59907. */
  59908. base: number;
  59909. private _scene;
  59910. private _depthTexture;
  59911. private _randomTexture;
  59912. private _originalColorPostProcess;
  59913. private _ssaoPostProcess;
  59914. private _blurHPostProcess;
  59915. private _blurVPostProcess;
  59916. private _ssaoCombinePostProcess;
  59917. private _firstUpdate;
  59918. /**
  59919. * Gets active scene
  59920. */
  59921. readonly scene: Scene;
  59922. /**
  59923. * @constructor
  59924. * @param name - The rendering pipeline name
  59925. * @param scene - The scene linked to this pipeline
  59926. * @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 }
  59927. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59928. */
  59929. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59930. /**
  59931. * Get the class name
  59932. * @returns "SSAORenderingPipeline"
  59933. */
  59934. getClassName(): string;
  59935. /**
  59936. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59937. */
  59938. dispose(disableDepthRender?: boolean): void;
  59939. private _createBlurPostProcess;
  59940. /** @hidden */
  59941. _rebuild(): void;
  59942. private _createSSAOPostProcess;
  59943. private _createSSAOCombinePostProcess;
  59944. private _createRandomTexture;
  59945. }
  59946. }
  59947. declare module "babylonjs/Shaders/standard.fragment" {
  59948. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  59949. /** @hidden */
  59950. export var standardPixelShader: {
  59951. name: string;
  59952. shader: string;
  59953. };
  59954. }
  59955. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  59956. import { Nullable } from "babylonjs/types";
  59957. import { IAnimatable } from "babylonjs/Misc/tools";
  59958. import { Camera } from "babylonjs/Cameras/camera";
  59959. import { Texture } from "babylonjs/Materials/Textures/texture";
  59960. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59961. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59962. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59963. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59964. import { IDisposable } from "babylonjs/scene";
  59965. import { SpotLight } from "babylonjs/Lights/spotLight";
  59966. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  59967. import { Scene } from "babylonjs/scene";
  59968. import { Animation } from "babylonjs/Animations/animation";
  59969. import "babylonjs/Shaders/standard.fragment";
  59970. /**
  59971. * Standard rendering pipeline
  59972. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59973. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59974. */
  59975. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59976. /**
  59977. * Public members
  59978. */
  59979. /**
  59980. * Post-process which contains the original scene color before the pipeline applies all the effects
  59981. */
  59982. originalPostProcess: Nullable<PostProcess>;
  59983. /**
  59984. * Post-process used to down scale an image x4
  59985. */
  59986. downSampleX4PostProcess: Nullable<PostProcess>;
  59987. /**
  59988. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59989. */
  59990. brightPassPostProcess: Nullable<PostProcess>;
  59991. /**
  59992. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59993. */
  59994. blurHPostProcesses: PostProcess[];
  59995. /**
  59996. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59997. */
  59998. blurVPostProcesses: PostProcess[];
  59999. /**
  60000. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  60001. */
  60002. textureAdderPostProcess: Nullable<PostProcess>;
  60003. /**
  60004. * Post-process used to create volumetric lighting effect
  60005. */
  60006. volumetricLightPostProcess: Nullable<PostProcess>;
  60007. /**
  60008. * Post-process used to smooth the previous volumetric light post-process on the X axis
  60009. */
  60010. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  60011. /**
  60012. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  60013. */
  60014. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  60015. /**
  60016. * Post-process used to merge the volumetric light effect and the real scene color
  60017. */
  60018. volumetricLightMergePostProces: Nullable<PostProcess>;
  60019. /**
  60020. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  60021. */
  60022. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  60023. /**
  60024. * Base post-process used to calculate the average luminance of the final image for HDR
  60025. */
  60026. luminancePostProcess: Nullable<PostProcess>;
  60027. /**
  60028. * Post-processes used to create down sample post-processes in order to get
  60029. * the average luminance of the final image for HDR
  60030. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  60031. */
  60032. luminanceDownSamplePostProcesses: PostProcess[];
  60033. /**
  60034. * Post-process used to create a HDR effect (light adaptation)
  60035. */
  60036. hdrPostProcess: Nullable<PostProcess>;
  60037. /**
  60038. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  60039. */
  60040. textureAdderFinalPostProcess: Nullable<PostProcess>;
  60041. /**
  60042. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  60043. */
  60044. lensFlareFinalPostProcess: Nullable<PostProcess>;
  60045. /**
  60046. * Post-process used to merge the final HDR post-process and the real scene color
  60047. */
  60048. hdrFinalPostProcess: Nullable<PostProcess>;
  60049. /**
  60050. * Post-process used to create a lens flare effect
  60051. */
  60052. lensFlarePostProcess: Nullable<PostProcess>;
  60053. /**
  60054. * Post-process that merges the result of the lens flare post-process and the real scene color
  60055. */
  60056. lensFlareComposePostProcess: Nullable<PostProcess>;
  60057. /**
  60058. * Post-process used to create a motion blur effect
  60059. */
  60060. motionBlurPostProcess: Nullable<PostProcess>;
  60061. /**
  60062. * Post-process used to create a depth of field effect
  60063. */
  60064. depthOfFieldPostProcess: Nullable<PostProcess>;
  60065. /**
  60066. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60067. */
  60068. fxaaPostProcess: Nullable<FxaaPostProcess>;
  60069. /**
  60070. * Represents the brightness threshold in order to configure the illuminated surfaces
  60071. */
  60072. brightThreshold: number;
  60073. /**
  60074. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  60075. */
  60076. blurWidth: number;
  60077. /**
  60078. * Sets if the blur for highlighted surfaces must be only horizontal
  60079. */
  60080. horizontalBlur: boolean;
  60081. /**
  60082. * Gets the overall exposure used by the pipeline
  60083. */
  60084. /**
  60085. * Sets the overall exposure used by the pipeline
  60086. */
  60087. exposure: number;
  60088. /**
  60089. * Texture used typically to simulate "dirty" on camera lens
  60090. */
  60091. lensTexture: Nullable<Texture>;
  60092. /**
  60093. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60094. */
  60095. volumetricLightCoefficient: number;
  60096. /**
  60097. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60098. */
  60099. volumetricLightPower: number;
  60100. /**
  60101. * Used the set the blur intensity to smooth the volumetric lights
  60102. */
  60103. volumetricLightBlurScale: number;
  60104. /**
  60105. * Light (spot or directional) used to generate the volumetric lights rays
  60106. * The source light must have a shadow generate so the pipeline can get its
  60107. * depth map
  60108. */
  60109. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60110. /**
  60111. * For eye adaptation, represents the minimum luminance the eye can see
  60112. */
  60113. hdrMinimumLuminance: number;
  60114. /**
  60115. * For eye adaptation, represents the decrease luminance speed
  60116. */
  60117. hdrDecreaseRate: number;
  60118. /**
  60119. * For eye adaptation, represents the increase luminance speed
  60120. */
  60121. hdrIncreaseRate: number;
  60122. /**
  60123. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60124. */
  60125. /**
  60126. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60127. */
  60128. hdrAutoExposure: boolean;
  60129. /**
  60130. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60131. */
  60132. lensColorTexture: Nullable<Texture>;
  60133. /**
  60134. * The overall strengh for the lens flare effect
  60135. */
  60136. lensFlareStrength: number;
  60137. /**
  60138. * Dispersion coefficient for lens flare ghosts
  60139. */
  60140. lensFlareGhostDispersal: number;
  60141. /**
  60142. * Main lens flare halo width
  60143. */
  60144. lensFlareHaloWidth: number;
  60145. /**
  60146. * Based on the lens distortion effect, defines how much the lens flare result
  60147. * is distorted
  60148. */
  60149. lensFlareDistortionStrength: number;
  60150. /**
  60151. * Lens star texture must be used to simulate rays on the flares and is available
  60152. * in the documentation
  60153. */
  60154. lensStarTexture: Nullable<Texture>;
  60155. /**
  60156. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60157. * flare effect by taking account of the dirt texture
  60158. */
  60159. lensFlareDirtTexture: Nullable<Texture>;
  60160. /**
  60161. * Represents the focal length for the depth of field effect
  60162. */
  60163. depthOfFieldDistance: number;
  60164. /**
  60165. * Represents the blur intensity for the blurred part of the depth of field effect
  60166. */
  60167. depthOfFieldBlurWidth: number;
  60168. /**
  60169. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60170. */
  60171. /**
  60172. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60173. */
  60174. motionStrength: number;
  60175. /**
  60176. * Gets wether or not the motion blur post-process is object based or screen based.
  60177. */
  60178. /**
  60179. * Sets wether or not the motion blur post-process should be object based or screen based
  60180. */
  60181. objectBasedMotionBlur: boolean;
  60182. /**
  60183. * List of animations for the pipeline (IAnimatable implementation)
  60184. */
  60185. animations: Animation[];
  60186. /**
  60187. * Private members
  60188. */
  60189. private _scene;
  60190. private _currentDepthOfFieldSource;
  60191. private _basePostProcess;
  60192. private _fixedExposure;
  60193. private _currentExposure;
  60194. private _hdrAutoExposure;
  60195. private _hdrCurrentLuminance;
  60196. private _motionStrength;
  60197. private _isObjectBasedMotionBlur;
  60198. private _floatTextureType;
  60199. private _ratio;
  60200. private _bloomEnabled;
  60201. private _depthOfFieldEnabled;
  60202. private _vlsEnabled;
  60203. private _lensFlareEnabled;
  60204. private _hdrEnabled;
  60205. private _motionBlurEnabled;
  60206. private _fxaaEnabled;
  60207. private _motionBlurSamples;
  60208. private _volumetricLightStepsCount;
  60209. private _samples;
  60210. /**
  60211. * @ignore
  60212. * Specifies if the bloom pipeline is enabled
  60213. */
  60214. BloomEnabled: boolean;
  60215. /**
  60216. * @ignore
  60217. * Specifies if the depth of field pipeline is enabed
  60218. */
  60219. DepthOfFieldEnabled: boolean;
  60220. /**
  60221. * @ignore
  60222. * Specifies if the lens flare pipeline is enabed
  60223. */
  60224. LensFlareEnabled: boolean;
  60225. /**
  60226. * @ignore
  60227. * Specifies if the HDR pipeline is enabled
  60228. */
  60229. HDREnabled: boolean;
  60230. /**
  60231. * @ignore
  60232. * Specifies if the volumetric lights scattering effect is enabled
  60233. */
  60234. VLSEnabled: boolean;
  60235. /**
  60236. * @ignore
  60237. * Specifies if the motion blur effect is enabled
  60238. */
  60239. MotionBlurEnabled: boolean;
  60240. /**
  60241. * Specifies if anti-aliasing is enabled
  60242. */
  60243. fxaaEnabled: boolean;
  60244. /**
  60245. * Specifies the number of steps used to calculate the volumetric lights
  60246. * Typically in interval [50, 200]
  60247. */
  60248. volumetricLightStepsCount: number;
  60249. /**
  60250. * Specifies the number of samples used for the motion blur effect
  60251. * Typically in interval [16, 64]
  60252. */
  60253. motionBlurSamples: number;
  60254. /**
  60255. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60256. */
  60257. samples: number;
  60258. /**
  60259. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60260. * @constructor
  60261. * @param name The rendering pipeline name
  60262. * @param scene The scene linked to this pipeline
  60263. * @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)
  60264. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60265. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60266. */
  60267. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60268. private _buildPipeline;
  60269. private _createDownSampleX4PostProcess;
  60270. private _createBrightPassPostProcess;
  60271. private _createBlurPostProcesses;
  60272. private _createTextureAdderPostProcess;
  60273. private _createVolumetricLightPostProcess;
  60274. private _createLuminancePostProcesses;
  60275. private _createHdrPostProcess;
  60276. private _createLensFlarePostProcess;
  60277. private _createDepthOfFieldPostProcess;
  60278. private _createMotionBlurPostProcess;
  60279. private _getDepthTexture;
  60280. private _disposePostProcesses;
  60281. /**
  60282. * Dispose of the pipeline and stop all post processes
  60283. */
  60284. dispose(): void;
  60285. /**
  60286. * Serialize the rendering pipeline (Used when exporting)
  60287. * @returns the serialized object
  60288. */
  60289. serialize(): any;
  60290. /**
  60291. * Parse the serialized pipeline
  60292. * @param source Source pipeline.
  60293. * @param scene The scene to load the pipeline to.
  60294. * @param rootUrl The URL of the serialized pipeline.
  60295. * @returns An instantiated pipeline from the serialized object.
  60296. */
  60297. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60298. /**
  60299. * Luminance steps
  60300. */
  60301. static LuminanceSteps: number;
  60302. }
  60303. }
  60304. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  60305. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  60306. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  60307. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  60308. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  60309. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  60310. }
  60311. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  60312. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  60313. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60314. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60315. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60316. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60317. }
  60318. declare module "babylonjs/Shaders/tonemap.fragment" {
  60319. /** @hidden */
  60320. export var tonemapPixelShader: {
  60321. name: string;
  60322. shader: string;
  60323. };
  60324. }
  60325. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  60326. import { Camera } from "babylonjs/Cameras/camera";
  60327. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60328. import "babylonjs/Shaders/tonemap.fragment";
  60329. import { Engine } from "babylonjs/Engines/engine";
  60330. /** Defines operator used for tonemapping */
  60331. export enum TonemappingOperator {
  60332. /** Hable */
  60333. Hable = 0,
  60334. /** Reinhard */
  60335. Reinhard = 1,
  60336. /** HejiDawson */
  60337. HejiDawson = 2,
  60338. /** Photographic */
  60339. Photographic = 3
  60340. }
  60341. /**
  60342. * Defines a post process to apply tone mapping
  60343. */
  60344. export class TonemapPostProcess extends PostProcess {
  60345. private _operator;
  60346. /** Defines the required exposure adjustement */
  60347. exposureAdjustment: number;
  60348. /**
  60349. * Creates a new TonemapPostProcess
  60350. * @param name defines the name of the postprocess
  60351. * @param _operator defines the operator to use
  60352. * @param exposureAdjustment defines the required exposure adjustement
  60353. * @param camera defines the camera to use (can be null)
  60354. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60355. * @param engine defines the hosting engine (can be ignore if camera is set)
  60356. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60357. */
  60358. constructor(name: string, _operator: TonemappingOperator,
  60359. /** Defines the required exposure adjustement */
  60360. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60361. }
  60362. }
  60363. declare module "babylonjs/Shaders/depth.vertex" {
  60364. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60365. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60366. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60367. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60368. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60369. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60370. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60371. /** @hidden */
  60372. export var depthVertexShader: {
  60373. name: string;
  60374. shader: string;
  60375. };
  60376. }
  60377. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  60378. /** @hidden */
  60379. export var volumetricLightScatteringPixelShader: {
  60380. name: string;
  60381. shader: string;
  60382. };
  60383. }
  60384. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  60385. /** @hidden */
  60386. export var volumetricLightScatteringPassPixelShader: {
  60387. name: string;
  60388. shader: string;
  60389. };
  60390. }
  60391. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  60392. import { Vector3 } from "babylonjs/Maths/math";
  60393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60394. import { Mesh } from "babylonjs/Meshes/mesh";
  60395. import { Camera } from "babylonjs/Cameras/camera";
  60396. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60397. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60398. import { Scene } from "babylonjs/scene";
  60399. import "babylonjs/Meshes/Builders/planeBuilder";
  60400. import "babylonjs/Shaders/depth.vertex";
  60401. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  60402. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  60403. import { Engine } from "babylonjs/Engines/engine";
  60404. /**
  60405. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60406. */
  60407. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60408. private _volumetricLightScatteringPass;
  60409. private _volumetricLightScatteringRTT;
  60410. private _viewPort;
  60411. private _screenCoordinates;
  60412. private _cachedDefines;
  60413. /**
  60414. * If not undefined, the mesh position is computed from the attached node position
  60415. */
  60416. attachedNode: {
  60417. position: Vector3;
  60418. };
  60419. /**
  60420. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60421. */
  60422. customMeshPosition: Vector3;
  60423. /**
  60424. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60425. */
  60426. useCustomMeshPosition: boolean;
  60427. /**
  60428. * If the post-process should inverse the light scattering direction
  60429. */
  60430. invert: boolean;
  60431. /**
  60432. * The internal mesh used by the post-process
  60433. */
  60434. mesh: Mesh;
  60435. /**
  60436. * @hidden
  60437. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60438. */
  60439. useDiffuseColor: boolean;
  60440. /**
  60441. * Array containing the excluded meshes not rendered in the internal pass
  60442. */
  60443. excludedMeshes: AbstractMesh[];
  60444. /**
  60445. * Controls the overall intensity of the post-process
  60446. */
  60447. exposure: number;
  60448. /**
  60449. * Dissipates each sample's contribution in range [0, 1]
  60450. */
  60451. decay: number;
  60452. /**
  60453. * Controls the overall intensity of each sample
  60454. */
  60455. weight: number;
  60456. /**
  60457. * Controls the density of each sample
  60458. */
  60459. density: number;
  60460. /**
  60461. * @constructor
  60462. * @param name The post-process name
  60463. * @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)
  60464. * @param camera The camera that the post-process will be attached to
  60465. * @param mesh The mesh used to create the light scattering
  60466. * @param samples The post-process quality, default 100
  60467. * @param samplingModeThe post-process filtering mode
  60468. * @param engine The babylon engine
  60469. * @param reusable If the post-process is reusable
  60470. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60471. */
  60472. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60473. /**
  60474. * Returns the string "VolumetricLightScatteringPostProcess"
  60475. * @returns "VolumetricLightScatteringPostProcess"
  60476. */
  60477. getClassName(): string;
  60478. private _isReady;
  60479. /**
  60480. * Sets the new light position for light scattering effect
  60481. * @param position The new custom light position
  60482. */
  60483. setCustomMeshPosition(position: Vector3): void;
  60484. /**
  60485. * Returns the light position for light scattering effect
  60486. * @return Vector3 The custom light position
  60487. */
  60488. getCustomMeshPosition(): Vector3;
  60489. /**
  60490. * Disposes the internal assets and detaches the post-process from the camera
  60491. */
  60492. dispose(camera: Camera): void;
  60493. /**
  60494. * Returns the render target texture used by the post-process
  60495. * @return the render target texture used by the post-process
  60496. */
  60497. getPass(): RenderTargetTexture;
  60498. private _meshExcluded;
  60499. private _createPass;
  60500. private _updateMeshScreenCoordinates;
  60501. /**
  60502. * Creates a default mesh for the Volumeric Light Scattering post-process
  60503. * @param name The mesh name
  60504. * @param scene The scene where to create the mesh
  60505. * @return the default mesh
  60506. */
  60507. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60508. }
  60509. }
  60510. declare module "babylonjs/PostProcesses/index" {
  60511. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  60512. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  60513. export * from "babylonjs/PostProcesses/bloomEffect";
  60514. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  60515. export * from "babylonjs/PostProcesses/blurPostProcess";
  60516. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60517. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  60518. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  60519. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  60520. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60521. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  60522. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  60523. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  60524. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60525. export * from "babylonjs/PostProcesses/filterPostProcess";
  60526. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  60527. export * from "babylonjs/PostProcesses/grainPostProcess";
  60528. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  60529. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60530. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  60531. export * from "babylonjs/PostProcesses/passPostProcess";
  60532. export * from "babylonjs/PostProcesses/postProcess";
  60533. export * from "babylonjs/PostProcesses/postProcessManager";
  60534. export * from "babylonjs/PostProcesses/refractionPostProcess";
  60535. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  60536. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  60537. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  60538. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  60539. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  60540. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  60541. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  60542. }
  60543. declare module "babylonjs/Probes/index" {
  60544. export * from "babylonjs/Probes/reflectionProbe";
  60545. }
  60546. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  60547. import { Scene } from "babylonjs/scene";
  60548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60549. import { Color3 } from "babylonjs/Maths/math";
  60550. import { SmartArray } from "babylonjs/Misc/smartArray";
  60551. import { ISceneComponent } from "babylonjs/sceneComponent";
  60552. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  60553. import "babylonjs/Meshes/Builders/boxBuilder";
  60554. import "babylonjs/Shaders/color.fragment";
  60555. import "babylonjs/Shaders/color.vertex";
  60556. module "babylonjs/scene" {
  60557. interface Scene {
  60558. /** @hidden (Backing field) */
  60559. _boundingBoxRenderer: BoundingBoxRenderer;
  60560. /** @hidden (Backing field) */
  60561. _forceShowBoundingBoxes: boolean;
  60562. /**
  60563. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60564. */
  60565. forceShowBoundingBoxes: boolean;
  60566. /**
  60567. * Gets the bounding box renderer associated with the scene
  60568. * @returns a BoundingBoxRenderer
  60569. */
  60570. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60571. }
  60572. }
  60573. module "babylonjs/Meshes/abstractMesh" {
  60574. interface AbstractMesh {
  60575. /** @hidden (Backing field) */
  60576. _showBoundingBox: boolean;
  60577. /**
  60578. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60579. */
  60580. showBoundingBox: boolean;
  60581. }
  60582. }
  60583. /**
  60584. * Component responsible of rendering the bounding box of the meshes in a scene.
  60585. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60586. */
  60587. export class BoundingBoxRenderer implements ISceneComponent {
  60588. /**
  60589. * The component name helpfull to identify the component in the list of scene components.
  60590. */
  60591. readonly name: string;
  60592. /**
  60593. * The scene the component belongs to.
  60594. */
  60595. scene: Scene;
  60596. /**
  60597. * Color of the bounding box lines placed in front of an object
  60598. */
  60599. frontColor: Color3;
  60600. /**
  60601. * Color of the bounding box lines placed behind an object
  60602. */
  60603. backColor: Color3;
  60604. /**
  60605. * Defines if the renderer should show the back lines or not
  60606. */
  60607. showBackLines: boolean;
  60608. /**
  60609. * @hidden
  60610. */
  60611. renderList: SmartArray<BoundingBox>;
  60612. private _colorShader;
  60613. private _vertexBuffers;
  60614. private _indexBuffer;
  60615. private _fillIndexBuffer;
  60616. private _fillIndexData;
  60617. /**
  60618. * Instantiates a new bounding box renderer in a scene.
  60619. * @param scene the scene the renderer renders in
  60620. */
  60621. constructor(scene: Scene);
  60622. /**
  60623. * Registers the component in a given scene
  60624. */
  60625. register(): void;
  60626. private _evaluateSubMesh;
  60627. private _activeMesh;
  60628. private _prepareRessources;
  60629. private _createIndexBuffer;
  60630. /**
  60631. * Rebuilds the elements related to this component in case of
  60632. * context lost for instance.
  60633. */
  60634. rebuild(): void;
  60635. /**
  60636. * @hidden
  60637. */
  60638. reset(): void;
  60639. /**
  60640. * Render the bounding boxes of a specific rendering group
  60641. * @param renderingGroupId defines the rendering group to render
  60642. */
  60643. render(renderingGroupId: number): void;
  60644. /**
  60645. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60646. * @param mesh Define the mesh to render the occlusion bounding box for
  60647. */
  60648. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60649. /**
  60650. * Dispose and release the resources attached to this renderer.
  60651. */
  60652. dispose(): void;
  60653. }
  60654. }
  60655. declare module "babylonjs/Shaders/depth.fragment" {
  60656. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60657. /** @hidden */
  60658. export var depthPixelShader: {
  60659. name: string;
  60660. shader: string;
  60661. };
  60662. }
  60663. declare module "babylonjs/Rendering/depthRenderer" {
  60664. import { Nullable } from "babylonjs/types";
  60665. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60666. import { Scene } from "babylonjs/scene";
  60667. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60668. import { Camera } from "babylonjs/Cameras/camera";
  60669. import "babylonjs/Shaders/depth.fragment";
  60670. import "babylonjs/Shaders/depth.vertex";
  60671. /**
  60672. * This represents a depth renderer in Babylon.
  60673. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60674. */
  60675. export class DepthRenderer {
  60676. private _scene;
  60677. private _depthMap;
  60678. private _effect;
  60679. private readonly _storeNonLinearDepth;
  60680. private readonly _clearColor;
  60681. /** Get if the depth renderer is using packed depth or not */
  60682. readonly isPacked: boolean;
  60683. private _cachedDefines;
  60684. private _camera;
  60685. /**
  60686. * Specifiess that the depth renderer will only be used within
  60687. * the camera it is created for.
  60688. * This can help forcing its rendering during the camera processing.
  60689. */
  60690. useOnlyInActiveCamera: boolean;
  60691. /** @hidden */
  60692. static _SceneComponentInitialization: (scene: Scene) => void;
  60693. /**
  60694. * Instantiates a depth renderer
  60695. * @param scene The scene the renderer belongs to
  60696. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60697. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60698. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60699. */
  60700. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60701. /**
  60702. * Creates the depth rendering effect and checks if the effect is ready.
  60703. * @param subMesh The submesh to be used to render the depth map of
  60704. * @param useInstances If multiple world instances should be used
  60705. * @returns if the depth renderer is ready to render the depth map
  60706. */
  60707. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60708. /**
  60709. * Gets the texture which the depth map will be written to.
  60710. * @returns The depth map texture
  60711. */
  60712. getDepthMap(): RenderTargetTexture;
  60713. /**
  60714. * Disposes of the depth renderer.
  60715. */
  60716. dispose(): void;
  60717. }
  60718. }
  60719. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  60720. import { Nullable } from "babylonjs/types";
  60721. import { Scene } from "babylonjs/scene";
  60722. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60723. import { Camera } from "babylonjs/Cameras/camera";
  60724. import { ISceneComponent } from "babylonjs/sceneComponent";
  60725. module "babylonjs/scene" {
  60726. interface Scene {
  60727. /** @hidden (Backing field) */
  60728. _depthRenderer: {
  60729. [id: string]: DepthRenderer;
  60730. };
  60731. /**
  60732. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60733. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60734. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60735. * @returns the created depth renderer
  60736. */
  60737. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60738. /**
  60739. * Disables a depth renderer for a given camera
  60740. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60741. */
  60742. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60743. }
  60744. }
  60745. /**
  60746. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60747. * in several rendering techniques.
  60748. */
  60749. export class DepthRendererSceneComponent implements ISceneComponent {
  60750. /**
  60751. * The component name helpfull to identify the component in the list of scene components.
  60752. */
  60753. readonly name: string;
  60754. /**
  60755. * The scene the component belongs to.
  60756. */
  60757. scene: Scene;
  60758. /**
  60759. * Creates a new instance of the component for the given scene
  60760. * @param scene Defines the scene to register the component in
  60761. */
  60762. constructor(scene: Scene);
  60763. /**
  60764. * Registers the component in a given scene
  60765. */
  60766. register(): void;
  60767. /**
  60768. * Rebuilds the elements related to this component in case of
  60769. * context lost for instance.
  60770. */
  60771. rebuild(): void;
  60772. /**
  60773. * Disposes the component and the associated ressources
  60774. */
  60775. dispose(): void;
  60776. private _gatherRenderTargets;
  60777. private _gatherActiveCameraRenderTargets;
  60778. }
  60779. }
  60780. declare module "babylonjs/Shaders/outline.fragment" {
  60781. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60782. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  60783. /** @hidden */
  60784. export var outlinePixelShader: {
  60785. name: string;
  60786. shader: string;
  60787. };
  60788. }
  60789. declare module "babylonjs/Shaders/outline.vertex" {
  60790. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60791. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60792. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60793. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60794. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60795. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60796. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60797. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60798. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  60799. /** @hidden */
  60800. export var outlineVertexShader: {
  60801. name: string;
  60802. shader: string;
  60803. };
  60804. }
  60805. declare module "babylonjs/Rendering/outlineRenderer" {
  60806. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60807. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  60808. import { Scene } from "babylonjs/scene";
  60809. import { ISceneComponent } from "babylonjs/sceneComponent";
  60810. import "babylonjs/Shaders/outline.fragment";
  60811. import "babylonjs/Shaders/outline.vertex";
  60812. module "babylonjs/scene" {
  60813. interface Scene {
  60814. /** @hidden */
  60815. _outlineRenderer: OutlineRenderer;
  60816. /**
  60817. * Gets the outline renderer associated with the scene
  60818. * @returns a OutlineRenderer
  60819. */
  60820. getOutlineRenderer(): OutlineRenderer;
  60821. }
  60822. }
  60823. module "babylonjs/Meshes/abstractMesh" {
  60824. interface AbstractMesh {
  60825. /** @hidden (Backing field) */
  60826. _renderOutline: boolean;
  60827. /**
  60828. * Gets or sets a boolean indicating if the outline must be rendered as well
  60829. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60830. */
  60831. renderOutline: boolean;
  60832. /** @hidden (Backing field) */
  60833. _renderOverlay: boolean;
  60834. /**
  60835. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60836. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60837. */
  60838. renderOverlay: boolean;
  60839. }
  60840. }
  60841. /**
  60842. * This class is responsible to draw bothe outline/overlay of meshes.
  60843. * It should not be used directly but through the available method on mesh.
  60844. */
  60845. export class OutlineRenderer implements ISceneComponent {
  60846. /**
  60847. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60848. */
  60849. private static _StencilReference;
  60850. /**
  60851. * The name of the component. Each component must have a unique name.
  60852. */
  60853. name: string;
  60854. /**
  60855. * The scene the component belongs to.
  60856. */
  60857. scene: Scene;
  60858. /**
  60859. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60860. */
  60861. zOffset: number;
  60862. private _engine;
  60863. private _effect;
  60864. private _cachedDefines;
  60865. private _savedDepthWrite;
  60866. /**
  60867. * Instantiates a new outline renderer. (There could be only one per scene).
  60868. * @param scene Defines the scene it belongs to
  60869. */
  60870. constructor(scene: Scene);
  60871. /**
  60872. * Register the component to one instance of a scene.
  60873. */
  60874. register(): void;
  60875. /**
  60876. * Rebuilds the elements related to this component in case of
  60877. * context lost for instance.
  60878. */
  60879. rebuild(): void;
  60880. /**
  60881. * Disposes the component and the associated ressources.
  60882. */
  60883. dispose(): void;
  60884. /**
  60885. * Renders the outline in the canvas.
  60886. * @param subMesh Defines the sumesh to render
  60887. * @param batch Defines the batch of meshes in case of instances
  60888. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60889. */
  60890. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60891. /**
  60892. * Returns whether or not the outline renderer is ready for a given submesh.
  60893. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60894. * @param subMesh Defines the submesh to check readyness for
  60895. * @param useInstances Defines wheter wee are trying to render instances or not
  60896. * @returns true if ready otherwise false
  60897. */
  60898. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60899. private _beforeRenderingMesh;
  60900. private _afterRenderingMesh;
  60901. }
  60902. }
  60903. declare module "babylonjs/Rendering/index" {
  60904. export * from "babylonjs/Rendering/boundingBoxRenderer";
  60905. export * from "babylonjs/Rendering/depthRenderer";
  60906. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  60907. export * from "babylonjs/Rendering/edgesRenderer";
  60908. export * from "babylonjs/Rendering/geometryBufferRenderer";
  60909. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60910. export * from "babylonjs/Rendering/outlineRenderer";
  60911. export * from "babylonjs/Rendering/renderingGroup";
  60912. export * from "babylonjs/Rendering/renderingManager";
  60913. export * from "babylonjs/Rendering/utilityLayerRenderer";
  60914. }
  60915. declare module "babylonjs/Sprites/index" {
  60916. export * from "babylonjs/Sprites/sprite";
  60917. export * from "babylonjs/Sprites/spriteManager";
  60918. export * from "babylonjs/Sprites/spriteSceneComponent";
  60919. }
  60920. declare module "babylonjs/Misc/assetsManager" {
  60921. import { Scene } from "babylonjs/scene";
  60922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60923. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60924. import { Skeleton } from "babylonjs/Bones/skeleton";
  60925. import { Observable } from "babylonjs/Misc/observable";
  60926. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60927. import { Texture } from "babylonjs/Materials/Textures/texture";
  60928. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  60929. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  60930. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60931. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  60932. /**
  60933. * Defines the list of states available for a task inside a AssetsManager
  60934. */
  60935. export enum AssetTaskState {
  60936. /**
  60937. * Initialization
  60938. */
  60939. INIT = 0,
  60940. /**
  60941. * Running
  60942. */
  60943. RUNNING = 1,
  60944. /**
  60945. * Done
  60946. */
  60947. DONE = 2,
  60948. /**
  60949. * Error
  60950. */
  60951. ERROR = 3
  60952. }
  60953. /**
  60954. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60955. */
  60956. export abstract class AbstractAssetTask {
  60957. /**
  60958. * Task name
  60959. */ name: string;
  60960. /**
  60961. * Callback called when the task is successful
  60962. */
  60963. onSuccess: (task: any) => void;
  60964. /**
  60965. * Callback called when the task is not successful
  60966. */
  60967. onError: (task: any, message?: string, exception?: any) => void;
  60968. /**
  60969. * Creates a new AssetsManager
  60970. * @param name defines the name of the task
  60971. */
  60972. constructor(
  60973. /**
  60974. * Task name
  60975. */ name: string);
  60976. private _isCompleted;
  60977. private _taskState;
  60978. private _errorObject;
  60979. /**
  60980. * Get if the task is completed
  60981. */
  60982. readonly isCompleted: boolean;
  60983. /**
  60984. * Gets the current state of the task
  60985. */
  60986. readonly taskState: AssetTaskState;
  60987. /**
  60988. * Gets the current error object (if task is in error)
  60989. */
  60990. readonly errorObject: {
  60991. message?: string;
  60992. exception?: any;
  60993. };
  60994. /**
  60995. * Internal only
  60996. * @hidden
  60997. */
  60998. _setErrorObject(message?: string, exception?: any): void;
  60999. /**
  61000. * Execute the current task
  61001. * @param scene defines the scene where you want your assets to be loaded
  61002. * @param onSuccess is a callback called when the task is successfully executed
  61003. * @param onError is a callback called if an error occurs
  61004. */
  61005. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61006. /**
  61007. * Execute the current task
  61008. * @param scene defines the scene where you want your assets to be loaded
  61009. * @param onSuccess is a callback called when the task is successfully executed
  61010. * @param onError is a callback called if an error occurs
  61011. */
  61012. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61013. /**
  61014. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  61015. * This can be used with failed tasks that have the reason for failure fixed.
  61016. */
  61017. reset(): void;
  61018. private onErrorCallback;
  61019. private onDoneCallback;
  61020. }
  61021. /**
  61022. * Define the interface used by progress events raised during assets loading
  61023. */
  61024. export interface IAssetsProgressEvent {
  61025. /**
  61026. * Defines the number of remaining tasks to process
  61027. */
  61028. remainingCount: number;
  61029. /**
  61030. * Defines the total number of tasks
  61031. */
  61032. totalCount: number;
  61033. /**
  61034. * Defines the task that was just processed
  61035. */
  61036. task: AbstractAssetTask;
  61037. }
  61038. /**
  61039. * Class used to share progress information about assets loading
  61040. */
  61041. export class AssetsProgressEvent implements IAssetsProgressEvent {
  61042. /**
  61043. * Defines the number of remaining tasks to process
  61044. */
  61045. remainingCount: number;
  61046. /**
  61047. * Defines the total number of tasks
  61048. */
  61049. totalCount: number;
  61050. /**
  61051. * Defines the task that was just processed
  61052. */
  61053. task: AbstractAssetTask;
  61054. /**
  61055. * Creates a AssetsProgressEvent
  61056. * @param remainingCount defines the number of remaining tasks to process
  61057. * @param totalCount defines the total number of tasks
  61058. * @param task defines the task that was just processed
  61059. */
  61060. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  61061. }
  61062. /**
  61063. * Define a task used by AssetsManager to load meshes
  61064. */
  61065. export class MeshAssetTask extends AbstractAssetTask {
  61066. /**
  61067. * Defines the name of the task
  61068. */
  61069. name: string;
  61070. /**
  61071. * Defines the list of mesh's names you want to load
  61072. */
  61073. meshesNames: any;
  61074. /**
  61075. * Defines the root url to use as a base to load your meshes and associated resources
  61076. */
  61077. rootUrl: string;
  61078. /**
  61079. * Defines the filename of the scene to load from
  61080. */
  61081. sceneFilename: string;
  61082. /**
  61083. * Gets the list of loaded meshes
  61084. */
  61085. loadedMeshes: Array<AbstractMesh>;
  61086. /**
  61087. * Gets the list of loaded particle systems
  61088. */
  61089. loadedParticleSystems: Array<IParticleSystem>;
  61090. /**
  61091. * Gets the list of loaded skeletons
  61092. */
  61093. loadedSkeletons: Array<Skeleton>;
  61094. /**
  61095. * Gets the list of loaded animation groups
  61096. */
  61097. loadedAnimationGroups: Array<AnimationGroup>;
  61098. /**
  61099. * Callback called when the task is successful
  61100. */
  61101. onSuccess: (task: MeshAssetTask) => void;
  61102. /**
  61103. * Callback called when the task is successful
  61104. */
  61105. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61106. /**
  61107. * Creates a new MeshAssetTask
  61108. * @param name defines the name of the task
  61109. * @param meshesNames defines the list of mesh's names you want to load
  61110. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61111. * @param sceneFilename defines the filename of the scene to load from
  61112. */
  61113. constructor(
  61114. /**
  61115. * Defines the name of the task
  61116. */
  61117. name: string,
  61118. /**
  61119. * Defines the list of mesh's names you want to load
  61120. */
  61121. meshesNames: any,
  61122. /**
  61123. * Defines the root url to use as a base to load your meshes and associated resources
  61124. */
  61125. rootUrl: string,
  61126. /**
  61127. * Defines the filename of the scene to load from
  61128. */
  61129. sceneFilename: string);
  61130. /**
  61131. * Execute the current task
  61132. * @param scene defines the scene where you want your assets to be loaded
  61133. * @param onSuccess is a callback called when the task is successfully executed
  61134. * @param onError is a callback called if an error occurs
  61135. */
  61136. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61137. }
  61138. /**
  61139. * Define a task used by AssetsManager to load text content
  61140. */
  61141. export class TextFileAssetTask extends AbstractAssetTask {
  61142. /**
  61143. * Defines the name of the task
  61144. */
  61145. name: string;
  61146. /**
  61147. * Defines the location of the file to load
  61148. */
  61149. url: string;
  61150. /**
  61151. * Gets the loaded text string
  61152. */
  61153. text: string;
  61154. /**
  61155. * Callback called when the task is successful
  61156. */
  61157. onSuccess: (task: TextFileAssetTask) => void;
  61158. /**
  61159. * Callback called when the task is successful
  61160. */
  61161. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61162. /**
  61163. * Creates a new TextFileAssetTask object
  61164. * @param name defines the name of the task
  61165. * @param url defines the location of the file to load
  61166. */
  61167. constructor(
  61168. /**
  61169. * Defines the name of the task
  61170. */
  61171. name: string,
  61172. /**
  61173. * Defines the location of the file to load
  61174. */
  61175. url: string);
  61176. /**
  61177. * Execute the current task
  61178. * @param scene defines the scene where you want your assets to be loaded
  61179. * @param onSuccess is a callback called when the task is successfully executed
  61180. * @param onError is a callback called if an error occurs
  61181. */
  61182. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61183. }
  61184. /**
  61185. * Define a task used by AssetsManager to load binary data
  61186. */
  61187. export class BinaryFileAssetTask extends AbstractAssetTask {
  61188. /**
  61189. * Defines the name of the task
  61190. */
  61191. name: string;
  61192. /**
  61193. * Defines the location of the file to load
  61194. */
  61195. url: string;
  61196. /**
  61197. * Gets the lodaded data (as an array buffer)
  61198. */
  61199. data: ArrayBuffer;
  61200. /**
  61201. * Callback called when the task is successful
  61202. */
  61203. onSuccess: (task: BinaryFileAssetTask) => void;
  61204. /**
  61205. * Callback called when the task is successful
  61206. */
  61207. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61208. /**
  61209. * Creates a new BinaryFileAssetTask object
  61210. * @param name defines the name of the new task
  61211. * @param url defines the location of the file to load
  61212. */
  61213. constructor(
  61214. /**
  61215. * Defines the name of the task
  61216. */
  61217. name: string,
  61218. /**
  61219. * Defines the location of the file to load
  61220. */
  61221. url: string);
  61222. /**
  61223. * Execute the current task
  61224. * @param scene defines the scene where you want your assets to be loaded
  61225. * @param onSuccess is a callback called when the task is successfully executed
  61226. * @param onError is a callback called if an error occurs
  61227. */
  61228. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61229. }
  61230. /**
  61231. * Define a task used by AssetsManager to load images
  61232. */
  61233. export class ImageAssetTask extends AbstractAssetTask {
  61234. /**
  61235. * Defines the name of the task
  61236. */
  61237. name: string;
  61238. /**
  61239. * Defines the location of the image to load
  61240. */
  61241. url: string;
  61242. /**
  61243. * Gets the loaded images
  61244. */
  61245. image: HTMLImageElement;
  61246. /**
  61247. * Callback called when the task is successful
  61248. */
  61249. onSuccess: (task: ImageAssetTask) => void;
  61250. /**
  61251. * Callback called when the task is successful
  61252. */
  61253. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61254. /**
  61255. * Creates a new ImageAssetTask
  61256. * @param name defines the name of the task
  61257. * @param url defines the location of the image to load
  61258. */
  61259. constructor(
  61260. /**
  61261. * Defines the name of the task
  61262. */
  61263. name: string,
  61264. /**
  61265. * Defines the location of the image to load
  61266. */
  61267. url: string);
  61268. /**
  61269. * Execute the current task
  61270. * @param scene defines the scene where you want your assets to be loaded
  61271. * @param onSuccess is a callback called when the task is successfully executed
  61272. * @param onError is a callback called if an error occurs
  61273. */
  61274. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61275. }
  61276. /**
  61277. * Defines the interface used by texture loading tasks
  61278. */
  61279. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61280. /**
  61281. * Gets the loaded texture
  61282. */
  61283. texture: TEX;
  61284. }
  61285. /**
  61286. * Define a task used by AssetsManager to load 2D textures
  61287. */
  61288. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61289. /**
  61290. * Defines the name of the task
  61291. */
  61292. name: string;
  61293. /**
  61294. * Defines the location of the file to load
  61295. */
  61296. url: string;
  61297. /**
  61298. * Defines if mipmap should not be generated (default is false)
  61299. */
  61300. noMipmap?: boolean | undefined;
  61301. /**
  61302. * Defines if texture must be inverted on Y axis (default is false)
  61303. */
  61304. invertY?: boolean | undefined;
  61305. /**
  61306. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61307. */
  61308. samplingMode: number;
  61309. /**
  61310. * Gets the loaded texture
  61311. */
  61312. texture: Texture;
  61313. /**
  61314. * Callback called when the task is successful
  61315. */
  61316. onSuccess: (task: TextureAssetTask) => void;
  61317. /**
  61318. * Callback called when the task is successful
  61319. */
  61320. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61321. /**
  61322. * Creates a new TextureAssetTask object
  61323. * @param name defines the name of the task
  61324. * @param url defines the location of the file to load
  61325. * @param noMipmap defines if mipmap should not be generated (default is false)
  61326. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61327. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61328. */
  61329. constructor(
  61330. /**
  61331. * Defines the name of the task
  61332. */
  61333. name: string,
  61334. /**
  61335. * Defines the location of the file to load
  61336. */
  61337. url: string,
  61338. /**
  61339. * Defines if mipmap should not be generated (default is false)
  61340. */
  61341. noMipmap?: boolean | undefined,
  61342. /**
  61343. * Defines if texture must be inverted on Y axis (default is false)
  61344. */
  61345. invertY?: boolean | undefined,
  61346. /**
  61347. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61348. */
  61349. samplingMode?: number);
  61350. /**
  61351. * Execute the current task
  61352. * @param scene defines the scene where you want your assets to be loaded
  61353. * @param onSuccess is a callback called when the task is successfully executed
  61354. * @param onError is a callback called if an error occurs
  61355. */
  61356. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61357. }
  61358. /**
  61359. * Define a task used by AssetsManager to load cube textures
  61360. */
  61361. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61362. /**
  61363. * Defines the name of the task
  61364. */
  61365. name: string;
  61366. /**
  61367. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61368. */
  61369. url: string;
  61370. /**
  61371. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61372. */
  61373. extensions?: string[] | undefined;
  61374. /**
  61375. * Defines if mipmaps should not be generated (default is false)
  61376. */
  61377. noMipmap?: boolean | undefined;
  61378. /**
  61379. * Defines the explicit list of files (undefined by default)
  61380. */
  61381. files?: string[] | undefined;
  61382. /**
  61383. * Gets the loaded texture
  61384. */
  61385. texture: CubeTexture;
  61386. /**
  61387. * Callback called when the task is successful
  61388. */
  61389. onSuccess: (task: CubeTextureAssetTask) => void;
  61390. /**
  61391. * Callback called when the task is successful
  61392. */
  61393. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61394. /**
  61395. * Creates a new CubeTextureAssetTask
  61396. * @param name defines the name of the task
  61397. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61398. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61399. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61400. * @param files defines the explicit list of files (undefined by default)
  61401. */
  61402. constructor(
  61403. /**
  61404. * Defines the name of the task
  61405. */
  61406. name: string,
  61407. /**
  61408. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61409. */
  61410. url: string,
  61411. /**
  61412. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61413. */
  61414. extensions?: string[] | undefined,
  61415. /**
  61416. * Defines if mipmaps should not be generated (default is false)
  61417. */
  61418. noMipmap?: boolean | undefined,
  61419. /**
  61420. * Defines the explicit list of files (undefined by default)
  61421. */
  61422. files?: string[] | undefined);
  61423. /**
  61424. * Execute the current task
  61425. * @param scene defines the scene where you want your assets to be loaded
  61426. * @param onSuccess is a callback called when the task is successfully executed
  61427. * @param onError is a callback called if an error occurs
  61428. */
  61429. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61430. }
  61431. /**
  61432. * Define a task used by AssetsManager to load HDR cube textures
  61433. */
  61434. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61435. /**
  61436. * Defines the name of the task
  61437. */
  61438. name: string;
  61439. /**
  61440. * Defines the location of the file to load
  61441. */
  61442. url: string;
  61443. /**
  61444. * Defines the desired size (the more it increases the longer the generation will be)
  61445. */
  61446. size: number;
  61447. /**
  61448. * Defines if mipmaps should not be generated (default is false)
  61449. */
  61450. noMipmap: boolean;
  61451. /**
  61452. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61453. */
  61454. generateHarmonics: boolean;
  61455. /**
  61456. * 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)
  61457. */
  61458. gammaSpace: boolean;
  61459. /**
  61460. * Internal Use Only
  61461. */
  61462. reserved: boolean;
  61463. /**
  61464. * Gets the loaded texture
  61465. */
  61466. texture: HDRCubeTexture;
  61467. /**
  61468. * Callback called when the task is successful
  61469. */
  61470. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61471. /**
  61472. * Callback called when the task is successful
  61473. */
  61474. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61475. /**
  61476. * Creates a new HDRCubeTextureAssetTask object
  61477. * @param name defines the name of the task
  61478. * @param url defines the location of the file to load
  61479. * @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.
  61480. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61481. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61482. * @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)
  61483. * @param reserved Internal use only
  61484. */
  61485. constructor(
  61486. /**
  61487. * Defines the name of the task
  61488. */
  61489. name: string,
  61490. /**
  61491. * Defines the location of the file to load
  61492. */
  61493. url: string,
  61494. /**
  61495. * Defines the desired size (the more it increases the longer the generation will be)
  61496. */
  61497. size: number,
  61498. /**
  61499. * Defines if mipmaps should not be generated (default is false)
  61500. */
  61501. noMipmap?: boolean,
  61502. /**
  61503. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61504. */
  61505. generateHarmonics?: boolean,
  61506. /**
  61507. * 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)
  61508. */
  61509. gammaSpace?: boolean,
  61510. /**
  61511. * Internal Use Only
  61512. */
  61513. reserved?: boolean);
  61514. /**
  61515. * Execute the current task
  61516. * @param scene defines the scene where you want your assets to be loaded
  61517. * @param onSuccess is a callback called when the task is successfully executed
  61518. * @param onError is a callback called if an error occurs
  61519. */
  61520. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61521. }
  61522. /**
  61523. * Define a task used by AssetsManager to load Equirectangular cube textures
  61524. */
  61525. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61526. /**
  61527. * Defines the name of the task
  61528. */
  61529. name: string;
  61530. /**
  61531. * Defines the location of the file to load
  61532. */
  61533. url: string;
  61534. /**
  61535. * Defines the desired size (the more it increases the longer the generation will be)
  61536. */
  61537. size: number;
  61538. /**
  61539. * Defines if mipmaps should not be generated (default is false)
  61540. */
  61541. noMipmap: boolean;
  61542. /**
  61543. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61544. * but the standard material would require them in Gamma space) (default is true)
  61545. */
  61546. gammaSpace: boolean;
  61547. /**
  61548. * Gets the loaded texture
  61549. */
  61550. texture: EquiRectangularCubeTexture;
  61551. /**
  61552. * Callback called when the task is successful
  61553. */
  61554. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61555. /**
  61556. * Callback called when the task is successful
  61557. */
  61558. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61559. /**
  61560. * Creates a new EquiRectangularCubeTextureAssetTask object
  61561. * @param name defines the name of the task
  61562. * @param url defines the location of the file to load
  61563. * @param size defines the desired size (the more it increases the longer the generation will be)
  61564. * If the size is omitted this implies you are using a preprocessed cubemap.
  61565. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61566. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61567. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61568. * (default is true)
  61569. */
  61570. constructor(
  61571. /**
  61572. * Defines the name of the task
  61573. */
  61574. name: string,
  61575. /**
  61576. * Defines the location of the file to load
  61577. */
  61578. url: string,
  61579. /**
  61580. * Defines the desired size (the more it increases the longer the generation will be)
  61581. */
  61582. size: number,
  61583. /**
  61584. * Defines if mipmaps should not be generated (default is false)
  61585. */
  61586. noMipmap?: boolean,
  61587. /**
  61588. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61589. * but the standard material would require them in Gamma space) (default is true)
  61590. */
  61591. gammaSpace?: boolean);
  61592. /**
  61593. * Execute the current task
  61594. * @param scene defines the scene where you want your assets to be loaded
  61595. * @param onSuccess is a callback called when the task is successfully executed
  61596. * @param onError is a callback called if an error occurs
  61597. */
  61598. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61599. }
  61600. /**
  61601. * This class can be used to easily import assets into a scene
  61602. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61603. */
  61604. export class AssetsManager {
  61605. private _scene;
  61606. private _isLoading;
  61607. protected _tasks: AbstractAssetTask[];
  61608. protected _waitingTasksCount: number;
  61609. protected _totalTasksCount: number;
  61610. /**
  61611. * Callback called when all tasks are processed
  61612. */
  61613. onFinish: (tasks: AbstractAssetTask[]) => void;
  61614. /**
  61615. * Callback called when a task is successful
  61616. */
  61617. onTaskSuccess: (task: AbstractAssetTask) => void;
  61618. /**
  61619. * Callback called when a task had an error
  61620. */
  61621. onTaskError: (task: AbstractAssetTask) => void;
  61622. /**
  61623. * Callback called when a task is done (whatever the result is)
  61624. */
  61625. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61626. /**
  61627. * Observable called when all tasks are processed
  61628. */
  61629. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61630. /**
  61631. * Observable called when a task had an error
  61632. */
  61633. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61634. /**
  61635. * Observable called when all tasks were executed
  61636. */
  61637. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61638. /**
  61639. * Observable called when a task is done (whatever the result is)
  61640. */
  61641. onProgressObservable: Observable<IAssetsProgressEvent>;
  61642. /**
  61643. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61644. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61645. */
  61646. useDefaultLoadingScreen: boolean;
  61647. /**
  61648. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61649. * when all assets have been downloaded.
  61650. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61651. */
  61652. autoHideLoadingUI: boolean;
  61653. /**
  61654. * Creates a new AssetsManager
  61655. * @param scene defines the scene to work on
  61656. */
  61657. constructor(scene: Scene);
  61658. /**
  61659. * Add a MeshAssetTask to the list of active tasks
  61660. * @param taskName defines the name of the new task
  61661. * @param meshesNames defines the name of meshes to load
  61662. * @param rootUrl defines the root url to use to locate files
  61663. * @param sceneFilename defines the filename of the scene file
  61664. * @returns a new MeshAssetTask object
  61665. */
  61666. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61667. /**
  61668. * Add a TextFileAssetTask to the list of active tasks
  61669. * @param taskName defines the name of the new task
  61670. * @param url defines the url of the file to load
  61671. * @returns a new TextFileAssetTask object
  61672. */
  61673. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61674. /**
  61675. * Add a BinaryFileAssetTask to the list of active tasks
  61676. * @param taskName defines the name of the new task
  61677. * @param url defines the url of the file to load
  61678. * @returns a new BinaryFileAssetTask object
  61679. */
  61680. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61681. /**
  61682. * Add a ImageAssetTask to the list of active tasks
  61683. * @param taskName defines the name of the new task
  61684. * @param url defines the url of the file to load
  61685. * @returns a new ImageAssetTask object
  61686. */
  61687. addImageTask(taskName: string, url: string): ImageAssetTask;
  61688. /**
  61689. * Add a TextureAssetTask to the list of active tasks
  61690. * @param taskName defines the name of the new task
  61691. * @param url defines the url of the file to load
  61692. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61693. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61694. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61695. * @returns a new TextureAssetTask object
  61696. */
  61697. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61698. /**
  61699. * Add a CubeTextureAssetTask to the list of active tasks
  61700. * @param taskName defines the name of the new task
  61701. * @param url defines the url of the file to load
  61702. * @param extensions defines the extension to use to load the cube map (can be null)
  61703. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61704. * @param files defines the list of files to load (can be null)
  61705. * @returns a new CubeTextureAssetTask object
  61706. */
  61707. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61708. /**
  61709. *
  61710. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61711. * @param taskName defines the name of the new task
  61712. * @param url defines the url of the file to load
  61713. * @param size defines the size you want for the cubemap (can be null)
  61714. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61715. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61716. * @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)
  61717. * @param reserved Internal use only
  61718. * @returns a new HDRCubeTextureAssetTask object
  61719. */
  61720. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61721. /**
  61722. *
  61723. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61724. * @param taskName defines the name of the new task
  61725. * @param url defines the url of the file to load
  61726. * @param size defines the size you want for the cubemap (can be null)
  61727. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61728. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61729. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61730. * @returns a new EquiRectangularCubeTextureAssetTask object
  61731. */
  61732. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61733. /**
  61734. * Remove a task from the assets manager.
  61735. * @param task the task to remove
  61736. */
  61737. removeTask(task: AbstractAssetTask): void;
  61738. private _decreaseWaitingTasksCount;
  61739. private _runTask;
  61740. /**
  61741. * Reset the AssetsManager and remove all tasks
  61742. * @return the current instance of the AssetsManager
  61743. */
  61744. reset(): AssetsManager;
  61745. /**
  61746. * Start the loading process
  61747. * @return the current instance of the AssetsManager
  61748. */
  61749. load(): AssetsManager;
  61750. /**
  61751. * Start the loading process as an async operation
  61752. * @return a promise returning the list of failed tasks
  61753. */
  61754. loadAsync(): Promise<void>;
  61755. }
  61756. }
  61757. declare module "babylonjs/Misc/deferred" {
  61758. /**
  61759. * Wrapper class for promise with external resolve and reject.
  61760. */
  61761. export class Deferred<T> {
  61762. /**
  61763. * The promise associated with this deferred object.
  61764. */
  61765. readonly promise: Promise<T>;
  61766. private _resolve;
  61767. private _reject;
  61768. /**
  61769. * The resolve method of the promise associated with this deferred object.
  61770. */
  61771. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61772. /**
  61773. * The reject method of the promise associated with this deferred object.
  61774. */
  61775. readonly reject: (reason?: any) => void;
  61776. /**
  61777. * Constructor for this deferred object.
  61778. */
  61779. constructor();
  61780. }
  61781. }
  61782. declare module "babylonjs/Misc/meshExploder" {
  61783. import { Mesh } from "babylonjs/Meshes/mesh";
  61784. /**
  61785. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61786. */
  61787. export class MeshExploder {
  61788. private _centerMesh;
  61789. private _meshes;
  61790. private _meshesOrigins;
  61791. private _toCenterVectors;
  61792. private _scaledDirection;
  61793. private _newPosition;
  61794. private _centerPosition;
  61795. /**
  61796. * Explodes meshes from a center mesh.
  61797. * @param meshes The meshes to explode.
  61798. * @param centerMesh The mesh to be center of explosion.
  61799. */
  61800. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61801. private _setCenterMesh;
  61802. /**
  61803. * Get class name
  61804. * @returns "MeshExploder"
  61805. */
  61806. getClassName(): string;
  61807. /**
  61808. * "Exploded meshes"
  61809. * @returns Array of meshes with the centerMesh at index 0.
  61810. */
  61811. getMeshes(): Array<Mesh>;
  61812. /**
  61813. * Explodes meshes giving a specific direction
  61814. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61815. */
  61816. explode(direction?: number): void;
  61817. }
  61818. }
  61819. declare module "babylonjs/Misc/filesInput" {
  61820. import { Engine } from "babylonjs/Engines/engine";
  61821. import { Scene } from "babylonjs/scene";
  61822. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61823. /**
  61824. * Class used to help managing file picking and drag'n'drop
  61825. */
  61826. export class FilesInput {
  61827. /**
  61828. * List of files ready to be loaded
  61829. */
  61830. static readonly FilesToLoad: {
  61831. [key: string]: File;
  61832. };
  61833. /**
  61834. * Callback called when a file is processed
  61835. */
  61836. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61837. private _engine;
  61838. private _currentScene;
  61839. private _sceneLoadedCallback;
  61840. private _progressCallback;
  61841. private _additionalRenderLoopLogicCallback;
  61842. private _textureLoadingCallback;
  61843. private _startingProcessingFilesCallback;
  61844. private _onReloadCallback;
  61845. private _errorCallback;
  61846. private _elementToMonitor;
  61847. private _sceneFileToLoad;
  61848. private _filesToLoad;
  61849. /**
  61850. * Creates a new FilesInput
  61851. * @param engine defines the rendering engine
  61852. * @param scene defines the hosting scene
  61853. * @param sceneLoadedCallback callback called when scene is loaded
  61854. * @param progressCallback callback called to track progress
  61855. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61856. * @param textureLoadingCallback callback called when a texture is loading
  61857. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61858. * @param onReloadCallback callback called when a reload is requested
  61859. * @param errorCallback callback call if an error occurs
  61860. */
  61861. 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);
  61862. private _dragEnterHandler;
  61863. private _dragOverHandler;
  61864. private _dropHandler;
  61865. /**
  61866. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61867. * @param elementToMonitor defines the DOM element to track
  61868. */
  61869. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61870. /**
  61871. * Release all associated resources
  61872. */
  61873. dispose(): void;
  61874. private renderFunction;
  61875. private drag;
  61876. private drop;
  61877. private _traverseFolder;
  61878. private _processFiles;
  61879. /**
  61880. * Load files from a drop event
  61881. * @param event defines the drop event to use as source
  61882. */
  61883. loadFiles(event: any): void;
  61884. private _processReload;
  61885. /**
  61886. * Reload the current scene from the loaded files
  61887. */
  61888. reload(): void;
  61889. }
  61890. }
  61891. declare module "babylonjs/Misc/HighDynamicRange/index" {
  61892. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  61893. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  61894. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61895. }
  61896. declare module "babylonjs/Misc/sceneOptimizer" {
  61897. import { Scene, IDisposable } from "babylonjs/scene";
  61898. import { Observable } from "babylonjs/Misc/observable";
  61899. /**
  61900. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61901. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61902. */
  61903. export class SceneOptimization {
  61904. /**
  61905. * Defines the priority of this optimization (0 by default which means first in the list)
  61906. */
  61907. priority: number;
  61908. /**
  61909. * Gets a string describing the action executed by the current optimization
  61910. * @returns description string
  61911. */
  61912. getDescription(): string;
  61913. /**
  61914. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61915. * @param scene defines the current scene where to apply this optimization
  61916. * @param optimizer defines the current optimizer
  61917. * @returns true if everything that can be done was applied
  61918. */
  61919. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61920. /**
  61921. * Creates the SceneOptimization object
  61922. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61923. * @param desc defines the description associated with the optimization
  61924. */
  61925. constructor(
  61926. /**
  61927. * Defines the priority of this optimization (0 by default which means first in the list)
  61928. */
  61929. priority?: number);
  61930. }
  61931. /**
  61932. * Defines an optimization used to reduce the size of render target textures
  61933. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61934. */
  61935. export class TextureOptimization extends SceneOptimization {
  61936. /**
  61937. * Defines the priority of this optimization (0 by default which means first in the list)
  61938. */
  61939. priority: number;
  61940. /**
  61941. * 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
  61942. */
  61943. maximumSize: number;
  61944. /**
  61945. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61946. */
  61947. step: number;
  61948. /**
  61949. * Gets a string describing the action executed by the current optimization
  61950. * @returns description string
  61951. */
  61952. getDescription(): string;
  61953. /**
  61954. * Creates the TextureOptimization object
  61955. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61956. * @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
  61957. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61958. */
  61959. constructor(
  61960. /**
  61961. * Defines the priority of this optimization (0 by default which means first in the list)
  61962. */
  61963. priority?: number,
  61964. /**
  61965. * 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
  61966. */
  61967. maximumSize?: number,
  61968. /**
  61969. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61970. */
  61971. step?: number);
  61972. /**
  61973. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61974. * @param scene defines the current scene where to apply this optimization
  61975. * @param optimizer defines the current optimizer
  61976. * @returns true if everything that can be done was applied
  61977. */
  61978. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61979. }
  61980. /**
  61981. * Defines an optimization used to increase or decrease the rendering resolution
  61982. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61983. */
  61984. export class HardwareScalingOptimization extends SceneOptimization {
  61985. /**
  61986. * Defines the priority of this optimization (0 by default which means first in the list)
  61987. */
  61988. priority: number;
  61989. /**
  61990. * Defines the maximum scale to use (2 by default)
  61991. */
  61992. maximumScale: number;
  61993. /**
  61994. * Defines the step to use between two passes (0.5 by default)
  61995. */
  61996. step: number;
  61997. private _currentScale;
  61998. private _directionOffset;
  61999. /**
  62000. * Gets a string describing the action executed by the current optimization
  62001. * @return description string
  62002. */
  62003. getDescription(): string;
  62004. /**
  62005. * Creates the HardwareScalingOptimization object
  62006. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62007. * @param maximumScale defines the maximum scale to use (2 by default)
  62008. * @param step defines the step to use between two passes (0.5 by default)
  62009. */
  62010. constructor(
  62011. /**
  62012. * Defines the priority of this optimization (0 by default which means first in the list)
  62013. */
  62014. priority?: number,
  62015. /**
  62016. * Defines the maximum scale to use (2 by default)
  62017. */
  62018. maximumScale?: number,
  62019. /**
  62020. * Defines the step to use between two passes (0.5 by default)
  62021. */
  62022. step?: number);
  62023. /**
  62024. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62025. * @param scene defines the current scene where to apply this optimization
  62026. * @param optimizer defines the current optimizer
  62027. * @returns true if everything that can be done was applied
  62028. */
  62029. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62030. }
  62031. /**
  62032. * Defines an optimization used to remove shadows
  62033. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62034. */
  62035. export class ShadowsOptimization extends SceneOptimization {
  62036. /**
  62037. * Gets a string describing the action executed by the current optimization
  62038. * @return description string
  62039. */
  62040. getDescription(): string;
  62041. /**
  62042. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62043. * @param scene defines the current scene where to apply this optimization
  62044. * @param optimizer defines the current optimizer
  62045. * @returns true if everything that can be done was applied
  62046. */
  62047. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62048. }
  62049. /**
  62050. * Defines an optimization used to turn post-processes off
  62051. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62052. */
  62053. export class PostProcessesOptimization extends SceneOptimization {
  62054. /**
  62055. * Gets a string describing the action executed by the current optimization
  62056. * @return description string
  62057. */
  62058. getDescription(): string;
  62059. /**
  62060. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62061. * @param scene defines the current scene where to apply this optimization
  62062. * @param optimizer defines the current optimizer
  62063. * @returns true if everything that can be done was applied
  62064. */
  62065. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62066. }
  62067. /**
  62068. * Defines an optimization used to turn lens flares off
  62069. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62070. */
  62071. export class LensFlaresOptimization extends SceneOptimization {
  62072. /**
  62073. * Gets a string describing the action executed by the current optimization
  62074. * @return description string
  62075. */
  62076. getDescription(): string;
  62077. /**
  62078. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62079. * @param scene defines the current scene where to apply this optimization
  62080. * @param optimizer defines the current optimizer
  62081. * @returns true if everything that can be done was applied
  62082. */
  62083. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62084. }
  62085. /**
  62086. * Defines an optimization based on user defined callback.
  62087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62088. */
  62089. export class CustomOptimization extends SceneOptimization {
  62090. /**
  62091. * Callback called to apply the custom optimization.
  62092. */
  62093. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  62094. /**
  62095. * Callback called to get custom description
  62096. */
  62097. onGetDescription: () => string;
  62098. /**
  62099. * Gets a string describing the action executed by the current optimization
  62100. * @returns description string
  62101. */
  62102. getDescription(): string;
  62103. /**
  62104. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62105. * @param scene defines the current scene where to apply this optimization
  62106. * @param optimizer defines the current optimizer
  62107. * @returns true if everything that can be done was applied
  62108. */
  62109. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62110. }
  62111. /**
  62112. * Defines an optimization used to turn particles off
  62113. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62114. */
  62115. export class ParticlesOptimization extends SceneOptimization {
  62116. /**
  62117. * Gets a string describing the action executed by the current optimization
  62118. * @return description string
  62119. */
  62120. getDescription(): string;
  62121. /**
  62122. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62123. * @param scene defines the current scene where to apply this optimization
  62124. * @param optimizer defines the current optimizer
  62125. * @returns true if everything that can be done was applied
  62126. */
  62127. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62128. }
  62129. /**
  62130. * Defines an optimization used to turn render targets off
  62131. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62132. */
  62133. export class RenderTargetsOptimization extends SceneOptimization {
  62134. /**
  62135. * Gets a string describing the action executed by the current optimization
  62136. * @return description string
  62137. */
  62138. getDescription(): string;
  62139. /**
  62140. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62141. * @param scene defines the current scene where to apply this optimization
  62142. * @param optimizer defines the current optimizer
  62143. * @returns true if everything that can be done was applied
  62144. */
  62145. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62146. }
  62147. /**
  62148. * Defines an optimization used to merge meshes with compatible materials
  62149. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62150. */
  62151. export class MergeMeshesOptimization extends SceneOptimization {
  62152. private static _UpdateSelectionTree;
  62153. /**
  62154. * Gets or sets a boolean which defines if optimization octree has to be updated
  62155. */
  62156. /**
  62157. * Gets or sets a boolean which defines if optimization octree has to be updated
  62158. */
  62159. static UpdateSelectionTree: boolean;
  62160. /**
  62161. * Gets a string describing the action executed by the current optimization
  62162. * @return description string
  62163. */
  62164. getDescription(): string;
  62165. private _canBeMerged;
  62166. /**
  62167. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62168. * @param scene defines the current scene where to apply this optimization
  62169. * @param optimizer defines the current optimizer
  62170. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62171. * @returns true if everything that can be done was applied
  62172. */
  62173. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62174. }
  62175. /**
  62176. * Defines a list of options used by SceneOptimizer
  62177. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62178. */
  62179. export class SceneOptimizerOptions {
  62180. /**
  62181. * Defines the target frame rate to reach (60 by default)
  62182. */
  62183. targetFrameRate: number;
  62184. /**
  62185. * Defines the interval between two checkes (2000ms by default)
  62186. */
  62187. trackerDuration: number;
  62188. /**
  62189. * Gets the list of optimizations to apply
  62190. */
  62191. optimizations: SceneOptimization[];
  62192. /**
  62193. * Creates a new list of options used by SceneOptimizer
  62194. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62195. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62196. */
  62197. constructor(
  62198. /**
  62199. * Defines the target frame rate to reach (60 by default)
  62200. */
  62201. targetFrameRate?: number,
  62202. /**
  62203. * Defines the interval between two checkes (2000ms by default)
  62204. */
  62205. trackerDuration?: number);
  62206. /**
  62207. * Add a new optimization
  62208. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62209. * @returns the current SceneOptimizerOptions
  62210. */
  62211. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62212. /**
  62213. * Add a new custom optimization
  62214. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62215. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62216. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62217. * @returns the current SceneOptimizerOptions
  62218. */
  62219. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62220. /**
  62221. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62222. * @param targetFrameRate defines the target frame rate (60 by default)
  62223. * @returns a SceneOptimizerOptions object
  62224. */
  62225. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62226. /**
  62227. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62228. * @param targetFrameRate defines the target frame rate (60 by default)
  62229. * @returns a SceneOptimizerOptions object
  62230. */
  62231. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62232. /**
  62233. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62234. * @param targetFrameRate defines the target frame rate (60 by default)
  62235. * @returns a SceneOptimizerOptions object
  62236. */
  62237. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62238. }
  62239. /**
  62240. * Class used to run optimizations in order to reach a target frame rate
  62241. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62242. */
  62243. export class SceneOptimizer implements IDisposable {
  62244. private _isRunning;
  62245. private _options;
  62246. private _scene;
  62247. private _currentPriorityLevel;
  62248. private _targetFrameRate;
  62249. private _trackerDuration;
  62250. private _currentFrameRate;
  62251. private _sceneDisposeObserver;
  62252. private _improvementMode;
  62253. /**
  62254. * Defines an observable called when the optimizer reaches the target frame rate
  62255. */
  62256. onSuccessObservable: Observable<SceneOptimizer>;
  62257. /**
  62258. * Defines an observable called when the optimizer enables an optimization
  62259. */
  62260. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62261. /**
  62262. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62263. */
  62264. onFailureObservable: Observable<SceneOptimizer>;
  62265. /**
  62266. * Gets a boolean indicating if the optimizer is in improvement mode
  62267. */
  62268. readonly isInImprovementMode: boolean;
  62269. /**
  62270. * Gets the current priority level (0 at start)
  62271. */
  62272. readonly currentPriorityLevel: number;
  62273. /**
  62274. * Gets the current frame rate checked by the SceneOptimizer
  62275. */
  62276. readonly currentFrameRate: number;
  62277. /**
  62278. * Gets or sets the current target frame rate (60 by default)
  62279. */
  62280. /**
  62281. * Gets or sets the current target frame rate (60 by default)
  62282. */
  62283. targetFrameRate: number;
  62284. /**
  62285. * Gets or sets the current interval between two checks (every 2000ms by default)
  62286. */
  62287. /**
  62288. * Gets or sets the current interval between two checks (every 2000ms by default)
  62289. */
  62290. trackerDuration: number;
  62291. /**
  62292. * Gets the list of active optimizations
  62293. */
  62294. readonly optimizations: SceneOptimization[];
  62295. /**
  62296. * Creates a new SceneOptimizer
  62297. * @param scene defines the scene to work on
  62298. * @param options defines the options to use with the SceneOptimizer
  62299. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62300. * @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)
  62301. */
  62302. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62303. /**
  62304. * Stops the current optimizer
  62305. */
  62306. stop(): void;
  62307. /**
  62308. * Reset the optimizer to initial step (current priority level = 0)
  62309. */
  62310. reset(): void;
  62311. /**
  62312. * Start the optimizer. By default it will try to reach a specific framerate
  62313. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62314. */
  62315. start(): void;
  62316. private _checkCurrentState;
  62317. /**
  62318. * Release all resources
  62319. */
  62320. dispose(): void;
  62321. /**
  62322. * Helper function to create a SceneOptimizer with one single line of code
  62323. * @param scene defines the scene to work on
  62324. * @param options defines the options to use with the SceneOptimizer
  62325. * @param onSuccess defines a callback to call on success
  62326. * @param onFailure defines a callback to call on failure
  62327. * @returns the new SceneOptimizer object
  62328. */
  62329. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62330. }
  62331. }
  62332. declare module "babylonjs/Misc/sceneSerializer" {
  62333. import { Scene } from "babylonjs/scene";
  62334. /**
  62335. * Class used to serialize a scene into a string
  62336. */
  62337. export class SceneSerializer {
  62338. /**
  62339. * Clear cache used by a previous serialization
  62340. */
  62341. static ClearCache(): void;
  62342. /**
  62343. * Serialize a scene into a JSON compatible object
  62344. * @param scene defines the scene to serialize
  62345. * @returns a JSON compatible object
  62346. */
  62347. static Serialize(scene: Scene): any;
  62348. /**
  62349. * Serialize a mesh into a JSON compatible object
  62350. * @param toSerialize defines the mesh to serialize
  62351. * @param withParents defines if parents must be serialized as well
  62352. * @param withChildren defines if children must be serialized as well
  62353. * @returns a JSON compatible object
  62354. */
  62355. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62356. }
  62357. }
  62358. declare module "babylonjs/Misc/textureTools" {
  62359. import { Texture } from "babylonjs/Materials/Textures/texture";
  62360. /**
  62361. * Class used to host texture specific utilities
  62362. */
  62363. export class TextureTools {
  62364. /**
  62365. * Uses the GPU to create a copy texture rescaled at a given size
  62366. * @param texture Texture to copy from
  62367. * @param width defines the desired width
  62368. * @param height defines the desired height
  62369. * @param useBilinearMode defines if bilinear mode has to be used
  62370. * @return the generated texture
  62371. */
  62372. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62373. }
  62374. }
  62375. declare module "babylonjs/Misc/videoRecorder" {
  62376. import { Nullable } from "babylonjs/types";
  62377. import { Engine } from "babylonjs/Engines/engine";
  62378. /**
  62379. * This represents the different options available for the video capture.
  62380. */
  62381. export interface VideoRecorderOptions {
  62382. /** Defines the mime type of the video. */
  62383. mimeType: string;
  62384. /** Defines the FPS the video should be recorded at. */
  62385. fps: number;
  62386. /** Defines the chunk size for the recording data. */
  62387. recordChunckSize: number;
  62388. /** The audio tracks to attach to the recording. */
  62389. audioTracks?: MediaStreamTrack[];
  62390. }
  62391. /**
  62392. * This can help with recording videos from BabylonJS.
  62393. * This is based on the available WebRTC functionalities of the browser.
  62394. *
  62395. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62396. */
  62397. export class VideoRecorder {
  62398. private static readonly _defaultOptions;
  62399. /**
  62400. * Returns whether or not the VideoRecorder is available in your browser.
  62401. * @param engine Defines the Babylon Engine.
  62402. * @returns true if supported otherwise false.
  62403. */
  62404. static IsSupported(engine: Engine): boolean;
  62405. private readonly _options;
  62406. private _canvas;
  62407. private _mediaRecorder;
  62408. private _recordedChunks;
  62409. private _fileName;
  62410. private _resolve;
  62411. private _reject;
  62412. /**
  62413. * True when a recording is already in progress.
  62414. */
  62415. readonly isRecording: boolean;
  62416. /**
  62417. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62418. * @param engine Defines the BabylonJS Engine you wish to record.
  62419. * @param options Defines options that can be used to customize the capture.
  62420. */
  62421. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62422. /**
  62423. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62424. */
  62425. stopRecording(): void;
  62426. /**
  62427. * Starts recording the canvas for a max duration specified in parameters.
  62428. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62429. * If null no automatic download will start and you can rely on the promise to get the data back.
  62430. * @param maxDuration Defines the maximum recording time in seconds.
  62431. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62432. * @return A promise callback at the end of the recording with the video data in Blob.
  62433. */
  62434. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62435. /**
  62436. * Releases internal resources used during the recording.
  62437. */
  62438. dispose(): void;
  62439. private _handleDataAvailable;
  62440. private _handleError;
  62441. private _handleStop;
  62442. }
  62443. }
  62444. declare module "babylonjs/Misc/screenshotTools" {
  62445. import { Camera } from "babylonjs/Cameras/camera";
  62446. import { Engine } from "babylonjs/Engines/engine";
  62447. /**
  62448. * Class containing a set of static utilities functions for screenshots
  62449. */
  62450. export class ScreenshotTools {
  62451. /**
  62452. * Captures a screenshot of the current rendering
  62453. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62454. * @param engine defines the rendering engine
  62455. * @param camera defines the source camera
  62456. * @param size This parameter can be set to a single number or to an object with the
  62457. * following (optional) properties: precision, width, height. If a single number is passed,
  62458. * it will be used for both width and height. If an object is passed, the screenshot size
  62459. * will be derived from the parameters. The precision property is a multiplier allowing
  62460. * rendering at a higher or lower resolution
  62461. * @param successCallback defines the callback receives a single parameter which contains the
  62462. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62463. * src parameter of an <img> to display it
  62464. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62465. * Check your browser for supported MIME types
  62466. */
  62467. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  62468. /**
  62469. * Generates an image screenshot from the specified camera.
  62470. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62471. * @param engine The engine to use for rendering
  62472. * @param camera The camera to use for rendering
  62473. * @param size This parameter can be set to a single number or to an object with the
  62474. * following (optional) properties: precision, width, height. If a single number is passed,
  62475. * it will be used for both width and height. If an object is passed, the screenshot size
  62476. * will be derived from the parameters. The precision property is a multiplier allowing
  62477. * rendering at a higher or lower resolution
  62478. * @param successCallback The callback receives a single parameter which contains the
  62479. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62480. * src parameter of an <img> to display it
  62481. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62482. * Check your browser for supported MIME types
  62483. * @param samples Texture samples (default: 1)
  62484. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62485. * @param fileName A name for for the downloaded file.
  62486. */
  62487. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62488. }
  62489. }
  62490. declare module "babylonjs/Misc/index" {
  62491. export * from "babylonjs/Misc/andOrNotEvaluator";
  62492. export * from "babylonjs/Misc/assetsManager";
  62493. export * from "babylonjs/Misc/dds";
  62494. export * from "babylonjs/Misc/decorators";
  62495. export * from "babylonjs/Misc/deferred";
  62496. export * from "babylonjs/Misc/environmentTextureTools";
  62497. export * from "babylonjs/Misc/meshExploder";
  62498. export * from "babylonjs/Misc/filesInput";
  62499. export * from "babylonjs/Misc/HighDynamicRange/index";
  62500. export * from "babylonjs/Misc/khronosTextureContainer";
  62501. export * from "babylonjs/Misc/observable";
  62502. export * from "babylonjs/Misc/performanceMonitor";
  62503. export * from "babylonjs/Misc/promise";
  62504. export * from "babylonjs/Misc/sceneOptimizer";
  62505. export * from "babylonjs/Misc/sceneSerializer";
  62506. export * from "babylonjs/Misc/smartArray";
  62507. export * from "babylonjs/Misc/stringDictionary";
  62508. export * from "babylonjs/Misc/tags";
  62509. export * from "babylonjs/Misc/textureTools";
  62510. export * from "babylonjs/Misc/tga";
  62511. export * from "babylonjs/Misc/tools";
  62512. export * from "babylonjs/Misc/videoRecorder";
  62513. export * from "babylonjs/Misc/virtualJoystick";
  62514. export * from "babylonjs/Misc/workerPool";
  62515. export * from "babylonjs/Misc/logger";
  62516. export * from "babylonjs/Misc/typeStore";
  62517. export * from "babylonjs/Misc/filesInputStore";
  62518. export * from "babylonjs/Misc/deepCopier";
  62519. export * from "babylonjs/Misc/pivotTools";
  62520. export * from "babylonjs/Misc/precisionDate";
  62521. export * from "babylonjs/Misc/screenshotTools";
  62522. export * from "babylonjs/Misc/typeStore";
  62523. export * from "babylonjs/Misc/webRequest";
  62524. export * from "babylonjs/Misc/iInspectable";
  62525. export * from "babylonjs/Misc/brdfTextureTools";
  62526. }
  62527. declare module "babylonjs/index" {
  62528. export * from "babylonjs/abstractScene";
  62529. export * from "babylonjs/Actions/index";
  62530. export * from "babylonjs/Animations/index";
  62531. export * from "babylonjs/assetContainer";
  62532. export * from "babylonjs/Audio/index";
  62533. export * from "babylonjs/Behaviors/index";
  62534. export * from "babylonjs/Bones/index";
  62535. export * from "babylonjs/Cameras/index";
  62536. export * from "babylonjs/Collisions/index";
  62537. export * from "babylonjs/Culling/index";
  62538. export * from "babylonjs/Debug/index";
  62539. export * from "babylonjs/Engines/index";
  62540. export * from "babylonjs/Events/index";
  62541. export * from "babylonjs/Gamepads/index";
  62542. export * from "babylonjs/Gizmos/index";
  62543. export * from "babylonjs/Helpers/index";
  62544. export * from "babylonjs/Instrumentation/index";
  62545. export * from "babylonjs/Layers/index";
  62546. export * from "babylonjs/LensFlares/index";
  62547. export * from "babylonjs/Lights/index";
  62548. export * from "babylonjs/Loading/index";
  62549. export * from "babylonjs/Materials/index";
  62550. export * from "babylonjs/Maths/index";
  62551. export * from "babylonjs/Meshes/index";
  62552. export * from "babylonjs/Morph/index";
  62553. export * from "babylonjs/node";
  62554. export * from "babylonjs/Offline/index";
  62555. export * from "babylonjs/Particles/index";
  62556. export * from "babylonjs/Physics/index";
  62557. export * from "babylonjs/PostProcesses/index";
  62558. export * from "babylonjs/Probes/index";
  62559. export * from "babylonjs/Rendering/index";
  62560. export * from "babylonjs/scene";
  62561. export * from "babylonjs/sceneComponent";
  62562. export * from "babylonjs/Sprites/index";
  62563. export * from "babylonjs/States/index";
  62564. export * from "babylonjs/Misc/index";
  62565. export * from "babylonjs/types";
  62566. }
  62567. declare module "babylonjs/Animations/pathCursor" {
  62568. import { Path2, Vector3 } from "babylonjs/Maths/math";
  62569. /**
  62570. * A cursor which tracks a point on a path
  62571. */
  62572. export class PathCursor {
  62573. private path;
  62574. /**
  62575. * Stores path cursor callbacks for when an onchange event is triggered
  62576. */
  62577. private _onchange;
  62578. /**
  62579. * The value of the path cursor
  62580. */
  62581. value: number;
  62582. /**
  62583. * The animation array of the path cursor
  62584. */
  62585. animations: Animation[];
  62586. /**
  62587. * Initializes the path cursor
  62588. * @param path The path to track
  62589. */
  62590. constructor(path: Path2);
  62591. /**
  62592. * Gets the cursor point on the path
  62593. * @returns A point on the path cursor at the cursor location
  62594. */
  62595. getPoint(): Vector3;
  62596. /**
  62597. * Moves the cursor ahead by the step amount
  62598. * @param step The amount to move the cursor forward
  62599. * @returns This path cursor
  62600. */
  62601. moveAhead(step?: number): PathCursor;
  62602. /**
  62603. * Moves the cursor behind by the step amount
  62604. * @param step The amount to move the cursor back
  62605. * @returns This path cursor
  62606. */
  62607. moveBack(step?: number): PathCursor;
  62608. /**
  62609. * Moves the cursor by the step amount
  62610. * If the step amount is greater than one, an exception is thrown
  62611. * @param step The amount to move the cursor
  62612. * @returns This path cursor
  62613. */
  62614. move(step: number): PathCursor;
  62615. /**
  62616. * Ensures that the value is limited between zero and one
  62617. * @returns This path cursor
  62618. */
  62619. private ensureLimits;
  62620. /**
  62621. * Runs onchange callbacks on change (used by the animation engine)
  62622. * @returns This path cursor
  62623. */
  62624. private raiseOnChange;
  62625. /**
  62626. * Executes a function on change
  62627. * @param f A path cursor onchange callback
  62628. * @returns This path cursor
  62629. */
  62630. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62631. }
  62632. }
  62633. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  62634. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  62635. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  62636. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  62637. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  62638. }
  62639. declare module "babylonjs/Engines/Processors/Expressions/index" {
  62640. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  62641. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  62642. }
  62643. declare module "babylonjs/Engines/Processors/index" {
  62644. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  62645. export * from "babylonjs/Engines/Processors/Expressions/index";
  62646. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  62647. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  62648. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  62649. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  62650. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  62651. export * from "babylonjs/Engines/Processors/shaderProcessor";
  62652. }
  62653. declare module "babylonjs/Legacy/legacy" {
  62654. import * as Babylon from "babylonjs/index";
  62655. export * from "babylonjs/index";
  62656. }
  62657. declare module "babylonjs/Shaders/blur.fragment" {
  62658. /** @hidden */
  62659. export var blurPixelShader: {
  62660. name: string;
  62661. shader: string;
  62662. };
  62663. }
  62664. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  62665. /** @hidden */
  62666. export var pointCloudVertexDeclaration: {
  62667. name: string;
  62668. shader: string;
  62669. };
  62670. }
  62671. declare module "babylonjs" {
  62672. export * from "babylonjs/Legacy/legacy";
  62673. }
  62674. declare module BABYLON {
  62675. /** Alias type for value that can be null */
  62676. export type Nullable<T> = T | null;
  62677. /**
  62678. * Alias type for number that are floats
  62679. * @ignorenaming
  62680. */
  62681. export type float = number;
  62682. /**
  62683. * Alias type for number that are doubles.
  62684. * @ignorenaming
  62685. */
  62686. export type double = number;
  62687. /**
  62688. * Alias type for number that are integer
  62689. * @ignorenaming
  62690. */
  62691. export type int = number;
  62692. /** Alias type for number array or Float32Array */
  62693. export type FloatArray = number[] | Float32Array;
  62694. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62695. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62696. /**
  62697. * Alias for types that can be used by a Buffer or VertexBuffer.
  62698. */
  62699. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62700. /**
  62701. * Alias type for primitive types
  62702. * @ignorenaming
  62703. */
  62704. type Primitive = undefined | null | boolean | string | number | Function;
  62705. /**
  62706. * Type modifier to make all the properties of an object Readonly
  62707. */
  62708. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62709. /**
  62710. * Type modifier to make all the properties of an object Readonly recursively
  62711. */
  62712. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62713. /** @hidden */
  62714. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62715. }
  62716. /** @hidden */
  62717. /** @hidden */
  62718. type DeepImmutableObject<T> = {
  62719. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62720. };
  62721. }
  62722. declare module BABYLON {
  62723. /**
  62724. * Class containing a set of static utilities functions for arrays.
  62725. */
  62726. export class ArrayTools {
  62727. /**
  62728. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62729. * @param size the number of element to construct and put in the array
  62730. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62731. * @returns a new array filled with new objects
  62732. */
  62733. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62734. }
  62735. }
  62736. declare module BABYLON {
  62737. /**
  62738. * Scalar computation library
  62739. */
  62740. export class Scalar {
  62741. /**
  62742. * Two pi constants convenient for computation.
  62743. */
  62744. static TwoPi: number;
  62745. /**
  62746. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62747. * @param a number
  62748. * @param b number
  62749. * @param epsilon (default = 1.401298E-45)
  62750. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62751. */
  62752. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  62753. /**
  62754. * Returns a string : the upper case translation of the number i to hexadecimal.
  62755. * @param i number
  62756. * @returns the upper case translation of the number i to hexadecimal.
  62757. */
  62758. static ToHex(i: number): string;
  62759. /**
  62760. * Returns -1 if value is negative and +1 is value is positive.
  62761. * @param value the value
  62762. * @returns the value itself if it's equal to zero.
  62763. */
  62764. static Sign(value: number): number;
  62765. /**
  62766. * Returns the value itself if it's between min and max.
  62767. * Returns min if the value is lower than min.
  62768. * Returns max if the value is greater than max.
  62769. * @param value the value to clmap
  62770. * @param min the min value to clamp to (default: 0)
  62771. * @param max the max value to clamp to (default: 1)
  62772. * @returns the clamped value
  62773. */
  62774. static Clamp(value: number, min?: number, max?: number): number;
  62775. /**
  62776. * the log2 of value.
  62777. * @param value the value to compute log2 of
  62778. * @returns the log2 of value.
  62779. */
  62780. static Log2(value: number): number;
  62781. /**
  62782. * Loops the value, so that it is never larger than length and never smaller than 0.
  62783. *
  62784. * This is similar to the modulo operator but it works with floating point numbers.
  62785. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  62786. * With t = 5 and length = 2.5, the result would be 0.0.
  62787. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  62788. * @param value the value
  62789. * @param length the length
  62790. * @returns the looped value
  62791. */
  62792. static Repeat(value: number, length: number): number;
  62793. /**
  62794. * Normalize the value between 0.0 and 1.0 using min and max values
  62795. * @param value value to normalize
  62796. * @param min max to normalize between
  62797. * @param max min to normalize between
  62798. * @returns the normalized value
  62799. */
  62800. static Normalize(value: number, min: number, max: number): number;
  62801. /**
  62802. * Denormalize the value from 0.0 and 1.0 using min and max values
  62803. * @param normalized value to denormalize
  62804. * @param min max to denormalize between
  62805. * @param max min to denormalize between
  62806. * @returns the denormalized value
  62807. */
  62808. static Denormalize(normalized: number, min: number, max: number): number;
  62809. /**
  62810. * Calculates the shortest difference between two given angles given in degrees.
  62811. * @param current current angle in degrees
  62812. * @param target target angle in degrees
  62813. * @returns the delta
  62814. */
  62815. static DeltaAngle(current: number, target: number): number;
  62816. /**
  62817. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  62818. * @param tx value
  62819. * @param length length
  62820. * @returns The returned value will move back and forth between 0 and length
  62821. */
  62822. static PingPong(tx: number, length: number): number;
  62823. /**
  62824. * Interpolates between min and max with smoothing at the limits.
  62825. *
  62826. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  62827. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  62828. * @param from from
  62829. * @param to to
  62830. * @param tx value
  62831. * @returns the smooth stepped value
  62832. */
  62833. static SmoothStep(from: number, to: number, tx: number): number;
  62834. /**
  62835. * Moves a value current towards target.
  62836. *
  62837. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  62838. * Negative values of maxDelta pushes the value away from target.
  62839. * @param current current value
  62840. * @param target target value
  62841. * @param maxDelta max distance to move
  62842. * @returns resulting value
  62843. */
  62844. static MoveTowards(current: number, target: number, maxDelta: number): number;
  62845. /**
  62846. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62847. *
  62848. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  62849. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  62850. * @param current current value
  62851. * @param target target value
  62852. * @param maxDelta max distance to move
  62853. * @returns resulting angle
  62854. */
  62855. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  62856. /**
  62857. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  62858. * @param start start value
  62859. * @param end target value
  62860. * @param amount amount to lerp between
  62861. * @returns the lerped value
  62862. */
  62863. static Lerp(start: number, end: number, amount: number): number;
  62864. /**
  62865. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62866. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  62867. * @param start start value
  62868. * @param end target value
  62869. * @param amount amount to lerp between
  62870. * @returns the lerped value
  62871. */
  62872. static LerpAngle(start: number, end: number, amount: number): number;
  62873. /**
  62874. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  62875. * @param a start value
  62876. * @param b target value
  62877. * @param value value between a and b
  62878. * @returns the inverseLerp value
  62879. */
  62880. static InverseLerp(a: number, b: number, value: number): number;
  62881. /**
  62882. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  62883. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  62884. * @param value1 spline value
  62885. * @param tangent1 spline value
  62886. * @param value2 spline value
  62887. * @param tangent2 spline value
  62888. * @param amount input value
  62889. * @returns hermite result
  62890. */
  62891. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  62892. /**
  62893. * Returns a random float number between and min and max values
  62894. * @param min min value of random
  62895. * @param max max value of random
  62896. * @returns random value
  62897. */
  62898. static RandomRange(min: number, max: number): number;
  62899. /**
  62900. * This function returns percentage of a number in a given range.
  62901. *
  62902. * RangeToPercent(40,20,60) will return 0.5 (50%)
  62903. * RangeToPercent(34,0,100) will return 0.34 (34%)
  62904. * @param number to convert to percentage
  62905. * @param min min range
  62906. * @param max max range
  62907. * @returns the percentage
  62908. */
  62909. static RangeToPercent(number: number, min: number, max: number): number;
  62910. /**
  62911. * This function returns number that corresponds to the percentage in a given range.
  62912. *
  62913. * PercentToRange(0.34,0,100) will return 34.
  62914. * @param percent to convert to number
  62915. * @param min min range
  62916. * @param max max range
  62917. * @returns the number
  62918. */
  62919. static PercentToRange(percent: number, min: number, max: number): number;
  62920. /**
  62921. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  62922. * @param angle The angle to normalize in radian.
  62923. * @return The converted angle.
  62924. */
  62925. static NormalizeRadians(angle: number): number;
  62926. }
  62927. }
  62928. declare module BABYLON {
  62929. /**
  62930. * Constant used to convert a value to gamma space
  62931. * @ignorenaming
  62932. */
  62933. export const ToGammaSpace: number;
  62934. /**
  62935. * Constant used to convert a value to linear space
  62936. * @ignorenaming
  62937. */
  62938. export const ToLinearSpace = 2.2;
  62939. /**
  62940. * Constant used to define the minimal number value in Babylon.js
  62941. * @ignorenaming
  62942. */
  62943. let Epsilon: number;
  62944. /**
  62945. * Class used to hold a RBG color
  62946. */
  62947. export class Color3 {
  62948. /**
  62949. * Defines the red component (between 0 and 1, default is 0)
  62950. */
  62951. r: number;
  62952. /**
  62953. * Defines the green component (between 0 and 1, default is 0)
  62954. */
  62955. g: number;
  62956. /**
  62957. * Defines the blue component (between 0 and 1, default is 0)
  62958. */
  62959. b: number;
  62960. /**
  62961. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  62962. * @param r defines the red component (between 0 and 1, default is 0)
  62963. * @param g defines the green component (between 0 and 1, default is 0)
  62964. * @param b defines the blue component (between 0 and 1, default is 0)
  62965. */
  62966. constructor(
  62967. /**
  62968. * Defines the red component (between 0 and 1, default is 0)
  62969. */
  62970. r?: number,
  62971. /**
  62972. * Defines the green component (between 0 and 1, default is 0)
  62973. */
  62974. g?: number,
  62975. /**
  62976. * Defines the blue component (between 0 and 1, default is 0)
  62977. */
  62978. b?: number);
  62979. /**
  62980. * Creates a string with the Color3 current values
  62981. * @returns the string representation of the Color3 object
  62982. */
  62983. toString(): string;
  62984. /**
  62985. * Returns the string "Color3"
  62986. * @returns "Color3"
  62987. */
  62988. getClassName(): string;
  62989. /**
  62990. * Compute the Color3 hash code
  62991. * @returns an unique number that can be used to hash Color3 objects
  62992. */
  62993. getHashCode(): number;
  62994. /**
  62995. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  62996. * @param array defines the array where to store the r,g,b components
  62997. * @param index defines an optional index in the target array to define where to start storing values
  62998. * @returns the current Color3 object
  62999. */
  63000. toArray(array: FloatArray, index?: number): Color3;
  63001. /**
  63002. * Returns a new Color4 object from the current Color3 and the given alpha
  63003. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  63004. * @returns a new Color4 object
  63005. */
  63006. toColor4(alpha?: number): Color4;
  63007. /**
  63008. * Returns a new array populated with 3 numeric elements : red, green and blue values
  63009. * @returns the new array
  63010. */
  63011. asArray(): number[];
  63012. /**
  63013. * Returns the luminance value
  63014. * @returns a float value
  63015. */
  63016. toLuminance(): number;
  63017. /**
  63018. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  63019. * @param otherColor defines the second operand
  63020. * @returns the new Color3 object
  63021. */
  63022. multiply(otherColor: DeepImmutable<Color3>): Color3;
  63023. /**
  63024. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  63025. * @param otherColor defines the second operand
  63026. * @param result defines the Color3 object where to store the result
  63027. * @returns the current Color3
  63028. */
  63029. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63030. /**
  63031. * Determines equality between Color3 objects
  63032. * @param otherColor defines the second operand
  63033. * @returns true if the rgb values are equal to the given ones
  63034. */
  63035. equals(otherColor: DeepImmutable<Color3>): boolean;
  63036. /**
  63037. * Determines equality between the current Color3 object and a set of r,b,g values
  63038. * @param r defines the red component to check
  63039. * @param g defines the green component to check
  63040. * @param b defines the blue component to check
  63041. * @returns true if the rgb values are equal to the given ones
  63042. */
  63043. equalsFloats(r: number, g: number, b: number): boolean;
  63044. /**
  63045. * Multiplies in place each rgb value by scale
  63046. * @param scale defines the scaling factor
  63047. * @returns the updated Color3
  63048. */
  63049. scale(scale: number): Color3;
  63050. /**
  63051. * Multiplies the rgb values by scale and stores the result into "result"
  63052. * @param scale defines the scaling factor
  63053. * @param result defines the Color3 object where to store the result
  63054. * @returns the unmodified current Color3
  63055. */
  63056. scaleToRef(scale: number, result: Color3): Color3;
  63057. /**
  63058. * Scale the current Color3 values by a factor and add the result to a given Color3
  63059. * @param scale defines the scale factor
  63060. * @param result defines color to store the result into
  63061. * @returns the unmodified current Color3
  63062. */
  63063. scaleAndAddToRef(scale: number, result: Color3): Color3;
  63064. /**
  63065. * Clamps the rgb values by the min and max values and stores the result into "result"
  63066. * @param min defines minimum clamping value (default is 0)
  63067. * @param max defines maximum clamping value (default is 1)
  63068. * @param result defines color to store the result into
  63069. * @returns the original Color3
  63070. */
  63071. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  63072. /**
  63073. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  63074. * @param otherColor defines the second operand
  63075. * @returns the new Color3
  63076. */
  63077. add(otherColor: DeepImmutable<Color3>): Color3;
  63078. /**
  63079. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  63080. * @param otherColor defines the second operand
  63081. * @param result defines Color3 object to store the result into
  63082. * @returns the unmodified current Color3
  63083. */
  63084. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63085. /**
  63086. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  63087. * @param otherColor defines the second operand
  63088. * @returns the new Color3
  63089. */
  63090. subtract(otherColor: DeepImmutable<Color3>): Color3;
  63091. /**
  63092. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  63093. * @param otherColor defines the second operand
  63094. * @param result defines Color3 object to store the result into
  63095. * @returns the unmodified current Color3
  63096. */
  63097. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63098. /**
  63099. * Copy the current object
  63100. * @returns a new Color3 copied the current one
  63101. */
  63102. clone(): Color3;
  63103. /**
  63104. * Copies the rgb values from the source in the current Color3
  63105. * @param source defines the source Color3 object
  63106. * @returns the updated Color3 object
  63107. */
  63108. copyFrom(source: DeepImmutable<Color3>): Color3;
  63109. /**
  63110. * Updates the Color3 rgb values from the given floats
  63111. * @param r defines the red component to read from
  63112. * @param g defines the green component to read from
  63113. * @param b defines the blue component to read from
  63114. * @returns the current Color3 object
  63115. */
  63116. copyFromFloats(r: number, g: number, b: number): Color3;
  63117. /**
  63118. * Updates the Color3 rgb values from the given floats
  63119. * @param r defines the red component to read from
  63120. * @param g defines the green component to read from
  63121. * @param b defines the blue component to read from
  63122. * @returns the current Color3 object
  63123. */
  63124. set(r: number, g: number, b: number): Color3;
  63125. /**
  63126. * Compute the Color3 hexadecimal code as a string
  63127. * @returns a string containing the hexadecimal representation of the Color3 object
  63128. */
  63129. toHexString(): string;
  63130. /**
  63131. * Computes a new Color3 converted from the current one to linear space
  63132. * @returns a new Color3 object
  63133. */
  63134. toLinearSpace(): Color3;
  63135. /**
  63136. * Converts current color in rgb space to HSV values
  63137. * @returns a new color3 representing the HSV values
  63138. */
  63139. toHSV(): Color3;
  63140. /**
  63141. * Converts current color in rgb space to HSV values
  63142. * @param result defines the Color3 where to store the HSV values
  63143. */
  63144. toHSVToRef(result: Color3): void;
  63145. /**
  63146. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  63147. * @param convertedColor defines the Color3 object where to store the linear space version
  63148. * @returns the unmodified Color3
  63149. */
  63150. toLinearSpaceToRef(convertedColor: Color3): Color3;
  63151. /**
  63152. * Computes a new Color3 converted from the current one to gamma space
  63153. * @returns a new Color3 object
  63154. */
  63155. toGammaSpace(): Color3;
  63156. /**
  63157. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  63158. * @param convertedColor defines the Color3 object where to store the gamma space version
  63159. * @returns the unmodified Color3
  63160. */
  63161. toGammaSpaceToRef(convertedColor: Color3): Color3;
  63162. private static _BlackReadOnly;
  63163. /**
  63164. * Convert Hue, saturation and value to a Color3 (RGB)
  63165. * @param hue defines the hue
  63166. * @param saturation defines the saturation
  63167. * @param value defines the value
  63168. * @param result defines the Color3 where to store the RGB values
  63169. */
  63170. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  63171. /**
  63172. * Creates a new Color3 from the string containing valid hexadecimal values
  63173. * @param hex defines a string containing valid hexadecimal values
  63174. * @returns a new Color3 object
  63175. */
  63176. static FromHexString(hex: string): Color3;
  63177. /**
  63178. * Creates a new Color3 from the starting index of the given array
  63179. * @param array defines the source array
  63180. * @param offset defines an offset in the source array
  63181. * @returns a new Color3 object
  63182. */
  63183. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  63184. /**
  63185. * Creates a new Color3 from integer values (< 256)
  63186. * @param r defines the red component to read from (value between 0 and 255)
  63187. * @param g defines the green component to read from (value between 0 and 255)
  63188. * @param b defines the blue component to read from (value between 0 and 255)
  63189. * @returns a new Color3 object
  63190. */
  63191. static FromInts(r: number, g: number, b: number): Color3;
  63192. /**
  63193. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63194. * @param start defines the start Color3 value
  63195. * @param end defines the end Color3 value
  63196. * @param amount defines the gradient value between start and end
  63197. * @returns a new Color3 object
  63198. */
  63199. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  63200. /**
  63201. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63202. * @param left defines the start value
  63203. * @param right defines the end value
  63204. * @param amount defines the gradient factor
  63205. * @param result defines the Color3 object where to store the result
  63206. */
  63207. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  63208. /**
  63209. * Returns a Color3 value containing a red color
  63210. * @returns a new Color3 object
  63211. */
  63212. static Red(): Color3;
  63213. /**
  63214. * Returns a Color3 value containing a green color
  63215. * @returns a new Color3 object
  63216. */
  63217. static Green(): Color3;
  63218. /**
  63219. * Returns a Color3 value containing a blue color
  63220. * @returns a new Color3 object
  63221. */
  63222. static Blue(): Color3;
  63223. /**
  63224. * Returns a Color3 value containing a black color
  63225. * @returns a new Color3 object
  63226. */
  63227. static Black(): Color3;
  63228. /**
  63229. * Gets a Color3 value containing a black color that must not be updated
  63230. */
  63231. static readonly BlackReadOnly: DeepImmutable<Color3>;
  63232. /**
  63233. * Returns a Color3 value containing a white color
  63234. * @returns a new Color3 object
  63235. */
  63236. static White(): Color3;
  63237. /**
  63238. * Returns a Color3 value containing a purple color
  63239. * @returns a new Color3 object
  63240. */
  63241. static Purple(): Color3;
  63242. /**
  63243. * Returns a Color3 value containing a magenta color
  63244. * @returns a new Color3 object
  63245. */
  63246. static Magenta(): Color3;
  63247. /**
  63248. * Returns a Color3 value containing a yellow color
  63249. * @returns a new Color3 object
  63250. */
  63251. static Yellow(): Color3;
  63252. /**
  63253. * Returns a Color3 value containing a gray color
  63254. * @returns a new Color3 object
  63255. */
  63256. static Gray(): Color3;
  63257. /**
  63258. * Returns a Color3 value containing a teal color
  63259. * @returns a new Color3 object
  63260. */
  63261. static Teal(): Color3;
  63262. /**
  63263. * Returns a Color3 value containing a random color
  63264. * @returns a new Color3 object
  63265. */
  63266. static Random(): Color3;
  63267. }
  63268. /**
  63269. * Class used to hold a RBGA color
  63270. */
  63271. export class Color4 {
  63272. /**
  63273. * Defines the red component (between 0 and 1, default is 0)
  63274. */
  63275. r: number;
  63276. /**
  63277. * Defines the green component (between 0 and 1, default is 0)
  63278. */
  63279. g: number;
  63280. /**
  63281. * Defines the blue component (between 0 and 1, default is 0)
  63282. */
  63283. b: number;
  63284. /**
  63285. * Defines the alpha component (between 0 and 1, default is 1)
  63286. */
  63287. a: number;
  63288. /**
  63289. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  63290. * @param r defines the red component (between 0 and 1, default is 0)
  63291. * @param g defines the green component (between 0 and 1, default is 0)
  63292. * @param b defines the blue component (between 0 and 1, default is 0)
  63293. * @param a defines the alpha component (between 0 and 1, default is 1)
  63294. */
  63295. constructor(
  63296. /**
  63297. * Defines the red component (between 0 and 1, default is 0)
  63298. */
  63299. r?: number,
  63300. /**
  63301. * Defines the green component (between 0 and 1, default is 0)
  63302. */
  63303. g?: number,
  63304. /**
  63305. * Defines the blue component (between 0 and 1, default is 0)
  63306. */
  63307. b?: number,
  63308. /**
  63309. * Defines the alpha component (between 0 and 1, default is 1)
  63310. */
  63311. a?: number);
  63312. /**
  63313. * Adds in place the given Color4 values to the current Color4 object
  63314. * @param right defines the second operand
  63315. * @returns the current updated Color4 object
  63316. */
  63317. addInPlace(right: DeepImmutable<Color4>): Color4;
  63318. /**
  63319. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  63320. * @returns the new array
  63321. */
  63322. asArray(): number[];
  63323. /**
  63324. * Stores from the starting index in the given array the Color4 successive values
  63325. * @param array defines the array where to store the r,g,b components
  63326. * @param index defines an optional index in the target array to define where to start storing values
  63327. * @returns the current Color4 object
  63328. */
  63329. toArray(array: number[], index?: number): Color4;
  63330. /**
  63331. * Determines equality between Color4 objects
  63332. * @param otherColor defines the second operand
  63333. * @returns true if the rgba values are equal to the given ones
  63334. */
  63335. equals(otherColor: DeepImmutable<Color4>): boolean;
  63336. /**
  63337. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  63338. * @param right defines the second operand
  63339. * @returns a new Color4 object
  63340. */
  63341. add(right: DeepImmutable<Color4>): Color4;
  63342. /**
  63343. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63344. * @param right defines the second operand
  63345. * @returns a new Color4 object
  63346. */
  63347. subtract(right: DeepImmutable<Color4>): Color4;
  63348. /**
  63349. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63350. * @param right defines the second operand
  63351. * @param result defines the Color4 object where to store the result
  63352. * @returns the current Color4 object
  63353. */
  63354. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63355. /**
  63356. * Creates a new Color4 with the current Color4 values multiplied by scale
  63357. * @param scale defines the scaling factor to apply
  63358. * @returns a new Color4 object
  63359. */
  63360. scale(scale: number): Color4;
  63361. /**
  63362. * Multiplies the current Color4 values by scale and stores the result in "result"
  63363. * @param scale defines the scaling factor to apply
  63364. * @param result defines the Color4 object where to store the result
  63365. * @returns the current unmodified Color4
  63366. */
  63367. scaleToRef(scale: number, result: Color4): Color4;
  63368. /**
  63369. * Scale the current Color4 values by a factor and add the result to a given Color4
  63370. * @param scale defines the scale factor
  63371. * @param result defines the Color4 object where to store the result
  63372. * @returns the unmodified current Color4
  63373. */
  63374. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63375. /**
  63376. * Clamps the rgb values by the min and max values and stores the result into "result"
  63377. * @param min defines minimum clamping value (default is 0)
  63378. * @param max defines maximum clamping value (default is 1)
  63379. * @param result defines color to store the result into.
  63380. * @returns the cuurent Color4
  63381. */
  63382. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63383. /**
  63384. * Multipy an Color4 value by another and return a new Color4 object
  63385. * @param color defines the Color4 value to multiply by
  63386. * @returns a new Color4 object
  63387. */
  63388. multiply(color: Color4): Color4;
  63389. /**
  63390. * Multipy a Color4 value by another and push the result in a reference value
  63391. * @param color defines the Color4 value to multiply by
  63392. * @param result defines the Color4 to fill the result in
  63393. * @returns the result Color4
  63394. */
  63395. multiplyToRef(color: Color4, result: Color4): Color4;
  63396. /**
  63397. * Creates a string with the Color4 current values
  63398. * @returns the string representation of the Color4 object
  63399. */
  63400. toString(): string;
  63401. /**
  63402. * Returns the string "Color4"
  63403. * @returns "Color4"
  63404. */
  63405. getClassName(): string;
  63406. /**
  63407. * Compute the Color4 hash code
  63408. * @returns an unique number that can be used to hash Color4 objects
  63409. */
  63410. getHashCode(): number;
  63411. /**
  63412. * Creates a new Color4 copied from the current one
  63413. * @returns a new Color4 object
  63414. */
  63415. clone(): Color4;
  63416. /**
  63417. * Copies the given Color4 values into the current one
  63418. * @param source defines the source Color4 object
  63419. * @returns the current updated Color4 object
  63420. */
  63421. copyFrom(source: Color4): Color4;
  63422. /**
  63423. * Copies the given float values into the current one
  63424. * @param r defines the red component to read from
  63425. * @param g defines the green component to read from
  63426. * @param b defines the blue component to read from
  63427. * @param a defines the alpha component to read from
  63428. * @returns the current updated Color4 object
  63429. */
  63430. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63431. /**
  63432. * Copies the given float values into the current one
  63433. * @param r defines the red component to read from
  63434. * @param g defines the green component to read from
  63435. * @param b defines the blue component to read from
  63436. * @param a defines the alpha component to read from
  63437. * @returns the current updated Color4 object
  63438. */
  63439. set(r: number, g: number, b: number, a: number): Color4;
  63440. /**
  63441. * Compute the Color4 hexadecimal code as a string
  63442. * @returns a string containing the hexadecimal representation of the Color4 object
  63443. */
  63444. toHexString(): string;
  63445. /**
  63446. * Computes a new Color4 converted from the current one to linear space
  63447. * @returns a new Color4 object
  63448. */
  63449. toLinearSpace(): Color4;
  63450. /**
  63451. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63452. * @param convertedColor defines the Color4 object where to store the linear space version
  63453. * @returns the unmodified Color4
  63454. */
  63455. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63456. /**
  63457. * Computes a new Color4 converted from the current one to gamma space
  63458. * @returns a new Color4 object
  63459. */
  63460. toGammaSpace(): Color4;
  63461. /**
  63462. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63463. * @param convertedColor defines the Color4 object where to store the gamma space version
  63464. * @returns the unmodified Color4
  63465. */
  63466. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63467. /**
  63468. * Creates a new Color4 from the string containing valid hexadecimal values
  63469. * @param hex defines a string containing valid hexadecimal values
  63470. * @returns a new Color4 object
  63471. */
  63472. static FromHexString(hex: string): Color4;
  63473. /**
  63474. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63475. * @param left defines the start value
  63476. * @param right defines the end value
  63477. * @param amount defines the gradient factor
  63478. * @returns a new Color4 object
  63479. */
  63480. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63481. /**
  63482. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63483. * @param left defines the start value
  63484. * @param right defines the end value
  63485. * @param amount defines the gradient factor
  63486. * @param result defines the Color4 object where to store data
  63487. */
  63488. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63489. /**
  63490. * Creates a new Color4 from a Color3 and an alpha value
  63491. * @param color3 defines the source Color3 to read from
  63492. * @param alpha defines the alpha component (1.0 by default)
  63493. * @returns a new Color4 object
  63494. */
  63495. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63496. /**
  63497. * Creates a new Color4 from the starting index element of the given array
  63498. * @param array defines the source array to read from
  63499. * @param offset defines the offset in the source array
  63500. * @returns a new Color4 object
  63501. */
  63502. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63503. /**
  63504. * Creates a new Color3 from integer values (< 256)
  63505. * @param r defines the red component to read from (value between 0 and 255)
  63506. * @param g defines the green component to read from (value between 0 and 255)
  63507. * @param b defines the blue component to read from (value between 0 and 255)
  63508. * @param a defines the alpha component to read from (value between 0 and 255)
  63509. * @returns a new Color3 object
  63510. */
  63511. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63512. /**
  63513. * Check the content of a given array and convert it to an array containing RGBA data
  63514. * If the original array was already containing count * 4 values then it is returned directly
  63515. * @param colors defines the array to check
  63516. * @param count defines the number of RGBA data to expect
  63517. * @returns an array containing count * 4 values (RGBA)
  63518. */
  63519. static CheckColors4(colors: number[], count: number): number[];
  63520. }
  63521. /**
  63522. * Class representing a vector containing 2 coordinates
  63523. */
  63524. export class Vector2 {
  63525. /** defines the first coordinate */
  63526. x: number;
  63527. /** defines the second coordinate */
  63528. y: number;
  63529. /**
  63530. * Creates a new Vector2 from the given x and y coordinates
  63531. * @param x defines the first coordinate
  63532. * @param y defines the second coordinate
  63533. */
  63534. constructor(
  63535. /** defines the first coordinate */
  63536. x?: number,
  63537. /** defines the second coordinate */
  63538. y?: number);
  63539. /**
  63540. * Gets a string with the Vector2 coordinates
  63541. * @returns a string with the Vector2 coordinates
  63542. */
  63543. toString(): string;
  63544. /**
  63545. * Gets class name
  63546. * @returns the string "Vector2"
  63547. */
  63548. getClassName(): string;
  63549. /**
  63550. * Gets current vector hash code
  63551. * @returns the Vector2 hash code as a number
  63552. */
  63553. getHashCode(): number;
  63554. /**
  63555. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63556. * @param array defines the source array
  63557. * @param index defines the offset in source array
  63558. * @returns the current Vector2
  63559. */
  63560. toArray(array: FloatArray, index?: number): Vector2;
  63561. /**
  63562. * Copy the current vector to an array
  63563. * @returns a new array with 2 elements: the Vector2 coordinates.
  63564. */
  63565. asArray(): number[];
  63566. /**
  63567. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63568. * @param source defines the source Vector2
  63569. * @returns the current updated Vector2
  63570. */
  63571. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63572. /**
  63573. * Sets the Vector2 coordinates with the given floats
  63574. * @param x defines the first coordinate
  63575. * @param y defines the second coordinate
  63576. * @returns the current updated Vector2
  63577. */
  63578. copyFromFloats(x: number, y: number): Vector2;
  63579. /**
  63580. * Sets the Vector2 coordinates with the given floats
  63581. * @param x defines the first coordinate
  63582. * @param y defines the second coordinate
  63583. * @returns the current updated Vector2
  63584. */
  63585. set(x: number, y: number): Vector2;
  63586. /**
  63587. * Add another vector with the current one
  63588. * @param otherVector defines the other vector
  63589. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63590. */
  63591. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63592. /**
  63593. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63594. * @param otherVector defines the other vector
  63595. * @param result defines the target vector
  63596. * @returns the unmodified current Vector2
  63597. */
  63598. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63599. /**
  63600. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63601. * @param otherVector defines the other vector
  63602. * @returns the current updated Vector2
  63603. */
  63604. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63605. /**
  63606. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63607. * @param otherVector defines the other vector
  63608. * @returns a new Vector2
  63609. */
  63610. addVector3(otherVector: Vector3): Vector2;
  63611. /**
  63612. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63613. * @param otherVector defines the other vector
  63614. * @returns a new Vector2
  63615. */
  63616. subtract(otherVector: Vector2): Vector2;
  63617. /**
  63618. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63619. * @param otherVector defines the other vector
  63620. * @param result defines the target vector
  63621. * @returns the unmodified current Vector2
  63622. */
  63623. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63624. /**
  63625. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63626. * @param otherVector defines the other vector
  63627. * @returns the current updated Vector2
  63628. */
  63629. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63630. /**
  63631. * Multiplies in place the current Vector2 coordinates by the given ones
  63632. * @param otherVector defines the other vector
  63633. * @returns the current updated Vector2
  63634. */
  63635. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63636. /**
  63637. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63638. * @param otherVector defines the other vector
  63639. * @returns a new Vector2
  63640. */
  63641. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63642. /**
  63643. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63644. * @param otherVector defines the other vector
  63645. * @param result defines the target vector
  63646. * @returns the unmodified current Vector2
  63647. */
  63648. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63649. /**
  63650. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63651. * @param x defines the first coordinate
  63652. * @param y defines the second coordinate
  63653. * @returns a new Vector2
  63654. */
  63655. multiplyByFloats(x: number, y: number): Vector2;
  63656. /**
  63657. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63658. * @param otherVector defines the other vector
  63659. * @returns a new Vector2
  63660. */
  63661. divide(otherVector: Vector2): Vector2;
  63662. /**
  63663. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63664. * @param otherVector defines the other vector
  63665. * @param result defines the target vector
  63666. * @returns the unmodified current Vector2
  63667. */
  63668. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63669. /**
  63670. * Divides the current Vector2 coordinates by the given ones
  63671. * @param otherVector defines the other vector
  63672. * @returns the current updated Vector2
  63673. */
  63674. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63675. /**
  63676. * Gets a new Vector2 with current Vector2 negated coordinates
  63677. * @returns a new Vector2
  63678. */
  63679. negate(): Vector2;
  63680. /**
  63681. * Multiply the Vector2 coordinates by scale
  63682. * @param scale defines the scaling factor
  63683. * @returns the current updated Vector2
  63684. */
  63685. scaleInPlace(scale: number): Vector2;
  63686. /**
  63687. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63688. * @param scale defines the scaling factor
  63689. * @returns a new Vector2
  63690. */
  63691. scale(scale: number): Vector2;
  63692. /**
  63693. * Scale the current Vector2 values by a factor to a given Vector2
  63694. * @param scale defines the scale factor
  63695. * @param result defines the Vector2 object where to store the result
  63696. * @returns the unmodified current Vector2
  63697. */
  63698. scaleToRef(scale: number, result: Vector2): Vector2;
  63699. /**
  63700. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63701. * @param scale defines the scale factor
  63702. * @param result defines the Vector2 object where to store the result
  63703. * @returns the unmodified current Vector2
  63704. */
  63705. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63706. /**
  63707. * Gets a boolean if two vectors are equals
  63708. * @param otherVector defines the other vector
  63709. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63710. */
  63711. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63712. /**
  63713. * Gets a boolean if two vectors are equals (using an epsilon value)
  63714. * @param otherVector defines the other vector
  63715. * @param epsilon defines the minimal distance to consider equality
  63716. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63717. */
  63718. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63719. /**
  63720. * Gets a new Vector2 from current Vector2 floored values
  63721. * @returns a new Vector2
  63722. */
  63723. floor(): Vector2;
  63724. /**
  63725. * Gets a new Vector2 from current Vector2 floored values
  63726. * @returns a new Vector2
  63727. */
  63728. fract(): Vector2;
  63729. /**
  63730. * Gets the length of the vector
  63731. * @returns the vector length (float)
  63732. */
  63733. length(): number;
  63734. /**
  63735. * Gets the vector squared length
  63736. * @returns the vector squared length (float)
  63737. */
  63738. lengthSquared(): number;
  63739. /**
  63740. * Normalize the vector
  63741. * @returns the current updated Vector2
  63742. */
  63743. normalize(): Vector2;
  63744. /**
  63745. * Gets a new Vector2 copied from the Vector2
  63746. * @returns a new Vector2
  63747. */
  63748. clone(): Vector2;
  63749. /**
  63750. * Gets a new Vector2(0, 0)
  63751. * @returns a new Vector2
  63752. */
  63753. static Zero(): Vector2;
  63754. /**
  63755. * Gets a new Vector2(1, 1)
  63756. * @returns a new Vector2
  63757. */
  63758. static One(): Vector2;
  63759. /**
  63760. * Gets a new Vector2 set from the given index element of the given array
  63761. * @param array defines the data source
  63762. * @param offset defines the offset in the data source
  63763. * @returns a new Vector2
  63764. */
  63765. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  63766. /**
  63767. * Sets "result" from the given index element of the given array
  63768. * @param array defines the data source
  63769. * @param offset defines the offset in the data source
  63770. * @param result defines the target vector
  63771. */
  63772. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  63773. /**
  63774. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  63775. * @param value1 defines 1st point of control
  63776. * @param value2 defines 2nd point of control
  63777. * @param value3 defines 3rd point of control
  63778. * @param value4 defines 4th point of control
  63779. * @param amount defines the interpolation factor
  63780. * @returns a new Vector2
  63781. */
  63782. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  63783. /**
  63784. * 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".
  63785. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  63786. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  63787. * @param value defines the value to clamp
  63788. * @param min defines the lower limit
  63789. * @param max defines the upper limit
  63790. * @returns a new Vector2
  63791. */
  63792. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  63793. /**
  63794. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  63795. * @param value1 defines the 1st control point
  63796. * @param tangent1 defines the outgoing tangent
  63797. * @param value2 defines the 2nd control point
  63798. * @param tangent2 defines the incoming tangent
  63799. * @param amount defines the interpolation factor
  63800. * @returns a new Vector2
  63801. */
  63802. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  63803. /**
  63804. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  63805. * @param start defines the start vector
  63806. * @param end defines the end vector
  63807. * @param amount defines the interpolation factor
  63808. * @returns a new Vector2
  63809. */
  63810. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  63811. /**
  63812. * Gets the dot product of the vector "left" and the vector "right"
  63813. * @param left defines first vector
  63814. * @param right defines second vector
  63815. * @returns the dot product (float)
  63816. */
  63817. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  63818. /**
  63819. * Returns a new Vector2 equal to the normalized given vector
  63820. * @param vector defines the vector to normalize
  63821. * @returns a new Vector2
  63822. */
  63823. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  63824. /**
  63825. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  63826. * @param left defines 1st vector
  63827. * @param right defines 2nd vector
  63828. * @returns a new Vector2
  63829. */
  63830. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63831. /**
  63832. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  63833. * @param left defines 1st vector
  63834. * @param right defines 2nd vector
  63835. * @returns a new Vector2
  63836. */
  63837. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63838. /**
  63839. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  63840. * @param vector defines the vector to transform
  63841. * @param transformation defines the matrix to apply
  63842. * @returns a new Vector2
  63843. */
  63844. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  63845. /**
  63846. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  63847. * @param vector defines the vector to transform
  63848. * @param transformation defines the matrix to apply
  63849. * @param result defines the target vector
  63850. */
  63851. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  63852. /**
  63853. * Determines if a given vector is included in a triangle
  63854. * @param p defines the vector to test
  63855. * @param p0 defines 1st triangle point
  63856. * @param p1 defines 2nd triangle point
  63857. * @param p2 defines 3rd triangle point
  63858. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  63859. */
  63860. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  63861. /**
  63862. * Gets the distance between the vectors "value1" and "value2"
  63863. * @param value1 defines first vector
  63864. * @param value2 defines second vector
  63865. * @returns the distance between vectors
  63866. */
  63867. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63868. /**
  63869. * Returns the squared distance between the vectors "value1" and "value2"
  63870. * @param value1 defines first vector
  63871. * @param value2 defines second vector
  63872. * @returns the squared distance between vectors
  63873. */
  63874. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63875. /**
  63876. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  63877. * @param value1 defines first vector
  63878. * @param value2 defines second vector
  63879. * @returns a new Vector2
  63880. */
  63881. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  63882. /**
  63883. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  63884. * @param p defines the middle point
  63885. * @param segA defines one point of the segment
  63886. * @param segB defines the other point of the segment
  63887. * @returns the shortest distance
  63888. */
  63889. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  63890. }
  63891. /**
  63892. * Classed used to store (x,y,z) vector representation
  63893. * A Vector3 is the main object used in 3D geometry
  63894. * It can represent etiher the coordinates of a point the space, either a direction
  63895. * Reminder: js uses a left handed forward facing system
  63896. */
  63897. export class Vector3 {
  63898. /**
  63899. * Defines the first coordinates (on X axis)
  63900. */
  63901. x: number;
  63902. /**
  63903. * Defines the second coordinates (on Y axis)
  63904. */
  63905. y: number;
  63906. /**
  63907. * Defines the third coordinates (on Z axis)
  63908. */
  63909. z: number;
  63910. private static _UpReadOnly;
  63911. private static _ZeroReadOnly;
  63912. /**
  63913. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  63914. * @param x defines the first coordinates (on X axis)
  63915. * @param y defines the second coordinates (on Y axis)
  63916. * @param z defines the third coordinates (on Z axis)
  63917. */
  63918. constructor(
  63919. /**
  63920. * Defines the first coordinates (on X axis)
  63921. */
  63922. x?: number,
  63923. /**
  63924. * Defines the second coordinates (on Y axis)
  63925. */
  63926. y?: number,
  63927. /**
  63928. * Defines the third coordinates (on Z axis)
  63929. */
  63930. z?: number);
  63931. /**
  63932. * Creates a string representation of the Vector3
  63933. * @returns a string with the Vector3 coordinates.
  63934. */
  63935. toString(): string;
  63936. /**
  63937. * Gets the class name
  63938. * @returns the string "Vector3"
  63939. */
  63940. getClassName(): string;
  63941. /**
  63942. * Creates the Vector3 hash code
  63943. * @returns a number which tends to be unique between Vector3 instances
  63944. */
  63945. getHashCode(): number;
  63946. /**
  63947. * Creates an array containing three elements : the coordinates of the Vector3
  63948. * @returns a new array of numbers
  63949. */
  63950. asArray(): number[];
  63951. /**
  63952. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  63953. * @param array defines the destination array
  63954. * @param index defines the offset in the destination array
  63955. * @returns the current Vector3
  63956. */
  63957. toArray(array: FloatArray, index?: number): Vector3;
  63958. /**
  63959. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  63960. * @returns a new Quaternion object, computed from the Vector3 coordinates
  63961. */
  63962. toQuaternion(): Quaternion;
  63963. /**
  63964. * Adds the given vector to the current Vector3
  63965. * @param otherVector defines the second operand
  63966. * @returns the current updated Vector3
  63967. */
  63968. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63969. /**
  63970. * Adds the given coordinates to the current Vector3
  63971. * @param x defines the x coordinate of the operand
  63972. * @param y defines the y coordinate of the operand
  63973. * @param z defines the z coordinate of the operand
  63974. * @returns the current updated Vector3
  63975. */
  63976. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63977. /**
  63978. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  63979. * @param otherVector defines the second operand
  63980. * @returns the resulting Vector3
  63981. */
  63982. add(otherVector: DeepImmutable<Vector3>): Vector3;
  63983. /**
  63984. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  63985. * @param otherVector defines the second operand
  63986. * @param result defines the Vector3 object where to store the result
  63987. * @returns the current Vector3
  63988. */
  63989. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63990. /**
  63991. * Subtract the given vector from the current Vector3
  63992. * @param otherVector defines the second operand
  63993. * @returns the current updated Vector3
  63994. */
  63995. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63996. /**
  63997. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  63998. * @param otherVector defines the second operand
  63999. * @returns the resulting Vector3
  64000. */
  64001. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  64002. /**
  64003. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  64004. * @param otherVector defines the second operand
  64005. * @param result defines the Vector3 object where to store the result
  64006. * @returns the current Vector3
  64007. */
  64008. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64009. /**
  64010. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  64011. * @param x defines the x coordinate of the operand
  64012. * @param y defines the y coordinate of the operand
  64013. * @param z defines the z coordinate of the operand
  64014. * @returns the resulting Vector3
  64015. */
  64016. subtractFromFloats(x: number, y: number, z: number): Vector3;
  64017. /**
  64018. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  64019. * @param x defines the x coordinate of the operand
  64020. * @param y defines the y coordinate of the operand
  64021. * @param z defines the z coordinate of the operand
  64022. * @param result defines the Vector3 object where to store the result
  64023. * @returns the current Vector3
  64024. */
  64025. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  64026. /**
  64027. * Gets a new Vector3 set with the current Vector3 negated coordinates
  64028. * @returns a new Vector3
  64029. */
  64030. negate(): Vector3;
  64031. /**
  64032. * Multiplies the Vector3 coordinates by the float "scale"
  64033. * @param scale defines the multiplier factor
  64034. * @returns the current updated Vector3
  64035. */
  64036. scaleInPlace(scale: number): Vector3;
  64037. /**
  64038. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  64039. * @param scale defines the multiplier factor
  64040. * @returns a new Vector3
  64041. */
  64042. scale(scale: number): Vector3;
  64043. /**
  64044. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  64045. * @param scale defines the multiplier factor
  64046. * @param result defines the Vector3 object where to store the result
  64047. * @returns the current Vector3
  64048. */
  64049. scaleToRef(scale: number, result: Vector3): Vector3;
  64050. /**
  64051. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  64052. * @param scale defines the scale factor
  64053. * @param result defines the Vector3 object where to store the result
  64054. * @returns the unmodified current Vector3
  64055. */
  64056. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  64057. /**
  64058. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  64059. * @param otherVector defines the second operand
  64060. * @returns true if both vectors are equals
  64061. */
  64062. equals(otherVector: DeepImmutable<Vector3>): boolean;
  64063. /**
  64064. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  64065. * @param otherVector defines the second operand
  64066. * @param epsilon defines the minimal distance to define values as equals
  64067. * @returns true if both vectors are distant less than epsilon
  64068. */
  64069. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  64070. /**
  64071. * Returns true if the current Vector3 coordinates equals the given floats
  64072. * @param x defines the x coordinate of the operand
  64073. * @param y defines the y coordinate of the operand
  64074. * @param z defines the z coordinate of the operand
  64075. * @returns true if both vectors are equals
  64076. */
  64077. equalsToFloats(x: number, y: number, z: number): boolean;
  64078. /**
  64079. * Multiplies the current Vector3 coordinates by the given ones
  64080. * @param otherVector defines the second operand
  64081. * @returns the current updated Vector3
  64082. */
  64083. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64084. /**
  64085. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  64086. * @param otherVector defines the second operand
  64087. * @returns the new Vector3
  64088. */
  64089. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  64090. /**
  64091. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  64092. * @param otherVector defines the second operand
  64093. * @param result defines the Vector3 object where to store the result
  64094. * @returns the current Vector3
  64095. */
  64096. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64097. /**
  64098. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  64099. * @param x defines the x coordinate of the operand
  64100. * @param y defines the y coordinate of the operand
  64101. * @param z defines the z coordinate of the operand
  64102. * @returns the new Vector3
  64103. */
  64104. multiplyByFloats(x: number, y: number, z: number): Vector3;
  64105. /**
  64106. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  64107. * @param otherVector defines the second operand
  64108. * @returns the new Vector3
  64109. */
  64110. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  64111. /**
  64112. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  64113. * @param otherVector defines the second operand
  64114. * @param result defines the Vector3 object where to store the result
  64115. * @returns the current Vector3
  64116. */
  64117. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64118. /**
  64119. * Divides the current Vector3 coordinates by the given ones.
  64120. * @param otherVector defines the second operand
  64121. * @returns the current updated Vector3
  64122. */
  64123. divideInPlace(otherVector: Vector3): Vector3;
  64124. /**
  64125. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  64126. * @param other defines the second operand
  64127. * @returns the current updated Vector3
  64128. */
  64129. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64130. /**
  64131. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  64132. * @param other defines the second operand
  64133. * @returns the current updated Vector3
  64134. */
  64135. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64136. /**
  64137. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  64138. * @param x defines the x coordinate of the operand
  64139. * @param y defines the y coordinate of the operand
  64140. * @param z defines the z coordinate of the operand
  64141. * @returns the current updated Vector3
  64142. */
  64143. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64144. /**
  64145. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  64146. * @param x defines the x coordinate of the operand
  64147. * @param y defines the y coordinate of the operand
  64148. * @param z defines the z coordinate of the operand
  64149. * @returns the current updated Vector3
  64150. */
  64151. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64152. /**
  64153. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  64154. * Check if is non uniform within a certain amount of decimal places to account for this
  64155. * @param epsilon the amount the values can differ
  64156. * @returns if the the vector is non uniform to a certain number of decimal places
  64157. */
  64158. isNonUniformWithinEpsilon(epsilon: number): boolean;
  64159. /**
  64160. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  64161. */
  64162. readonly isNonUniform: boolean;
  64163. /**
  64164. * Gets a new Vector3 from current Vector3 floored values
  64165. * @returns a new Vector3
  64166. */
  64167. floor(): Vector3;
  64168. /**
  64169. * Gets a new Vector3 from current Vector3 floored values
  64170. * @returns a new Vector3
  64171. */
  64172. fract(): Vector3;
  64173. /**
  64174. * Gets the length of the Vector3
  64175. * @returns the length of the Vector3
  64176. */
  64177. length(): number;
  64178. /**
  64179. * Gets the squared length of the Vector3
  64180. * @returns squared length of the Vector3
  64181. */
  64182. lengthSquared(): number;
  64183. /**
  64184. * Normalize the current Vector3.
  64185. * Please note that this is an in place operation.
  64186. * @returns the current updated Vector3
  64187. */
  64188. normalize(): Vector3;
  64189. /**
  64190. * Reorders the x y z properties of the vector in place
  64191. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  64192. * @returns the current updated vector
  64193. */
  64194. reorderInPlace(order: string): this;
  64195. /**
  64196. * Rotates the vector around 0,0,0 by a quaternion
  64197. * @param quaternion the rotation quaternion
  64198. * @param result vector to store the result
  64199. * @returns the resulting vector
  64200. */
  64201. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  64202. /**
  64203. * Rotates a vector around a given point
  64204. * @param quaternion the rotation quaternion
  64205. * @param point the point to rotate around
  64206. * @param result vector to store the result
  64207. * @returns the resulting vector
  64208. */
  64209. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  64210. /**
  64211. * Normalize the current Vector3 with the given input length.
  64212. * Please note that this is an in place operation.
  64213. * @param len the length of the vector
  64214. * @returns the current updated Vector3
  64215. */
  64216. normalizeFromLength(len: number): Vector3;
  64217. /**
  64218. * Normalize the current Vector3 to a new vector
  64219. * @returns the new Vector3
  64220. */
  64221. normalizeToNew(): Vector3;
  64222. /**
  64223. * Normalize the current Vector3 to the reference
  64224. * @param reference define the Vector3 to update
  64225. * @returns the updated Vector3
  64226. */
  64227. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  64228. /**
  64229. * Creates a new Vector3 copied from the current Vector3
  64230. * @returns the new Vector3
  64231. */
  64232. clone(): Vector3;
  64233. /**
  64234. * Copies the given vector coordinates to the current Vector3 ones
  64235. * @param source defines the source Vector3
  64236. * @returns the current updated Vector3
  64237. */
  64238. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  64239. /**
  64240. * Copies the given floats to the current Vector3 coordinates
  64241. * @param x defines the x coordinate of the operand
  64242. * @param y defines the y coordinate of the operand
  64243. * @param z defines the z coordinate of the operand
  64244. * @returns the current updated Vector3
  64245. */
  64246. copyFromFloats(x: number, y: number, z: number): Vector3;
  64247. /**
  64248. * Copies the given floats to the current Vector3 coordinates
  64249. * @param x defines the x coordinate of the operand
  64250. * @param y defines the y coordinate of the operand
  64251. * @param z defines the z coordinate of the operand
  64252. * @returns the current updated Vector3
  64253. */
  64254. set(x: number, y: number, z: number): Vector3;
  64255. /**
  64256. * Copies the given float to the current Vector3 coordinates
  64257. * @param v defines the x, y and z coordinates of the operand
  64258. * @returns the current updated Vector3
  64259. */
  64260. setAll(v: number): Vector3;
  64261. /**
  64262. * Get the clip factor between two vectors
  64263. * @param vector0 defines the first operand
  64264. * @param vector1 defines the second operand
  64265. * @param axis defines the axis to use
  64266. * @param size defines the size along the axis
  64267. * @returns the clip factor
  64268. */
  64269. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  64270. /**
  64271. * Get angle between two vectors
  64272. * @param vector0 angle between vector0 and vector1
  64273. * @param vector1 angle between vector0 and vector1
  64274. * @param normal direction of the normal
  64275. * @return the angle between vector0 and vector1
  64276. */
  64277. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  64278. /**
  64279. * Returns a new Vector3 set from the index "offset" of the given array
  64280. * @param array defines the source array
  64281. * @param offset defines the offset in the source array
  64282. * @returns the new Vector3
  64283. */
  64284. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  64285. /**
  64286. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  64287. * This function is deprecated. Use FromArray instead
  64288. * @param array defines the source array
  64289. * @param offset defines the offset in the source array
  64290. * @returns the new Vector3
  64291. */
  64292. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  64293. /**
  64294. * Sets the given vector "result" with the element values from the index "offset" of the given array
  64295. * @param array defines the source array
  64296. * @param offset defines the offset in the source array
  64297. * @param result defines the Vector3 where to store the result
  64298. */
  64299. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  64300. /**
  64301. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  64302. * This function is deprecated. Use FromArrayToRef instead.
  64303. * @param array defines the source array
  64304. * @param offset defines the offset in the source array
  64305. * @param result defines the Vector3 where to store the result
  64306. */
  64307. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  64308. /**
  64309. * Sets the given vector "result" with the given floats.
  64310. * @param x defines the x coordinate of the source
  64311. * @param y defines the y coordinate of the source
  64312. * @param z defines the z coordinate of the source
  64313. * @param result defines the Vector3 where to store the result
  64314. */
  64315. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  64316. /**
  64317. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  64318. * @returns a new empty Vector3
  64319. */
  64320. static Zero(): Vector3;
  64321. /**
  64322. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  64323. * @returns a new unit Vector3
  64324. */
  64325. static One(): Vector3;
  64326. /**
  64327. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  64328. * @returns a new up Vector3
  64329. */
  64330. static Up(): Vector3;
  64331. /**
  64332. * Gets a up Vector3 that must not be updated
  64333. */
  64334. static readonly UpReadOnly: DeepImmutable<Vector3>;
  64335. /**
  64336. * Gets a zero Vector3 that must not be updated
  64337. */
  64338. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  64339. /**
  64340. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  64341. * @returns a new down Vector3
  64342. */
  64343. static Down(): Vector3;
  64344. /**
  64345. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64346. * @returns a new forward Vector3
  64347. */
  64348. static Forward(): Vector3;
  64349. /**
  64350. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64351. * @returns a new forward Vector3
  64352. */
  64353. static Backward(): Vector3;
  64354. /**
  64355. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64356. * @returns a new right Vector3
  64357. */
  64358. static Right(): Vector3;
  64359. /**
  64360. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64361. * @returns a new left Vector3
  64362. */
  64363. static Left(): Vector3;
  64364. /**
  64365. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64366. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64367. * @param vector defines the Vector3 to transform
  64368. * @param transformation defines the transformation matrix
  64369. * @returns the transformed Vector3
  64370. */
  64371. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64372. /**
  64373. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64374. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64375. * @param vector defines the Vector3 to transform
  64376. * @param transformation defines the transformation matrix
  64377. * @param result defines the Vector3 where to store the result
  64378. */
  64379. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64380. /**
  64381. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64382. * This method computes tranformed coordinates only, not transformed direction vectors
  64383. * @param x define the x coordinate of the source vector
  64384. * @param y define the y coordinate of the source vector
  64385. * @param z define the z coordinate of the source vector
  64386. * @param transformation defines the transformation matrix
  64387. * @param result defines the Vector3 where to store the result
  64388. */
  64389. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64390. /**
  64391. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64392. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64393. * @param vector defines the Vector3 to transform
  64394. * @param transformation defines the transformation matrix
  64395. * @returns the new Vector3
  64396. */
  64397. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64398. /**
  64399. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64400. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64401. * @param vector defines the Vector3 to transform
  64402. * @param transformation defines the transformation matrix
  64403. * @param result defines the Vector3 where to store the result
  64404. */
  64405. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64406. /**
  64407. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64408. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64409. * @param x define the x coordinate of the source vector
  64410. * @param y define the y coordinate of the source vector
  64411. * @param z define the z coordinate of the source vector
  64412. * @param transformation defines the transformation matrix
  64413. * @param result defines the Vector3 where to store the result
  64414. */
  64415. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64416. /**
  64417. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64418. * @param value1 defines the first control point
  64419. * @param value2 defines the second control point
  64420. * @param value3 defines the third control point
  64421. * @param value4 defines the fourth control point
  64422. * @param amount defines the amount on the spline to use
  64423. * @returns the new Vector3
  64424. */
  64425. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64426. /**
  64427. * 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"
  64428. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64429. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64430. * @param value defines the current value
  64431. * @param min defines the lower range value
  64432. * @param max defines the upper range value
  64433. * @returns the new Vector3
  64434. */
  64435. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64436. /**
  64437. * 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"
  64438. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64439. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64440. * @param value defines the current value
  64441. * @param min defines the lower range value
  64442. * @param max defines the upper range value
  64443. * @param result defines the Vector3 where to store the result
  64444. */
  64445. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64446. /**
  64447. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64448. * @param value1 defines the first control point
  64449. * @param tangent1 defines the first tangent vector
  64450. * @param value2 defines the second control point
  64451. * @param tangent2 defines the second tangent vector
  64452. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64453. * @returns the new Vector3
  64454. */
  64455. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64456. /**
  64457. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64458. * @param start defines the start value
  64459. * @param end defines the end value
  64460. * @param amount max defines amount between both (between 0 and 1)
  64461. * @returns the new Vector3
  64462. */
  64463. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64464. /**
  64465. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64466. * @param start defines the start value
  64467. * @param end defines the end value
  64468. * @param amount max defines amount between both (between 0 and 1)
  64469. * @param result defines the Vector3 where to store the result
  64470. */
  64471. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64472. /**
  64473. * Returns the dot product (float) between the vectors "left" and "right"
  64474. * @param left defines the left operand
  64475. * @param right defines the right operand
  64476. * @returns the dot product
  64477. */
  64478. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64479. /**
  64480. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64481. * The cross product is then orthogonal to both "left" and "right"
  64482. * @param left defines the left operand
  64483. * @param right defines the right operand
  64484. * @returns the cross product
  64485. */
  64486. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64487. /**
  64488. * Sets the given vector "result" with the cross product of "left" and "right"
  64489. * The cross product is then orthogonal to both "left" and "right"
  64490. * @param left defines the left operand
  64491. * @param right defines the right operand
  64492. * @param result defines the Vector3 where to store the result
  64493. */
  64494. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64495. /**
  64496. * Returns a new Vector3 as the normalization of the given vector
  64497. * @param vector defines the Vector3 to normalize
  64498. * @returns the new Vector3
  64499. */
  64500. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64501. /**
  64502. * Sets the given vector "result" with the normalization of the given first vector
  64503. * @param vector defines the Vector3 to normalize
  64504. * @param result defines the Vector3 where to store the result
  64505. */
  64506. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64507. /**
  64508. * Project a Vector3 onto screen space
  64509. * @param vector defines the Vector3 to project
  64510. * @param world defines the world matrix to use
  64511. * @param transform defines the transform (view x projection) matrix to use
  64512. * @param viewport defines the screen viewport to use
  64513. * @returns the new Vector3
  64514. */
  64515. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64516. /** @hidden */
  64517. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64518. /**
  64519. * Unproject from screen space to object space
  64520. * @param source defines the screen space Vector3 to use
  64521. * @param viewportWidth defines the current width of the viewport
  64522. * @param viewportHeight defines the current height of the viewport
  64523. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64524. * @param transform defines the transform (view x projection) matrix to use
  64525. * @returns the new Vector3
  64526. */
  64527. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64528. /**
  64529. * Unproject from screen space to object space
  64530. * @param source defines the screen space Vector3 to use
  64531. * @param viewportWidth defines the current width of the viewport
  64532. * @param viewportHeight defines the current height of the viewport
  64533. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64534. * @param view defines the view matrix to use
  64535. * @param projection defines the projection matrix to use
  64536. * @returns the new Vector3
  64537. */
  64538. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64539. /**
  64540. * Unproject from screen space to object space
  64541. * @param source defines the screen space Vector3 to use
  64542. * @param viewportWidth defines the current width of the viewport
  64543. * @param viewportHeight defines the current height of the viewport
  64544. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64545. * @param view defines the view matrix to use
  64546. * @param projection defines the projection matrix to use
  64547. * @param result defines the Vector3 where to store the result
  64548. */
  64549. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64550. /**
  64551. * Unproject from screen space to object space
  64552. * @param sourceX defines the screen space x coordinate to use
  64553. * @param sourceY defines the screen space y coordinate to use
  64554. * @param sourceZ defines the screen space z coordinate to use
  64555. * @param viewportWidth defines the current width of the viewport
  64556. * @param viewportHeight defines the current height of the viewport
  64557. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64558. * @param view defines the view matrix to use
  64559. * @param projection defines the projection matrix to use
  64560. * @param result defines the Vector3 where to store the result
  64561. */
  64562. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64563. /**
  64564. * Gets the minimal coordinate values between two Vector3
  64565. * @param left defines the first operand
  64566. * @param right defines the second operand
  64567. * @returns the new Vector3
  64568. */
  64569. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64570. /**
  64571. * Gets the maximal coordinate values between two Vector3
  64572. * @param left defines the first operand
  64573. * @param right defines the second operand
  64574. * @returns the new Vector3
  64575. */
  64576. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64577. /**
  64578. * Returns the distance between the vectors "value1" and "value2"
  64579. * @param value1 defines the first operand
  64580. * @param value2 defines the second operand
  64581. * @returns the distance
  64582. */
  64583. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64584. /**
  64585. * Returns the squared distance between the vectors "value1" and "value2"
  64586. * @param value1 defines the first operand
  64587. * @param value2 defines the second operand
  64588. * @returns the squared distance
  64589. */
  64590. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64591. /**
  64592. * Returns a new Vector3 located at the center between "value1" and "value2"
  64593. * @param value1 defines the first operand
  64594. * @param value2 defines the second operand
  64595. * @returns the new Vector3
  64596. */
  64597. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64598. /**
  64599. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64600. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64601. * to something in order to rotate it from its local system to the given target system
  64602. * Note: axis1, axis2 and axis3 are normalized during this operation
  64603. * @param axis1 defines the first axis
  64604. * @param axis2 defines the second axis
  64605. * @param axis3 defines the third axis
  64606. * @returns a new Vector3
  64607. */
  64608. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64609. /**
  64610. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64611. * @param axis1 defines the first axis
  64612. * @param axis2 defines the second axis
  64613. * @param axis3 defines the third axis
  64614. * @param ref defines the Vector3 where to store the result
  64615. */
  64616. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64617. }
  64618. /**
  64619. * Vector4 class created for EulerAngle class conversion to Quaternion
  64620. */
  64621. export class Vector4 {
  64622. /** x value of the vector */
  64623. x: number;
  64624. /** y value of the vector */
  64625. y: number;
  64626. /** z value of the vector */
  64627. z: number;
  64628. /** w value of the vector */
  64629. w: number;
  64630. /**
  64631. * Creates a Vector4 object from the given floats.
  64632. * @param x x value of the vector
  64633. * @param y y value of the vector
  64634. * @param z z value of the vector
  64635. * @param w w value of the vector
  64636. */
  64637. constructor(
  64638. /** x value of the vector */
  64639. x: number,
  64640. /** y value of the vector */
  64641. y: number,
  64642. /** z value of the vector */
  64643. z: number,
  64644. /** w value of the vector */
  64645. w: number);
  64646. /**
  64647. * Returns the string with the Vector4 coordinates.
  64648. * @returns a string containing all the vector values
  64649. */
  64650. toString(): string;
  64651. /**
  64652. * Returns the string "Vector4".
  64653. * @returns "Vector4"
  64654. */
  64655. getClassName(): string;
  64656. /**
  64657. * Returns the Vector4 hash code.
  64658. * @returns a unique hash code
  64659. */
  64660. getHashCode(): number;
  64661. /**
  64662. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64663. * @returns the resulting array
  64664. */
  64665. asArray(): number[];
  64666. /**
  64667. * Populates the given array from the given index with the Vector4 coordinates.
  64668. * @param array array to populate
  64669. * @param index index of the array to start at (default: 0)
  64670. * @returns the Vector4.
  64671. */
  64672. toArray(array: FloatArray, index?: number): Vector4;
  64673. /**
  64674. * Adds the given vector to the current Vector4.
  64675. * @param otherVector the vector to add
  64676. * @returns the updated Vector4.
  64677. */
  64678. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64679. /**
  64680. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64681. * @param otherVector the vector to add
  64682. * @returns the resulting vector
  64683. */
  64684. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64685. /**
  64686. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64687. * @param otherVector the vector to add
  64688. * @param result the vector to store the result
  64689. * @returns the current Vector4.
  64690. */
  64691. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64692. /**
  64693. * Subtract in place the given vector from the current Vector4.
  64694. * @param otherVector the vector to subtract
  64695. * @returns the updated Vector4.
  64696. */
  64697. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64698. /**
  64699. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64700. * @param otherVector the vector to add
  64701. * @returns the new vector with the result
  64702. */
  64703. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64704. /**
  64705. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64706. * @param otherVector the vector to subtract
  64707. * @param result the vector to store the result
  64708. * @returns the current Vector4.
  64709. */
  64710. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64711. /**
  64712. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64713. */
  64714. /**
  64715. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64716. * @param x value to subtract
  64717. * @param y value to subtract
  64718. * @param z value to subtract
  64719. * @param w value to subtract
  64720. * @returns new vector containing the result
  64721. */
  64722. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64723. /**
  64724. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64725. * @param x value to subtract
  64726. * @param y value to subtract
  64727. * @param z value to subtract
  64728. * @param w value to subtract
  64729. * @param result the vector to store the result in
  64730. * @returns the current Vector4.
  64731. */
  64732. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64733. /**
  64734. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64735. * @returns a new vector with the negated values
  64736. */
  64737. negate(): Vector4;
  64738. /**
  64739. * Multiplies the current Vector4 coordinates by scale (float).
  64740. * @param scale the number to scale with
  64741. * @returns the updated Vector4.
  64742. */
  64743. scaleInPlace(scale: number): Vector4;
  64744. /**
  64745. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  64746. * @param scale the number to scale with
  64747. * @returns a new vector with the result
  64748. */
  64749. scale(scale: number): Vector4;
  64750. /**
  64751. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  64752. * @param scale the number to scale with
  64753. * @param result a vector to store the result in
  64754. * @returns the current Vector4.
  64755. */
  64756. scaleToRef(scale: number, result: Vector4): Vector4;
  64757. /**
  64758. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  64759. * @param scale defines the scale factor
  64760. * @param result defines the Vector4 object where to store the result
  64761. * @returns the unmodified current Vector4
  64762. */
  64763. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  64764. /**
  64765. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  64766. * @param otherVector the vector to compare against
  64767. * @returns true if they are equal
  64768. */
  64769. equals(otherVector: DeepImmutable<Vector4>): boolean;
  64770. /**
  64771. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  64772. * @param otherVector vector to compare against
  64773. * @param epsilon (Default: very small number)
  64774. * @returns true if they are equal
  64775. */
  64776. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  64777. /**
  64778. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  64779. * @param x x value to compare against
  64780. * @param y y value to compare against
  64781. * @param z z value to compare against
  64782. * @param w w value to compare against
  64783. * @returns true if equal
  64784. */
  64785. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  64786. /**
  64787. * Multiplies in place the current Vector4 by the given one.
  64788. * @param otherVector vector to multiple with
  64789. * @returns the updated Vector4.
  64790. */
  64791. multiplyInPlace(otherVector: Vector4): Vector4;
  64792. /**
  64793. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  64794. * @param otherVector vector to multiple with
  64795. * @returns resulting new vector
  64796. */
  64797. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  64798. /**
  64799. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  64800. * @param otherVector vector to multiple with
  64801. * @param result vector to store the result
  64802. * @returns the current Vector4.
  64803. */
  64804. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64805. /**
  64806. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  64807. * @param x x value multiply with
  64808. * @param y y value multiply with
  64809. * @param z z value multiply with
  64810. * @param w w value multiply with
  64811. * @returns resulting new vector
  64812. */
  64813. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  64814. /**
  64815. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  64816. * @param otherVector vector to devide with
  64817. * @returns resulting new vector
  64818. */
  64819. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  64820. /**
  64821. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  64822. * @param otherVector vector to devide with
  64823. * @param result vector to store the result
  64824. * @returns the current Vector4.
  64825. */
  64826. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64827. /**
  64828. * Divides the current Vector3 coordinates by the given ones.
  64829. * @param otherVector vector to devide with
  64830. * @returns the updated Vector3.
  64831. */
  64832. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64833. /**
  64834. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  64835. * @param other defines the second operand
  64836. * @returns the current updated Vector4
  64837. */
  64838. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64839. /**
  64840. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  64841. * @param other defines the second operand
  64842. * @returns the current updated Vector4
  64843. */
  64844. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64845. /**
  64846. * Gets a new Vector4 from current Vector4 floored values
  64847. * @returns a new Vector4
  64848. */
  64849. floor(): Vector4;
  64850. /**
  64851. * Gets a new Vector4 from current Vector3 floored values
  64852. * @returns a new Vector4
  64853. */
  64854. fract(): Vector4;
  64855. /**
  64856. * Returns the Vector4 length (float).
  64857. * @returns the length
  64858. */
  64859. length(): number;
  64860. /**
  64861. * Returns the Vector4 squared length (float).
  64862. * @returns the length squared
  64863. */
  64864. lengthSquared(): number;
  64865. /**
  64866. * Normalizes in place the Vector4.
  64867. * @returns the updated Vector4.
  64868. */
  64869. normalize(): Vector4;
  64870. /**
  64871. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  64872. * @returns this converted to a new vector3
  64873. */
  64874. toVector3(): Vector3;
  64875. /**
  64876. * Returns a new Vector4 copied from the current one.
  64877. * @returns the new cloned vector
  64878. */
  64879. clone(): Vector4;
  64880. /**
  64881. * Updates the current Vector4 with the given one coordinates.
  64882. * @param source the source vector to copy from
  64883. * @returns the updated Vector4.
  64884. */
  64885. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  64886. /**
  64887. * Updates the current Vector4 coordinates with the given floats.
  64888. * @param x float to copy from
  64889. * @param y float to copy from
  64890. * @param z float to copy from
  64891. * @param w float to copy from
  64892. * @returns the updated Vector4.
  64893. */
  64894. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64895. /**
  64896. * Updates the current Vector4 coordinates with the given floats.
  64897. * @param x float to set from
  64898. * @param y float to set from
  64899. * @param z float to set from
  64900. * @param w float to set from
  64901. * @returns the updated Vector4.
  64902. */
  64903. set(x: number, y: number, z: number, w: number): Vector4;
  64904. /**
  64905. * Copies the given float to the current Vector3 coordinates
  64906. * @param v defines the x, y, z and w coordinates of the operand
  64907. * @returns the current updated Vector3
  64908. */
  64909. setAll(v: number): Vector4;
  64910. /**
  64911. * Returns a new Vector4 set from the starting index of the given array.
  64912. * @param array the array to pull values from
  64913. * @param offset the offset into the array to start at
  64914. * @returns the new vector
  64915. */
  64916. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  64917. /**
  64918. * Updates the given vector "result" from the starting index of the given array.
  64919. * @param array the array to pull values from
  64920. * @param offset the offset into the array to start at
  64921. * @param result the vector to store the result in
  64922. */
  64923. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  64924. /**
  64925. * Updates the given vector "result" from the starting index of the given Float32Array.
  64926. * @param array the array to pull values from
  64927. * @param offset the offset into the array to start at
  64928. * @param result the vector to store the result in
  64929. */
  64930. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  64931. /**
  64932. * Updates the given vector "result" coordinates from the given floats.
  64933. * @param x float to set from
  64934. * @param y float to set from
  64935. * @param z float to set from
  64936. * @param w float to set from
  64937. * @param result the vector to the floats in
  64938. */
  64939. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  64940. /**
  64941. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  64942. * @returns the new vector
  64943. */
  64944. static Zero(): Vector4;
  64945. /**
  64946. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  64947. * @returns the new vector
  64948. */
  64949. static One(): Vector4;
  64950. /**
  64951. * Returns a new normalized Vector4 from the given one.
  64952. * @param vector the vector to normalize
  64953. * @returns the vector
  64954. */
  64955. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  64956. /**
  64957. * Updates the given vector "result" from the normalization of the given one.
  64958. * @param vector the vector to normalize
  64959. * @param result the vector to store the result in
  64960. */
  64961. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  64962. /**
  64963. * Returns a vector with the minimum values from the left and right vectors
  64964. * @param left left vector to minimize
  64965. * @param right right vector to minimize
  64966. * @returns a new vector with the minimum of the left and right vector values
  64967. */
  64968. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64969. /**
  64970. * Returns a vector with the maximum values from the left and right vectors
  64971. * @param left left vector to maximize
  64972. * @param right right vector to maximize
  64973. * @returns a new vector with the maximum of the left and right vector values
  64974. */
  64975. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64976. /**
  64977. * Returns the distance (float) between the vectors "value1" and "value2".
  64978. * @param value1 value to calulate the distance between
  64979. * @param value2 value to calulate the distance between
  64980. * @return the distance between the two vectors
  64981. */
  64982. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64983. /**
  64984. * Returns the squared distance (float) between the vectors "value1" and "value2".
  64985. * @param value1 value to calulate the distance between
  64986. * @param value2 value to calulate the distance between
  64987. * @return the distance between the two vectors squared
  64988. */
  64989. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64990. /**
  64991. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  64992. * @param value1 value to calulate the center between
  64993. * @param value2 value to calulate the center between
  64994. * @return the center between the two vectors
  64995. */
  64996. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  64997. /**
  64998. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  64999. * This methods computes transformed normalized direction vectors only.
  65000. * @param vector the vector to transform
  65001. * @param transformation the transformation matrix to apply
  65002. * @returns the new vector
  65003. */
  65004. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  65005. /**
  65006. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  65007. * This methods computes transformed normalized direction vectors only.
  65008. * @param vector the vector to transform
  65009. * @param transformation the transformation matrix to apply
  65010. * @param result the vector to store the result in
  65011. */
  65012. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  65013. /**
  65014. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  65015. * This methods computes transformed normalized direction vectors only.
  65016. * @param x value to transform
  65017. * @param y value to transform
  65018. * @param z value to transform
  65019. * @param w value to transform
  65020. * @param transformation the transformation matrix to apply
  65021. * @param result the vector to store the results in
  65022. */
  65023. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  65024. /**
  65025. * Creates a new Vector4 from a Vector3
  65026. * @param source defines the source data
  65027. * @param w defines the 4th component (default is 0)
  65028. * @returns a new Vector4
  65029. */
  65030. static FromVector3(source: Vector3, w?: number): Vector4;
  65031. }
  65032. /**
  65033. * Interface for the size containing width and height
  65034. */
  65035. export interface ISize {
  65036. /**
  65037. * Width
  65038. */
  65039. width: number;
  65040. /**
  65041. * Heighht
  65042. */
  65043. height: number;
  65044. }
  65045. /**
  65046. * Size containing widht and height
  65047. */
  65048. export class Size implements ISize {
  65049. /**
  65050. * Width
  65051. */
  65052. width: number;
  65053. /**
  65054. * Height
  65055. */
  65056. height: number;
  65057. /**
  65058. * Creates a Size object from the given width and height (floats).
  65059. * @param width width of the new size
  65060. * @param height height of the new size
  65061. */
  65062. constructor(width: number, height: number);
  65063. /**
  65064. * Returns a string with the Size width and height
  65065. * @returns a string with the Size width and height
  65066. */
  65067. toString(): string;
  65068. /**
  65069. * "Size"
  65070. * @returns the string "Size"
  65071. */
  65072. getClassName(): string;
  65073. /**
  65074. * Returns the Size hash code.
  65075. * @returns a hash code for a unique width and height
  65076. */
  65077. getHashCode(): number;
  65078. /**
  65079. * Updates the current size from the given one.
  65080. * @param src the given size
  65081. */
  65082. copyFrom(src: Size): void;
  65083. /**
  65084. * Updates in place the current Size from the given floats.
  65085. * @param width width of the new size
  65086. * @param height height of the new size
  65087. * @returns the updated Size.
  65088. */
  65089. copyFromFloats(width: number, height: number): Size;
  65090. /**
  65091. * Updates in place the current Size from the given floats.
  65092. * @param width width to set
  65093. * @param height height to set
  65094. * @returns the updated Size.
  65095. */
  65096. set(width: number, height: number): Size;
  65097. /**
  65098. * Multiplies the width and height by numbers
  65099. * @param w factor to multiple the width by
  65100. * @param h factor to multiple the height by
  65101. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  65102. */
  65103. multiplyByFloats(w: number, h: number): Size;
  65104. /**
  65105. * Clones the size
  65106. * @returns a new Size copied from the given one.
  65107. */
  65108. clone(): Size;
  65109. /**
  65110. * True if the current Size and the given one width and height are strictly equal.
  65111. * @param other the other size to compare against
  65112. * @returns True if the current Size and the given one width and height are strictly equal.
  65113. */
  65114. equals(other: Size): boolean;
  65115. /**
  65116. * The surface of the Size : width * height (float).
  65117. */
  65118. readonly surface: number;
  65119. /**
  65120. * Create a new size of zero
  65121. * @returns a new Size set to (0.0, 0.0)
  65122. */
  65123. static Zero(): Size;
  65124. /**
  65125. * Sums the width and height of two sizes
  65126. * @param otherSize size to add to this size
  65127. * @returns a new Size set as the addition result of the current Size and the given one.
  65128. */
  65129. add(otherSize: Size): Size;
  65130. /**
  65131. * Subtracts the width and height of two
  65132. * @param otherSize size to subtract to this size
  65133. * @returns a new Size set as the subtraction result of the given one from the current Size.
  65134. */
  65135. subtract(otherSize: Size): Size;
  65136. /**
  65137. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  65138. * @param start starting size to lerp between
  65139. * @param end end size to lerp between
  65140. * @param amount amount to lerp between the start and end values
  65141. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  65142. */
  65143. static Lerp(start: Size, end: Size, amount: number): Size;
  65144. }
  65145. /**
  65146. * Class used to store quaternion data
  65147. * @see https://en.wikipedia.org/wiki/Quaternion
  65148. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  65149. */
  65150. export class Quaternion {
  65151. /** defines the first component (0 by default) */
  65152. x: number;
  65153. /** defines the second component (0 by default) */
  65154. y: number;
  65155. /** defines the third component (0 by default) */
  65156. z: number;
  65157. /** defines the fourth component (1.0 by default) */
  65158. w: number;
  65159. /**
  65160. * Creates a new Quaternion from the given floats
  65161. * @param x defines the first component (0 by default)
  65162. * @param y defines the second component (0 by default)
  65163. * @param z defines the third component (0 by default)
  65164. * @param w defines the fourth component (1.0 by default)
  65165. */
  65166. constructor(
  65167. /** defines the first component (0 by default) */
  65168. x?: number,
  65169. /** defines the second component (0 by default) */
  65170. y?: number,
  65171. /** defines the third component (0 by default) */
  65172. z?: number,
  65173. /** defines the fourth component (1.0 by default) */
  65174. w?: number);
  65175. /**
  65176. * Gets a string representation for the current quaternion
  65177. * @returns a string with the Quaternion coordinates
  65178. */
  65179. toString(): string;
  65180. /**
  65181. * Gets the class name of the quaternion
  65182. * @returns the string "Quaternion"
  65183. */
  65184. getClassName(): string;
  65185. /**
  65186. * Gets a hash code for this quaternion
  65187. * @returns the quaternion hash code
  65188. */
  65189. getHashCode(): number;
  65190. /**
  65191. * Copy the quaternion to an array
  65192. * @returns a new array populated with 4 elements from the quaternion coordinates
  65193. */
  65194. asArray(): number[];
  65195. /**
  65196. * Check if two quaternions are equals
  65197. * @param otherQuaternion defines the second operand
  65198. * @return true if the current quaternion and the given one coordinates are strictly equals
  65199. */
  65200. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  65201. /**
  65202. * Clone the current quaternion
  65203. * @returns a new quaternion copied from the current one
  65204. */
  65205. clone(): Quaternion;
  65206. /**
  65207. * Copy a quaternion to the current one
  65208. * @param other defines the other quaternion
  65209. * @returns the updated current quaternion
  65210. */
  65211. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  65212. /**
  65213. * Updates the current quaternion with the given float coordinates
  65214. * @param x defines the x coordinate
  65215. * @param y defines the y coordinate
  65216. * @param z defines the z coordinate
  65217. * @param w defines the w coordinate
  65218. * @returns the updated current quaternion
  65219. */
  65220. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  65221. /**
  65222. * Updates the current quaternion from the given float coordinates
  65223. * @param x defines the x coordinate
  65224. * @param y defines the y coordinate
  65225. * @param z defines the z coordinate
  65226. * @param w defines the w coordinate
  65227. * @returns the updated current quaternion
  65228. */
  65229. set(x: number, y: number, z: number, w: number): Quaternion;
  65230. /**
  65231. * Adds two quaternions
  65232. * @param other defines the second operand
  65233. * @returns a new quaternion as the addition result of the given one and the current quaternion
  65234. */
  65235. add(other: DeepImmutable<Quaternion>): Quaternion;
  65236. /**
  65237. * Add a quaternion to the current one
  65238. * @param other defines the quaternion to add
  65239. * @returns the current quaternion
  65240. */
  65241. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  65242. /**
  65243. * Subtract two quaternions
  65244. * @param other defines the second operand
  65245. * @returns a new quaternion as the subtraction result of the given one from the current one
  65246. */
  65247. subtract(other: Quaternion): Quaternion;
  65248. /**
  65249. * Multiplies the current quaternion by a scale factor
  65250. * @param value defines the scale factor
  65251. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  65252. */
  65253. scale(value: number): Quaternion;
  65254. /**
  65255. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  65256. * @param scale defines the scale factor
  65257. * @param result defines the Quaternion object where to store the result
  65258. * @returns the unmodified current quaternion
  65259. */
  65260. scaleToRef(scale: number, result: Quaternion): Quaternion;
  65261. /**
  65262. * Multiplies in place the current quaternion by a scale factor
  65263. * @param value defines the scale factor
  65264. * @returns the current modified quaternion
  65265. */
  65266. scaleInPlace(value: number): Quaternion;
  65267. /**
  65268. * Scale the current quaternion values by a factor and add the result to a given quaternion
  65269. * @param scale defines the scale factor
  65270. * @param result defines the Quaternion object where to store the result
  65271. * @returns the unmodified current quaternion
  65272. */
  65273. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  65274. /**
  65275. * Multiplies two quaternions
  65276. * @param q1 defines the second operand
  65277. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  65278. */
  65279. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  65280. /**
  65281. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  65282. * @param q1 defines the second operand
  65283. * @param result defines the target quaternion
  65284. * @returns the current quaternion
  65285. */
  65286. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  65287. /**
  65288. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  65289. * @param q1 defines the second operand
  65290. * @returns the currentupdated quaternion
  65291. */
  65292. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  65293. /**
  65294. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  65295. * @param ref defines the target quaternion
  65296. * @returns the current quaternion
  65297. */
  65298. conjugateToRef(ref: Quaternion): Quaternion;
  65299. /**
  65300. * Conjugates in place (1-q) the current quaternion
  65301. * @returns the current updated quaternion
  65302. */
  65303. conjugateInPlace(): Quaternion;
  65304. /**
  65305. * Conjugates in place (1-q) the current quaternion
  65306. * @returns a new quaternion
  65307. */
  65308. conjugate(): Quaternion;
  65309. /**
  65310. * Gets length of current quaternion
  65311. * @returns the quaternion length (float)
  65312. */
  65313. length(): number;
  65314. /**
  65315. * Normalize in place the current quaternion
  65316. * @returns the current updated quaternion
  65317. */
  65318. normalize(): Quaternion;
  65319. /**
  65320. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  65321. * @param order is a reserved parameter and is ignore for now
  65322. * @returns a new Vector3 containing the Euler angles
  65323. */
  65324. toEulerAngles(order?: string): Vector3;
  65325. /**
  65326. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  65327. * @param result defines the vector which will be filled with the Euler angles
  65328. * @param order is a reserved parameter and is ignore for now
  65329. * @returns the current unchanged quaternion
  65330. */
  65331. toEulerAnglesToRef(result: Vector3): Quaternion;
  65332. /**
  65333. * Updates the given rotation matrix with the current quaternion values
  65334. * @param result defines the target matrix
  65335. * @returns the current unchanged quaternion
  65336. */
  65337. toRotationMatrix(result: Matrix): Quaternion;
  65338. /**
  65339. * Updates the current quaternion from the given rotation matrix values
  65340. * @param matrix defines the source matrix
  65341. * @returns the current updated quaternion
  65342. */
  65343. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65344. /**
  65345. * Creates a new quaternion from a rotation matrix
  65346. * @param matrix defines the source matrix
  65347. * @returns a new quaternion created from the given rotation matrix values
  65348. */
  65349. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65350. /**
  65351. * Updates the given quaternion with the given rotation matrix values
  65352. * @param matrix defines the source matrix
  65353. * @param result defines the target quaternion
  65354. */
  65355. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65356. /**
  65357. * Returns the dot product (float) between the quaternions "left" and "right"
  65358. * @param left defines the left operand
  65359. * @param right defines the right operand
  65360. * @returns the dot product
  65361. */
  65362. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65363. /**
  65364. * Checks if the two quaternions are close to each other
  65365. * @param quat0 defines the first quaternion to check
  65366. * @param quat1 defines the second quaternion to check
  65367. * @returns true if the two quaternions are close to each other
  65368. */
  65369. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65370. /**
  65371. * Creates an empty quaternion
  65372. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65373. */
  65374. static Zero(): Quaternion;
  65375. /**
  65376. * Inverse a given quaternion
  65377. * @param q defines the source quaternion
  65378. * @returns a new quaternion as the inverted current quaternion
  65379. */
  65380. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65381. /**
  65382. * Inverse a given quaternion
  65383. * @param q defines the source quaternion
  65384. * @param result the quaternion the result will be stored in
  65385. * @returns the result quaternion
  65386. */
  65387. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65388. /**
  65389. * Creates an identity quaternion
  65390. * @returns the identity quaternion
  65391. */
  65392. static Identity(): Quaternion;
  65393. /**
  65394. * Gets a boolean indicating if the given quaternion is identity
  65395. * @param quaternion defines the quaternion to check
  65396. * @returns true if the quaternion is identity
  65397. */
  65398. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65399. /**
  65400. * Creates a quaternion from a rotation around an axis
  65401. * @param axis defines the axis to use
  65402. * @param angle defines the angle to use
  65403. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65404. */
  65405. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65406. /**
  65407. * Creates a rotation around an axis and stores it into the given quaternion
  65408. * @param axis defines the axis to use
  65409. * @param angle defines the angle to use
  65410. * @param result defines the target quaternion
  65411. * @returns the target quaternion
  65412. */
  65413. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65414. /**
  65415. * Creates a new quaternion from data stored into an array
  65416. * @param array defines the data source
  65417. * @param offset defines the offset in the source array where the data starts
  65418. * @returns a new quaternion
  65419. */
  65420. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65421. /**
  65422. * Create a quaternion from Euler rotation angles
  65423. * @param x Pitch
  65424. * @param y Yaw
  65425. * @param z Roll
  65426. * @returns the new Quaternion
  65427. */
  65428. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65429. /**
  65430. * Updates a quaternion from Euler rotation angles
  65431. * @param x Pitch
  65432. * @param y Yaw
  65433. * @param z Roll
  65434. * @param result the quaternion to store the result
  65435. * @returns the updated quaternion
  65436. */
  65437. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65438. /**
  65439. * Create a quaternion from Euler rotation vector
  65440. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65441. * @returns the new Quaternion
  65442. */
  65443. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65444. /**
  65445. * Updates a quaternion from Euler rotation vector
  65446. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65447. * @param result the quaternion to store the result
  65448. * @returns the updated quaternion
  65449. */
  65450. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65451. /**
  65452. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65453. * @param yaw defines the rotation around Y axis
  65454. * @param pitch defines the rotation around X axis
  65455. * @param roll defines the rotation around Z axis
  65456. * @returns the new quaternion
  65457. */
  65458. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65459. /**
  65460. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65461. * @param yaw defines the rotation around Y axis
  65462. * @param pitch defines the rotation around X axis
  65463. * @param roll defines the rotation around Z axis
  65464. * @param result defines the target quaternion
  65465. */
  65466. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65467. /**
  65468. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65469. * @param alpha defines the rotation around first axis
  65470. * @param beta defines the rotation around second axis
  65471. * @param gamma defines the rotation around third axis
  65472. * @returns the new quaternion
  65473. */
  65474. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65475. /**
  65476. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65477. * @param alpha defines the rotation around first axis
  65478. * @param beta defines the rotation around second axis
  65479. * @param gamma defines the rotation around third axis
  65480. * @param result defines the target quaternion
  65481. */
  65482. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65483. /**
  65484. * 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)
  65485. * @param axis1 defines the first axis
  65486. * @param axis2 defines the second axis
  65487. * @param axis3 defines the third axis
  65488. * @returns the new quaternion
  65489. */
  65490. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65491. /**
  65492. * 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
  65493. * @param axis1 defines the first axis
  65494. * @param axis2 defines the second axis
  65495. * @param axis3 defines the third axis
  65496. * @param ref defines the target quaternion
  65497. */
  65498. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65499. /**
  65500. * Interpolates between two quaternions
  65501. * @param left defines first quaternion
  65502. * @param right defines second quaternion
  65503. * @param amount defines the gradient to use
  65504. * @returns the new interpolated quaternion
  65505. */
  65506. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65507. /**
  65508. * Interpolates between two quaternions and stores it into a target quaternion
  65509. * @param left defines first quaternion
  65510. * @param right defines second quaternion
  65511. * @param amount defines the gradient to use
  65512. * @param result defines the target quaternion
  65513. */
  65514. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65515. /**
  65516. * Interpolate between two quaternions using Hermite interpolation
  65517. * @param value1 defines first quaternion
  65518. * @param tangent1 defines the incoming tangent
  65519. * @param value2 defines second quaternion
  65520. * @param tangent2 defines the outgoing tangent
  65521. * @param amount defines the target quaternion
  65522. * @returns the new interpolated quaternion
  65523. */
  65524. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65525. }
  65526. /**
  65527. * Class used to store matrix data (4x4)
  65528. */
  65529. export class Matrix {
  65530. private static _updateFlagSeed;
  65531. private static _identityReadOnly;
  65532. private _isIdentity;
  65533. private _isIdentityDirty;
  65534. private _isIdentity3x2;
  65535. private _isIdentity3x2Dirty;
  65536. /**
  65537. * Gets the update flag of the matrix which is an unique number for the matrix.
  65538. * It will be incremented every time the matrix data change.
  65539. * You can use it to speed the comparison between two versions of the same matrix.
  65540. */
  65541. updateFlag: number;
  65542. private readonly _m;
  65543. /**
  65544. * Gets the internal data of the matrix
  65545. */
  65546. readonly m: DeepImmutable<Float32Array>;
  65547. /** @hidden */
  65548. _markAsUpdated(): void;
  65549. /** @hidden */
  65550. private _updateIdentityStatus;
  65551. /**
  65552. * Creates an empty matrix (filled with zeros)
  65553. */
  65554. constructor();
  65555. /**
  65556. * Check if the current matrix is identity
  65557. * @returns true is the matrix is the identity matrix
  65558. */
  65559. isIdentity(): boolean;
  65560. /**
  65561. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65562. * @returns true is the matrix is the identity matrix
  65563. */
  65564. isIdentityAs3x2(): boolean;
  65565. /**
  65566. * Gets the determinant of the matrix
  65567. * @returns the matrix determinant
  65568. */
  65569. determinant(): number;
  65570. /**
  65571. * Returns the matrix as a Float32Array
  65572. * @returns the matrix underlying array
  65573. */
  65574. toArray(): DeepImmutable<Float32Array>;
  65575. /**
  65576. * Returns the matrix as a Float32Array
  65577. * @returns the matrix underlying array.
  65578. */
  65579. asArray(): DeepImmutable<Float32Array>;
  65580. /**
  65581. * Inverts the current matrix in place
  65582. * @returns the current inverted matrix
  65583. */
  65584. invert(): Matrix;
  65585. /**
  65586. * Sets all the matrix elements to zero
  65587. * @returns the current matrix
  65588. */
  65589. reset(): Matrix;
  65590. /**
  65591. * Adds the current matrix with a second one
  65592. * @param other defines the matrix to add
  65593. * @returns a new matrix as the addition of the current matrix and the given one
  65594. */
  65595. add(other: DeepImmutable<Matrix>): Matrix;
  65596. /**
  65597. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65598. * @param other defines the matrix to add
  65599. * @param result defines the target matrix
  65600. * @returns the current matrix
  65601. */
  65602. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65603. /**
  65604. * Adds in place the given matrix to the current matrix
  65605. * @param other defines the second operand
  65606. * @returns the current updated matrix
  65607. */
  65608. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65609. /**
  65610. * Sets the given matrix to the current inverted Matrix
  65611. * @param other defines the target matrix
  65612. * @returns the unmodified current matrix
  65613. */
  65614. invertToRef(other: Matrix): Matrix;
  65615. /**
  65616. * add a value at the specified position in the current Matrix
  65617. * @param index the index of the value within the matrix. between 0 and 15.
  65618. * @param value the value to be added
  65619. * @returns the current updated matrix
  65620. */
  65621. addAtIndex(index: number, value: number): Matrix;
  65622. /**
  65623. * mutiply the specified position in the current Matrix by a value
  65624. * @param index the index of the value within the matrix. between 0 and 15.
  65625. * @param value the value to be added
  65626. * @returns the current updated matrix
  65627. */
  65628. multiplyAtIndex(index: number, value: number): Matrix;
  65629. /**
  65630. * Inserts the translation vector (using 3 floats) in the current matrix
  65631. * @param x defines the 1st component of the translation
  65632. * @param y defines the 2nd component of the translation
  65633. * @param z defines the 3rd component of the translation
  65634. * @returns the current updated matrix
  65635. */
  65636. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65637. /**
  65638. * Adds the translation vector (using 3 floats) in the current matrix
  65639. * @param x defines the 1st component of the translation
  65640. * @param y defines the 2nd component of the translation
  65641. * @param z defines the 3rd component of the translation
  65642. * @returns the current updated matrix
  65643. */
  65644. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65645. /**
  65646. * Inserts the translation vector in the current matrix
  65647. * @param vector3 defines the translation to insert
  65648. * @returns the current updated matrix
  65649. */
  65650. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65651. /**
  65652. * Gets the translation value of the current matrix
  65653. * @returns a new Vector3 as the extracted translation from the matrix
  65654. */
  65655. getTranslation(): Vector3;
  65656. /**
  65657. * Fill a Vector3 with the extracted translation from the matrix
  65658. * @param result defines the Vector3 where to store the translation
  65659. * @returns the current matrix
  65660. */
  65661. getTranslationToRef(result: Vector3): Matrix;
  65662. /**
  65663. * Remove rotation and scaling part from the matrix
  65664. * @returns the updated matrix
  65665. */
  65666. removeRotationAndScaling(): Matrix;
  65667. /**
  65668. * Multiply two matrices
  65669. * @param other defines the second operand
  65670. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65671. */
  65672. multiply(other: DeepImmutable<Matrix>): Matrix;
  65673. /**
  65674. * Copy the current matrix from the given one
  65675. * @param other defines the source matrix
  65676. * @returns the current updated matrix
  65677. */
  65678. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65679. /**
  65680. * Populates the given array from the starting index with the current matrix values
  65681. * @param array defines the target array
  65682. * @param offset defines the offset in the target array where to start storing values
  65683. * @returns the current matrix
  65684. */
  65685. copyToArray(array: Float32Array, offset?: number): Matrix;
  65686. /**
  65687. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65688. * @param other defines the second operand
  65689. * @param result defines the matrix where to store the multiplication
  65690. * @returns the current matrix
  65691. */
  65692. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65693. /**
  65694. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65695. * @param other defines the second operand
  65696. * @param result defines the array where to store the multiplication
  65697. * @param offset defines the offset in the target array where to start storing values
  65698. * @returns the current matrix
  65699. */
  65700. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65701. /**
  65702. * Check equality between this matrix and a second one
  65703. * @param value defines the second matrix to compare
  65704. * @returns true is the current matrix and the given one values are strictly equal
  65705. */
  65706. equals(value: DeepImmutable<Matrix>): boolean;
  65707. /**
  65708. * Clone the current matrix
  65709. * @returns a new matrix from the current matrix
  65710. */
  65711. clone(): Matrix;
  65712. /**
  65713. * Returns the name of the current matrix class
  65714. * @returns the string "Matrix"
  65715. */
  65716. getClassName(): string;
  65717. /**
  65718. * Gets the hash code of the current matrix
  65719. * @returns the hash code
  65720. */
  65721. getHashCode(): number;
  65722. /**
  65723. * Decomposes the current Matrix into a translation, rotation and scaling components
  65724. * @param scale defines the scale vector3 given as a reference to update
  65725. * @param rotation defines the rotation quaternion given as a reference to update
  65726. * @param translation defines the translation vector3 given as a reference to update
  65727. * @returns true if operation was successful
  65728. */
  65729. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65730. /**
  65731. * Gets specific row of the matrix
  65732. * @param index defines the number of the row to get
  65733. * @returns the index-th row of the current matrix as a new Vector4
  65734. */
  65735. getRow(index: number): Nullable<Vector4>;
  65736. /**
  65737. * Sets the index-th row of the current matrix to the vector4 values
  65738. * @param index defines the number of the row to set
  65739. * @param row defines the target vector4
  65740. * @returns the updated current matrix
  65741. */
  65742. setRow(index: number, row: Vector4): Matrix;
  65743. /**
  65744. * Compute the transpose of the matrix
  65745. * @returns the new transposed matrix
  65746. */
  65747. transpose(): Matrix;
  65748. /**
  65749. * Compute the transpose of the matrix and store it in a given matrix
  65750. * @param result defines the target matrix
  65751. * @returns the current matrix
  65752. */
  65753. transposeToRef(result: Matrix): Matrix;
  65754. /**
  65755. * Sets the index-th row of the current matrix with the given 4 x float values
  65756. * @param index defines the row index
  65757. * @param x defines the x component to set
  65758. * @param y defines the y component to set
  65759. * @param z defines the z component to set
  65760. * @param w defines the w component to set
  65761. * @returns the updated current matrix
  65762. */
  65763. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  65764. /**
  65765. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  65766. * @param scale defines the scale factor
  65767. * @returns a new matrix
  65768. */
  65769. scale(scale: number): Matrix;
  65770. /**
  65771. * Scale the current matrix values by a factor to a given result matrix
  65772. * @param scale defines the scale factor
  65773. * @param result defines the matrix to store the result
  65774. * @returns the current matrix
  65775. */
  65776. scaleToRef(scale: number, result: Matrix): Matrix;
  65777. /**
  65778. * Scale the current matrix values by a factor and add the result to a given matrix
  65779. * @param scale defines the scale factor
  65780. * @param result defines the Matrix to store the result
  65781. * @returns the current matrix
  65782. */
  65783. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  65784. /**
  65785. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  65786. * @param ref matrix to store the result
  65787. */
  65788. toNormalMatrix(ref: Matrix): void;
  65789. /**
  65790. * Gets only rotation part of the current matrix
  65791. * @returns a new matrix sets to the extracted rotation matrix from the current one
  65792. */
  65793. getRotationMatrix(): Matrix;
  65794. /**
  65795. * Extracts the rotation matrix from the current one and sets it as the given "result"
  65796. * @param result defines the target matrix to store data to
  65797. * @returns the current matrix
  65798. */
  65799. getRotationMatrixToRef(result: Matrix): Matrix;
  65800. /**
  65801. * Toggles model matrix from being right handed to left handed in place and vice versa
  65802. */
  65803. toggleModelMatrixHandInPlace(): void;
  65804. /**
  65805. * Toggles projection matrix from being right handed to left handed in place and vice versa
  65806. */
  65807. toggleProjectionMatrixHandInPlace(): void;
  65808. /**
  65809. * Creates a matrix from an array
  65810. * @param array defines the source array
  65811. * @param offset defines an offset in the source array
  65812. * @returns a new Matrix set from the starting index of the given array
  65813. */
  65814. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  65815. /**
  65816. * Copy the content of an array into a given matrix
  65817. * @param array defines the source array
  65818. * @param offset defines an offset in the source array
  65819. * @param result defines the target matrix
  65820. */
  65821. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  65822. /**
  65823. * Stores an array into a matrix after having multiplied each component by a given factor
  65824. * @param array defines the source array
  65825. * @param offset defines the offset in the source array
  65826. * @param scale defines the scaling factor
  65827. * @param result defines the target matrix
  65828. */
  65829. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  65830. /**
  65831. * Gets an identity matrix that must not be updated
  65832. */
  65833. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  65834. /**
  65835. * Stores a list of values (16) inside a given matrix
  65836. * @param initialM11 defines 1st value of 1st row
  65837. * @param initialM12 defines 2nd value of 1st row
  65838. * @param initialM13 defines 3rd value of 1st row
  65839. * @param initialM14 defines 4th value of 1st row
  65840. * @param initialM21 defines 1st value of 2nd row
  65841. * @param initialM22 defines 2nd value of 2nd row
  65842. * @param initialM23 defines 3rd value of 2nd row
  65843. * @param initialM24 defines 4th value of 2nd row
  65844. * @param initialM31 defines 1st value of 3rd row
  65845. * @param initialM32 defines 2nd value of 3rd row
  65846. * @param initialM33 defines 3rd value of 3rd row
  65847. * @param initialM34 defines 4th value of 3rd row
  65848. * @param initialM41 defines 1st value of 4th row
  65849. * @param initialM42 defines 2nd value of 4th row
  65850. * @param initialM43 defines 3rd value of 4th row
  65851. * @param initialM44 defines 4th value of 4th row
  65852. * @param result defines the target matrix
  65853. */
  65854. 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;
  65855. /**
  65856. * Creates new matrix from a list of values (16)
  65857. * @param initialM11 defines 1st value of 1st row
  65858. * @param initialM12 defines 2nd value of 1st row
  65859. * @param initialM13 defines 3rd value of 1st row
  65860. * @param initialM14 defines 4th value of 1st row
  65861. * @param initialM21 defines 1st value of 2nd row
  65862. * @param initialM22 defines 2nd value of 2nd row
  65863. * @param initialM23 defines 3rd value of 2nd row
  65864. * @param initialM24 defines 4th value of 2nd row
  65865. * @param initialM31 defines 1st value of 3rd row
  65866. * @param initialM32 defines 2nd value of 3rd row
  65867. * @param initialM33 defines 3rd value of 3rd row
  65868. * @param initialM34 defines 4th value of 3rd row
  65869. * @param initialM41 defines 1st value of 4th row
  65870. * @param initialM42 defines 2nd value of 4th row
  65871. * @param initialM43 defines 3rd value of 4th row
  65872. * @param initialM44 defines 4th value of 4th row
  65873. * @returns the new matrix
  65874. */
  65875. 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;
  65876. /**
  65877. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65878. * @param scale defines the scale vector3
  65879. * @param rotation defines the rotation quaternion
  65880. * @param translation defines the translation vector3
  65881. * @returns a new matrix
  65882. */
  65883. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  65884. /**
  65885. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65886. * @param scale defines the scale vector3
  65887. * @param rotation defines the rotation quaternion
  65888. * @param translation defines the translation vector3
  65889. * @param result defines the target matrix
  65890. */
  65891. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  65892. /**
  65893. * Creates a new identity matrix
  65894. * @returns a new identity matrix
  65895. */
  65896. static Identity(): Matrix;
  65897. /**
  65898. * Creates a new identity matrix and stores the result in a given matrix
  65899. * @param result defines the target matrix
  65900. */
  65901. static IdentityToRef(result: Matrix): void;
  65902. /**
  65903. * Creates a new zero matrix
  65904. * @returns a new zero matrix
  65905. */
  65906. static Zero(): Matrix;
  65907. /**
  65908. * Creates a new rotation matrix for "angle" radians around the X axis
  65909. * @param angle defines the angle (in radians) to use
  65910. * @return the new matrix
  65911. */
  65912. static RotationX(angle: number): Matrix;
  65913. /**
  65914. * Creates a new matrix as the invert of a given matrix
  65915. * @param source defines the source matrix
  65916. * @returns the new matrix
  65917. */
  65918. static Invert(source: DeepImmutable<Matrix>): Matrix;
  65919. /**
  65920. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  65921. * @param angle defines the angle (in radians) to use
  65922. * @param result defines the target matrix
  65923. */
  65924. static RotationXToRef(angle: number, result: Matrix): void;
  65925. /**
  65926. * Creates a new rotation matrix for "angle" radians around the Y axis
  65927. * @param angle defines the angle (in radians) to use
  65928. * @return the new matrix
  65929. */
  65930. static RotationY(angle: number): Matrix;
  65931. /**
  65932. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  65933. * @param angle defines the angle (in radians) to use
  65934. * @param result defines the target matrix
  65935. */
  65936. static RotationYToRef(angle: number, result: Matrix): void;
  65937. /**
  65938. * Creates a new rotation matrix for "angle" radians around the Z axis
  65939. * @param angle defines the angle (in radians) to use
  65940. * @return the new matrix
  65941. */
  65942. static RotationZ(angle: number): Matrix;
  65943. /**
  65944. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  65945. * @param angle defines the angle (in radians) to use
  65946. * @param result defines the target matrix
  65947. */
  65948. static RotationZToRef(angle: number, result: Matrix): void;
  65949. /**
  65950. * Creates a new rotation matrix for "angle" radians around the given axis
  65951. * @param axis defines the axis to use
  65952. * @param angle defines the angle (in radians) to use
  65953. * @return the new matrix
  65954. */
  65955. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  65956. /**
  65957. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  65958. * @param axis defines the axis to use
  65959. * @param angle defines the angle (in radians) to use
  65960. * @param result defines the target matrix
  65961. */
  65962. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  65963. /**
  65964. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  65965. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  65966. * @param from defines the vector to align
  65967. * @param to defines the vector to align to
  65968. * @param result defines the target matrix
  65969. */
  65970. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  65971. /**
  65972. * Creates a rotation matrix
  65973. * @param yaw defines the yaw angle in radians (Y axis)
  65974. * @param pitch defines the pitch angle in radians (X axis)
  65975. * @param roll defines the roll angle in radians (X axis)
  65976. * @returns the new rotation matrix
  65977. */
  65978. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  65979. /**
  65980. * Creates a rotation matrix and stores it in a given matrix
  65981. * @param yaw defines the yaw angle in radians (Y axis)
  65982. * @param pitch defines the pitch angle in radians (X axis)
  65983. * @param roll defines the roll angle in radians (X axis)
  65984. * @param result defines the target matrix
  65985. */
  65986. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  65987. /**
  65988. * Creates a scaling matrix
  65989. * @param x defines the scale factor on X axis
  65990. * @param y defines the scale factor on Y axis
  65991. * @param z defines the scale factor on Z axis
  65992. * @returns the new matrix
  65993. */
  65994. static Scaling(x: number, y: number, z: number): Matrix;
  65995. /**
  65996. * Creates a scaling matrix and stores it in a given matrix
  65997. * @param x defines the scale factor on X axis
  65998. * @param y defines the scale factor on Y axis
  65999. * @param z defines the scale factor on Z axis
  66000. * @param result defines the target matrix
  66001. */
  66002. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  66003. /**
  66004. * Creates a translation matrix
  66005. * @param x defines the translation on X axis
  66006. * @param y defines the translation on Y axis
  66007. * @param z defines the translationon Z axis
  66008. * @returns the new matrix
  66009. */
  66010. static Translation(x: number, y: number, z: number): Matrix;
  66011. /**
  66012. * Creates a translation matrix and stores it in a given matrix
  66013. * @param x defines the translation on X axis
  66014. * @param y defines the translation on Y axis
  66015. * @param z defines the translationon Z axis
  66016. * @param result defines the target matrix
  66017. */
  66018. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  66019. /**
  66020. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  66021. * @param startValue defines the start value
  66022. * @param endValue defines the end value
  66023. * @param gradient defines the gradient factor
  66024. * @returns the new matrix
  66025. */
  66026. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  66027. /**
  66028. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  66029. * @param startValue defines the start value
  66030. * @param endValue defines the end value
  66031. * @param gradient defines the gradient factor
  66032. * @param result defines the Matrix object where to store data
  66033. */
  66034. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66035. /**
  66036. * Builds a new matrix whose values are computed by:
  66037. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  66038. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  66039. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  66040. * @param startValue defines the first matrix
  66041. * @param endValue defines the second matrix
  66042. * @param gradient defines the gradient between the two matrices
  66043. * @returns the new matrix
  66044. */
  66045. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  66046. /**
  66047. * Update a matrix to values which are computed by:
  66048. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  66049. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  66050. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  66051. * @param startValue defines the first matrix
  66052. * @param endValue defines the second matrix
  66053. * @param gradient defines the gradient between the two matrices
  66054. * @param result defines the target matrix
  66055. */
  66056. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66057. /**
  66058. * 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"
  66059. * This function works in left handed mode
  66060. * @param eye defines the final position of the entity
  66061. * @param target defines where the entity should look at
  66062. * @param up defines the up vector for the entity
  66063. * @returns the new matrix
  66064. */
  66065. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66066. /**
  66067. * 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".
  66068. * This function works in left handed mode
  66069. * @param eye defines the final position of the entity
  66070. * @param target defines where the entity should look at
  66071. * @param up defines the up vector for the entity
  66072. * @param result defines the target matrix
  66073. */
  66074. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66075. /**
  66076. * 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"
  66077. * This function works in right handed mode
  66078. * @param eye defines the final position of the entity
  66079. * @param target defines where the entity should look at
  66080. * @param up defines the up vector for the entity
  66081. * @returns the new matrix
  66082. */
  66083. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66084. /**
  66085. * 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".
  66086. * This function works in right handed mode
  66087. * @param eye defines the final position of the entity
  66088. * @param target defines where the entity should look at
  66089. * @param up defines the up vector for the entity
  66090. * @param result defines the target matrix
  66091. */
  66092. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66093. /**
  66094. * Create a left-handed orthographic projection matrix
  66095. * @param width defines the viewport width
  66096. * @param height defines the viewport height
  66097. * @param znear defines the near clip plane
  66098. * @param zfar defines the far clip plane
  66099. * @returns a new matrix as a left-handed orthographic projection matrix
  66100. */
  66101. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66102. /**
  66103. * Store a left-handed orthographic projection to a given matrix
  66104. * @param width defines the viewport width
  66105. * @param height defines the viewport height
  66106. * @param znear defines the near clip plane
  66107. * @param zfar defines the far clip plane
  66108. * @param result defines the target matrix
  66109. */
  66110. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  66111. /**
  66112. * Create a left-handed orthographic projection matrix
  66113. * @param left defines the viewport left coordinate
  66114. * @param right defines the viewport right coordinate
  66115. * @param bottom defines the viewport bottom coordinate
  66116. * @param top defines the viewport top coordinate
  66117. * @param znear defines the near clip plane
  66118. * @param zfar defines the far clip plane
  66119. * @returns a new matrix as a left-handed orthographic projection matrix
  66120. */
  66121. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66122. /**
  66123. * Stores a left-handed orthographic projection into a given matrix
  66124. * @param left defines the viewport left coordinate
  66125. * @param right defines the viewport right coordinate
  66126. * @param bottom defines the viewport bottom coordinate
  66127. * @param top defines the viewport top coordinate
  66128. * @param znear defines the near clip plane
  66129. * @param zfar defines the far clip plane
  66130. * @param result defines the target matrix
  66131. */
  66132. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66133. /**
  66134. * Creates a right-handed orthographic projection matrix
  66135. * @param left defines the viewport left coordinate
  66136. * @param right defines the viewport right coordinate
  66137. * @param bottom defines the viewport bottom coordinate
  66138. * @param top defines the viewport top coordinate
  66139. * @param znear defines the near clip plane
  66140. * @param zfar defines the far clip plane
  66141. * @returns a new matrix as a right-handed orthographic projection matrix
  66142. */
  66143. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66144. /**
  66145. * Stores a right-handed orthographic projection into a given matrix
  66146. * @param left defines the viewport left coordinate
  66147. * @param right defines the viewport right coordinate
  66148. * @param bottom defines the viewport bottom coordinate
  66149. * @param top defines the viewport top coordinate
  66150. * @param znear defines the near clip plane
  66151. * @param zfar defines the far clip plane
  66152. * @param result defines the target matrix
  66153. */
  66154. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66155. /**
  66156. * Creates a left-handed perspective projection matrix
  66157. * @param width defines the viewport width
  66158. * @param height defines the viewport height
  66159. * @param znear defines the near clip plane
  66160. * @param zfar defines the far clip plane
  66161. * @returns a new matrix as a left-handed perspective projection matrix
  66162. */
  66163. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66164. /**
  66165. * Creates a left-handed perspective projection matrix
  66166. * @param fov defines the horizontal field of view
  66167. * @param aspect defines the aspect ratio
  66168. * @param znear defines the near clip plane
  66169. * @param zfar defines the far clip plane
  66170. * @returns a new matrix as a left-handed perspective projection matrix
  66171. */
  66172. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66173. /**
  66174. * Stores a left-handed perspective projection into a given matrix
  66175. * @param fov defines the horizontal field of view
  66176. * @param aspect defines the aspect ratio
  66177. * @param znear defines the near clip plane
  66178. * @param zfar defines the far clip plane
  66179. * @param result defines the target matrix
  66180. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66181. */
  66182. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66183. /**
  66184. * Creates a right-handed perspective projection matrix
  66185. * @param fov defines the horizontal field of view
  66186. * @param aspect defines the aspect ratio
  66187. * @param znear defines the near clip plane
  66188. * @param zfar defines the far clip plane
  66189. * @returns a new matrix as a right-handed perspective projection matrix
  66190. */
  66191. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66192. /**
  66193. * Stores a right-handed perspective projection into a given matrix
  66194. * @param fov defines the horizontal field of view
  66195. * @param aspect defines the aspect ratio
  66196. * @param znear defines the near clip plane
  66197. * @param zfar defines the far clip plane
  66198. * @param result defines the target matrix
  66199. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66200. */
  66201. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66202. /**
  66203. * Stores a perspective projection for WebVR info a given matrix
  66204. * @param fov defines the field of view
  66205. * @param znear defines the near clip plane
  66206. * @param zfar defines the far clip plane
  66207. * @param result defines the target matrix
  66208. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  66209. */
  66210. static PerspectiveFovWebVRToRef(fov: {
  66211. upDegrees: number;
  66212. downDegrees: number;
  66213. leftDegrees: number;
  66214. rightDegrees: number;
  66215. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  66216. /**
  66217. * Computes a complete transformation matrix
  66218. * @param viewport defines the viewport to use
  66219. * @param world defines the world matrix
  66220. * @param view defines the view matrix
  66221. * @param projection defines the projection matrix
  66222. * @param zmin defines the near clip plane
  66223. * @param zmax defines the far clip plane
  66224. * @returns the transformation matrix
  66225. */
  66226. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  66227. /**
  66228. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  66229. * @param matrix defines the matrix to use
  66230. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  66231. */
  66232. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  66233. /**
  66234. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  66235. * @param matrix defines the matrix to use
  66236. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  66237. */
  66238. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  66239. /**
  66240. * Compute the transpose of a given matrix
  66241. * @param matrix defines the matrix to transpose
  66242. * @returns the new matrix
  66243. */
  66244. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  66245. /**
  66246. * Compute the transpose of a matrix and store it in a target matrix
  66247. * @param matrix defines the matrix to transpose
  66248. * @param result defines the target matrix
  66249. */
  66250. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  66251. /**
  66252. * Computes a reflection matrix from a plane
  66253. * @param plane defines the reflection plane
  66254. * @returns a new matrix
  66255. */
  66256. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  66257. /**
  66258. * Computes a reflection matrix from a plane
  66259. * @param plane defines the reflection plane
  66260. * @param result defines the target matrix
  66261. */
  66262. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  66263. /**
  66264. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  66265. * @param xaxis defines the value of the 1st axis
  66266. * @param yaxis defines the value of the 2nd axis
  66267. * @param zaxis defines the value of the 3rd axis
  66268. * @param result defines the target matrix
  66269. */
  66270. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  66271. /**
  66272. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  66273. * @param quat defines the quaternion to use
  66274. * @param result defines the target matrix
  66275. */
  66276. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  66277. }
  66278. /**
  66279. * Represens a plane by the equation ax + by + cz + d = 0
  66280. */
  66281. export class Plane {
  66282. /**
  66283. * Normal of the plane (a,b,c)
  66284. */
  66285. normal: Vector3;
  66286. /**
  66287. * d component of the plane
  66288. */
  66289. d: number;
  66290. /**
  66291. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  66292. * @param a a component of the plane
  66293. * @param b b component of the plane
  66294. * @param c c component of the plane
  66295. * @param d d component of the plane
  66296. */
  66297. constructor(a: number, b: number, c: number, d: number);
  66298. /**
  66299. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  66300. */
  66301. asArray(): number[];
  66302. /**
  66303. * @returns a new plane copied from the current Plane.
  66304. */
  66305. clone(): Plane;
  66306. /**
  66307. * @returns the string "Plane".
  66308. */
  66309. getClassName(): string;
  66310. /**
  66311. * @returns the Plane hash code.
  66312. */
  66313. getHashCode(): number;
  66314. /**
  66315. * Normalize the current Plane in place.
  66316. * @returns the updated Plane.
  66317. */
  66318. normalize(): Plane;
  66319. /**
  66320. * Applies a transformation the plane and returns the result
  66321. * @param transformation the transformation matrix to be applied to the plane
  66322. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  66323. */
  66324. transform(transformation: DeepImmutable<Matrix>): Plane;
  66325. /**
  66326. * Calcualtte the dot product between the point and the plane normal
  66327. * @param point point to calculate the dot product with
  66328. * @returns the dot product (float) of the point coordinates and the plane normal.
  66329. */
  66330. dotCoordinate(point: DeepImmutable<Vector3>): number;
  66331. /**
  66332. * Updates the current Plane from the plane defined by the three given points.
  66333. * @param point1 one of the points used to contruct the plane
  66334. * @param point2 one of the points used to contruct the plane
  66335. * @param point3 one of the points used to contruct the plane
  66336. * @returns the updated Plane.
  66337. */
  66338. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66339. /**
  66340. * Checks if the plane is facing a given direction
  66341. * @param direction the direction to check if the plane is facing
  66342. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66343. * @returns True is the vector "direction" is the same side than the plane normal.
  66344. */
  66345. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66346. /**
  66347. * Calculates the distance to a point
  66348. * @param point point to calculate distance to
  66349. * @returns the signed distance (float) from the given point to the Plane.
  66350. */
  66351. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66352. /**
  66353. * Creates a plane from an array
  66354. * @param array the array to create a plane from
  66355. * @returns a new Plane from the given array.
  66356. */
  66357. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66358. /**
  66359. * Creates a plane from three points
  66360. * @param point1 point used to create the plane
  66361. * @param point2 point used to create the plane
  66362. * @param point3 point used to create the plane
  66363. * @returns a new Plane defined by the three given points.
  66364. */
  66365. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66366. /**
  66367. * Creates a plane from an origin point and a normal
  66368. * @param origin origin of the plane to be constructed
  66369. * @param normal normal of the plane to be constructed
  66370. * @returns a new Plane the normal vector to this plane at the given origin point.
  66371. * Note : the vector "normal" is updated because normalized.
  66372. */
  66373. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66374. /**
  66375. * Calculates the distance from a plane and a point
  66376. * @param origin origin of the plane to be constructed
  66377. * @param normal normal of the plane to be constructed
  66378. * @param point point to calculate distance to
  66379. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66380. */
  66381. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66382. }
  66383. /**
  66384. * Class used to represent a viewport on screen
  66385. */
  66386. export class Viewport {
  66387. /** viewport left coordinate */
  66388. x: number;
  66389. /** viewport top coordinate */
  66390. y: number;
  66391. /**viewport width */
  66392. width: number;
  66393. /** viewport height */
  66394. height: number;
  66395. /**
  66396. * Creates a Viewport object located at (x, y) and sized (width, height)
  66397. * @param x defines viewport left coordinate
  66398. * @param y defines viewport top coordinate
  66399. * @param width defines the viewport width
  66400. * @param height defines the viewport height
  66401. */
  66402. constructor(
  66403. /** viewport left coordinate */
  66404. x: number,
  66405. /** viewport top coordinate */
  66406. y: number,
  66407. /**viewport width */
  66408. width: number,
  66409. /** viewport height */
  66410. height: number);
  66411. /**
  66412. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66413. * @param renderWidth defines the rendering width
  66414. * @param renderHeight defines the rendering height
  66415. * @returns a new Viewport
  66416. */
  66417. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66418. /**
  66419. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66420. * @param renderWidth defines the rendering width
  66421. * @param renderHeight defines the rendering height
  66422. * @param ref defines the target viewport
  66423. * @returns the current viewport
  66424. */
  66425. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66426. /**
  66427. * Returns a new Viewport copied from the current one
  66428. * @returns a new Viewport
  66429. */
  66430. clone(): Viewport;
  66431. }
  66432. /**
  66433. * Reprasents a camera frustum
  66434. */
  66435. export class Frustum {
  66436. /**
  66437. * Gets the planes representing the frustum
  66438. * @param transform matrix to be applied to the returned planes
  66439. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66440. */
  66441. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66442. /**
  66443. * Gets the near frustum plane transformed by the transform matrix
  66444. * @param transform transformation matrix to be applied to the resulting frustum plane
  66445. * @param frustumPlane the resuling frustum plane
  66446. */
  66447. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66448. /**
  66449. * Gets the far frustum plane transformed by the transform matrix
  66450. * @param transform transformation matrix to be applied to the resulting frustum plane
  66451. * @param frustumPlane the resuling frustum plane
  66452. */
  66453. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66454. /**
  66455. * Gets the left frustum plane transformed by the transform matrix
  66456. * @param transform transformation matrix to be applied to the resulting frustum plane
  66457. * @param frustumPlane the resuling frustum plane
  66458. */
  66459. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66460. /**
  66461. * Gets the right frustum plane transformed by the transform matrix
  66462. * @param transform transformation matrix to be applied to the resulting frustum plane
  66463. * @param frustumPlane the resuling frustum plane
  66464. */
  66465. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66466. /**
  66467. * Gets the top frustum plane transformed by the transform matrix
  66468. * @param transform transformation matrix to be applied to the resulting frustum plane
  66469. * @param frustumPlane the resuling frustum plane
  66470. */
  66471. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66472. /**
  66473. * Gets the bottom frustum plane transformed by the transform matrix
  66474. * @param transform transformation matrix to be applied to the resulting frustum plane
  66475. * @param frustumPlane the resuling frustum plane
  66476. */
  66477. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66478. /**
  66479. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66480. * @param transform transformation matrix to be applied to the resulting frustum planes
  66481. * @param frustumPlanes the resuling frustum planes
  66482. */
  66483. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66484. }
  66485. /** Defines supported spaces */
  66486. export enum Space {
  66487. /** Local (object) space */
  66488. LOCAL = 0,
  66489. /** World space */
  66490. WORLD = 1,
  66491. /** Bone space */
  66492. BONE = 2
  66493. }
  66494. /** Defines the 3 main axes */
  66495. export class Axis {
  66496. /** X axis */
  66497. static X: Vector3;
  66498. /** Y axis */
  66499. static Y: Vector3;
  66500. /** Z axis */
  66501. static Z: Vector3;
  66502. }
  66503. /** Class used to represent a Bezier curve */
  66504. export class BezierCurve {
  66505. /**
  66506. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66507. * @param t defines the time
  66508. * @param x1 defines the left coordinate on X axis
  66509. * @param y1 defines the left coordinate on Y axis
  66510. * @param x2 defines the right coordinate on X axis
  66511. * @param y2 defines the right coordinate on Y axis
  66512. * @returns the interpolated value
  66513. */
  66514. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66515. }
  66516. /**
  66517. * Defines potential orientation for back face culling
  66518. */
  66519. export enum Orientation {
  66520. /**
  66521. * Clockwise
  66522. */
  66523. CW = 0,
  66524. /** Counter clockwise */
  66525. CCW = 1
  66526. }
  66527. /**
  66528. * Defines angle representation
  66529. */
  66530. export class Angle {
  66531. private _radians;
  66532. /**
  66533. * Creates an Angle object of "radians" radians (float).
  66534. * @param radians the angle in radians
  66535. */
  66536. constructor(radians: number);
  66537. /**
  66538. * Get value in degrees
  66539. * @returns the Angle value in degrees (float)
  66540. */
  66541. degrees(): number;
  66542. /**
  66543. * Get value in radians
  66544. * @returns the Angle value in radians (float)
  66545. */
  66546. radians(): number;
  66547. /**
  66548. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66549. * @param a defines first vector
  66550. * @param b defines second vector
  66551. * @returns a new Angle
  66552. */
  66553. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66554. /**
  66555. * Gets a new Angle object from the given float in radians
  66556. * @param radians defines the angle value in radians
  66557. * @returns a new Angle
  66558. */
  66559. static FromRadians(radians: number): Angle;
  66560. /**
  66561. * Gets a new Angle object from the given float in degrees
  66562. * @param degrees defines the angle value in degrees
  66563. * @returns a new Angle
  66564. */
  66565. static FromDegrees(degrees: number): Angle;
  66566. }
  66567. /**
  66568. * This represents an arc in a 2d space.
  66569. */
  66570. export class Arc2 {
  66571. /** Defines the start point of the arc */
  66572. startPoint: Vector2;
  66573. /** Defines the mid point of the arc */
  66574. midPoint: Vector2;
  66575. /** Defines the end point of the arc */
  66576. endPoint: Vector2;
  66577. /**
  66578. * Defines the center point of the arc.
  66579. */
  66580. centerPoint: Vector2;
  66581. /**
  66582. * Defines the radius of the arc.
  66583. */
  66584. radius: number;
  66585. /**
  66586. * Defines the angle of the arc (from mid point to end point).
  66587. */
  66588. angle: Angle;
  66589. /**
  66590. * Defines the start angle of the arc (from start point to middle point).
  66591. */
  66592. startAngle: Angle;
  66593. /**
  66594. * Defines the orientation of the arc (clock wise/counter clock wise).
  66595. */
  66596. orientation: Orientation;
  66597. /**
  66598. * Creates an Arc object from the three given points : start, middle and end.
  66599. * @param startPoint Defines the start point of the arc
  66600. * @param midPoint Defines the midlle point of the arc
  66601. * @param endPoint Defines the end point of the arc
  66602. */
  66603. constructor(
  66604. /** Defines the start point of the arc */
  66605. startPoint: Vector2,
  66606. /** Defines the mid point of the arc */
  66607. midPoint: Vector2,
  66608. /** Defines the end point of the arc */
  66609. endPoint: Vector2);
  66610. }
  66611. /**
  66612. * Represents a 2D path made up of multiple 2D points
  66613. */
  66614. export class Path2 {
  66615. private _points;
  66616. private _length;
  66617. /**
  66618. * If the path start and end point are the same
  66619. */
  66620. closed: boolean;
  66621. /**
  66622. * Creates a Path2 object from the starting 2D coordinates x and y.
  66623. * @param x the starting points x value
  66624. * @param y the starting points y value
  66625. */
  66626. constructor(x: number, y: number);
  66627. /**
  66628. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66629. * @param x the added points x value
  66630. * @param y the added points y value
  66631. * @returns the updated Path2.
  66632. */
  66633. addLineTo(x: number, y: number): Path2;
  66634. /**
  66635. * 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.
  66636. * @param midX middle point x value
  66637. * @param midY middle point y value
  66638. * @param endX end point x value
  66639. * @param endY end point y value
  66640. * @param numberOfSegments (default: 36)
  66641. * @returns the updated Path2.
  66642. */
  66643. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66644. /**
  66645. * Closes the Path2.
  66646. * @returns the Path2.
  66647. */
  66648. close(): Path2;
  66649. /**
  66650. * Gets the sum of the distance between each sequential point in the path
  66651. * @returns the Path2 total length (float).
  66652. */
  66653. length(): number;
  66654. /**
  66655. * Gets the points which construct the path
  66656. * @returns the Path2 internal array of points.
  66657. */
  66658. getPoints(): Vector2[];
  66659. /**
  66660. * Retreives the point at the distance aways from the starting point
  66661. * @param normalizedLengthPosition the length along the path to retreive the point from
  66662. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66663. */
  66664. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66665. /**
  66666. * Creates a new path starting from an x and y position
  66667. * @param x starting x value
  66668. * @param y starting y value
  66669. * @returns a new Path2 starting at the coordinates (x, y).
  66670. */
  66671. static StartingAt(x: number, y: number): Path2;
  66672. }
  66673. /**
  66674. * Represents a 3D path made up of multiple 3D points
  66675. */
  66676. export class Path3D {
  66677. /**
  66678. * an array of Vector3, the curve axis of the Path3D
  66679. */
  66680. path: Vector3[];
  66681. private _curve;
  66682. private _distances;
  66683. private _tangents;
  66684. private _normals;
  66685. private _binormals;
  66686. private _raw;
  66687. /**
  66688. * new Path3D(path, normal, raw)
  66689. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66690. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66691. * @param path an array of Vector3, the curve axis of the Path3D
  66692. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66693. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66694. */
  66695. constructor(
  66696. /**
  66697. * an array of Vector3, the curve axis of the Path3D
  66698. */
  66699. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66700. /**
  66701. * Returns the Path3D array of successive Vector3 designing its curve.
  66702. * @returns the Path3D array of successive Vector3 designing its curve.
  66703. */
  66704. getCurve(): Vector3[];
  66705. /**
  66706. * Returns an array populated with tangent vectors on each Path3D curve point.
  66707. * @returns an array populated with tangent vectors on each Path3D curve point.
  66708. */
  66709. getTangents(): Vector3[];
  66710. /**
  66711. * Returns an array populated with normal vectors on each Path3D curve point.
  66712. * @returns an array populated with normal vectors on each Path3D curve point.
  66713. */
  66714. getNormals(): Vector3[];
  66715. /**
  66716. * Returns an array populated with binormal vectors on each Path3D curve point.
  66717. * @returns an array populated with binormal vectors on each Path3D curve point.
  66718. */
  66719. getBinormals(): Vector3[];
  66720. /**
  66721. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66722. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66723. */
  66724. getDistances(): number[];
  66725. /**
  66726. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66727. * @param path path which all values are copied into the curves points
  66728. * @param firstNormal which should be projected onto the curve
  66729. * @returns the same object updated.
  66730. */
  66731. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66732. private _compute;
  66733. private _getFirstNonNullVector;
  66734. private _getLastNonNullVector;
  66735. private _normalVector;
  66736. }
  66737. /**
  66738. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66739. * A Curve3 is designed from a series of successive Vector3.
  66740. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66741. */
  66742. export class Curve3 {
  66743. private _points;
  66744. private _length;
  66745. /**
  66746. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  66747. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  66748. * @param v1 (Vector3) the control point
  66749. * @param v2 (Vector3) the end point of the Quadratic Bezier
  66750. * @param nbPoints (integer) the wanted number of points in the curve
  66751. * @returns the created Curve3
  66752. */
  66753. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66754. /**
  66755. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  66756. * @param v0 (Vector3) the origin point of the Cubic Bezier
  66757. * @param v1 (Vector3) the first control point
  66758. * @param v2 (Vector3) the second control point
  66759. * @param v3 (Vector3) the end point of the Cubic Bezier
  66760. * @param nbPoints (integer) the wanted number of points in the curve
  66761. * @returns the created Curve3
  66762. */
  66763. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66764. /**
  66765. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  66766. * @param p1 (Vector3) the origin point of the Hermite Spline
  66767. * @param t1 (Vector3) the tangent vector at the origin point
  66768. * @param p2 (Vector3) the end point of the Hermite Spline
  66769. * @param t2 (Vector3) the tangent vector at the end point
  66770. * @param nbPoints (integer) the wanted number of points in the curve
  66771. * @returns the created Curve3
  66772. */
  66773. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66774. /**
  66775. * Returns a Curve3 object along a CatmullRom Spline curve :
  66776. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  66777. * @param nbPoints (integer) the wanted number of points between each curve control points
  66778. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  66779. * @returns the created Curve3
  66780. */
  66781. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  66782. /**
  66783. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66784. * A Curve3 is designed from a series of successive Vector3.
  66785. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  66786. * @param points points which make up the curve
  66787. */
  66788. constructor(points: Vector3[]);
  66789. /**
  66790. * @returns the Curve3 stored array of successive Vector3
  66791. */
  66792. getPoints(): Vector3[];
  66793. /**
  66794. * @returns the computed length (float) of the curve.
  66795. */
  66796. length(): number;
  66797. /**
  66798. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  66799. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  66800. * curveA and curveB keep unchanged.
  66801. * @param curve the curve to continue from this curve
  66802. * @returns the newly constructed curve
  66803. */
  66804. continue(curve: DeepImmutable<Curve3>): Curve3;
  66805. private _computeLength;
  66806. }
  66807. /**
  66808. * Contains position and normal vectors for a vertex
  66809. */
  66810. export class PositionNormalVertex {
  66811. /** the position of the vertex (defaut: 0,0,0) */
  66812. position: Vector3;
  66813. /** the normal of the vertex (defaut: 0,1,0) */
  66814. normal: Vector3;
  66815. /**
  66816. * Creates a PositionNormalVertex
  66817. * @param position the position of the vertex (defaut: 0,0,0)
  66818. * @param normal the normal of the vertex (defaut: 0,1,0)
  66819. */
  66820. constructor(
  66821. /** the position of the vertex (defaut: 0,0,0) */
  66822. position?: Vector3,
  66823. /** the normal of the vertex (defaut: 0,1,0) */
  66824. normal?: Vector3);
  66825. /**
  66826. * Clones the PositionNormalVertex
  66827. * @returns the cloned PositionNormalVertex
  66828. */
  66829. clone(): PositionNormalVertex;
  66830. }
  66831. /**
  66832. * Contains position, normal and uv vectors for a vertex
  66833. */
  66834. export class PositionNormalTextureVertex {
  66835. /** the position of the vertex (defaut: 0,0,0) */
  66836. position: Vector3;
  66837. /** the normal of the vertex (defaut: 0,1,0) */
  66838. normal: Vector3;
  66839. /** the uv of the vertex (default: 0,0) */
  66840. uv: Vector2;
  66841. /**
  66842. * Creates a PositionNormalTextureVertex
  66843. * @param position the position of the vertex (defaut: 0,0,0)
  66844. * @param normal the normal of the vertex (defaut: 0,1,0)
  66845. * @param uv the uv of the vertex (default: 0,0)
  66846. */
  66847. constructor(
  66848. /** the position of the vertex (defaut: 0,0,0) */
  66849. position?: Vector3,
  66850. /** the normal of the vertex (defaut: 0,1,0) */
  66851. normal?: Vector3,
  66852. /** the uv of the vertex (default: 0,0) */
  66853. uv?: Vector2);
  66854. /**
  66855. * Clones the PositionNormalTextureVertex
  66856. * @returns the cloned PositionNormalTextureVertex
  66857. */
  66858. clone(): PositionNormalTextureVertex;
  66859. }
  66860. /**
  66861. * @hidden
  66862. */
  66863. export class Tmp {
  66864. static Color3: Color3[];
  66865. static Color4: Color4[];
  66866. static Vector2: Vector2[];
  66867. static Vector3: Vector3[];
  66868. static Vector4: Vector4[];
  66869. static Quaternion: Quaternion[];
  66870. static Matrix: Matrix[];
  66871. }
  66872. }
  66873. declare module BABYLON {
  66874. /**
  66875. * Class used to enable access to offline support
  66876. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66877. */
  66878. export interface IOfflineProvider {
  66879. /**
  66880. * Gets a boolean indicating if scene must be saved in the database
  66881. */
  66882. enableSceneOffline: boolean;
  66883. /**
  66884. * Gets a boolean indicating if textures must be saved in the database
  66885. */
  66886. enableTexturesOffline: boolean;
  66887. /**
  66888. * Open the offline support and make it available
  66889. * @param successCallback defines the callback to call on success
  66890. * @param errorCallback defines the callback to call on error
  66891. */
  66892. open(successCallback: () => void, errorCallback: () => void): void;
  66893. /**
  66894. * Loads an image from the offline support
  66895. * @param url defines the url to load from
  66896. * @param image defines the target DOM image
  66897. */
  66898. loadImage(url: string, image: HTMLImageElement): void;
  66899. /**
  66900. * Loads a file from offline support
  66901. * @param url defines the URL to load from
  66902. * @param sceneLoaded defines a callback to call on success
  66903. * @param progressCallBack defines a callback to call when progress changed
  66904. * @param errorCallback defines a callback to call on error
  66905. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66906. */
  66907. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66908. }
  66909. }
  66910. declare module BABYLON {
  66911. /**
  66912. * A class serves as a medium between the observable and its observers
  66913. */
  66914. export class EventState {
  66915. /**
  66916. * Create a new EventState
  66917. * @param mask defines the mask associated with this state
  66918. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66919. * @param target defines the original target of the state
  66920. * @param currentTarget defines the current target of the state
  66921. */
  66922. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66923. /**
  66924. * Initialize the current event state
  66925. * @param mask defines the mask associated with this state
  66926. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66927. * @param target defines the original target of the state
  66928. * @param currentTarget defines the current target of the state
  66929. * @returns the current event state
  66930. */
  66931. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66932. /**
  66933. * An Observer can set this property to true to prevent subsequent observers of being notified
  66934. */
  66935. skipNextObservers: boolean;
  66936. /**
  66937. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66938. */
  66939. mask: number;
  66940. /**
  66941. * The object that originally notified the event
  66942. */
  66943. target?: any;
  66944. /**
  66945. * The current object in the bubbling phase
  66946. */
  66947. currentTarget?: any;
  66948. /**
  66949. * This will be populated with the return value of the last function that was executed.
  66950. * If it is the first function in the callback chain it will be the event data.
  66951. */
  66952. lastReturnValue?: any;
  66953. }
  66954. /**
  66955. * Represent an Observer registered to a given Observable object.
  66956. */
  66957. export class Observer<T> {
  66958. /**
  66959. * Defines the callback to call when the observer is notified
  66960. */
  66961. callback: (eventData: T, eventState: EventState) => void;
  66962. /**
  66963. * Defines the mask of the observer (used to filter notifications)
  66964. */
  66965. mask: number;
  66966. /**
  66967. * Defines the current scope used to restore the JS context
  66968. */
  66969. scope: any;
  66970. /** @hidden */
  66971. _willBeUnregistered: boolean;
  66972. /**
  66973. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66974. */
  66975. unregisterOnNextCall: boolean;
  66976. /**
  66977. * Creates a new observer
  66978. * @param callback defines the callback to call when the observer is notified
  66979. * @param mask defines the mask of the observer (used to filter notifications)
  66980. * @param scope defines the current scope used to restore the JS context
  66981. */
  66982. constructor(
  66983. /**
  66984. * Defines the callback to call when the observer is notified
  66985. */
  66986. callback: (eventData: T, eventState: EventState) => void,
  66987. /**
  66988. * Defines the mask of the observer (used to filter notifications)
  66989. */
  66990. mask: number,
  66991. /**
  66992. * Defines the current scope used to restore the JS context
  66993. */
  66994. scope?: any);
  66995. }
  66996. /**
  66997. * Represent a list of observers registered to multiple Observables object.
  66998. */
  66999. export class MultiObserver<T> {
  67000. private _observers;
  67001. private _observables;
  67002. /**
  67003. * Release associated resources
  67004. */
  67005. dispose(): void;
  67006. /**
  67007. * Raise a callback when one of the observable will notify
  67008. * @param observables defines a list of observables to watch
  67009. * @param callback defines the callback to call on notification
  67010. * @param mask defines the mask used to filter notifications
  67011. * @param scope defines the current scope used to restore the JS context
  67012. * @returns the new MultiObserver
  67013. */
  67014. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  67015. }
  67016. /**
  67017. * The Observable class is a simple implementation of the Observable pattern.
  67018. *
  67019. * 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.
  67020. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  67021. * 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).
  67022. * 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.
  67023. */
  67024. export class Observable<T> {
  67025. private _observers;
  67026. private _eventState;
  67027. private _onObserverAdded;
  67028. /**
  67029. * Gets the list of observers
  67030. */
  67031. readonly observers: Array<Observer<T>>;
  67032. /**
  67033. * Creates a new observable
  67034. * @param onObserverAdded defines a callback to call when a new observer is added
  67035. */
  67036. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67037. /**
  67038. * Create a new Observer with the specified callback
  67039. * @param callback the callback that will be executed for that Observer
  67040. * @param mask the mask used to filter observers
  67041. * @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.
  67042. * @param scope optional scope for the callback to be called from
  67043. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67044. * @returns the new observer created for the callback
  67045. */
  67046. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67047. /**
  67048. * Create a new Observer with the specified callback and unregisters after the next notification
  67049. * @param callback the callback that will be executed for that Observer
  67050. * @returns the new observer created for the callback
  67051. */
  67052. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67053. /**
  67054. * Remove an Observer from the Observable object
  67055. * @param observer the instance of the Observer to remove
  67056. * @returns false if it doesn't belong to this Observable
  67057. */
  67058. remove(observer: Nullable<Observer<T>>): boolean;
  67059. /**
  67060. * Remove a callback from the Observable object
  67061. * @param callback the callback to remove
  67062. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67063. * @returns false if it doesn't belong to this Observable
  67064. */
  67065. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67066. private _deferUnregister;
  67067. private _remove;
  67068. /**
  67069. * Moves the observable to the top of the observer list making it get called first when notified
  67070. * @param observer the observer to move
  67071. */
  67072. makeObserverTopPriority(observer: Observer<T>): void;
  67073. /**
  67074. * Moves the observable to the bottom of the observer list making it get called last when notified
  67075. * @param observer the observer to move
  67076. */
  67077. makeObserverBottomPriority(observer: Observer<T>): void;
  67078. /**
  67079. * Notify all Observers by calling their respective callback with the given data
  67080. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67081. * @param eventData defines the data to send to all observers
  67082. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67083. * @param target defines the original target of the state
  67084. * @param currentTarget defines the current target of the state
  67085. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67086. */
  67087. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67088. /**
  67089. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67090. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67091. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67092. * and it is crucial that all callbacks will be executed.
  67093. * The order of the callbacks is kept, callbacks are not executed parallel.
  67094. *
  67095. * @param eventData The data to be sent to each callback
  67096. * @param mask is used to filter observers defaults to -1
  67097. * @param target defines the callback target (see EventState)
  67098. * @param currentTarget defines he current object in the bubbling phase
  67099. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67100. */
  67101. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67102. /**
  67103. * Notify a specific observer
  67104. * @param observer defines the observer to notify
  67105. * @param eventData defines the data to be sent to each callback
  67106. * @param mask is used to filter observers defaults to -1
  67107. */
  67108. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67109. /**
  67110. * Gets a boolean indicating if the observable has at least one observer
  67111. * @returns true is the Observable has at least one Observer registered
  67112. */
  67113. hasObservers(): boolean;
  67114. /**
  67115. * Clear the list of observers
  67116. */
  67117. clear(): void;
  67118. /**
  67119. * Clone the current observable
  67120. * @returns a new observable
  67121. */
  67122. clone(): Observable<T>;
  67123. /**
  67124. * Does this observable handles observer registered with a given mask
  67125. * @param mask defines the mask to be tested
  67126. * @return whether or not one observer registered with the given mask is handeled
  67127. **/
  67128. hasSpecificMask(mask?: number): boolean;
  67129. }
  67130. }
  67131. declare module BABYLON {
  67132. /**
  67133. * Class used to help managing file picking and drag'n'drop
  67134. * File Storage
  67135. */
  67136. export class FilesInputStore {
  67137. /**
  67138. * List of files ready to be loaded
  67139. */
  67140. static FilesToLoad: {
  67141. [key: string]: File;
  67142. };
  67143. }
  67144. }
  67145. declare module BABYLON {
  67146. /** Defines the cross module used constants to avoid circular dependncies */
  67147. export class Constants {
  67148. /** Defines that alpha blending is disabled */
  67149. static readonly ALPHA_DISABLE: number;
  67150. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67151. static readonly ALPHA_ADD: number;
  67152. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67153. static readonly ALPHA_COMBINE: number;
  67154. /** Defines that alpha blending to DEST - SRC * DEST */
  67155. static readonly ALPHA_SUBTRACT: number;
  67156. /** Defines that alpha blending to SRC * DEST */
  67157. static readonly ALPHA_MULTIPLY: number;
  67158. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67159. static readonly ALPHA_MAXIMIZED: number;
  67160. /** Defines that alpha blending to SRC + DEST */
  67161. static readonly ALPHA_ONEONE: number;
  67162. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67163. static readonly ALPHA_PREMULTIPLIED: number;
  67164. /**
  67165. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67166. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67167. */
  67168. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67169. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67170. static readonly ALPHA_INTERPOLATE: number;
  67171. /**
  67172. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67173. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67174. */
  67175. static readonly ALPHA_SCREENMODE: number;
  67176. /** Defines that the ressource is not delayed*/
  67177. static readonly DELAYLOADSTATE_NONE: number;
  67178. /** Defines that the ressource was successfully delay loaded */
  67179. static readonly DELAYLOADSTATE_LOADED: number;
  67180. /** Defines that the ressource is currently delay loading */
  67181. static readonly DELAYLOADSTATE_LOADING: number;
  67182. /** Defines that the ressource is delayed and has not started loading */
  67183. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67184. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67185. static readonly NEVER: number;
  67186. /** 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 */
  67187. static readonly ALWAYS: number;
  67188. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67189. static readonly LESS: number;
  67190. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67191. static readonly EQUAL: number;
  67192. /** 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 */
  67193. static readonly LEQUAL: number;
  67194. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67195. static readonly GREATER: number;
  67196. /** 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 */
  67197. static readonly GEQUAL: number;
  67198. /** 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 */
  67199. static readonly NOTEQUAL: number;
  67200. /** Passed to stencilOperation to specify that stencil value must be kept */
  67201. static readonly KEEP: number;
  67202. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67203. static readonly REPLACE: number;
  67204. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67205. static readonly INCR: number;
  67206. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67207. static readonly DECR: number;
  67208. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67209. static readonly INVERT: number;
  67210. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67211. static readonly INCR_WRAP: number;
  67212. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67213. static readonly DECR_WRAP: number;
  67214. /** Texture is not repeating outside of 0..1 UVs */
  67215. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67216. /** Texture is repeating outside of 0..1 UVs */
  67217. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67218. /** Texture is repeating and mirrored */
  67219. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67220. /** ALPHA */
  67221. static readonly TEXTUREFORMAT_ALPHA: number;
  67222. /** LUMINANCE */
  67223. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67224. /** LUMINANCE_ALPHA */
  67225. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67226. /** RGB */
  67227. static readonly TEXTUREFORMAT_RGB: number;
  67228. /** RGBA */
  67229. static readonly TEXTUREFORMAT_RGBA: number;
  67230. /** RED */
  67231. static readonly TEXTUREFORMAT_RED: number;
  67232. /** RED (2nd reference) */
  67233. static readonly TEXTUREFORMAT_R: number;
  67234. /** RG */
  67235. static readonly TEXTUREFORMAT_RG: number;
  67236. /** RED_INTEGER */
  67237. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67238. /** RED_INTEGER (2nd reference) */
  67239. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67240. /** RG_INTEGER */
  67241. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67242. /** RGB_INTEGER */
  67243. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67244. /** RGBA_INTEGER */
  67245. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67246. /** UNSIGNED_BYTE */
  67247. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67248. /** UNSIGNED_BYTE (2nd reference) */
  67249. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67250. /** FLOAT */
  67251. static readonly TEXTURETYPE_FLOAT: number;
  67252. /** HALF_FLOAT */
  67253. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67254. /** BYTE */
  67255. static readonly TEXTURETYPE_BYTE: number;
  67256. /** SHORT */
  67257. static readonly TEXTURETYPE_SHORT: number;
  67258. /** UNSIGNED_SHORT */
  67259. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67260. /** INT */
  67261. static readonly TEXTURETYPE_INT: number;
  67262. /** UNSIGNED_INT */
  67263. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67264. /** UNSIGNED_SHORT_4_4_4_4 */
  67265. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67266. /** UNSIGNED_SHORT_5_5_5_1 */
  67267. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67268. /** UNSIGNED_SHORT_5_6_5 */
  67269. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67270. /** UNSIGNED_INT_2_10_10_10_REV */
  67271. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67272. /** UNSIGNED_INT_24_8 */
  67273. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67274. /** UNSIGNED_INT_10F_11F_11F_REV */
  67275. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67276. /** UNSIGNED_INT_5_9_9_9_REV */
  67277. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67278. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67279. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67280. /** nearest is mag = nearest and min = nearest and mip = linear */
  67281. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67282. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67283. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67284. /** Trilinear is mag = linear and min = linear and mip = linear */
  67285. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67286. /** nearest is mag = nearest and min = nearest and mip = linear */
  67287. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67288. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67289. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67290. /** Trilinear is mag = linear and min = linear and mip = linear */
  67291. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67292. /** mag = nearest and min = nearest and mip = nearest */
  67293. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67294. /** mag = nearest and min = linear and mip = nearest */
  67295. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67296. /** mag = nearest and min = linear and mip = linear */
  67297. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67298. /** mag = nearest and min = linear and mip = none */
  67299. static readonly TEXTURE_NEAREST_LINEAR: number;
  67300. /** mag = nearest and min = nearest and mip = none */
  67301. static readonly TEXTURE_NEAREST_NEAREST: number;
  67302. /** mag = linear and min = nearest and mip = nearest */
  67303. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67304. /** mag = linear and min = nearest and mip = linear */
  67305. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67306. /** mag = linear and min = linear and mip = none */
  67307. static readonly TEXTURE_LINEAR_LINEAR: number;
  67308. /** mag = linear and min = nearest and mip = none */
  67309. static readonly TEXTURE_LINEAR_NEAREST: number;
  67310. /** Explicit coordinates mode */
  67311. static readonly TEXTURE_EXPLICIT_MODE: number;
  67312. /** Spherical coordinates mode */
  67313. static readonly TEXTURE_SPHERICAL_MODE: number;
  67314. /** Planar coordinates mode */
  67315. static readonly TEXTURE_PLANAR_MODE: number;
  67316. /** Cubic coordinates mode */
  67317. static readonly TEXTURE_CUBIC_MODE: number;
  67318. /** Projection coordinates mode */
  67319. static readonly TEXTURE_PROJECTION_MODE: number;
  67320. /** Skybox coordinates mode */
  67321. static readonly TEXTURE_SKYBOX_MODE: number;
  67322. /** Inverse Cubic coordinates mode */
  67323. static readonly TEXTURE_INVCUBIC_MODE: number;
  67324. /** Equirectangular coordinates mode */
  67325. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67326. /** Equirectangular Fixed coordinates mode */
  67327. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67328. /** Equirectangular Fixed Mirrored coordinates mode */
  67329. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67330. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67331. static readonly SCALEMODE_FLOOR: number;
  67332. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67333. static readonly SCALEMODE_NEAREST: number;
  67334. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67335. static readonly SCALEMODE_CEILING: number;
  67336. /**
  67337. * The dirty texture flag value
  67338. */
  67339. static readonly MATERIAL_TextureDirtyFlag: number;
  67340. /**
  67341. * The dirty light flag value
  67342. */
  67343. static readonly MATERIAL_LightDirtyFlag: number;
  67344. /**
  67345. * The dirty fresnel flag value
  67346. */
  67347. static readonly MATERIAL_FresnelDirtyFlag: number;
  67348. /**
  67349. * The dirty attribute flag value
  67350. */
  67351. static readonly MATERIAL_AttributesDirtyFlag: number;
  67352. /**
  67353. * The dirty misc flag value
  67354. */
  67355. static readonly MATERIAL_MiscDirtyFlag: number;
  67356. /**
  67357. * The all dirty flag value
  67358. */
  67359. static readonly MATERIAL_AllDirtyFlag: number;
  67360. /**
  67361. * Returns the triangle fill mode
  67362. */
  67363. static readonly MATERIAL_TriangleFillMode: number;
  67364. /**
  67365. * Returns the wireframe mode
  67366. */
  67367. static readonly MATERIAL_WireFrameFillMode: number;
  67368. /**
  67369. * Returns the point fill mode
  67370. */
  67371. static readonly MATERIAL_PointFillMode: number;
  67372. /**
  67373. * Returns the point list draw mode
  67374. */
  67375. static readonly MATERIAL_PointListDrawMode: number;
  67376. /**
  67377. * Returns the line list draw mode
  67378. */
  67379. static readonly MATERIAL_LineListDrawMode: number;
  67380. /**
  67381. * Returns the line loop draw mode
  67382. */
  67383. static readonly MATERIAL_LineLoopDrawMode: number;
  67384. /**
  67385. * Returns the line strip draw mode
  67386. */
  67387. static readonly MATERIAL_LineStripDrawMode: number;
  67388. /**
  67389. * Returns the triangle strip draw mode
  67390. */
  67391. static readonly MATERIAL_TriangleStripDrawMode: number;
  67392. /**
  67393. * Returns the triangle fan draw mode
  67394. */
  67395. static readonly MATERIAL_TriangleFanDrawMode: number;
  67396. /**
  67397. * Stores the clock-wise side orientation
  67398. */
  67399. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67400. /**
  67401. * Stores the counter clock-wise side orientation
  67402. */
  67403. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67404. /**
  67405. * Nothing
  67406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67407. */
  67408. static readonly ACTION_NothingTrigger: number;
  67409. /**
  67410. * On pick
  67411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67412. */
  67413. static readonly ACTION_OnPickTrigger: number;
  67414. /**
  67415. * On left pick
  67416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67417. */
  67418. static readonly ACTION_OnLeftPickTrigger: number;
  67419. /**
  67420. * On right pick
  67421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67422. */
  67423. static readonly ACTION_OnRightPickTrigger: number;
  67424. /**
  67425. * On center pick
  67426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67427. */
  67428. static readonly ACTION_OnCenterPickTrigger: number;
  67429. /**
  67430. * On pick down
  67431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67432. */
  67433. static readonly ACTION_OnPickDownTrigger: number;
  67434. /**
  67435. * On double pick
  67436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67437. */
  67438. static readonly ACTION_OnDoublePickTrigger: number;
  67439. /**
  67440. * On pick up
  67441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67442. */
  67443. static readonly ACTION_OnPickUpTrigger: number;
  67444. /**
  67445. * On pick out.
  67446. * This trigger will only be raised if you also declared a OnPickDown
  67447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67448. */
  67449. static readonly ACTION_OnPickOutTrigger: number;
  67450. /**
  67451. * On long press
  67452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67453. */
  67454. static readonly ACTION_OnLongPressTrigger: number;
  67455. /**
  67456. * On pointer over
  67457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67458. */
  67459. static readonly ACTION_OnPointerOverTrigger: number;
  67460. /**
  67461. * On pointer out
  67462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67463. */
  67464. static readonly ACTION_OnPointerOutTrigger: number;
  67465. /**
  67466. * On every frame
  67467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67468. */
  67469. static readonly ACTION_OnEveryFrameTrigger: number;
  67470. /**
  67471. * On intersection enter
  67472. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67473. */
  67474. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67475. /**
  67476. * On intersection exit
  67477. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67478. */
  67479. static readonly ACTION_OnIntersectionExitTrigger: number;
  67480. /**
  67481. * On key down
  67482. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67483. */
  67484. static readonly ACTION_OnKeyDownTrigger: number;
  67485. /**
  67486. * On key up
  67487. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67488. */
  67489. static readonly ACTION_OnKeyUpTrigger: number;
  67490. /**
  67491. * Billboard mode will only apply to Y axis
  67492. */
  67493. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67494. /**
  67495. * Billboard mode will apply to all axes
  67496. */
  67497. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67498. /**
  67499. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67500. */
  67501. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67502. /**
  67503. * Gets or sets base Assets URL
  67504. */
  67505. static PARTICLES_BaseAssetsUrl: string;
  67506. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67507. * Test order :
  67508. * Is the bounding sphere outside the frustum ?
  67509. * If not, are the bounding box vertices outside the frustum ?
  67510. * It not, then the cullable object is in the frustum.
  67511. */
  67512. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67513. /** Culling strategy : Bounding Sphere Only.
  67514. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67515. * It's also less accurate than the standard because some not visible objects can still be selected.
  67516. * Test : is the bounding sphere outside the frustum ?
  67517. * If not, then the cullable object is in the frustum.
  67518. */
  67519. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67520. /** Culling strategy : Optimistic Inclusion.
  67521. * This in an inclusion test first, then the standard exclusion test.
  67522. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67523. * 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.
  67524. * Anyway, it's as accurate as the standard strategy.
  67525. * Test :
  67526. * Is the cullable object bounding sphere center in the frustum ?
  67527. * If not, apply the default culling strategy.
  67528. */
  67529. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67530. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67531. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67532. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67533. * 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.
  67534. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67535. * Test :
  67536. * Is the cullable object bounding sphere center in the frustum ?
  67537. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67538. */
  67539. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67540. /**
  67541. * No logging while loading
  67542. */
  67543. static readonly SCENELOADER_NO_LOGGING: number;
  67544. /**
  67545. * Minimal logging while loading
  67546. */
  67547. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67548. /**
  67549. * Summary logging while loading
  67550. */
  67551. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67552. /**
  67553. * Detailled logging while loading
  67554. */
  67555. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67556. }
  67557. }
  67558. declare module BABYLON {
  67559. /**
  67560. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67561. * Babylon.js
  67562. */
  67563. export class DomManagement {
  67564. /**
  67565. * Checks if the window object exists
  67566. * @returns true if the window object exists
  67567. */
  67568. static IsWindowObjectExist(): boolean;
  67569. /**
  67570. * Extracts text content from a DOM element hierarchy
  67571. * @param element defines the root element
  67572. * @returns a string
  67573. */
  67574. static GetDOMTextContent(element: HTMLElement): string;
  67575. }
  67576. }
  67577. declare module BABYLON {
  67578. /**
  67579. * Logger used througouht the application to allow configuration of
  67580. * the log level required for the messages.
  67581. */
  67582. export class Logger {
  67583. /**
  67584. * No log
  67585. */
  67586. static readonly NoneLogLevel: number;
  67587. /**
  67588. * Only message logs
  67589. */
  67590. static readonly MessageLogLevel: number;
  67591. /**
  67592. * Only warning logs
  67593. */
  67594. static readonly WarningLogLevel: number;
  67595. /**
  67596. * Only error logs
  67597. */
  67598. static readonly ErrorLogLevel: number;
  67599. /**
  67600. * All logs
  67601. */
  67602. static readonly AllLogLevel: number;
  67603. private static _LogCache;
  67604. /**
  67605. * Gets a value indicating the number of loading errors
  67606. * @ignorenaming
  67607. */
  67608. static errorsCount: number;
  67609. /**
  67610. * Callback called when a new log is added
  67611. */
  67612. static OnNewCacheEntry: (entry: string) => void;
  67613. private static _AddLogEntry;
  67614. private static _FormatMessage;
  67615. private static _LogDisabled;
  67616. private static _LogEnabled;
  67617. private static _WarnDisabled;
  67618. private static _WarnEnabled;
  67619. private static _ErrorDisabled;
  67620. private static _ErrorEnabled;
  67621. /**
  67622. * Log a message to the console
  67623. */
  67624. static Log: (message: string) => void;
  67625. /**
  67626. * Write a warning message to the console
  67627. */
  67628. static Warn: (message: string) => void;
  67629. /**
  67630. * Write an error message to the console
  67631. */
  67632. static Error: (message: string) => void;
  67633. /**
  67634. * Gets current log cache (list of logs)
  67635. */
  67636. static readonly LogCache: string;
  67637. /**
  67638. * Clears the log cache
  67639. */
  67640. static ClearLogCache(): void;
  67641. /**
  67642. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67643. */
  67644. static LogLevels: number;
  67645. }
  67646. }
  67647. declare module BABYLON {
  67648. /** @hidden */
  67649. export class _TypeStore {
  67650. /** @hidden */
  67651. static RegisteredTypes: {
  67652. [key: string]: Object;
  67653. };
  67654. /** @hidden */
  67655. static GetClass(fqdn: string): any;
  67656. }
  67657. }
  67658. declare module BABYLON {
  67659. /**
  67660. * Class containing a set of static utilities functions for deep copy.
  67661. */
  67662. export class DeepCopier {
  67663. /**
  67664. * Tries to copy an object by duplicating every property
  67665. * @param source defines the source object
  67666. * @param destination defines the target object
  67667. * @param doNotCopyList defines a list of properties to avoid
  67668. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67669. */
  67670. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67671. }
  67672. }
  67673. declare module BABYLON {
  67674. /**
  67675. * Class containing a set of static utilities functions for precision date
  67676. */
  67677. export class PrecisionDate {
  67678. /**
  67679. * Gets either window.performance.now() if supported or Date.now() else
  67680. */
  67681. static readonly Now: number;
  67682. }
  67683. }
  67684. declare module BABYLON {
  67685. /** @hidden */
  67686. export class _DevTools {
  67687. static WarnImport(name: string): string;
  67688. }
  67689. }
  67690. declare module BABYLON {
  67691. /**
  67692. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67693. */
  67694. export class WebRequest {
  67695. private _xhr;
  67696. /**
  67697. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67698. * i.e. when loading files, where the server/service expects an Authorization header
  67699. */
  67700. static CustomRequestHeaders: {
  67701. [key: string]: string;
  67702. };
  67703. /**
  67704. * Add callback functions in this array to update all the requests before they get sent to the network
  67705. */
  67706. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67707. private _injectCustomRequestHeaders;
  67708. /**
  67709. * Gets or sets a function to be called when loading progress changes
  67710. */
  67711. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67712. /**
  67713. * Returns client's state
  67714. */
  67715. readonly readyState: number;
  67716. /**
  67717. * Returns client's status
  67718. */
  67719. readonly status: number;
  67720. /**
  67721. * Returns client's status as a text
  67722. */
  67723. readonly statusText: string;
  67724. /**
  67725. * Returns client's response
  67726. */
  67727. readonly response: any;
  67728. /**
  67729. * Returns client's response url
  67730. */
  67731. readonly responseURL: string;
  67732. /**
  67733. * Returns client's response as text
  67734. */
  67735. readonly responseText: string;
  67736. /**
  67737. * Gets or sets the expected response type
  67738. */
  67739. responseType: XMLHttpRequestResponseType;
  67740. /** @hidden */
  67741. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67742. /** @hidden */
  67743. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67744. /**
  67745. * Cancels any network activity
  67746. */
  67747. abort(): void;
  67748. /**
  67749. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67750. * @param body defines an optional request body
  67751. */
  67752. send(body?: Document | BodyInit | null): void;
  67753. /**
  67754. * Sets the request method, request URL
  67755. * @param method defines the method to use (GET, POST, etc..)
  67756. * @param url defines the url to connect with
  67757. */
  67758. open(method: string, url: string): void;
  67759. }
  67760. }
  67761. declare module BABYLON {
  67762. /**
  67763. * Class used to evalaute queries containing `and` and `or` operators
  67764. */
  67765. export class AndOrNotEvaluator {
  67766. /**
  67767. * Evaluate a query
  67768. * @param query defines the query to evaluate
  67769. * @param evaluateCallback defines the callback used to filter result
  67770. * @returns true if the query matches
  67771. */
  67772. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  67773. private static _HandleParenthesisContent;
  67774. private static _SimplifyNegation;
  67775. }
  67776. }
  67777. declare module BABYLON {
  67778. /**
  67779. * Class used to store custom tags
  67780. */
  67781. export class Tags {
  67782. /**
  67783. * Adds support for tags on the given object
  67784. * @param obj defines the object to use
  67785. */
  67786. static EnableFor(obj: any): void;
  67787. /**
  67788. * Removes tags support
  67789. * @param obj defines the object to use
  67790. */
  67791. static DisableFor(obj: any): void;
  67792. /**
  67793. * Gets a boolean indicating if the given object has tags
  67794. * @param obj defines the object to use
  67795. * @returns a boolean
  67796. */
  67797. static HasTags(obj: any): boolean;
  67798. /**
  67799. * Gets the tags available on a given object
  67800. * @param obj defines the object to use
  67801. * @param asString defines if the tags must be returned as a string instead of an array of strings
  67802. * @returns the tags
  67803. */
  67804. static GetTags(obj: any, asString?: boolean): any;
  67805. /**
  67806. * Adds tags to an object
  67807. * @param obj defines the object to use
  67808. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  67809. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  67810. */
  67811. static AddTagsTo(obj: any, tagsString: string): void;
  67812. /**
  67813. * @hidden
  67814. */
  67815. static _AddTagTo(obj: any, tag: string): void;
  67816. /**
  67817. * Removes specific tags from a specific object
  67818. * @param obj defines the object to use
  67819. * @param tagsString defines the tags to remove
  67820. */
  67821. static RemoveTagsFrom(obj: any, tagsString: string): void;
  67822. /**
  67823. * @hidden
  67824. */
  67825. static _RemoveTagFrom(obj: any, tag: string): void;
  67826. /**
  67827. * Defines if tags hosted on an object match a given query
  67828. * @param obj defines the object to use
  67829. * @param tagsQuery defines the tag query
  67830. * @returns a boolean
  67831. */
  67832. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  67833. }
  67834. }
  67835. declare module BABYLON {
  67836. /**
  67837. * Manages the defines for the Material
  67838. */
  67839. export class MaterialDefines {
  67840. /** @hidden */
  67841. protected _keys: string[];
  67842. private _isDirty;
  67843. /** @hidden */
  67844. _renderId: number;
  67845. /** @hidden */
  67846. _areLightsDirty: boolean;
  67847. /** @hidden */
  67848. _areAttributesDirty: boolean;
  67849. /** @hidden */
  67850. _areTexturesDirty: boolean;
  67851. /** @hidden */
  67852. _areFresnelDirty: boolean;
  67853. /** @hidden */
  67854. _areMiscDirty: boolean;
  67855. /** @hidden */
  67856. _areImageProcessingDirty: boolean;
  67857. /** @hidden */
  67858. _normals: boolean;
  67859. /** @hidden */
  67860. _uvs: boolean;
  67861. /** @hidden */
  67862. _needNormals: boolean;
  67863. /** @hidden */
  67864. _needUVs: boolean;
  67865. [id: string]: any;
  67866. /**
  67867. * Specifies if the material needs to be re-calculated
  67868. */
  67869. readonly isDirty: boolean;
  67870. /**
  67871. * Marks the material to indicate that it has been re-calculated
  67872. */
  67873. markAsProcessed(): void;
  67874. /**
  67875. * Marks the material to indicate that it needs to be re-calculated
  67876. */
  67877. markAsUnprocessed(): void;
  67878. /**
  67879. * Marks the material to indicate all of its defines need to be re-calculated
  67880. */
  67881. markAllAsDirty(): void;
  67882. /**
  67883. * Marks the material to indicate that image processing needs to be re-calculated
  67884. */
  67885. markAsImageProcessingDirty(): void;
  67886. /**
  67887. * Marks the material to indicate the lights need to be re-calculated
  67888. */
  67889. markAsLightDirty(): void;
  67890. /**
  67891. * Marks the attribute state as changed
  67892. */
  67893. markAsAttributesDirty(): void;
  67894. /**
  67895. * Marks the texture state as changed
  67896. */
  67897. markAsTexturesDirty(): void;
  67898. /**
  67899. * Marks the fresnel state as changed
  67900. */
  67901. markAsFresnelDirty(): void;
  67902. /**
  67903. * Marks the misc state as changed
  67904. */
  67905. markAsMiscDirty(): void;
  67906. /**
  67907. * Rebuilds the material defines
  67908. */
  67909. rebuild(): void;
  67910. /**
  67911. * Specifies if two material defines are equal
  67912. * @param other - A material define instance to compare to
  67913. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  67914. */
  67915. isEqual(other: MaterialDefines): boolean;
  67916. /**
  67917. * Clones this instance's defines to another instance
  67918. * @param other - material defines to clone values to
  67919. */
  67920. cloneTo(other: MaterialDefines): void;
  67921. /**
  67922. * Resets the material define values
  67923. */
  67924. reset(): void;
  67925. /**
  67926. * Converts the material define values to a string
  67927. * @returns - String of material define information
  67928. */
  67929. toString(): string;
  67930. }
  67931. }
  67932. declare module BABYLON {
  67933. /**
  67934. * Class used to store and describe the pipeline context associated with an effect
  67935. */
  67936. export interface IPipelineContext {
  67937. /**
  67938. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67939. */
  67940. isAsync: boolean;
  67941. /**
  67942. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67943. */
  67944. isReady: boolean;
  67945. /** @hidden */
  67946. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67947. }
  67948. }
  67949. declare module BABYLON {
  67950. /**
  67951. * Class used to store gfx data (like WebGLBuffer)
  67952. */
  67953. export class DataBuffer {
  67954. /**
  67955. * Gets or sets the number of objects referencing this buffer
  67956. */
  67957. references: number;
  67958. /** Gets or sets the size of the underlying buffer */
  67959. capacity: number;
  67960. /**
  67961. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67962. */
  67963. is32Bits: boolean;
  67964. /**
  67965. * Gets the underlying buffer
  67966. */
  67967. readonly underlyingResource: any;
  67968. }
  67969. }
  67970. declare module BABYLON {
  67971. /** @hidden */
  67972. export interface IShaderProcessor {
  67973. attributeProcessor?: (attribute: string) => string;
  67974. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67975. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  67976. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  67977. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  67978. lineProcessor?: (line: string, isFragment: boolean) => string;
  67979. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67980. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67981. }
  67982. }
  67983. declare module BABYLON {
  67984. /** @hidden */
  67985. export interface ProcessingOptions {
  67986. defines: string[];
  67987. indexParameters: any;
  67988. isFragment: boolean;
  67989. shouldUseHighPrecisionShader: boolean;
  67990. supportsUniformBuffers: boolean;
  67991. shadersRepository: string;
  67992. includesShadersStore: {
  67993. [key: string]: string;
  67994. };
  67995. processor?: IShaderProcessor;
  67996. version: string;
  67997. platformName: string;
  67998. lookForClosingBracketForUniformBuffer?: boolean;
  67999. }
  68000. }
  68001. declare module BABYLON {
  68002. /** @hidden */
  68003. export class ShaderCodeNode {
  68004. line: string;
  68005. children: ShaderCodeNode[];
  68006. additionalDefineKey?: string;
  68007. additionalDefineValue?: string;
  68008. isValid(preprocessors: {
  68009. [key: string]: string;
  68010. }): boolean;
  68011. process(preprocessors: {
  68012. [key: string]: string;
  68013. }, options: ProcessingOptions): string;
  68014. }
  68015. }
  68016. declare module BABYLON {
  68017. /** @hidden */
  68018. export class ShaderCodeCursor {
  68019. private _lines;
  68020. lineIndex: number;
  68021. readonly currentLine: string;
  68022. readonly canRead: boolean;
  68023. lines: string[];
  68024. }
  68025. }
  68026. declare module BABYLON {
  68027. /** @hidden */
  68028. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68029. process(preprocessors: {
  68030. [key: string]: string;
  68031. }, options: ProcessingOptions): string;
  68032. }
  68033. }
  68034. declare module BABYLON {
  68035. /** @hidden */
  68036. export class ShaderDefineExpression {
  68037. isTrue(preprocessors: {
  68038. [key: string]: string;
  68039. }): boolean;
  68040. }
  68041. }
  68042. declare module BABYLON {
  68043. /** @hidden */
  68044. export class ShaderCodeTestNode extends ShaderCodeNode {
  68045. testExpression: ShaderDefineExpression;
  68046. isValid(preprocessors: {
  68047. [key: string]: string;
  68048. }): boolean;
  68049. }
  68050. }
  68051. declare module BABYLON {
  68052. /** @hidden */
  68053. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68054. define: string;
  68055. not: boolean;
  68056. constructor(define: string, not?: boolean);
  68057. isTrue(preprocessors: {
  68058. [key: string]: string;
  68059. }): boolean;
  68060. }
  68061. }
  68062. declare module BABYLON {
  68063. /** @hidden */
  68064. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68065. leftOperand: ShaderDefineExpression;
  68066. rightOperand: ShaderDefineExpression;
  68067. isTrue(preprocessors: {
  68068. [key: string]: string;
  68069. }): boolean;
  68070. }
  68071. }
  68072. declare module BABYLON {
  68073. /** @hidden */
  68074. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68075. leftOperand: ShaderDefineExpression;
  68076. rightOperand: ShaderDefineExpression;
  68077. isTrue(preprocessors: {
  68078. [key: string]: string;
  68079. }): boolean;
  68080. }
  68081. }
  68082. declare module BABYLON {
  68083. /** @hidden */
  68084. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68085. define: string;
  68086. operand: string;
  68087. testValue: string;
  68088. constructor(define: string, operand: string, testValue: string);
  68089. isTrue(preprocessors: {
  68090. [key: string]: string;
  68091. }): boolean;
  68092. }
  68093. }
  68094. declare module BABYLON {
  68095. /** @hidden */
  68096. export class ShaderProcessor {
  68097. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68098. private static _ProcessPrecision;
  68099. private static _ExtractOperation;
  68100. private static _BuildSubExpression;
  68101. private static _BuildExpression;
  68102. private static _MoveCursorWithinIf;
  68103. private static _MoveCursor;
  68104. private static _EvaluatePreProcessors;
  68105. private static _PreparePreProcessors;
  68106. private static _ProcessShaderConversion;
  68107. private static _ProcessIncludes;
  68108. }
  68109. }
  68110. declare module BABYLON {
  68111. /**
  68112. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  68113. */
  68114. export class PerformanceMonitor {
  68115. private _enabled;
  68116. private _rollingFrameTime;
  68117. private _lastFrameTimeMs;
  68118. /**
  68119. * constructor
  68120. * @param frameSampleSize The number of samples required to saturate the sliding window
  68121. */
  68122. constructor(frameSampleSize?: number);
  68123. /**
  68124. * Samples current frame
  68125. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  68126. */
  68127. sampleFrame(timeMs?: number): void;
  68128. /**
  68129. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68130. */
  68131. readonly averageFrameTime: number;
  68132. /**
  68133. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68134. */
  68135. readonly averageFrameTimeVariance: number;
  68136. /**
  68137. * Returns the frame time of the most recent frame
  68138. */
  68139. readonly instantaneousFrameTime: number;
  68140. /**
  68141. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  68142. */
  68143. readonly averageFPS: number;
  68144. /**
  68145. * Returns the average framerate in frames per second using the most recent frame time
  68146. */
  68147. readonly instantaneousFPS: number;
  68148. /**
  68149. * Returns true if enough samples have been taken to completely fill the sliding window
  68150. */
  68151. readonly isSaturated: boolean;
  68152. /**
  68153. * Enables contributions to the sliding window sample set
  68154. */
  68155. enable(): void;
  68156. /**
  68157. * Disables contributions to the sliding window sample set
  68158. * Samples will not be interpolated over the disabled period
  68159. */
  68160. disable(): void;
  68161. /**
  68162. * Returns true if sampling is enabled
  68163. */
  68164. readonly isEnabled: boolean;
  68165. /**
  68166. * Resets performance monitor
  68167. */
  68168. reset(): void;
  68169. }
  68170. /**
  68171. * RollingAverage
  68172. *
  68173. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  68174. */
  68175. export class RollingAverage {
  68176. /**
  68177. * Current average
  68178. */
  68179. average: number;
  68180. /**
  68181. * Current variance
  68182. */
  68183. variance: number;
  68184. protected _samples: Array<number>;
  68185. protected _sampleCount: number;
  68186. protected _pos: number;
  68187. protected _m2: number;
  68188. /**
  68189. * constructor
  68190. * @param length The number of samples required to saturate the sliding window
  68191. */
  68192. constructor(length: number);
  68193. /**
  68194. * Adds a sample to the sample set
  68195. * @param v The sample value
  68196. */
  68197. add(v: number): void;
  68198. /**
  68199. * Returns previously added values or null if outside of history or outside the sliding window domain
  68200. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  68201. * @return Value previously recorded with add() or null if outside of range
  68202. */
  68203. history(i: number): number;
  68204. /**
  68205. * Returns true if enough samples have been taken to completely fill the sliding window
  68206. * @return true if sample-set saturated
  68207. */
  68208. isSaturated(): boolean;
  68209. /**
  68210. * Resets the rolling average (equivalent to 0 samples taken so far)
  68211. */
  68212. reset(): void;
  68213. /**
  68214. * Wraps a value around the sample range boundaries
  68215. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  68216. * @return Wrapped position in sample range
  68217. */
  68218. protected _wrapPosition(i: number): number;
  68219. }
  68220. }
  68221. declare module BABYLON {
  68222. /**
  68223. * This class implement a typical dictionary using a string as key and the generic type T as value.
  68224. * The underlying implementation relies on an associative array to ensure the best performances.
  68225. * The value can be anything including 'null' but except 'undefined'
  68226. */
  68227. export class StringDictionary<T> {
  68228. /**
  68229. * This will clear this dictionary and copy the content from the 'source' one.
  68230. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  68231. * @param source the dictionary to take the content from and copy to this dictionary
  68232. */
  68233. copyFrom(source: StringDictionary<T>): void;
  68234. /**
  68235. * Get a value based from its key
  68236. * @param key the given key to get the matching value from
  68237. * @return the value if found, otherwise undefined is returned
  68238. */
  68239. get(key: string): T | undefined;
  68240. /**
  68241. * Get a value from its key or add it if it doesn't exist.
  68242. * This method will ensure you that a given key/data will be present in the dictionary.
  68243. * @param key the given key to get the matching value from
  68244. * @param factory the factory that will create the value if the key is not present in the dictionary.
  68245. * The factory will only be invoked if there's no data for the given key.
  68246. * @return the value corresponding to the key.
  68247. */
  68248. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  68249. /**
  68250. * Get a value from its key if present in the dictionary otherwise add it
  68251. * @param key the key to get the value from
  68252. * @param val if there's no such key/value pair in the dictionary add it with this value
  68253. * @return the value corresponding to the key
  68254. */
  68255. getOrAdd(key: string, val: T): T;
  68256. /**
  68257. * Check if there's a given key in the dictionary
  68258. * @param key the key to check for
  68259. * @return true if the key is present, false otherwise
  68260. */
  68261. contains(key: string): boolean;
  68262. /**
  68263. * Add a new key and its corresponding value
  68264. * @param key the key to add
  68265. * @param value the value corresponding to the key
  68266. * @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
  68267. */
  68268. add(key: string, value: T): boolean;
  68269. /**
  68270. * Update a specific value associated to a key
  68271. * @param key defines the key to use
  68272. * @param value defines the value to store
  68273. * @returns true if the value was updated (or false if the key was not found)
  68274. */
  68275. set(key: string, value: T): boolean;
  68276. /**
  68277. * Get the element of the given key and remove it from the dictionary
  68278. * @param key defines the key to search
  68279. * @returns the value associated with the key or null if not found
  68280. */
  68281. getAndRemove(key: string): Nullable<T>;
  68282. /**
  68283. * Remove a key/value from the dictionary.
  68284. * @param key the key to remove
  68285. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  68286. */
  68287. remove(key: string): boolean;
  68288. /**
  68289. * Clear the whole content of the dictionary
  68290. */
  68291. clear(): void;
  68292. /**
  68293. * Gets the current count
  68294. */
  68295. readonly count: number;
  68296. /**
  68297. * Execute a callback on each key/val of the dictionary.
  68298. * Note that you can remove any element in this dictionary in the callback implementation
  68299. * @param callback the callback to execute on a given key/value pair
  68300. */
  68301. forEach(callback: (key: string, val: T) => void): void;
  68302. /**
  68303. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  68304. * If the callback returns null or undefined the method will iterate to the next key/value pair
  68305. * Note that you can remove any element in this dictionary in the callback implementation
  68306. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  68307. * @returns the first item
  68308. */
  68309. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  68310. private _count;
  68311. private _data;
  68312. }
  68313. }
  68314. declare module BABYLON {
  68315. /**
  68316. * Helper class that provides a small promise polyfill
  68317. */
  68318. export class PromisePolyfill {
  68319. /**
  68320. * Static function used to check if the polyfill is required
  68321. * If this is the case then the function will inject the polyfill to window.Promise
  68322. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  68323. */
  68324. static Apply(force?: boolean): void;
  68325. }
  68326. }
  68327. declare module BABYLON {
  68328. /**
  68329. * Class used to store data that will be store in GPU memory
  68330. */
  68331. export class Buffer {
  68332. private _engine;
  68333. private _buffer;
  68334. /** @hidden */
  68335. _data: Nullable<DataArray>;
  68336. private _updatable;
  68337. private _instanced;
  68338. /**
  68339. * Gets the byte stride.
  68340. */
  68341. readonly byteStride: number;
  68342. /**
  68343. * Constructor
  68344. * @param engine the engine
  68345. * @param data the data to use for this buffer
  68346. * @param updatable whether the data is updatable
  68347. * @param stride the stride (optional)
  68348. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68349. * @param instanced whether the buffer is instanced (optional)
  68350. * @param useBytes set to true if the stride in in bytes (optional)
  68351. */
  68352. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68353. /**
  68354. * Create a new VertexBuffer based on the current buffer
  68355. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68356. * @param offset defines offset in the buffer (0 by default)
  68357. * @param size defines the size in floats of attributes (position is 3 for instance)
  68358. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68359. * @param instanced defines if the vertex buffer contains indexed data
  68360. * @param useBytes defines if the offset and stride are in bytes
  68361. * @returns the new vertex buffer
  68362. */
  68363. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68364. /**
  68365. * Gets a boolean indicating if the Buffer is updatable?
  68366. * @returns true if the buffer is updatable
  68367. */
  68368. isUpdatable(): boolean;
  68369. /**
  68370. * Gets current buffer's data
  68371. * @returns a DataArray or null
  68372. */
  68373. getData(): Nullable<DataArray>;
  68374. /**
  68375. * Gets underlying native buffer
  68376. * @returns underlying native buffer
  68377. */
  68378. getBuffer(): Nullable<DataBuffer>;
  68379. /**
  68380. * Gets the stride in float32 units (i.e. byte stride / 4).
  68381. * May not be an integer if the byte stride is not divisible by 4.
  68382. * DEPRECATED. Use byteStride instead.
  68383. * @returns the stride in float32 units
  68384. */
  68385. getStrideSize(): number;
  68386. /**
  68387. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68388. * @param data defines the data to store
  68389. */
  68390. create(data?: Nullable<DataArray>): void;
  68391. /** @hidden */
  68392. _rebuild(): void;
  68393. /**
  68394. * Update current buffer data
  68395. * @param data defines the data to store
  68396. */
  68397. update(data: DataArray): void;
  68398. /**
  68399. * Updates the data directly.
  68400. * @param data the new data
  68401. * @param offset the new offset
  68402. * @param vertexCount the vertex count (optional)
  68403. * @param useBytes set to true if the offset is in bytes
  68404. */
  68405. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68406. /**
  68407. * Release all resources
  68408. */
  68409. dispose(): void;
  68410. }
  68411. /**
  68412. * Specialized buffer used to store vertex data
  68413. */
  68414. export class VertexBuffer {
  68415. /** @hidden */
  68416. _buffer: Buffer;
  68417. private _kind;
  68418. private _size;
  68419. private _ownsBuffer;
  68420. private _instanced;
  68421. private _instanceDivisor;
  68422. /**
  68423. * The byte type.
  68424. */
  68425. static readonly BYTE: number;
  68426. /**
  68427. * The unsigned byte type.
  68428. */
  68429. static readonly UNSIGNED_BYTE: number;
  68430. /**
  68431. * The short type.
  68432. */
  68433. static readonly SHORT: number;
  68434. /**
  68435. * The unsigned short type.
  68436. */
  68437. static readonly UNSIGNED_SHORT: number;
  68438. /**
  68439. * The integer type.
  68440. */
  68441. static readonly INT: number;
  68442. /**
  68443. * The unsigned integer type.
  68444. */
  68445. static readonly UNSIGNED_INT: number;
  68446. /**
  68447. * The float type.
  68448. */
  68449. static readonly FLOAT: number;
  68450. /**
  68451. * Gets or sets the instance divisor when in instanced mode
  68452. */
  68453. instanceDivisor: number;
  68454. /**
  68455. * Gets the byte stride.
  68456. */
  68457. readonly byteStride: number;
  68458. /**
  68459. * Gets the byte offset.
  68460. */
  68461. readonly byteOffset: number;
  68462. /**
  68463. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68464. */
  68465. readonly normalized: boolean;
  68466. /**
  68467. * Gets the data type of each component in the array.
  68468. */
  68469. readonly type: number;
  68470. /**
  68471. * Constructor
  68472. * @param engine the engine
  68473. * @param data the data to use for this vertex buffer
  68474. * @param kind the vertex buffer kind
  68475. * @param updatable whether the data is updatable
  68476. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68477. * @param stride the stride (optional)
  68478. * @param instanced whether the buffer is instanced (optional)
  68479. * @param offset the offset of the data (optional)
  68480. * @param size the number of components (optional)
  68481. * @param type the type of the component (optional)
  68482. * @param normalized whether the data contains normalized data (optional)
  68483. * @param useBytes set to true if stride and offset are in bytes (optional)
  68484. */
  68485. 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);
  68486. /** @hidden */
  68487. _rebuild(): void;
  68488. /**
  68489. * Returns the kind of the VertexBuffer (string)
  68490. * @returns a string
  68491. */
  68492. getKind(): string;
  68493. /**
  68494. * Gets a boolean indicating if the VertexBuffer is updatable?
  68495. * @returns true if the buffer is updatable
  68496. */
  68497. isUpdatable(): boolean;
  68498. /**
  68499. * Gets current buffer's data
  68500. * @returns a DataArray or null
  68501. */
  68502. getData(): Nullable<DataArray>;
  68503. /**
  68504. * Gets underlying native buffer
  68505. * @returns underlying native buffer
  68506. */
  68507. getBuffer(): Nullable<DataBuffer>;
  68508. /**
  68509. * Gets the stride in float32 units (i.e. byte stride / 4).
  68510. * May not be an integer if the byte stride is not divisible by 4.
  68511. * DEPRECATED. Use byteStride instead.
  68512. * @returns the stride in float32 units
  68513. */
  68514. getStrideSize(): number;
  68515. /**
  68516. * Returns the offset as a multiple of the type byte length.
  68517. * DEPRECATED. Use byteOffset instead.
  68518. * @returns the offset in bytes
  68519. */
  68520. getOffset(): number;
  68521. /**
  68522. * Returns the number of components per vertex attribute (integer)
  68523. * @returns the size in float
  68524. */
  68525. getSize(): number;
  68526. /**
  68527. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68528. * @returns true if this buffer is instanced
  68529. */
  68530. getIsInstanced(): boolean;
  68531. /**
  68532. * Returns the instancing divisor, zero for non-instanced (integer).
  68533. * @returns a number
  68534. */
  68535. getInstanceDivisor(): number;
  68536. /**
  68537. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68538. * @param data defines the data to store
  68539. */
  68540. create(data?: DataArray): void;
  68541. /**
  68542. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68543. * This function will create a new buffer if the current one is not updatable
  68544. * @param data defines the data to store
  68545. */
  68546. update(data: DataArray): void;
  68547. /**
  68548. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68549. * Returns the directly updated WebGLBuffer.
  68550. * @param data the new data
  68551. * @param offset the new offset
  68552. * @param useBytes set to true if the offset is in bytes
  68553. */
  68554. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68555. /**
  68556. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68557. */
  68558. dispose(): void;
  68559. /**
  68560. * Enumerates each value of this vertex buffer as numbers.
  68561. * @param count the number of values to enumerate
  68562. * @param callback the callback function called for each value
  68563. */
  68564. forEach(count: number, callback: (value: number, index: number) => void): void;
  68565. /**
  68566. * Positions
  68567. */
  68568. static readonly PositionKind: string;
  68569. /**
  68570. * Normals
  68571. */
  68572. static readonly NormalKind: string;
  68573. /**
  68574. * Tangents
  68575. */
  68576. static readonly TangentKind: string;
  68577. /**
  68578. * Texture coordinates
  68579. */
  68580. static readonly UVKind: string;
  68581. /**
  68582. * Texture coordinates 2
  68583. */
  68584. static readonly UV2Kind: string;
  68585. /**
  68586. * Texture coordinates 3
  68587. */
  68588. static readonly UV3Kind: string;
  68589. /**
  68590. * Texture coordinates 4
  68591. */
  68592. static readonly UV4Kind: string;
  68593. /**
  68594. * Texture coordinates 5
  68595. */
  68596. static readonly UV5Kind: string;
  68597. /**
  68598. * Texture coordinates 6
  68599. */
  68600. static readonly UV6Kind: string;
  68601. /**
  68602. * Colors
  68603. */
  68604. static readonly ColorKind: string;
  68605. /**
  68606. * Matrix indices (for bones)
  68607. */
  68608. static readonly MatricesIndicesKind: string;
  68609. /**
  68610. * Matrix weights (for bones)
  68611. */
  68612. static readonly MatricesWeightsKind: string;
  68613. /**
  68614. * Additional matrix indices (for bones)
  68615. */
  68616. static readonly MatricesIndicesExtraKind: string;
  68617. /**
  68618. * Additional matrix weights (for bones)
  68619. */
  68620. static readonly MatricesWeightsExtraKind: string;
  68621. /**
  68622. * Deduces the stride given a kind.
  68623. * @param kind The kind string to deduce
  68624. * @returns The deduced stride
  68625. */
  68626. static DeduceStride(kind: string): number;
  68627. /**
  68628. * Gets the byte length of the given type.
  68629. * @param type the type
  68630. * @returns the number of bytes
  68631. */
  68632. static GetTypeByteLength(type: number): number;
  68633. /**
  68634. * Enumerates each value of the given parameters as numbers.
  68635. * @param data the data to enumerate
  68636. * @param byteOffset the byte offset of the data
  68637. * @param byteStride the byte stride of the data
  68638. * @param componentCount the number of components per element
  68639. * @param componentType the type of the component
  68640. * @param count the number of values to enumerate
  68641. * @param normalized whether the data is normalized
  68642. * @param callback the callback function called for each value
  68643. */
  68644. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68645. private static _GetFloatValue;
  68646. }
  68647. }
  68648. declare module BABYLON {
  68649. /**
  68650. * Class representing spherical harmonics coefficients to the 3rd degree
  68651. */
  68652. export class SphericalHarmonics {
  68653. /**
  68654. * Defines whether or not the harmonics have been prescaled for rendering.
  68655. */
  68656. preScaled: boolean;
  68657. /**
  68658. * The l0,0 coefficients of the spherical harmonics
  68659. */
  68660. l00: Vector3;
  68661. /**
  68662. * The l1,-1 coefficients of the spherical harmonics
  68663. */
  68664. l1_1: Vector3;
  68665. /**
  68666. * The l1,0 coefficients of the spherical harmonics
  68667. */
  68668. l10: Vector3;
  68669. /**
  68670. * The l1,1 coefficients of the spherical harmonics
  68671. */
  68672. l11: Vector3;
  68673. /**
  68674. * The l2,-2 coefficients of the spherical harmonics
  68675. */
  68676. l2_2: Vector3;
  68677. /**
  68678. * The l2,-1 coefficients of the spherical harmonics
  68679. */
  68680. l2_1: Vector3;
  68681. /**
  68682. * The l2,0 coefficients of the spherical harmonics
  68683. */
  68684. l20: Vector3;
  68685. /**
  68686. * The l2,1 coefficients of the spherical harmonics
  68687. */
  68688. l21: Vector3;
  68689. /**
  68690. * The l2,2 coefficients of the spherical harmonics
  68691. */
  68692. l22: Vector3;
  68693. /**
  68694. * Adds a light to the spherical harmonics
  68695. * @param direction the direction of the light
  68696. * @param color the color of the light
  68697. * @param deltaSolidAngle the delta solid angle of the light
  68698. */
  68699. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  68700. /**
  68701. * Scales the spherical harmonics by the given amount
  68702. * @param scale the amount to scale
  68703. */
  68704. scaleInPlace(scale: number): void;
  68705. /**
  68706. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  68707. *
  68708. * ```
  68709. * E_lm = A_l * L_lm
  68710. * ```
  68711. *
  68712. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  68713. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68714. * the scaling factors are given in equation 9.
  68715. */
  68716. convertIncidentRadianceToIrradiance(): void;
  68717. /**
  68718. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68719. *
  68720. * ```
  68721. * L = (1/pi) * E * rho
  68722. * ```
  68723. *
  68724. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68725. */
  68726. convertIrradianceToLambertianRadiance(): void;
  68727. /**
  68728. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68729. * required operations at run time.
  68730. *
  68731. * This is simply done by scaling back the SH with Ylm constants parameter.
  68732. * The trigonometric part being applied by the shader at run time.
  68733. */
  68734. preScaleForRendering(): void;
  68735. /**
  68736. * Constructs a spherical harmonics from an array.
  68737. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68738. * @returns the spherical harmonics
  68739. */
  68740. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68741. /**
  68742. * Gets the spherical harmonics from polynomial
  68743. * @param polynomial the spherical polynomial
  68744. * @returns the spherical harmonics
  68745. */
  68746. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  68747. }
  68748. /**
  68749. * Class representing spherical polynomial coefficients to the 3rd degree
  68750. */
  68751. export class SphericalPolynomial {
  68752. private _harmonics;
  68753. /**
  68754. * The spherical harmonics used to create the polynomials.
  68755. */
  68756. readonly preScaledHarmonics: SphericalHarmonics;
  68757. /**
  68758. * The x coefficients of the spherical polynomial
  68759. */
  68760. x: Vector3;
  68761. /**
  68762. * The y coefficients of the spherical polynomial
  68763. */
  68764. y: Vector3;
  68765. /**
  68766. * The z coefficients of the spherical polynomial
  68767. */
  68768. z: Vector3;
  68769. /**
  68770. * The xx coefficients of the spherical polynomial
  68771. */
  68772. xx: Vector3;
  68773. /**
  68774. * The yy coefficients of the spherical polynomial
  68775. */
  68776. yy: Vector3;
  68777. /**
  68778. * The zz coefficients of the spherical polynomial
  68779. */
  68780. zz: Vector3;
  68781. /**
  68782. * The xy coefficients of the spherical polynomial
  68783. */
  68784. xy: Vector3;
  68785. /**
  68786. * The yz coefficients of the spherical polynomial
  68787. */
  68788. yz: Vector3;
  68789. /**
  68790. * The zx coefficients of the spherical polynomial
  68791. */
  68792. zx: Vector3;
  68793. /**
  68794. * Adds an ambient color to the spherical polynomial
  68795. * @param color the color to add
  68796. */
  68797. addAmbient(color: Color3): void;
  68798. /**
  68799. * Scales the spherical polynomial by the given amount
  68800. * @param scale the amount to scale
  68801. */
  68802. scaleInPlace(scale: number): void;
  68803. /**
  68804. * Gets the spherical polynomial from harmonics
  68805. * @param harmonics the spherical harmonics
  68806. * @returns the spherical polynomial
  68807. */
  68808. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  68809. /**
  68810. * Constructs a spherical polynomial from an array.
  68811. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  68812. * @returns the spherical polynomial
  68813. */
  68814. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  68815. }
  68816. }
  68817. declare module BABYLON {
  68818. /**
  68819. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  68820. */
  68821. export interface CubeMapInfo {
  68822. /**
  68823. * The pixel array for the front face.
  68824. * This is stored in format, left to right, up to down format.
  68825. */
  68826. front: Nullable<ArrayBufferView>;
  68827. /**
  68828. * The pixel array for the back face.
  68829. * This is stored in format, left to right, up to down format.
  68830. */
  68831. back: Nullable<ArrayBufferView>;
  68832. /**
  68833. * The pixel array for the left face.
  68834. * This is stored in format, left to right, up to down format.
  68835. */
  68836. left: Nullable<ArrayBufferView>;
  68837. /**
  68838. * The pixel array for the right face.
  68839. * This is stored in format, left to right, up to down format.
  68840. */
  68841. right: Nullable<ArrayBufferView>;
  68842. /**
  68843. * The pixel array for the up face.
  68844. * This is stored in format, left to right, up to down format.
  68845. */
  68846. up: Nullable<ArrayBufferView>;
  68847. /**
  68848. * The pixel array for the down face.
  68849. * This is stored in format, left to right, up to down format.
  68850. */
  68851. down: Nullable<ArrayBufferView>;
  68852. /**
  68853. * The size of the cubemap stored.
  68854. *
  68855. * Each faces will be size * size pixels.
  68856. */
  68857. size: number;
  68858. /**
  68859. * The format of the texture.
  68860. *
  68861. * RGBA, RGB.
  68862. */
  68863. format: number;
  68864. /**
  68865. * The type of the texture data.
  68866. *
  68867. * UNSIGNED_INT, FLOAT.
  68868. */
  68869. type: number;
  68870. /**
  68871. * Specifies whether the texture is in gamma space.
  68872. */
  68873. gammaSpace: boolean;
  68874. }
  68875. /**
  68876. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  68877. */
  68878. export class PanoramaToCubeMapTools {
  68879. private static FACE_FRONT;
  68880. private static FACE_BACK;
  68881. private static FACE_RIGHT;
  68882. private static FACE_LEFT;
  68883. private static FACE_DOWN;
  68884. private static FACE_UP;
  68885. /**
  68886. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  68887. *
  68888. * @param float32Array The source data.
  68889. * @param inputWidth The width of the input panorama.
  68890. * @param inputHeight The height of the input panorama.
  68891. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  68892. * @return The cubemap data
  68893. */
  68894. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  68895. private static CreateCubemapTexture;
  68896. private static CalcProjectionSpherical;
  68897. }
  68898. }
  68899. declare module BABYLON {
  68900. /**
  68901. * Helper class dealing with the extraction of spherical polynomial dataArray
  68902. * from a cube map.
  68903. */
  68904. export class CubeMapToSphericalPolynomialTools {
  68905. private static FileFaces;
  68906. /**
  68907. * Converts a texture to the according Spherical Polynomial data.
  68908. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68909. *
  68910. * @param texture The texture to extract the information from.
  68911. * @return The Spherical Polynomial data.
  68912. */
  68913. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  68914. /**
  68915. * Converts a cubemap to the according Spherical Polynomial data.
  68916. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68917. *
  68918. * @param cubeInfo The Cube map to extract the information from.
  68919. * @return The Spherical Polynomial data.
  68920. */
  68921. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  68922. }
  68923. }
  68924. declare module BABYLON {
  68925. /**
  68926. * The engine store class is responsible to hold all the instances of Engine and Scene created
  68927. * during the life time of the application.
  68928. */
  68929. export class EngineStore {
  68930. /** Gets the list of created engines */
  68931. static Instances: Engine[];
  68932. /** @hidden */
  68933. static _LastCreatedScene: Nullable<Scene>;
  68934. /**
  68935. * Gets the latest created engine
  68936. */
  68937. static readonly LastCreatedEngine: Nullable<Engine>;
  68938. /**
  68939. * Gets the latest created scene
  68940. */
  68941. static readonly LastCreatedScene: Nullable<Scene>;
  68942. }
  68943. }
  68944. declare module BABYLON {
  68945. /**
  68946. * Define options used to create a render target texture
  68947. */
  68948. export class RenderTargetCreationOptions {
  68949. /**
  68950. * Specifies is mipmaps must be generated
  68951. */
  68952. generateMipMaps?: boolean;
  68953. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68954. generateDepthBuffer?: boolean;
  68955. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68956. generateStencilBuffer?: boolean;
  68957. /** Defines texture type (int by default) */
  68958. type?: number;
  68959. /** Defines sampling mode (trilinear by default) */
  68960. samplingMode?: number;
  68961. /** Defines format (RGBA by default) */
  68962. format?: number;
  68963. }
  68964. }
  68965. declare module BABYLON {
  68966. /**
  68967. * @hidden
  68968. **/
  68969. export class _AlphaState {
  68970. private _isAlphaBlendDirty;
  68971. private _isBlendFunctionParametersDirty;
  68972. private _isBlendEquationParametersDirty;
  68973. private _isBlendConstantsDirty;
  68974. private _alphaBlend;
  68975. private _blendFunctionParameters;
  68976. private _blendEquationParameters;
  68977. private _blendConstants;
  68978. /**
  68979. * Initializes the state.
  68980. */
  68981. constructor();
  68982. readonly isDirty: boolean;
  68983. alphaBlend: boolean;
  68984. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  68985. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  68986. setAlphaEquationParameters(rgb: number, alpha: number): void;
  68987. reset(): void;
  68988. apply(gl: WebGLRenderingContext): void;
  68989. }
  68990. }
  68991. declare module BABYLON {
  68992. /**
  68993. * @hidden
  68994. **/
  68995. export class _DepthCullingState {
  68996. private _isDepthTestDirty;
  68997. private _isDepthMaskDirty;
  68998. private _isDepthFuncDirty;
  68999. private _isCullFaceDirty;
  69000. private _isCullDirty;
  69001. private _isZOffsetDirty;
  69002. private _isFrontFaceDirty;
  69003. private _depthTest;
  69004. private _depthMask;
  69005. private _depthFunc;
  69006. private _cull;
  69007. private _cullFace;
  69008. private _zOffset;
  69009. private _frontFace;
  69010. /**
  69011. * Initializes the state.
  69012. */
  69013. constructor();
  69014. readonly isDirty: boolean;
  69015. zOffset: number;
  69016. cullFace: Nullable<number>;
  69017. cull: Nullable<boolean>;
  69018. depthFunc: Nullable<number>;
  69019. depthMask: boolean;
  69020. depthTest: boolean;
  69021. frontFace: Nullable<number>;
  69022. reset(): void;
  69023. apply(gl: WebGLRenderingContext): void;
  69024. }
  69025. }
  69026. declare module BABYLON {
  69027. /**
  69028. * @hidden
  69029. **/
  69030. export class _StencilState {
  69031. /** 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 */
  69032. static readonly ALWAYS: number;
  69033. /** Passed to stencilOperation to specify that stencil value must be kept */
  69034. static readonly KEEP: number;
  69035. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69036. static readonly REPLACE: number;
  69037. private _isStencilTestDirty;
  69038. private _isStencilMaskDirty;
  69039. private _isStencilFuncDirty;
  69040. private _isStencilOpDirty;
  69041. private _stencilTest;
  69042. private _stencilMask;
  69043. private _stencilFunc;
  69044. private _stencilFuncRef;
  69045. private _stencilFuncMask;
  69046. private _stencilOpStencilFail;
  69047. private _stencilOpDepthFail;
  69048. private _stencilOpStencilDepthPass;
  69049. readonly isDirty: boolean;
  69050. stencilFunc: number;
  69051. stencilFuncRef: number;
  69052. stencilFuncMask: number;
  69053. stencilOpStencilFail: number;
  69054. stencilOpDepthFail: number;
  69055. stencilOpStencilDepthPass: number;
  69056. stencilMask: number;
  69057. stencilTest: boolean;
  69058. constructor();
  69059. reset(): void;
  69060. apply(gl: WebGLRenderingContext): void;
  69061. }
  69062. }
  69063. declare module BABYLON {
  69064. /**
  69065. * @hidden
  69066. **/
  69067. export class _TimeToken {
  69068. _startTimeQuery: Nullable<WebGLQuery>;
  69069. _endTimeQuery: Nullable<WebGLQuery>;
  69070. _timeElapsedQuery: Nullable<WebGLQuery>;
  69071. _timeElapsedQueryEnded: boolean;
  69072. }
  69073. }
  69074. declare module BABYLON {
  69075. /**
  69076. * Class used to store data associated with WebGL texture data for the engine
  69077. * This class should not be used directly
  69078. */
  69079. export class InternalTexture {
  69080. /** @hidden */
  69081. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  69082. /**
  69083. * The source of the texture data is unknown
  69084. */
  69085. static DATASOURCE_UNKNOWN: number;
  69086. /**
  69087. * Texture data comes from an URL
  69088. */
  69089. static DATASOURCE_URL: number;
  69090. /**
  69091. * Texture data is only used for temporary storage
  69092. */
  69093. static DATASOURCE_TEMP: number;
  69094. /**
  69095. * Texture data comes from raw data (ArrayBuffer)
  69096. */
  69097. static DATASOURCE_RAW: number;
  69098. /**
  69099. * Texture content is dynamic (video or dynamic texture)
  69100. */
  69101. static DATASOURCE_DYNAMIC: number;
  69102. /**
  69103. * Texture content is generated by rendering to it
  69104. */
  69105. static DATASOURCE_RENDERTARGET: number;
  69106. /**
  69107. * Texture content is part of a multi render target process
  69108. */
  69109. static DATASOURCE_MULTIRENDERTARGET: number;
  69110. /**
  69111. * Texture data comes from a cube data file
  69112. */
  69113. static DATASOURCE_CUBE: number;
  69114. /**
  69115. * Texture data comes from a raw cube data
  69116. */
  69117. static DATASOURCE_CUBERAW: number;
  69118. /**
  69119. * Texture data come from a prefiltered cube data file
  69120. */
  69121. static DATASOURCE_CUBEPREFILTERED: number;
  69122. /**
  69123. * Texture content is raw 3D data
  69124. */
  69125. static DATASOURCE_RAW3D: number;
  69126. /**
  69127. * Texture content is a depth texture
  69128. */
  69129. static DATASOURCE_DEPTHTEXTURE: number;
  69130. /**
  69131. * Texture data comes from a raw cube data encoded with RGBD
  69132. */
  69133. static DATASOURCE_CUBERAW_RGBD: number;
  69134. /**
  69135. * Defines if the texture is ready
  69136. */
  69137. isReady: boolean;
  69138. /**
  69139. * Defines if the texture is a cube texture
  69140. */
  69141. isCube: boolean;
  69142. /**
  69143. * Defines if the texture contains 3D data
  69144. */
  69145. is3D: boolean;
  69146. /**
  69147. * Defines if the texture contains multiview data
  69148. */
  69149. isMultiview: boolean;
  69150. /**
  69151. * Gets the URL used to load this texture
  69152. */
  69153. url: string;
  69154. /**
  69155. * Gets the sampling mode of the texture
  69156. */
  69157. samplingMode: number;
  69158. /**
  69159. * Gets a boolean indicating if the texture needs mipmaps generation
  69160. */
  69161. generateMipMaps: boolean;
  69162. /**
  69163. * Gets the number of samples used by the texture (WebGL2+ only)
  69164. */
  69165. samples: number;
  69166. /**
  69167. * Gets the type of the texture (int, float...)
  69168. */
  69169. type: number;
  69170. /**
  69171. * Gets the format of the texture (RGB, RGBA...)
  69172. */
  69173. format: number;
  69174. /**
  69175. * Observable called when the texture is loaded
  69176. */
  69177. onLoadedObservable: Observable<InternalTexture>;
  69178. /**
  69179. * Gets the width of the texture
  69180. */
  69181. width: number;
  69182. /**
  69183. * Gets the height of the texture
  69184. */
  69185. height: number;
  69186. /**
  69187. * Gets the depth of the texture
  69188. */
  69189. depth: number;
  69190. /**
  69191. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  69192. */
  69193. baseWidth: number;
  69194. /**
  69195. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  69196. */
  69197. baseHeight: number;
  69198. /**
  69199. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  69200. */
  69201. baseDepth: number;
  69202. /**
  69203. * Gets a boolean indicating if the texture is inverted on Y axis
  69204. */
  69205. invertY: boolean;
  69206. /** @hidden */
  69207. _invertVScale: boolean;
  69208. /** @hidden */
  69209. _associatedChannel: number;
  69210. /** @hidden */
  69211. _dataSource: number;
  69212. /** @hidden */
  69213. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  69214. /** @hidden */
  69215. _bufferView: Nullable<ArrayBufferView>;
  69216. /** @hidden */
  69217. _bufferViewArray: Nullable<ArrayBufferView[]>;
  69218. /** @hidden */
  69219. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  69220. /** @hidden */
  69221. _size: number;
  69222. /** @hidden */
  69223. _extension: string;
  69224. /** @hidden */
  69225. _files: Nullable<string[]>;
  69226. /** @hidden */
  69227. _workingCanvas: Nullable<HTMLCanvasElement>;
  69228. /** @hidden */
  69229. _workingContext: Nullable<CanvasRenderingContext2D>;
  69230. /** @hidden */
  69231. _framebuffer: Nullable<WebGLFramebuffer>;
  69232. /** @hidden */
  69233. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  69234. /** @hidden */
  69235. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  69236. /** @hidden */
  69237. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  69238. /** @hidden */
  69239. _attachments: Nullable<number[]>;
  69240. /** @hidden */
  69241. _cachedCoordinatesMode: Nullable<number>;
  69242. /** @hidden */
  69243. _cachedWrapU: Nullable<number>;
  69244. /** @hidden */
  69245. _cachedWrapV: Nullable<number>;
  69246. /** @hidden */
  69247. _cachedWrapR: Nullable<number>;
  69248. /** @hidden */
  69249. _cachedAnisotropicFilteringLevel: Nullable<number>;
  69250. /** @hidden */
  69251. _isDisabled: boolean;
  69252. /** @hidden */
  69253. _compression: Nullable<string>;
  69254. /** @hidden */
  69255. _generateStencilBuffer: boolean;
  69256. /** @hidden */
  69257. _generateDepthBuffer: boolean;
  69258. /** @hidden */
  69259. _comparisonFunction: number;
  69260. /** @hidden */
  69261. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  69262. /** @hidden */
  69263. _lodGenerationScale: number;
  69264. /** @hidden */
  69265. _lodGenerationOffset: number;
  69266. /** @hidden */
  69267. _colorTextureArray: Nullable<WebGLTexture>;
  69268. /** @hidden */
  69269. _depthStencilTextureArray: Nullable<WebGLTexture>;
  69270. /** @hidden */
  69271. _lodTextureHigh: Nullable<BaseTexture>;
  69272. /** @hidden */
  69273. _lodTextureMid: Nullable<BaseTexture>;
  69274. /** @hidden */
  69275. _lodTextureLow: Nullable<BaseTexture>;
  69276. /** @hidden */
  69277. _isRGBD: boolean;
  69278. /** @hidden */
  69279. _linearSpecularLOD: boolean;
  69280. /** @hidden */
  69281. _irradianceTexture: Nullable<BaseTexture>;
  69282. /** @hidden */
  69283. _webGLTexture: Nullable<WebGLTexture>;
  69284. /** @hidden */
  69285. _references: number;
  69286. private _engine;
  69287. /**
  69288. * Gets the Engine the texture belongs to.
  69289. * @returns The babylon engine
  69290. */
  69291. getEngine(): Engine;
  69292. /**
  69293. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  69294. */
  69295. readonly dataSource: number;
  69296. /**
  69297. * Creates a new InternalTexture
  69298. * @param engine defines the engine to use
  69299. * @param dataSource defines the type of data that will be used
  69300. * @param delayAllocation if the texture allocation should be delayed (default: false)
  69301. */
  69302. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  69303. /**
  69304. * Increments the number of references (ie. the number of Texture that point to it)
  69305. */
  69306. incrementReferences(): void;
  69307. /**
  69308. * Change the size of the texture (not the size of the content)
  69309. * @param width defines the new width
  69310. * @param height defines the new height
  69311. * @param depth defines the new depth (1 by default)
  69312. */
  69313. updateSize(width: int, height: int, depth?: int): void;
  69314. /** @hidden */
  69315. _rebuild(): void;
  69316. /** @hidden */
  69317. _swapAndDie(target: InternalTexture): void;
  69318. /**
  69319. * Dispose the current allocated resources
  69320. */
  69321. dispose(): void;
  69322. }
  69323. }
  69324. declare module BABYLON {
  69325. /**
  69326. * This represents the main contract an easing function should follow.
  69327. * Easing functions are used throughout the animation system.
  69328. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69329. */
  69330. export interface IEasingFunction {
  69331. /**
  69332. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69333. * of the easing function.
  69334. * The link below provides some of the most common examples of easing functions.
  69335. * @see https://easings.net/
  69336. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69337. * @returns the corresponding value on the curve defined by the easing function
  69338. */
  69339. ease(gradient: number): number;
  69340. }
  69341. /**
  69342. * Base class used for every default easing function.
  69343. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69344. */
  69345. export class EasingFunction implements IEasingFunction {
  69346. /**
  69347. * Interpolation follows the mathematical formula associated with the easing function.
  69348. */
  69349. static readonly EASINGMODE_EASEIN: number;
  69350. /**
  69351. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69352. */
  69353. static readonly EASINGMODE_EASEOUT: number;
  69354. /**
  69355. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69356. */
  69357. static readonly EASINGMODE_EASEINOUT: number;
  69358. private _easingMode;
  69359. /**
  69360. * Sets the easing mode of the current function.
  69361. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69362. */
  69363. setEasingMode(easingMode: number): void;
  69364. /**
  69365. * Gets the current easing mode.
  69366. * @returns the easing mode
  69367. */
  69368. getEasingMode(): number;
  69369. /**
  69370. * @hidden
  69371. */
  69372. easeInCore(gradient: number): number;
  69373. /**
  69374. * Given an input gradient between 0 and 1, this returns the corresponding value
  69375. * of the easing function.
  69376. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69377. * @returns the corresponding value on the curve defined by the easing function
  69378. */
  69379. ease(gradient: number): number;
  69380. }
  69381. /**
  69382. * Easing function with a circle shape (see link below).
  69383. * @see https://easings.net/#easeInCirc
  69384. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69385. */
  69386. export class CircleEase extends EasingFunction implements IEasingFunction {
  69387. /** @hidden */
  69388. easeInCore(gradient: number): number;
  69389. }
  69390. /**
  69391. * Easing function with a ease back shape (see link below).
  69392. * @see https://easings.net/#easeInBack
  69393. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69394. */
  69395. export class BackEase extends EasingFunction implements IEasingFunction {
  69396. /** Defines the amplitude of the function */
  69397. amplitude: number;
  69398. /**
  69399. * Instantiates a back ease easing
  69400. * @see https://easings.net/#easeInBack
  69401. * @param amplitude Defines the amplitude of the function
  69402. */
  69403. constructor(
  69404. /** Defines the amplitude of the function */
  69405. amplitude?: number);
  69406. /** @hidden */
  69407. easeInCore(gradient: number): number;
  69408. }
  69409. /**
  69410. * Easing function with a bouncing shape (see link below).
  69411. * @see https://easings.net/#easeInBounce
  69412. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69413. */
  69414. export class BounceEase extends EasingFunction implements IEasingFunction {
  69415. /** Defines the number of bounces */
  69416. bounces: number;
  69417. /** Defines the amplitude of the bounce */
  69418. bounciness: number;
  69419. /**
  69420. * Instantiates a bounce easing
  69421. * @see https://easings.net/#easeInBounce
  69422. * @param bounces Defines the number of bounces
  69423. * @param bounciness Defines the amplitude of the bounce
  69424. */
  69425. constructor(
  69426. /** Defines the number of bounces */
  69427. bounces?: number,
  69428. /** Defines the amplitude of the bounce */
  69429. bounciness?: number);
  69430. /** @hidden */
  69431. easeInCore(gradient: number): number;
  69432. }
  69433. /**
  69434. * Easing function with a power of 3 shape (see link below).
  69435. * @see https://easings.net/#easeInCubic
  69436. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69437. */
  69438. export class CubicEase extends EasingFunction implements IEasingFunction {
  69439. /** @hidden */
  69440. easeInCore(gradient: number): number;
  69441. }
  69442. /**
  69443. * Easing function with an elastic shape (see link below).
  69444. * @see https://easings.net/#easeInElastic
  69445. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69446. */
  69447. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69448. /** Defines the number of oscillations*/
  69449. oscillations: number;
  69450. /** Defines the amplitude of the oscillations*/
  69451. springiness: number;
  69452. /**
  69453. * Instantiates an elastic easing function
  69454. * @see https://easings.net/#easeInElastic
  69455. * @param oscillations Defines the number of oscillations
  69456. * @param springiness Defines the amplitude of the oscillations
  69457. */
  69458. constructor(
  69459. /** Defines the number of oscillations*/
  69460. oscillations?: number,
  69461. /** Defines the amplitude of the oscillations*/
  69462. springiness?: number);
  69463. /** @hidden */
  69464. easeInCore(gradient: number): number;
  69465. }
  69466. /**
  69467. * Easing function with an exponential shape (see link below).
  69468. * @see https://easings.net/#easeInExpo
  69469. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69470. */
  69471. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69472. /** Defines the exponent of the function */
  69473. exponent: number;
  69474. /**
  69475. * Instantiates an exponential easing function
  69476. * @see https://easings.net/#easeInExpo
  69477. * @param exponent Defines the exponent of the function
  69478. */
  69479. constructor(
  69480. /** Defines the exponent of the function */
  69481. exponent?: number);
  69482. /** @hidden */
  69483. easeInCore(gradient: number): number;
  69484. }
  69485. /**
  69486. * Easing function with a power shape (see link below).
  69487. * @see https://easings.net/#easeInQuad
  69488. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69489. */
  69490. export class PowerEase extends EasingFunction implements IEasingFunction {
  69491. /** Defines the power of the function */
  69492. power: number;
  69493. /**
  69494. * Instantiates an power base easing function
  69495. * @see https://easings.net/#easeInQuad
  69496. * @param power Defines the power of the function
  69497. */
  69498. constructor(
  69499. /** Defines the power of the function */
  69500. power?: number);
  69501. /** @hidden */
  69502. easeInCore(gradient: number): number;
  69503. }
  69504. /**
  69505. * Easing function with a power of 2 shape (see link below).
  69506. * @see https://easings.net/#easeInQuad
  69507. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69508. */
  69509. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69510. /** @hidden */
  69511. easeInCore(gradient: number): number;
  69512. }
  69513. /**
  69514. * Easing function with a power of 4 shape (see link below).
  69515. * @see https://easings.net/#easeInQuart
  69516. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69517. */
  69518. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69519. /** @hidden */
  69520. easeInCore(gradient: number): number;
  69521. }
  69522. /**
  69523. * Easing function with a power of 5 shape (see link below).
  69524. * @see https://easings.net/#easeInQuint
  69525. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69526. */
  69527. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69528. /** @hidden */
  69529. easeInCore(gradient: number): number;
  69530. }
  69531. /**
  69532. * Easing function with a sin shape (see link below).
  69533. * @see https://easings.net/#easeInSine
  69534. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69535. */
  69536. export class SineEase extends EasingFunction implements IEasingFunction {
  69537. /** @hidden */
  69538. easeInCore(gradient: number): number;
  69539. }
  69540. /**
  69541. * Easing function with a bezier shape (see link below).
  69542. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69543. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69544. */
  69545. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69546. /** Defines the x component of the start tangent in the bezier curve */
  69547. x1: number;
  69548. /** Defines the y component of the start tangent in the bezier curve */
  69549. y1: number;
  69550. /** Defines the x component of the end tangent in the bezier curve */
  69551. x2: number;
  69552. /** Defines the y component of the end tangent in the bezier curve */
  69553. y2: number;
  69554. /**
  69555. * Instantiates a bezier function
  69556. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69557. * @param x1 Defines the x component of the start tangent in the bezier curve
  69558. * @param y1 Defines the y component of the start tangent in the bezier curve
  69559. * @param x2 Defines the x component of the end tangent in the bezier curve
  69560. * @param y2 Defines the y component of the end tangent in the bezier curve
  69561. */
  69562. constructor(
  69563. /** Defines the x component of the start tangent in the bezier curve */
  69564. x1?: number,
  69565. /** Defines the y component of the start tangent in the bezier curve */
  69566. y1?: number,
  69567. /** Defines the x component of the end tangent in the bezier curve */
  69568. x2?: number,
  69569. /** Defines the y component of the end tangent in the bezier curve */
  69570. y2?: number);
  69571. /** @hidden */
  69572. easeInCore(gradient: number): number;
  69573. }
  69574. }
  69575. declare module BABYLON {
  69576. /**
  69577. * Defines an interface which represents an animation key frame
  69578. */
  69579. export interface IAnimationKey {
  69580. /**
  69581. * Frame of the key frame
  69582. */
  69583. frame: number;
  69584. /**
  69585. * Value at the specifies key frame
  69586. */
  69587. value: any;
  69588. /**
  69589. * The input tangent for the cubic hermite spline
  69590. */
  69591. inTangent?: any;
  69592. /**
  69593. * The output tangent for the cubic hermite spline
  69594. */
  69595. outTangent?: any;
  69596. /**
  69597. * The animation interpolation type
  69598. */
  69599. interpolation?: AnimationKeyInterpolation;
  69600. }
  69601. /**
  69602. * Enum for the animation key frame interpolation type
  69603. */
  69604. export enum AnimationKeyInterpolation {
  69605. /**
  69606. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69607. */
  69608. STEP = 1
  69609. }
  69610. }
  69611. declare module BABYLON {
  69612. /**
  69613. * Represents the range of an animation
  69614. */
  69615. export class AnimationRange {
  69616. /**The name of the animation range**/
  69617. name: string;
  69618. /**The starting frame of the animation */
  69619. from: number;
  69620. /**The ending frame of the animation*/
  69621. to: number;
  69622. /**
  69623. * Initializes the range of an animation
  69624. * @param name The name of the animation range
  69625. * @param from The starting frame of the animation
  69626. * @param to The ending frame of the animation
  69627. */
  69628. constructor(
  69629. /**The name of the animation range**/
  69630. name: string,
  69631. /**The starting frame of the animation */
  69632. from: number,
  69633. /**The ending frame of the animation*/
  69634. to: number);
  69635. /**
  69636. * Makes a copy of the animation range
  69637. * @returns A copy of the animation range
  69638. */
  69639. clone(): AnimationRange;
  69640. }
  69641. }
  69642. declare module BABYLON {
  69643. /**
  69644. * Composed of a frame, and an action function
  69645. */
  69646. export class AnimationEvent {
  69647. /** The frame for which the event is triggered **/
  69648. frame: number;
  69649. /** The event to perform when triggered **/
  69650. action: (currentFrame: number) => void;
  69651. /** Specifies if the event should be triggered only once**/
  69652. onlyOnce?: boolean | undefined;
  69653. /**
  69654. * Specifies if the animation event is done
  69655. */
  69656. isDone: boolean;
  69657. /**
  69658. * Initializes the animation event
  69659. * @param frame The frame for which the event is triggered
  69660. * @param action The event to perform when triggered
  69661. * @param onlyOnce Specifies if the event should be triggered only once
  69662. */
  69663. constructor(
  69664. /** The frame for which the event is triggered **/
  69665. frame: number,
  69666. /** The event to perform when triggered **/
  69667. action: (currentFrame: number) => void,
  69668. /** Specifies if the event should be triggered only once**/
  69669. onlyOnce?: boolean | undefined);
  69670. /** @hidden */
  69671. _clone(): AnimationEvent;
  69672. }
  69673. }
  69674. declare module BABYLON {
  69675. /**
  69676. * Interface used to define a behavior
  69677. */
  69678. export interface Behavior<T> {
  69679. /** gets or sets behavior's name */
  69680. name: string;
  69681. /**
  69682. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69683. */
  69684. init(): void;
  69685. /**
  69686. * Called when the behavior is attached to a target
  69687. * @param target defines the target where the behavior is attached to
  69688. */
  69689. attach(target: T): void;
  69690. /**
  69691. * Called when the behavior is detached from its target
  69692. */
  69693. detach(): void;
  69694. }
  69695. /**
  69696. * Interface implemented by classes supporting behaviors
  69697. */
  69698. export interface IBehaviorAware<T> {
  69699. /**
  69700. * Attach a behavior
  69701. * @param behavior defines the behavior to attach
  69702. * @returns the current host
  69703. */
  69704. addBehavior(behavior: Behavior<T>): T;
  69705. /**
  69706. * Remove a behavior from the current object
  69707. * @param behavior defines the behavior to detach
  69708. * @returns the current host
  69709. */
  69710. removeBehavior(behavior: Behavior<T>): T;
  69711. /**
  69712. * Gets a behavior using its name to search
  69713. * @param name defines the name to search
  69714. * @returns the behavior or null if not found
  69715. */
  69716. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  69717. }
  69718. }
  69719. declare module BABYLON {
  69720. /**
  69721. * @hidden
  69722. */
  69723. export class IntersectionInfo {
  69724. bu: Nullable<number>;
  69725. bv: Nullable<number>;
  69726. distance: number;
  69727. faceId: number;
  69728. subMeshId: number;
  69729. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69730. }
  69731. }
  69732. declare module BABYLON {
  69733. /**
  69734. * Class used to store bounding sphere information
  69735. */
  69736. export class BoundingSphere {
  69737. /**
  69738. * Gets the center of the bounding sphere in local space
  69739. */
  69740. readonly center: Vector3;
  69741. /**
  69742. * Radius of the bounding sphere in local space
  69743. */
  69744. radius: number;
  69745. /**
  69746. * Gets the center of the bounding sphere in world space
  69747. */
  69748. readonly centerWorld: Vector3;
  69749. /**
  69750. * Radius of the bounding sphere in world space
  69751. */
  69752. radiusWorld: number;
  69753. /**
  69754. * Gets the minimum vector in local space
  69755. */
  69756. readonly minimum: Vector3;
  69757. /**
  69758. * Gets the maximum vector in local space
  69759. */
  69760. readonly maximum: Vector3;
  69761. private _worldMatrix;
  69762. private static readonly TmpVector3;
  69763. /**
  69764. * Creates a new bounding sphere
  69765. * @param min defines the minimum vector (in local space)
  69766. * @param max defines the maximum vector (in local space)
  69767. * @param worldMatrix defines the new world matrix
  69768. */
  69769. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69770. /**
  69771. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  69772. * @param min defines the new minimum vector (in local space)
  69773. * @param max defines the new maximum vector (in local space)
  69774. * @param worldMatrix defines the new world matrix
  69775. */
  69776. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69777. /**
  69778. * Scale the current bounding sphere by applying a scale factor
  69779. * @param factor defines the scale factor to apply
  69780. * @returns the current bounding box
  69781. */
  69782. scale(factor: number): BoundingSphere;
  69783. /**
  69784. * Gets the world matrix of the bounding box
  69785. * @returns a matrix
  69786. */
  69787. getWorldMatrix(): DeepImmutable<Matrix>;
  69788. /** @hidden */
  69789. _update(worldMatrix: DeepImmutable<Matrix>): void;
  69790. /**
  69791. * Tests if the bounding sphere is intersecting the frustum planes
  69792. * @param frustumPlanes defines the frustum planes to test
  69793. * @returns true if there is an intersection
  69794. */
  69795. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69796. /**
  69797. * Tests if the bounding sphere center is in between the frustum planes.
  69798. * Used for optimistic fast inclusion.
  69799. * @param frustumPlanes defines the frustum planes to test
  69800. * @returns true if the sphere center is in between the frustum planes
  69801. */
  69802. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69803. /**
  69804. * Tests if a point is inside the bounding sphere
  69805. * @param point defines the point to test
  69806. * @returns true if the point is inside the bounding sphere
  69807. */
  69808. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69809. /**
  69810. * Checks if two sphere intersct
  69811. * @param sphere0 sphere 0
  69812. * @param sphere1 sphere 1
  69813. * @returns true if the speres intersect
  69814. */
  69815. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  69816. }
  69817. }
  69818. declare module BABYLON {
  69819. /**
  69820. * Class used to store bounding box information
  69821. */
  69822. export class BoundingBox implements ICullable {
  69823. /**
  69824. * Gets the 8 vectors representing the bounding box in local space
  69825. */
  69826. readonly vectors: Vector3[];
  69827. /**
  69828. * Gets the center of the bounding box in local space
  69829. */
  69830. readonly center: Vector3;
  69831. /**
  69832. * Gets the center of the bounding box in world space
  69833. */
  69834. readonly centerWorld: Vector3;
  69835. /**
  69836. * Gets the extend size in local space
  69837. */
  69838. readonly extendSize: Vector3;
  69839. /**
  69840. * Gets the extend size in world space
  69841. */
  69842. readonly extendSizeWorld: Vector3;
  69843. /**
  69844. * Gets the OBB (object bounding box) directions
  69845. */
  69846. readonly directions: Vector3[];
  69847. /**
  69848. * Gets the 8 vectors representing the bounding box in world space
  69849. */
  69850. readonly vectorsWorld: Vector3[];
  69851. /**
  69852. * Gets the minimum vector in world space
  69853. */
  69854. readonly minimumWorld: Vector3;
  69855. /**
  69856. * Gets the maximum vector in world space
  69857. */
  69858. readonly maximumWorld: Vector3;
  69859. /**
  69860. * Gets the minimum vector in local space
  69861. */
  69862. readonly minimum: Vector3;
  69863. /**
  69864. * Gets the maximum vector in local space
  69865. */
  69866. readonly maximum: Vector3;
  69867. private _worldMatrix;
  69868. private static readonly TmpVector3;
  69869. /**
  69870. * @hidden
  69871. */
  69872. _tag: number;
  69873. /**
  69874. * Creates a new bounding box
  69875. * @param min defines the minimum vector (in local space)
  69876. * @param max defines the maximum vector (in local space)
  69877. * @param worldMatrix defines the new world matrix
  69878. */
  69879. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69880. /**
  69881. * Recreates the entire bounding box from scratch as if we call the constructor in place
  69882. * @param min defines the new minimum vector (in local space)
  69883. * @param max defines the new maximum vector (in local space)
  69884. * @param worldMatrix defines the new world matrix
  69885. */
  69886. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69887. /**
  69888. * Scale the current bounding box by applying a scale factor
  69889. * @param factor defines the scale factor to apply
  69890. * @returns the current bounding box
  69891. */
  69892. scale(factor: number): BoundingBox;
  69893. /**
  69894. * Gets the world matrix of the bounding box
  69895. * @returns a matrix
  69896. */
  69897. getWorldMatrix(): DeepImmutable<Matrix>;
  69898. /** @hidden */
  69899. _update(world: DeepImmutable<Matrix>): void;
  69900. /**
  69901. * Tests if the bounding box is intersecting the frustum planes
  69902. * @param frustumPlanes defines the frustum planes to test
  69903. * @returns true if there is an intersection
  69904. */
  69905. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69906. /**
  69907. * Tests if the bounding box is entirely inside the frustum planes
  69908. * @param frustumPlanes defines the frustum planes to test
  69909. * @returns true if there is an inclusion
  69910. */
  69911. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69912. /**
  69913. * Tests if a point is inside the bounding box
  69914. * @param point defines the point to test
  69915. * @returns true if the point is inside the bounding box
  69916. */
  69917. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69918. /**
  69919. * Tests if the bounding box intersects with a bounding sphere
  69920. * @param sphere defines the sphere to test
  69921. * @returns true if there is an intersection
  69922. */
  69923. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  69924. /**
  69925. * Tests if the bounding box intersects with a box defined by a min and max vectors
  69926. * @param min defines the min vector to use
  69927. * @param max defines the max vector to use
  69928. * @returns true if there is an intersection
  69929. */
  69930. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  69931. /**
  69932. * Tests if two bounding boxes are intersections
  69933. * @param box0 defines the first box to test
  69934. * @param box1 defines the second box to test
  69935. * @returns true if there is an intersection
  69936. */
  69937. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  69938. /**
  69939. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  69940. * @param minPoint defines the minimum vector of the bounding box
  69941. * @param maxPoint defines the maximum vector of the bounding box
  69942. * @param sphereCenter defines the sphere center
  69943. * @param sphereRadius defines the sphere radius
  69944. * @returns true if there is an intersection
  69945. */
  69946. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  69947. /**
  69948. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  69949. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69950. * @param frustumPlanes defines the frustum planes to test
  69951. * @return true if there is an inclusion
  69952. */
  69953. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69954. /**
  69955. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  69956. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69957. * @param frustumPlanes defines the frustum planes to test
  69958. * @return true if there is an intersection
  69959. */
  69960. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69961. }
  69962. }
  69963. declare module BABYLON {
  69964. /** @hidden */
  69965. export class Collider {
  69966. /** Define if a collision was found */
  69967. collisionFound: boolean;
  69968. /**
  69969. * Define last intersection point in local space
  69970. */
  69971. intersectionPoint: Vector3;
  69972. /**
  69973. * Define last collided mesh
  69974. */
  69975. collidedMesh: Nullable<AbstractMesh>;
  69976. private _collisionPoint;
  69977. private _planeIntersectionPoint;
  69978. private _tempVector;
  69979. private _tempVector2;
  69980. private _tempVector3;
  69981. private _tempVector4;
  69982. private _edge;
  69983. private _baseToVertex;
  69984. private _destinationPoint;
  69985. private _slidePlaneNormal;
  69986. private _displacementVector;
  69987. /** @hidden */
  69988. _radius: Vector3;
  69989. /** @hidden */
  69990. _retry: number;
  69991. private _velocity;
  69992. private _basePoint;
  69993. private _epsilon;
  69994. /** @hidden */
  69995. _velocityWorldLength: number;
  69996. /** @hidden */
  69997. _basePointWorld: Vector3;
  69998. private _velocityWorld;
  69999. private _normalizedVelocity;
  70000. /** @hidden */
  70001. _initialVelocity: Vector3;
  70002. /** @hidden */
  70003. _initialPosition: Vector3;
  70004. private _nearestDistance;
  70005. private _collisionMask;
  70006. collisionMask: number;
  70007. /**
  70008. * Gets the plane normal used to compute the sliding response (in local space)
  70009. */
  70010. readonly slidePlaneNormal: Vector3;
  70011. /** @hidden */
  70012. _initialize(source: Vector3, dir: Vector3, e: number): void;
  70013. /** @hidden */
  70014. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  70015. /** @hidden */
  70016. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  70017. /** @hidden */
  70018. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  70019. /** @hidden */
  70020. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  70021. /** @hidden */
  70022. _getResponse(pos: Vector3, vel: Vector3): void;
  70023. }
  70024. }
  70025. declare module BABYLON {
  70026. /**
  70027. * Interface for cullable objects
  70028. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  70029. */
  70030. export interface ICullable {
  70031. /**
  70032. * Checks if the object or part of the object is in the frustum
  70033. * @param frustumPlanes Camera near/planes
  70034. * @returns true if the object is in frustum otherwise false
  70035. */
  70036. isInFrustum(frustumPlanes: Plane[]): boolean;
  70037. /**
  70038. * Checks if a cullable object (mesh...) is in the camera frustum
  70039. * Unlike isInFrustum this cheks the full bounding box
  70040. * @param frustumPlanes Camera near/planes
  70041. * @returns true if the object is in frustum otherwise false
  70042. */
  70043. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  70044. }
  70045. /**
  70046. * Info for a bounding data of a mesh
  70047. */
  70048. export class BoundingInfo implements ICullable {
  70049. /**
  70050. * Bounding box for the mesh
  70051. */
  70052. readonly boundingBox: BoundingBox;
  70053. /**
  70054. * Bounding sphere for the mesh
  70055. */
  70056. readonly boundingSphere: BoundingSphere;
  70057. private _isLocked;
  70058. private static readonly TmpVector3;
  70059. /**
  70060. * Constructs bounding info
  70061. * @param minimum min vector of the bounding box/sphere
  70062. * @param maximum max vector of the bounding box/sphere
  70063. * @param worldMatrix defines the new world matrix
  70064. */
  70065. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70066. /**
  70067. * Recreates the entire bounding info from scratch as if we call the constructor in place
  70068. * @param min defines the new minimum vector (in local space)
  70069. * @param max defines the new maximum vector (in local space)
  70070. * @param worldMatrix defines the new world matrix
  70071. */
  70072. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70073. /**
  70074. * min vector of the bounding box/sphere
  70075. */
  70076. readonly minimum: Vector3;
  70077. /**
  70078. * max vector of the bounding box/sphere
  70079. */
  70080. readonly maximum: Vector3;
  70081. /**
  70082. * If the info is locked and won't be updated to avoid perf overhead
  70083. */
  70084. isLocked: boolean;
  70085. /**
  70086. * Updates the bounding sphere and box
  70087. * @param world world matrix to be used to update
  70088. */
  70089. update(world: DeepImmutable<Matrix>): void;
  70090. /**
  70091. * Recreate the bounding info to be centered around a specific point given a specific extend.
  70092. * @param center New center of the bounding info
  70093. * @param extend New extend of the bounding info
  70094. * @returns the current bounding info
  70095. */
  70096. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  70097. /**
  70098. * Scale the current bounding info by applying a scale factor
  70099. * @param factor defines the scale factor to apply
  70100. * @returns the current bounding info
  70101. */
  70102. scale(factor: number): BoundingInfo;
  70103. /**
  70104. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  70105. * @param frustumPlanes defines the frustum to test
  70106. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  70107. * @returns true if the bounding info is in the frustum planes
  70108. */
  70109. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  70110. /**
  70111. * Gets the world distance between the min and max points of the bounding box
  70112. */
  70113. readonly diagonalLength: number;
  70114. /**
  70115. * Checks if a cullable object (mesh...) is in the camera frustum
  70116. * Unlike isInFrustum this cheks the full bounding box
  70117. * @param frustumPlanes Camera near/planes
  70118. * @returns true if the object is in frustum otherwise false
  70119. */
  70120. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70121. /** @hidden */
  70122. _checkCollision(collider: Collider): boolean;
  70123. /**
  70124. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  70125. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70126. * @param point the point to check intersection with
  70127. * @returns if the point intersects
  70128. */
  70129. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70130. /**
  70131. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70132. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70133. * @param boundingInfo the bounding info to check intersection with
  70134. * @param precise if the intersection should be done using OBB
  70135. * @returns if the bounding info intersects
  70136. */
  70137. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70138. }
  70139. }
  70140. declare module BABYLON {
  70141. /**
  70142. * Defines an array and its length.
  70143. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70144. */
  70145. export interface ISmartArrayLike<T> {
  70146. /**
  70147. * The data of the array.
  70148. */
  70149. data: Array<T>;
  70150. /**
  70151. * The active length of the array.
  70152. */
  70153. length: number;
  70154. }
  70155. /**
  70156. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70157. */
  70158. export class SmartArray<T> implements ISmartArrayLike<T> {
  70159. /**
  70160. * The full set of data from the array.
  70161. */
  70162. data: Array<T>;
  70163. /**
  70164. * The active length of the array.
  70165. */
  70166. length: number;
  70167. protected _id: number;
  70168. /**
  70169. * Instantiates a Smart Array.
  70170. * @param capacity defines the default capacity of the array.
  70171. */
  70172. constructor(capacity: number);
  70173. /**
  70174. * Pushes a value at the end of the active data.
  70175. * @param value defines the object to push in the array.
  70176. */
  70177. push(value: T): void;
  70178. /**
  70179. * Iterates over the active data and apply the lambda to them.
  70180. * @param func defines the action to apply on each value.
  70181. */
  70182. forEach(func: (content: T) => void): void;
  70183. /**
  70184. * Sorts the full sets of data.
  70185. * @param compareFn defines the comparison function to apply.
  70186. */
  70187. sort(compareFn: (a: T, b: T) => number): void;
  70188. /**
  70189. * Resets the active data to an empty array.
  70190. */
  70191. reset(): void;
  70192. /**
  70193. * Releases all the data from the array as well as the array.
  70194. */
  70195. dispose(): void;
  70196. /**
  70197. * Concats the active data with a given array.
  70198. * @param array defines the data to concatenate with.
  70199. */
  70200. concat(array: any): void;
  70201. /**
  70202. * Returns the position of a value in the active data.
  70203. * @param value defines the value to find the index for
  70204. * @returns the index if found in the active data otherwise -1
  70205. */
  70206. indexOf(value: T): number;
  70207. /**
  70208. * Returns whether an element is part of the active data.
  70209. * @param value defines the value to look for
  70210. * @returns true if found in the active data otherwise false
  70211. */
  70212. contains(value: T): boolean;
  70213. private static _GlobalId;
  70214. }
  70215. /**
  70216. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70217. * The data in this array can only be present once
  70218. */
  70219. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70220. private _duplicateId;
  70221. /**
  70222. * Pushes a value at the end of the active data.
  70223. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70224. * @param value defines the object to push in the array.
  70225. */
  70226. push(value: T): void;
  70227. /**
  70228. * Pushes a value at the end of the active data.
  70229. * If the data is already present, it won t be added again
  70230. * @param value defines the object to push in the array.
  70231. * @returns true if added false if it was already present
  70232. */
  70233. pushNoDuplicate(value: T): boolean;
  70234. /**
  70235. * Resets the active data to an empty array.
  70236. */
  70237. reset(): void;
  70238. /**
  70239. * Concats the active data with a given array.
  70240. * This ensures no dupplicate will be present in the result.
  70241. * @param array defines the data to concatenate with.
  70242. */
  70243. concatWithNoDuplicate(array: any): void;
  70244. }
  70245. }
  70246. declare module BABYLON {
  70247. /**
  70248. * Enum that determines the text-wrapping mode to use.
  70249. */
  70250. export enum InspectableType {
  70251. /**
  70252. * Checkbox for booleans
  70253. */
  70254. Checkbox = 0,
  70255. /**
  70256. * Sliders for numbers
  70257. */
  70258. Slider = 1,
  70259. /**
  70260. * Vector3
  70261. */
  70262. Vector3 = 2,
  70263. /**
  70264. * Quaternions
  70265. */
  70266. Quaternion = 3,
  70267. /**
  70268. * Color3
  70269. */
  70270. Color3 = 4
  70271. }
  70272. /**
  70273. * Interface used to define custom inspectable properties.
  70274. * This interface is used by the inspector to display custom property grids
  70275. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70276. */
  70277. export interface IInspectable {
  70278. /**
  70279. * Gets the label to display
  70280. */
  70281. label: string;
  70282. /**
  70283. * Gets the name of the property to edit
  70284. */
  70285. propertyName: string;
  70286. /**
  70287. * Gets the type of the editor to use
  70288. */
  70289. type: InspectableType;
  70290. /**
  70291. * Gets the minimum value of the property when using in "slider" mode
  70292. */
  70293. min?: number;
  70294. /**
  70295. * Gets the maximum value of the property when using in "slider" mode
  70296. */
  70297. max?: number;
  70298. /**
  70299. * Gets the setp to use when using in "slider" mode
  70300. */
  70301. step?: number;
  70302. }
  70303. }
  70304. declare module BABYLON {
  70305. /**
  70306. * This represents the required contract to create a new type of texture loader.
  70307. */
  70308. export interface IInternalTextureLoader {
  70309. /**
  70310. * Defines wether the loader supports cascade loading the different faces.
  70311. */
  70312. supportCascades: boolean;
  70313. /**
  70314. * This returns if the loader support the current file information.
  70315. * @param extension defines the file extension of the file being loaded
  70316. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70317. * @param fallback defines the fallback internal texture if any
  70318. * @param isBase64 defines whether the texture is encoded as a base64
  70319. * @param isBuffer defines whether the texture data are stored as a buffer
  70320. * @returns true if the loader can load the specified file
  70321. */
  70322. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70323. /**
  70324. * Transform the url before loading if required.
  70325. * @param rootUrl the url of the texture
  70326. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70327. * @returns the transformed texture
  70328. */
  70329. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70330. /**
  70331. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70332. * @param rootUrl the url of the texture
  70333. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70334. * @returns the fallback texture
  70335. */
  70336. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70337. /**
  70338. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70339. * @param data contains the texture data
  70340. * @param texture defines the BabylonJS internal texture
  70341. * @param createPolynomials will be true if polynomials have been requested
  70342. * @param onLoad defines the callback to trigger once the texture is ready
  70343. * @param onError defines the callback to trigger in case of error
  70344. */
  70345. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70346. /**
  70347. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70348. * @param data contains the texture data
  70349. * @param texture defines the BabylonJS internal texture
  70350. * @param callback defines the method to call once ready to upload
  70351. */
  70352. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70353. }
  70354. }
  70355. declare module BABYLON {
  70356. interface Engine {
  70357. /**
  70358. * Creates a depth stencil cube texture.
  70359. * This is only available in WebGL 2.
  70360. * @param size The size of face edge in the cube texture.
  70361. * @param options The options defining the cube texture.
  70362. * @returns The cube texture
  70363. */
  70364. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70365. /**
  70366. * Creates a cube texture
  70367. * @param rootUrl defines the url where the files to load is located
  70368. * @param scene defines the current scene
  70369. * @param files defines the list of files to load (1 per face)
  70370. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70371. * @param onLoad defines an optional callback raised when the texture is loaded
  70372. * @param onError defines an optional callback raised if there is an issue to load the texture
  70373. * @param format defines the format of the data
  70374. * @param forcedExtension defines the extension to use to pick the right loader
  70375. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70376. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70377. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70378. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70379. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70380. * @returns the cube texture as an InternalTexture
  70381. */
  70382. 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;
  70383. /**
  70384. * Creates a cube texture
  70385. * @param rootUrl defines the url where the files to load is located
  70386. * @param scene defines the current scene
  70387. * @param files defines the list of files to load (1 per face)
  70388. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70389. * @param onLoad defines an optional callback raised when the texture is loaded
  70390. * @param onError defines an optional callback raised if there is an issue to load the texture
  70391. * @param format defines the format of the data
  70392. * @param forcedExtension defines the extension to use to pick the right loader
  70393. * @returns the cube texture as an InternalTexture
  70394. */
  70395. 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;
  70396. /**
  70397. * Creates a cube texture
  70398. * @param rootUrl defines the url where the files to load is located
  70399. * @param scene defines the current scene
  70400. * @param files defines the list of files to load (1 per face)
  70401. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70402. * @param onLoad defines an optional callback raised when the texture is loaded
  70403. * @param onError defines an optional callback raised if there is an issue to load the texture
  70404. * @param format defines the format of the data
  70405. * @param forcedExtension defines the extension to use to pick the right loader
  70406. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70407. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70408. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70409. * @returns the cube texture as an InternalTexture
  70410. */
  70411. 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;
  70412. /** @hidden */
  70413. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70414. /** @hidden */
  70415. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70416. /** @hidden */
  70417. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70418. /** @hidden */
  70419. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70420. }
  70421. }
  70422. declare module BABYLON {
  70423. /**
  70424. * Class for creating a cube texture
  70425. */
  70426. export class CubeTexture extends BaseTexture {
  70427. private _delayedOnLoad;
  70428. /**
  70429. * The url of the texture
  70430. */
  70431. url: string;
  70432. /**
  70433. * Gets or sets the center of the bounding box associated with the cube texture.
  70434. * It must define where the camera used to render the texture was set
  70435. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70436. */
  70437. boundingBoxPosition: Vector3;
  70438. private _boundingBoxSize;
  70439. /**
  70440. * Gets or sets the size of the bounding box associated with the cube texture
  70441. * When defined, the cubemap will switch to local mode
  70442. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70443. * @example https://www.babylonjs-playground.com/#RNASML
  70444. */
  70445. /**
  70446. * Returns the bounding box size
  70447. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70448. */
  70449. boundingBoxSize: Vector3;
  70450. protected _rotationY: number;
  70451. /**
  70452. * Sets texture matrix rotation angle around Y axis in radians.
  70453. */
  70454. /**
  70455. * Gets texture matrix rotation angle around Y axis radians.
  70456. */
  70457. rotationY: number;
  70458. /**
  70459. * Are mip maps generated for this texture or not.
  70460. */
  70461. readonly noMipmap: boolean;
  70462. private _noMipmap;
  70463. private _files;
  70464. private _extensions;
  70465. private _textureMatrix;
  70466. private _format;
  70467. private _createPolynomials;
  70468. /** @hidden */
  70469. _prefiltered: boolean;
  70470. /**
  70471. * Creates a cube texture from an array of image urls
  70472. * @param files defines an array of image urls
  70473. * @param scene defines the hosting scene
  70474. * @param noMipmap specifies if mip maps are not used
  70475. * @returns a cube texture
  70476. */
  70477. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70478. /**
  70479. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70480. * @param url defines the url of the prefiltered texture
  70481. * @param scene defines the scene the texture is attached to
  70482. * @param forcedExtension defines the extension of the file if different from the url
  70483. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70484. * @return the prefiltered texture
  70485. */
  70486. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70487. /**
  70488. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70489. * as prefiltered data.
  70490. * @param rootUrl defines the url of the texture or the root name of the six images
  70491. * @param scene defines the scene the texture is attached to
  70492. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70493. * @param noMipmap defines if mipmaps should be created or not
  70494. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70495. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70496. * @param onError defines a callback triggered in case of error during load
  70497. * @param format defines the internal format to use for the texture once loaded
  70498. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70499. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70500. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70501. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70502. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70503. * @return the cube texture
  70504. */
  70505. 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);
  70506. /**
  70507. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70508. */
  70509. readonly isPrefiltered: boolean;
  70510. /**
  70511. * Get the current class name of the texture useful for serialization or dynamic coding.
  70512. * @returns "CubeTexture"
  70513. */
  70514. getClassName(): string;
  70515. /**
  70516. * Update the url (and optional buffer) of this texture if url was null during construction.
  70517. * @param url the url of the texture
  70518. * @param forcedExtension defines the extension to use
  70519. * @param onLoad callback called when the texture is loaded (defaults to null)
  70520. */
  70521. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70522. /**
  70523. * Delays loading of the cube texture
  70524. * @param forcedExtension defines the extension to use
  70525. */
  70526. delayLoad(forcedExtension?: string): void;
  70527. /**
  70528. * Returns the reflection texture matrix
  70529. * @returns the reflection texture matrix
  70530. */
  70531. getReflectionTextureMatrix(): Matrix;
  70532. /**
  70533. * Sets the reflection texture matrix
  70534. * @param value Reflection texture matrix
  70535. */
  70536. setReflectionTextureMatrix(value: Matrix): void;
  70537. /**
  70538. * Parses text to create a cube texture
  70539. * @param parsedTexture define the serialized text to read from
  70540. * @param scene defines the hosting scene
  70541. * @param rootUrl defines the root url of the cube texture
  70542. * @returns a cube texture
  70543. */
  70544. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70545. /**
  70546. * Makes a clone, or deep copy, of the cube texture
  70547. * @returns a new cube texture
  70548. */
  70549. clone(): CubeTexture;
  70550. }
  70551. }
  70552. declare module BABYLON {
  70553. /** @hidden */
  70554. export var postprocessVertexShader: {
  70555. name: string;
  70556. shader: string;
  70557. };
  70558. }
  70559. declare module BABYLON {
  70560. /**
  70561. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  70562. * This is the base of the follow, arc rotate cameras and Free camera
  70563. * @see http://doc.babylonjs.com/features/cameras
  70564. */
  70565. export class TargetCamera extends Camera {
  70566. private static _RigCamTransformMatrix;
  70567. private static _TargetTransformMatrix;
  70568. private static _TargetFocalPoint;
  70569. /**
  70570. * Define the current direction the camera is moving to
  70571. */
  70572. cameraDirection: Vector3;
  70573. /**
  70574. * Define the current rotation the camera is rotating to
  70575. */
  70576. cameraRotation: Vector2;
  70577. /**
  70578. * When set, the up vector of the camera will be updated by the rotation of the camera
  70579. */
  70580. updateUpVectorFromRotation: boolean;
  70581. private _tmpQuaternion;
  70582. /**
  70583. * Define the current rotation of the camera
  70584. */
  70585. rotation: Vector3;
  70586. /**
  70587. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  70588. */
  70589. rotationQuaternion: Quaternion;
  70590. /**
  70591. * Define the current speed of the camera
  70592. */
  70593. speed: number;
  70594. /**
  70595. * Add cconstraint to the camera to prevent it to move freely in all directions and
  70596. * around all axis.
  70597. */
  70598. noRotationConstraint: boolean;
  70599. /**
  70600. * Define the current target of the camera as an object or a position.
  70601. */
  70602. lockedTarget: any;
  70603. /** @hidden */
  70604. _currentTarget: Vector3;
  70605. /** @hidden */
  70606. _initialFocalDistance: number;
  70607. /** @hidden */
  70608. _viewMatrix: Matrix;
  70609. /** @hidden */
  70610. _camMatrix: Matrix;
  70611. /** @hidden */
  70612. _cameraTransformMatrix: Matrix;
  70613. /** @hidden */
  70614. _cameraRotationMatrix: Matrix;
  70615. /** @hidden */
  70616. _referencePoint: Vector3;
  70617. /** @hidden */
  70618. _transformedReferencePoint: Vector3;
  70619. protected _globalCurrentTarget: Vector3;
  70620. protected _globalCurrentUpVector: Vector3;
  70621. /** @hidden */
  70622. _reset: () => void;
  70623. private _defaultUp;
  70624. /**
  70625. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  70626. * This is the base of the follow, arc rotate cameras and Free camera
  70627. * @see http://doc.babylonjs.com/features/cameras
  70628. * @param name Defines the name of the camera in the scene
  70629. * @param position Defines the start position of the camera in the scene
  70630. * @param scene Defines the scene the camera belongs to
  70631. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70632. */
  70633. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70634. /**
  70635. * Gets the position in front of the camera at a given distance.
  70636. * @param distance The distance from the camera we want the position to be
  70637. * @returns the position
  70638. */
  70639. getFrontPosition(distance: number): Vector3;
  70640. /** @hidden */
  70641. _getLockedTargetPosition(): Nullable<Vector3>;
  70642. private _storedPosition;
  70643. private _storedRotation;
  70644. private _storedRotationQuaternion;
  70645. /**
  70646. * Store current camera state of the camera (fov, position, rotation, etc..)
  70647. * @returns the camera
  70648. */
  70649. storeState(): Camera;
  70650. /**
  70651. * Restored camera state. You must call storeState() first
  70652. * @returns whether it was successful or not
  70653. * @hidden
  70654. */
  70655. _restoreStateValues(): boolean;
  70656. /** @hidden */
  70657. _initCache(): void;
  70658. /** @hidden */
  70659. _updateCache(ignoreParentClass?: boolean): void;
  70660. /** @hidden */
  70661. _isSynchronizedViewMatrix(): boolean;
  70662. /** @hidden */
  70663. _computeLocalCameraSpeed(): number;
  70664. /**
  70665. * Defines the target the camera should look at.
  70666. * @param target Defines the new target as a Vector or a mesh
  70667. */
  70668. setTarget(target: Vector3): void;
  70669. /**
  70670. * Return the current target position of the camera. This value is expressed in local space.
  70671. * @returns the target position
  70672. */
  70673. getTarget(): Vector3;
  70674. /** @hidden */
  70675. _decideIfNeedsToMove(): boolean;
  70676. /** @hidden */
  70677. _updatePosition(): void;
  70678. /** @hidden */
  70679. _checkInputs(): void;
  70680. protected _updateCameraRotationMatrix(): void;
  70681. /**
  70682. * 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)
  70683. * @returns the current camera
  70684. */
  70685. private _rotateUpVectorWithCameraRotationMatrix;
  70686. private _cachedRotationZ;
  70687. private _cachedQuaternionRotationZ;
  70688. /** @hidden */
  70689. _getViewMatrix(): Matrix;
  70690. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  70691. /**
  70692. * @hidden
  70693. */
  70694. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  70695. /**
  70696. * @hidden
  70697. */
  70698. _updateRigCameras(): void;
  70699. private _getRigCamPositionAndTarget;
  70700. /**
  70701. * Gets the current object class name.
  70702. * @return the class name
  70703. */
  70704. getClassName(): string;
  70705. }
  70706. }
  70707. declare module BABYLON {
  70708. /**
  70709. * @ignore
  70710. * This is a list of all the different input types that are available in the application.
  70711. * Fo instance: ArcRotateCameraGamepadInput...
  70712. */
  70713. export var CameraInputTypes: {};
  70714. /**
  70715. * This is the contract to implement in order to create a new input class.
  70716. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70717. */
  70718. export interface ICameraInput<TCamera extends Camera> {
  70719. /**
  70720. * Defines the camera the input is attached to.
  70721. */
  70722. camera: Nullable<TCamera>;
  70723. /**
  70724. * Gets the class name of the current intput.
  70725. * @returns the class name
  70726. */
  70727. getClassName(): string;
  70728. /**
  70729. * Get the friendly name associated with the input class.
  70730. * @returns the input friendly name
  70731. */
  70732. getSimpleName(): string;
  70733. /**
  70734. * Attach the input controls to a specific dom element to get the input from.
  70735. * @param element Defines the element the controls should be listened from
  70736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70737. */
  70738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70739. /**
  70740. * Detach the current controls from the specified dom element.
  70741. * @param element Defines the element to stop listening the inputs from
  70742. */
  70743. detachControl(element: Nullable<HTMLElement>): void;
  70744. /**
  70745. * Update the current camera state depending on the inputs that have been used this frame.
  70746. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70747. */
  70748. checkInputs?: () => void;
  70749. }
  70750. /**
  70751. * Represents a map of input types to input instance or input index to input instance.
  70752. */
  70753. export interface CameraInputsMap<TCamera extends Camera> {
  70754. /**
  70755. * Accessor to the input by input type.
  70756. */
  70757. [name: string]: ICameraInput<TCamera>;
  70758. /**
  70759. * Accessor to the input by input index.
  70760. */
  70761. [idx: number]: ICameraInput<TCamera>;
  70762. }
  70763. /**
  70764. * This represents the input manager used within a camera.
  70765. * It helps dealing with all the different kind of input attached to a camera.
  70766. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70767. */
  70768. export class CameraInputsManager<TCamera extends Camera> {
  70769. /**
  70770. * Defines the list of inputs attahed to the camera.
  70771. */
  70772. attached: CameraInputsMap<TCamera>;
  70773. /**
  70774. * Defines the dom element the camera is collecting inputs from.
  70775. * This is null if the controls have not been attached.
  70776. */
  70777. attachedElement: Nullable<HTMLElement>;
  70778. /**
  70779. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70780. */
  70781. noPreventDefault: boolean;
  70782. /**
  70783. * Defined the camera the input manager belongs to.
  70784. */
  70785. camera: TCamera;
  70786. /**
  70787. * Update the current camera state depending on the inputs that have been used this frame.
  70788. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70789. */
  70790. checkInputs: () => void;
  70791. /**
  70792. * Instantiate a new Camera Input Manager.
  70793. * @param camera Defines the camera the input manager blongs to
  70794. */
  70795. constructor(camera: TCamera);
  70796. /**
  70797. * Add an input method to a camera
  70798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70799. * @param input camera input method
  70800. */
  70801. add(input: ICameraInput<TCamera>): void;
  70802. /**
  70803. * Remove a specific input method from a camera
  70804. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70805. * @param inputToRemove camera input method
  70806. */
  70807. remove(inputToRemove: ICameraInput<TCamera>): void;
  70808. /**
  70809. * Remove a specific input type from a camera
  70810. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70811. * @param inputType the type of the input to remove
  70812. */
  70813. removeByType(inputType: string): void;
  70814. private _addCheckInputs;
  70815. /**
  70816. * Attach the input controls to the currently attached dom element to listen the events from.
  70817. * @param input Defines the input to attach
  70818. */
  70819. attachInput(input: ICameraInput<TCamera>): void;
  70820. /**
  70821. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70822. * @param element Defines the dom element to collect the events from
  70823. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70824. */
  70825. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70826. /**
  70827. * Detach the current manager inputs controls from a specific dom element.
  70828. * @param element Defines the dom element to collect the events from
  70829. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70830. */
  70831. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70832. /**
  70833. * Rebuild the dynamic inputCheck function from the current list of
  70834. * defined inputs in the manager.
  70835. */
  70836. rebuildInputCheck(): void;
  70837. /**
  70838. * Remove all attached input methods from a camera
  70839. */
  70840. clear(): void;
  70841. /**
  70842. * Serialize the current input manager attached to a camera.
  70843. * This ensures than once parsed,
  70844. * the input associated to the camera will be identical to the current ones
  70845. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70846. */
  70847. serialize(serializedCamera: any): void;
  70848. /**
  70849. * Parses an input manager serialized JSON to restore the previous list of inputs
  70850. * and states associated to a camera.
  70851. * @param parsedCamera Defines the JSON to parse
  70852. */
  70853. parse(parsedCamera: any): void;
  70854. }
  70855. }
  70856. declare module BABYLON {
  70857. /**
  70858. * Gather the list of keyboard event types as constants.
  70859. */
  70860. export class KeyboardEventTypes {
  70861. /**
  70862. * The keydown event is fired when a key becomes active (pressed).
  70863. */
  70864. static readonly KEYDOWN: number;
  70865. /**
  70866. * The keyup event is fired when a key has been released.
  70867. */
  70868. static readonly KEYUP: number;
  70869. }
  70870. /**
  70871. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70872. */
  70873. export class KeyboardInfo {
  70874. /**
  70875. * Defines the type of event (KeyboardEventTypes)
  70876. */
  70877. type: number;
  70878. /**
  70879. * Defines the related dom event
  70880. */
  70881. event: KeyboardEvent;
  70882. /**
  70883. * Instantiates a new keyboard info.
  70884. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70885. * @param type Defines the type of event (KeyboardEventTypes)
  70886. * @param event Defines the related dom event
  70887. */
  70888. constructor(
  70889. /**
  70890. * Defines the type of event (KeyboardEventTypes)
  70891. */
  70892. type: number,
  70893. /**
  70894. * Defines the related dom event
  70895. */
  70896. event: KeyboardEvent);
  70897. }
  70898. /**
  70899. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70900. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  70901. */
  70902. export class KeyboardInfoPre extends KeyboardInfo {
  70903. /**
  70904. * Defines the type of event (KeyboardEventTypes)
  70905. */
  70906. type: number;
  70907. /**
  70908. * Defines the related dom event
  70909. */
  70910. event: KeyboardEvent;
  70911. /**
  70912. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  70913. */
  70914. skipOnPointerObservable: boolean;
  70915. /**
  70916. * Instantiates a new keyboard pre info.
  70917. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70918. * @param type Defines the type of event (KeyboardEventTypes)
  70919. * @param event Defines the related dom event
  70920. */
  70921. constructor(
  70922. /**
  70923. * Defines the type of event (KeyboardEventTypes)
  70924. */
  70925. type: number,
  70926. /**
  70927. * Defines the related dom event
  70928. */
  70929. event: KeyboardEvent);
  70930. }
  70931. }
  70932. declare module BABYLON {
  70933. /**
  70934. * Manage the keyboard inputs to control the movement of a free camera.
  70935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70936. */
  70937. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  70938. /**
  70939. * Defines the camera the input is attached to.
  70940. */
  70941. camera: FreeCamera;
  70942. /**
  70943. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70944. */
  70945. keysUp: number[];
  70946. /**
  70947. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70948. */
  70949. keysDown: number[];
  70950. /**
  70951. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70952. */
  70953. keysLeft: number[];
  70954. /**
  70955. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70956. */
  70957. keysRight: number[];
  70958. private _keys;
  70959. private _onCanvasBlurObserver;
  70960. private _onKeyboardObserver;
  70961. private _engine;
  70962. private _scene;
  70963. /**
  70964. * Attach the input controls to a specific dom element to get the input from.
  70965. * @param element Defines the element the controls should be listened from
  70966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70967. */
  70968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70969. /**
  70970. * Detach the current controls from the specified dom element.
  70971. * @param element Defines the element to stop listening the inputs from
  70972. */
  70973. detachControl(element: Nullable<HTMLElement>): void;
  70974. /**
  70975. * Update the current camera state depending on the inputs that have been used this frame.
  70976. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70977. */
  70978. checkInputs(): void;
  70979. /**
  70980. * Gets the class name of the current intput.
  70981. * @returns the class name
  70982. */
  70983. getClassName(): string;
  70984. /** @hidden */
  70985. _onLostFocus(): void;
  70986. /**
  70987. * Get the friendly name associated with the input class.
  70988. * @returns the input friendly name
  70989. */
  70990. getSimpleName(): string;
  70991. }
  70992. }
  70993. declare module BABYLON {
  70994. /**
  70995. * A multi-material is used to apply different materials to different parts of the same object without the need of
  70996. * separate meshes. This can be use to improve performances.
  70997. * @see http://doc.babylonjs.com/how_to/multi_materials
  70998. */
  70999. export class MultiMaterial extends Material {
  71000. private _subMaterials;
  71001. /**
  71002. * Gets or Sets the list of Materials used within the multi material.
  71003. * They need to be ordered according to the submeshes order in the associated mesh
  71004. */
  71005. subMaterials: Nullable<Material>[];
  71006. /**
  71007. * Function used to align with Node.getChildren()
  71008. * @returns the list of Materials used within the multi material
  71009. */
  71010. getChildren(): Nullable<Material>[];
  71011. /**
  71012. * Instantiates a new Multi Material
  71013. * A multi-material is used to apply different materials to different parts of the same object without the need of
  71014. * separate meshes. This can be use to improve performances.
  71015. * @see http://doc.babylonjs.com/how_to/multi_materials
  71016. * @param name Define the name in the scene
  71017. * @param scene Define the scene the material belongs to
  71018. */
  71019. constructor(name: string, scene: Scene);
  71020. private _hookArray;
  71021. /**
  71022. * Get one of the submaterial by its index in the submaterials array
  71023. * @param index The index to look the sub material at
  71024. * @returns The Material if the index has been defined
  71025. */
  71026. getSubMaterial(index: number): Nullable<Material>;
  71027. /**
  71028. * Get the list of active textures for the whole sub materials list.
  71029. * @returns All the textures that will be used during the rendering
  71030. */
  71031. getActiveTextures(): BaseTexture[];
  71032. /**
  71033. * Gets the current class name of the material e.g. "MultiMaterial"
  71034. * Mainly use in serialization.
  71035. * @returns the class name
  71036. */
  71037. getClassName(): string;
  71038. /**
  71039. * Checks if the material is ready to render the requested sub mesh
  71040. * @param mesh Define the mesh the submesh belongs to
  71041. * @param subMesh Define the sub mesh to look readyness for
  71042. * @param useInstances Define whether or not the material is used with instances
  71043. * @returns true if ready, otherwise false
  71044. */
  71045. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  71046. /**
  71047. * Clones the current material and its related sub materials
  71048. * @param name Define the name of the newly cloned material
  71049. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  71050. * @returns the cloned material
  71051. */
  71052. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  71053. /**
  71054. * Serializes the materials into a JSON representation.
  71055. * @returns the JSON representation
  71056. */
  71057. serialize(): any;
  71058. /**
  71059. * Dispose the material and release its associated resources
  71060. * @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)
  71061. * @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)
  71062. * @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)
  71063. */
  71064. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  71065. /**
  71066. * Creates a MultiMaterial from parsed MultiMaterial data.
  71067. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  71068. * @param scene defines the hosting scene
  71069. * @returns a new MultiMaterial
  71070. */
  71071. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  71072. }
  71073. }
  71074. declare module BABYLON {
  71075. /**
  71076. * Class used to represent data loading progression
  71077. */
  71078. export class SceneLoaderFlags {
  71079. private static _ForceFullSceneLoadingForIncremental;
  71080. private static _ShowLoadingScreen;
  71081. private static _CleanBoneMatrixWeights;
  71082. private static _loggingLevel;
  71083. /**
  71084. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  71085. */
  71086. static ForceFullSceneLoadingForIncremental: boolean;
  71087. /**
  71088. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  71089. */
  71090. static ShowLoadingScreen: boolean;
  71091. /**
  71092. * Defines the current logging level (while loading the scene)
  71093. * @ignorenaming
  71094. */
  71095. static loggingLevel: number;
  71096. /**
  71097. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  71098. */
  71099. static CleanBoneMatrixWeights: boolean;
  71100. }
  71101. }
  71102. declare module BABYLON {
  71103. /**
  71104. * 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.
  71105. * @see https://doc.babylonjs.com/how_to/transformnode
  71106. */
  71107. export class TransformNode extends Node {
  71108. /**
  71109. * Object will not rotate to face the camera
  71110. */
  71111. static BILLBOARDMODE_NONE: number;
  71112. /**
  71113. * Object will rotate to face the camera but only on the x axis
  71114. */
  71115. static BILLBOARDMODE_X: number;
  71116. /**
  71117. * Object will rotate to face the camera but only on the y axis
  71118. */
  71119. static BILLBOARDMODE_Y: number;
  71120. /**
  71121. * Object will rotate to face the camera but only on the z axis
  71122. */
  71123. static BILLBOARDMODE_Z: number;
  71124. /**
  71125. * Object will rotate to face the camera
  71126. */
  71127. static BILLBOARDMODE_ALL: number;
  71128. private _forward;
  71129. private _forwardInverted;
  71130. private _up;
  71131. private _right;
  71132. private _rightInverted;
  71133. private _position;
  71134. private _rotation;
  71135. private _rotationQuaternion;
  71136. protected _scaling: Vector3;
  71137. protected _isDirty: boolean;
  71138. private _transformToBoneReferal;
  71139. private _billboardMode;
  71140. /**
  71141. * Gets or sets the billboard mode. Default is 0.
  71142. *
  71143. * | Value | Type | Description |
  71144. * | --- | --- | --- |
  71145. * | 0 | BILLBOARDMODE_NONE | |
  71146. * | 1 | BILLBOARDMODE_X | |
  71147. * | 2 | BILLBOARDMODE_Y | |
  71148. * | 4 | BILLBOARDMODE_Z | |
  71149. * | 7 | BILLBOARDMODE_ALL | |
  71150. *
  71151. */
  71152. billboardMode: number;
  71153. private _preserveParentRotationForBillboard;
  71154. /**
  71155. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  71156. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  71157. */
  71158. preserveParentRotationForBillboard: boolean;
  71159. /**
  71160. * 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
  71161. */
  71162. scalingDeterminant: number;
  71163. private _infiniteDistance;
  71164. /**
  71165. * Gets or sets the distance of the object to max, often used by skybox
  71166. */
  71167. infiniteDistance: boolean;
  71168. /**
  71169. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  71170. * By default the system will update normals to compensate
  71171. */
  71172. ignoreNonUniformScaling: boolean;
  71173. /**
  71174. * 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
  71175. */
  71176. reIntegrateRotationIntoRotationQuaternion: boolean;
  71177. /** @hidden */
  71178. _poseMatrix: Nullable<Matrix>;
  71179. /** @hidden */
  71180. _localMatrix: Matrix;
  71181. private _usePivotMatrix;
  71182. private _absolutePosition;
  71183. private _pivotMatrix;
  71184. private _pivotMatrixInverse;
  71185. protected _postMultiplyPivotMatrix: boolean;
  71186. protected _isWorldMatrixFrozen: boolean;
  71187. /** @hidden */
  71188. _indexInSceneTransformNodesArray: number;
  71189. /**
  71190. * An event triggered after the world matrix is updated
  71191. */
  71192. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  71193. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  71194. /**
  71195. * Gets a string identifying the name of the class
  71196. * @returns "TransformNode" string
  71197. */
  71198. getClassName(): string;
  71199. /**
  71200. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  71201. */
  71202. position: Vector3;
  71203. /**
  71204. * 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)).
  71205. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  71206. */
  71207. rotation: Vector3;
  71208. /**
  71209. * 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)).
  71210. */
  71211. scaling: Vector3;
  71212. /**
  71213. * 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).
  71214. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  71215. */
  71216. rotationQuaternion: Nullable<Quaternion>;
  71217. /**
  71218. * The forward direction of that transform in world space.
  71219. */
  71220. readonly forward: Vector3;
  71221. /**
  71222. * The up direction of that transform in world space.
  71223. */
  71224. readonly up: Vector3;
  71225. /**
  71226. * The right direction of that transform in world space.
  71227. */
  71228. readonly right: Vector3;
  71229. /**
  71230. * Copies the parameter passed Matrix into the mesh Pose matrix.
  71231. * @param matrix the matrix to copy the pose from
  71232. * @returns this TransformNode.
  71233. */
  71234. updatePoseMatrix(matrix: Matrix): TransformNode;
  71235. /**
  71236. * Returns the mesh Pose matrix.
  71237. * @returns the pose matrix
  71238. */
  71239. getPoseMatrix(): Matrix;
  71240. /** @hidden */
  71241. _isSynchronized(): boolean;
  71242. /** @hidden */
  71243. _initCache(): void;
  71244. /**
  71245. * Flag the transform node as dirty (Forcing it to update everything)
  71246. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  71247. * @returns this transform node
  71248. */
  71249. markAsDirty(property: string): TransformNode;
  71250. /**
  71251. * Returns the current mesh absolute position.
  71252. * Returns a Vector3.
  71253. */
  71254. readonly absolutePosition: Vector3;
  71255. /**
  71256. * Sets a new matrix to apply before all other transformation
  71257. * @param matrix defines the transform matrix
  71258. * @returns the current TransformNode
  71259. */
  71260. setPreTransformMatrix(matrix: Matrix): TransformNode;
  71261. /**
  71262. * Sets a new pivot matrix to the current node
  71263. * @param matrix defines the new pivot matrix to use
  71264. * @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
  71265. * @returns the current TransformNode
  71266. */
  71267. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  71268. /**
  71269. * Returns the mesh pivot matrix.
  71270. * Default : Identity.
  71271. * @returns the matrix
  71272. */
  71273. getPivotMatrix(): Matrix;
  71274. /**
  71275. * Prevents the World matrix to be computed any longer.
  71276. * @returns the TransformNode.
  71277. */
  71278. freezeWorldMatrix(): TransformNode;
  71279. /**
  71280. * Allows back the World matrix computation.
  71281. * @returns the TransformNode.
  71282. */
  71283. unfreezeWorldMatrix(): this;
  71284. /**
  71285. * True if the World matrix has been frozen.
  71286. */
  71287. readonly isWorldMatrixFrozen: boolean;
  71288. /**
  71289. * Retuns the mesh absolute position in the World.
  71290. * @returns a Vector3.
  71291. */
  71292. getAbsolutePosition(): Vector3;
  71293. /**
  71294. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  71295. * @param absolutePosition the absolute position to set
  71296. * @returns the TransformNode.
  71297. */
  71298. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  71299. /**
  71300. * Sets the mesh position in its local space.
  71301. * @param vector3 the position to set in localspace
  71302. * @returns the TransformNode.
  71303. */
  71304. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  71305. /**
  71306. * Returns the mesh position in the local space from the current World matrix values.
  71307. * @returns a new Vector3.
  71308. */
  71309. getPositionExpressedInLocalSpace(): Vector3;
  71310. /**
  71311. * Translates the mesh along the passed Vector3 in its local space.
  71312. * @param vector3 the distance to translate in localspace
  71313. * @returns the TransformNode.
  71314. */
  71315. locallyTranslate(vector3: Vector3): TransformNode;
  71316. private static _lookAtVectorCache;
  71317. /**
  71318. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  71319. * @param targetPoint the position (must be in same space as current mesh) to look at
  71320. * @param yawCor optional yaw (y-axis) correction in radians
  71321. * @param pitchCor optional pitch (x-axis) correction in radians
  71322. * @param rollCor optional roll (z-axis) correction in radians
  71323. * @param space the choosen space of the target
  71324. * @returns the TransformNode.
  71325. */
  71326. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  71327. /**
  71328. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71329. * This Vector3 is expressed in the World space.
  71330. * @param localAxis axis to rotate
  71331. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71332. */
  71333. getDirection(localAxis: Vector3): Vector3;
  71334. /**
  71335. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  71336. * localAxis is expressed in the mesh local space.
  71337. * result is computed in the Wordl space from the mesh World matrix.
  71338. * @param localAxis axis to rotate
  71339. * @param result the resulting transformnode
  71340. * @returns this TransformNode.
  71341. */
  71342. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  71343. /**
  71344. * Sets this transform node rotation to the given local axis.
  71345. * @param localAxis the axis in local space
  71346. * @param yawCor optional yaw (y-axis) correction in radians
  71347. * @param pitchCor optional pitch (x-axis) correction in radians
  71348. * @param rollCor optional roll (z-axis) correction in radians
  71349. * @returns this TransformNode
  71350. */
  71351. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  71352. /**
  71353. * Sets a new pivot point to the current node
  71354. * @param point defines the new pivot point to use
  71355. * @param space defines if the point is in world or local space (local by default)
  71356. * @returns the current TransformNode
  71357. */
  71358. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  71359. /**
  71360. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  71361. * @returns the pivot point
  71362. */
  71363. getPivotPoint(): Vector3;
  71364. /**
  71365. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  71366. * @param result the vector3 to store the result
  71367. * @returns this TransformNode.
  71368. */
  71369. getPivotPointToRef(result: Vector3): TransformNode;
  71370. /**
  71371. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  71372. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  71373. */
  71374. getAbsolutePivotPoint(): Vector3;
  71375. /**
  71376. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  71377. * @param result vector3 to store the result
  71378. * @returns this TransformNode.
  71379. */
  71380. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  71381. /**
  71382. * Defines the passed node as the parent of the current node.
  71383. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  71384. * @see https://doc.babylonjs.com/how_to/parenting
  71385. * @param node the node ot set as the parent
  71386. * @returns this TransformNode.
  71387. */
  71388. setParent(node: Nullable<Node>): TransformNode;
  71389. private _nonUniformScaling;
  71390. /**
  71391. * True if the scaling property of this object is non uniform eg. (1,2,1)
  71392. */
  71393. readonly nonUniformScaling: boolean;
  71394. /** @hidden */
  71395. _updateNonUniformScalingState(value: boolean): boolean;
  71396. /**
  71397. * Attach the current TransformNode to another TransformNode associated with a bone
  71398. * @param bone Bone affecting the TransformNode
  71399. * @param affectedTransformNode TransformNode associated with the bone
  71400. * @returns this object
  71401. */
  71402. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  71403. /**
  71404. * Detach the transform node if its associated with a bone
  71405. * @returns this object
  71406. */
  71407. detachFromBone(): TransformNode;
  71408. private static _rotationAxisCache;
  71409. /**
  71410. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  71411. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71412. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71413. * The passed axis is also normalized.
  71414. * @param axis the axis to rotate around
  71415. * @param amount the amount to rotate in radians
  71416. * @param space Space to rotate in (Default: local)
  71417. * @returns the TransformNode.
  71418. */
  71419. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  71420. /**
  71421. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  71422. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71423. * The passed axis is also normalized. .
  71424. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  71425. * @param point the point to rotate around
  71426. * @param axis the axis to rotate around
  71427. * @param amount the amount to rotate in radians
  71428. * @returns the TransformNode
  71429. */
  71430. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  71431. /**
  71432. * Translates the mesh along the axis vector for the passed distance in the given space.
  71433. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71434. * @param axis the axis to translate in
  71435. * @param distance the distance to translate
  71436. * @param space Space to rotate in (Default: local)
  71437. * @returns the TransformNode.
  71438. */
  71439. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  71440. /**
  71441. * Adds a rotation step to the mesh current rotation.
  71442. * x, y, z are Euler angles expressed in radians.
  71443. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  71444. * This means this rotation is made in the mesh local space only.
  71445. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  71446. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  71447. * ```javascript
  71448. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  71449. * ```
  71450. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  71451. * 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.
  71452. * @param x Rotation to add
  71453. * @param y Rotation to add
  71454. * @param z Rotation to add
  71455. * @returns the TransformNode.
  71456. */
  71457. addRotation(x: number, y: number, z: number): TransformNode;
  71458. /**
  71459. * @hidden
  71460. */
  71461. protected _getEffectiveParent(): Nullable<Node>;
  71462. /**
  71463. * Computes the world matrix of the node
  71464. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71465. * @returns the world matrix
  71466. */
  71467. computeWorldMatrix(force?: boolean): Matrix;
  71468. protected _afterComputeWorldMatrix(): void;
  71469. /**
  71470. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  71471. * @param func callback function to add
  71472. *
  71473. * @returns the TransformNode.
  71474. */
  71475. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71476. /**
  71477. * Removes a registered callback function.
  71478. * @param func callback function to remove
  71479. * @returns the TransformNode.
  71480. */
  71481. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71482. /**
  71483. * Gets the position of the current mesh in camera space
  71484. * @param camera defines the camera to use
  71485. * @returns a position
  71486. */
  71487. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  71488. /**
  71489. * Returns the distance from the mesh to the active camera
  71490. * @param camera defines the camera to use
  71491. * @returns the distance
  71492. */
  71493. getDistanceToCamera(camera?: Nullable<Camera>): number;
  71494. /**
  71495. * Clone the current transform node
  71496. * @param name Name of the new clone
  71497. * @param newParent New parent for the clone
  71498. * @param doNotCloneChildren Do not clone children hierarchy
  71499. * @returns the new transform node
  71500. */
  71501. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  71502. /**
  71503. * Serializes the objects information.
  71504. * @param currentSerializationObject defines the object to serialize in
  71505. * @returns the serialized object
  71506. */
  71507. serialize(currentSerializationObject?: any): any;
  71508. /**
  71509. * Returns a new TransformNode object parsed from the source provided.
  71510. * @param parsedTransformNode is the source.
  71511. * @param scene the scne the object belongs to
  71512. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  71513. * @returns a new TransformNode object parsed from the source provided.
  71514. */
  71515. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  71516. /**
  71517. * Get all child-transformNodes of this node
  71518. * @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
  71519. * @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
  71520. * @returns an array of TransformNode
  71521. */
  71522. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  71523. /**
  71524. * Releases resources associated with this transform node.
  71525. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  71526. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  71527. */
  71528. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  71529. /**
  71530. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  71531. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  71532. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  71533. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  71534. * @returns the current mesh
  71535. */
  71536. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  71537. }
  71538. }
  71539. declare module BABYLON {
  71540. /**
  71541. * Class used to override all child animations of a given target
  71542. */
  71543. export class AnimationPropertiesOverride {
  71544. /**
  71545. * Gets or sets a value indicating if animation blending must be used
  71546. */
  71547. enableBlending: boolean;
  71548. /**
  71549. * Gets or sets the blending speed to use when enableBlending is true
  71550. */
  71551. blendingSpeed: number;
  71552. /**
  71553. * Gets or sets the default loop mode to use
  71554. */
  71555. loopMode: number;
  71556. }
  71557. }
  71558. declare module BABYLON {
  71559. /**
  71560. * Class used to store bone information
  71561. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  71562. */
  71563. export class Bone extends Node {
  71564. /**
  71565. * defines the bone name
  71566. */
  71567. name: string;
  71568. private static _tmpVecs;
  71569. private static _tmpQuat;
  71570. private static _tmpMats;
  71571. /**
  71572. * Gets the list of child bones
  71573. */
  71574. children: Bone[];
  71575. /** Gets the animations associated with this bone */
  71576. animations: Animation[];
  71577. /**
  71578. * Gets or sets bone length
  71579. */
  71580. length: number;
  71581. /**
  71582. * @hidden Internal only
  71583. * Set this value to map this bone to a different index in the transform matrices
  71584. * Set this value to -1 to exclude the bone from the transform matrices
  71585. */
  71586. _index: Nullable<number>;
  71587. private _skeleton;
  71588. private _localMatrix;
  71589. private _restPose;
  71590. private _baseMatrix;
  71591. private _absoluteTransform;
  71592. private _invertedAbsoluteTransform;
  71593. private _parent;
  71594. private _scalingDeterminant;
  71595. private _worldTransform;
  71596. private _localScaling;
  71597. private _localRotation;
  71598. private _localPosition;
  71599. private _needToDecompose;
  71600. private _needToCompose;
  71601. /** @hidden */
  71602. _linkedTransformNode: Nullable<TransformNode>;
  71603. /** @hidden */
  71604. _waitingTransformNodeId: Nullable<string>;
  71605. /** @hidden */
  71606. /** @hidden */
  71607. _matrix: Matrix;
  71608. /**
  71609. * Create a new bone
  71610. * @param name defines the bone name
  71611. * @param skeleton defines the parent skeleton
  71612. * @param parentBone defines the parent (can be null if the bone is the root)
  71613. * @param localMatrix defines the local matrix
  71614. * @param restPose defines the rest pose matrix
  71615. * @param baseMatrix defines the base matrix
  71616. * @param index defines index of the bone in the hiearchy
  71617. */
  71618. constructor(
  71619. /**
  71620. * defines the bone name
  71621. */
  71622. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  71623. /**
  71624. * Gets the current object class name.
  71625. * @return the class name
  71626. */
  71627. getClassName(): string;
  71628. /**
  71629. * Gets the parent skeleton
  71630. * @returns a skeleton
  71631. */
  71632. getSkeleton(): Skeleton;
  71633. /**
  71634. * Gets parent bone
  71635. * @returns a bone or null if the bone is the root of the bone hierarchy
  71636. */
  71637. getParent(): Nullable<Bone>;
  71638. /**
  71639. * Returns an array containing the root bones
  71640. * @returns an array containing the root bones
  71641. */
  71642. getChildren(): Array<Bone>;
  71643. /**
  71644. * Sets the parent bone
  71645. * @param parent defines the parent (can be null if the bone is the root)
  71646. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71647. */
  71648. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  71649. /**
  71650. * Gets the local matrix
  71651. * @returns a matrix
  71652. */
  71653. getLocalMatrix(): Matrix;
  71654. /**
  71655. * Gets the base matrix (initial matrix which remains unchanged)
  71656. * @returns a matrix
  71657. */
  71658. getBaseMatrix(): Matrix;
  71659. /**
  71660. * Gets the rest pose matrix
  71661. * @returns a matrix
  71662. */
  71663. getRestPose(): Matrix;
  71664. /**
  71665. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  71666. */
  71667. getWorldMatrix(): Matrix;
  71668. /**
  71669. * Sets the local matrix to rest pose matrix
  71670. */
  71671. returnToRest(): void;
  71672. /**
  71673. * Gets the inverse of the absolute transform matrix.
  71674. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  71675. * @returns a matrix
  71676. */
  71677. getInvertedAbsoluteTransform(): Matrix;
  71678. /**
  71679. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  71680. * @returns a matrix
  71681. */
  71682. getAbsoluteTransform(): Matrix;
  71683. /**
  71684. * Links with the given transform node.
  71685. * The local matrix of this bone is copied from the transform node every frame.
  71686. * @param transformNode defines the transform node to link to
  71687. */
  71688. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  71689. /** Gets or sets current position (in local space) */
  71690. position: Vector3;
  71691. /** Gets or sets current rotation (in local space) */
  71692. rotation: Vector3;
  71693. /** Gets or sets current rotation quaternion (in local space) */
  71694. rotationQuaternion: Quaternion;
  71695. /** Gets or sets current scaling (in local space) */
  71696. scaling: Vector3;
  71697. /**
  71698. * Gets the animation properties override
  71699. */
  71700. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  71701. private _decompose;
  71702. private _compose;
  71703. /**
  71704. * Update the base and local matrices
  71705. * @param matrix defines the new base or local matrix
  71706. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71707. * @param updateLocalMatrix defines if the local matrix should be updated
  71708. */
  71709. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  71710. /** @hidden */
  71711. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  71712. /**
  71713. * Flag the bone as dirty (Forcing it to update everything)
  71714. */
  71715. markAsDirty(): void;
  71716. /** @hidden */
  71717. _markAsDirtyAndCompose(): void;
  71718. private _markAsDirtyAndDecompose;
  71719. /**
  71720. * Translate the bone in local or world space
  71721. * @param vec The amount to translate the bone
  71722. * @param space The space that the translation is in
  71723. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71724. */
  71725. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71726. /**
  71727. * Set the postion of the bone in local or world space
  71728. * @param position The position to set the bone
  71729. * @param space The space that the position is in
  71730. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71731. */
  71732. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71733. /**
  71734. * Set the absolute position of the bone (world space)
  71735. * @param position The position to set the bone
  71736. * @param mesh The mesh that this bone is attached to
  71737. */
  71738. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  71739. /**
  71740. * Scale the bone on the x, y and z axes (in local space)
  71741. * @param x The amount to scale the bone on the x axis
  71742. * @param y The amount to scale the bone on the y axis
  71743. * @param z The amount to scale the bone on the z axis
  71744. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  71745. */
  71746. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  71747. /**
  71748. * Set the bone scaling in local space
  71749. * @param scale defines the scaling vector
  71750. */
  71751. setScale(scale: Vector3): void;
  71752. /**
  71753. * Gets the current scaling in local space
  71754. * @returns the current scaling vector
  71755. */
  71756. getScale(): Vector3;
  71757. /**
  71758. * Gets the current scaling in local space and stores it in a target vector
  71759. * @param result defines the target vector
  71760. */
  71761. getScaleToRef(result: Vector3): void;
  71762. /**
  71763. * Set the yaw, pitch, and roll of the bone in local or world space
  71764. * @param yaw The rotation of the bone on the y axis
  71765. * @param pitch The rotation of the bone on the x axis
  71766. * @param roll The rotation of the bone on the z axis
  71767. * @param space The space that the axes of rotation are in
  71768. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71769. */
  71770. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  71771. /**
  71772. * Add a rotation to the bone on an axis in local or world space
  71773. * @param axis The axis to rotate the bone on
  71774. * @param amount The amount to rotate the bone
  71775. * @param space The space that the axis is in
  71776. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71777. */
  71778. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  71779. /**
  71780. * Set the rotation of the bone to a particular axis angle in local or world space
  71781. * @param axis The axis to rotate the bone on
  71782. * @param angle The angle that the bone should be rotated to
  71783. * @param space The space that the axis is in
  71784. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71785. */
  71786. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  71787. /**
  71788. * Set the euler rotation of the bone in local of world space
  71789. * @param rotation The euler rotation that the bone should be set to
  71790. * @param space The space that the rotation is in
  71791. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71792. */
  71793. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71794. /**
  71795. * Set the quaternion rotation of the bone in local of world space
  71796. * @param quat The quaternion rotation that the bone should be set to
  71797. * @param space The space that the rotation is in
  71798. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71799. */
  71800. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  71801. /**
  71802. * Set the rotation matrix of the bone in local of world space
  71803. * @param rotMat The rotation matrix that the bone should be set to
  71804. * @param space The space that the rotation is in
  71805. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71806. */
  71807. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  71808. private _rotateWithMatrix;
  71809. private _getNegativeRotationToRef;
  71810. /**
  71811. * Get the position of the bone in local or world space
  71812. * @param space The space that the returned position is in
  71813. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71814. * @returns The position of the bone
  71815. */
  71816. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71817. /**
  71818. * Copy the position of the bone to a vector3 in local or world space
  71819. * @param space The space that the returned position is in
  71820. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71821. * @param result The vector3 to copy the position to
  71822. */
  71823. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  71824. /**
  71825. * Get the absolute position of the bone (world space)
  71826. * @param mesh The mesh that this bone is attached to
  71827. * @returns The absolute position of the bone
  71828. */
  71829. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  71830. /**
  71831. * Copy the absolute position of the bone (world space) to the result param
  71832. * @param mesh The mesh that this bone is attached to
  71833. * @param result The vector3 to copy the absolute position to
  71834. */
  71835. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  71836. /**
  71837. * Compute the absolute transforms of this bone and its children
  71838. */
  71839. computeAbsoluteTransforms(): void;
  71840. /**
  71841. * Get the world direction from an axis that is in the local space of the bone
  71842. * @param localAxis The local direction that is used to compute the world direction
  71843. * @param mesh The mesh that this bone is attached to
  71844. * @returns The world direction
  71845. */
  71846. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71847. /**
  71848. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  71849. * @param localAxis The local direction that is used to compute the world direction
  71850. * @param mesh The mesh that this bone is attached to
  71851. * @param result The vector3 that the world direction will be copied to
  71852. */
  71853. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71854. /**
  71855. * Get the euler rotation of the bone in local or world space
  71856. * @param space The space that the rotation should be in
  71857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71858. * @returns The euler rotation
  71859. */
  71860. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71861. /**
  71862. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  71863. * @param space The space that the rotation should be in
  71864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71865. * @param result The vector3 that the rotation should be copied to
  71866. */
  71867. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71868. /**
  71869. * Get the quaternion rotation of the bone in either local or world space
  71870. * @param space The space that the rotation should be in
  71871. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71872. * @returns The quaternion rotation
  71873. */
  71874. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  71875. /**
  71876. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  71877. * @param space The space that the rotation should be in
  71878. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71879. * @param result The quaternion that the rotation should be copied to
  71880. */
  71881. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  71882. /**
  71883. * Get the rotation matrix of the bone in local or world space
  71884. * @param space The space that the rotation should be in
  71885. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71886. * @returns The rotation matrix
  71887. */
  71888. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  71889. /**
  71890. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  71891. * @param space The space that the rotation should be in
  71892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71893. * @param result The quaternion that the rotation should be copied to
  71894. */
  71895. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  71896. /**
  71897. * Get the world position of a point that is in the local space of the bone
  71898. * @param position The local position
  71899. * @param mesh The mesh that this bone is attached to
  71900. * @returns The world position
  71901. */
  71902. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71903. /**
  71904. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  71905. * @param position The local position
  71906. * @param mesh The mesh that this bone is attached to
  71907. * @param result The vector3 that the world position should be copied to
  71908. */
  71909. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71910. /**
  71911. * Get the local position of a point that is in world space
  71912. * @param position The world position
  71913. * @param mesh The mesh that this bone is attached to
  71914. * @returns The local position
  71915. */
  71916. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71917. /**
  71918. * Get the local position of a point that is in world space and copy it to the result param
  71919. * @param position The world position
  71920. * @param mesh The mesh that this bone is attached to
  71921. * @param result The vector3 that the local position should be copied to
  71922. */
  71923. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71924. }
  71925. }
  71926. declare module BABYLON {
  71927. interface Engine {
  71928. /**
  71929. * Creates a raw texture
  71930. * @param data defines the data to store in the texture
  71931. * @param width defines the width of the texture
  71932. * @param height defines the height of the texture
  71933. * @param format defines the format of the data
  71934. * @param generateMipMaps defines if the engine should generate the mip levels
  71935. * @param invertY defines if data must be stored with Y axis inverted
  71936. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71937. * @param compression defines the compression used (null by default)
  71938. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71939. * @returns the raw texture inside an InternalTexture
  71940. */
  71941. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  71942. /**
  71943. * Update a raw texture
  71944. * @param texture defines the texture to update
  71945. * @param data defines the data to store in the texture
  71946. * @param format defines the format of the data
  71947. * @param invertY defines if data must be stored with Y axis inverted
  71948. */
  71949. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  71950. /**
  71951. * Update a raw texture
  71952. * @param texture defines the texture to update
  71953. * @param data defines the data to store in the texture
  71954. * @param format defines the format of the data
  71955. * @param invertY defines if data must be stored with Y axis inverted
  71956. * @param compression defines the compression used (null by default)
  71957. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71958. */
  71959. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  71960. /**
  71961. * Creates a new raw cube texture
  71962. * @param data defines the array of data to use to create each face
  71963. * @param size defines the size of the textures
  71964. * @param format defines the format of the data
  71965. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71966. * @param generateMipMaps defines if the engine should generate the mip levels
  71967. * @param invertY defines if data must be stored with Y axis inverted
  71968. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71969. * @param compression defines the compression used (null by default)
  71970. * @returns the cube texture as an InternalTexture
  71971. */
  71972. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  71973. /**
  71974. * Update a raw cube texture
  71975. * @param texture defines the texture to udpdate
  71976. * @param data defines the data to store
  71977. * @param format defines the data format
  71978. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71979. * @param invertY defines if data must be stored with Y axis inverted
  71980. */
  71981. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  71982. /**
  71983. * Update a raw cube texture
  71984. * @param texture defines the texture to udpdate
  71985. * @param data defines the data to store
  71986. * @param format defines the data format
  71987. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71988. * @param invertY defines if data must be stored with Y axis inverted
  71989. * @param compression defines the compression used (null by default)
  71990. */
  71991. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  71992. /**
  71993. * Update a raw cube texture
  71994. * @param texture defines the texture to udpdate
  71995. * @param data defines the data to store
  71996. * @param format defines the data format
  71997. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71998. * @param invertY defines if data must be stored with Y axis inverted
  71999. * @param compression defines the compression used (null by default)
  72000. * @param level defines which level of the texture to update
  72001. */
  72002. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  72003. /**
  72004. * Creates a new raw cube texture from a specified url
  72005. * @param url defines the url where the data is located
  72006. * @param scene defines the current scene
  72007. * @param size defines the size of the textures
  72008. * @param format defines the format of the data
  72009. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72010. * @param noMipmap defines if the engine should avoid generating the mip levels
  72011. * @param callback defines a callback used to extract texture data from loaded data
  72012. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  72013. * @param onLoad defines a callback called when texture is loaded
  72014. * @param onError defines a callback called if there is an error
  72015. * @returns the cube texture as an InternalTexture
  72016. */
  72017. 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;
  72018. /**
  72019. * Creates a new raw cube texture from a specified url
  72020. * @param url defines the url where the data is located
  72021. * @param scene defines the current scene
  72022. * @param size defines the size of the textures
  72023. * @param format defines the format of the data
  72024. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72025. * @param noMipmap defines if the engine should avoid generating the mip levels
  72026. * @param callback defines a callback used to extract texture data from loaded data
  72027. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  72028. * @param onLoad defines a callback called when texture is loaded
  72029. * @param onError defines a callback called if there is an error
  72030. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72031. * @param invertY defines if data must be stored with Y axis inverted
  72032. * @returns the cube texture as an InternalTexture
  72033. */
  72034. 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;
  72035. /**
  72036. * Creates a new raw 3D texture
  72037. * @param data defines the data used to create the texture
  72038. * @param width defines the width of the texture
  72039. * @param height defines the height of the texture
  72040. * @param depth defines the depth of the texture
  72041. * @param format defines the format of the texture
  72042. * @param generateMipMaps defines if the engine must generate mip levels
  72043. * @param invertY defines if data must be stored with Y axis inverted
  72044. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72045. * @param compression defines the compressed used (can be null)
  72046. * @param textureType defines the compressed used (can be null)
  72047. * @returns a new raw 3D texture (stored in an InternalTexture)
  72048. */
  72049. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  72050. /**
  72051. * Update a raw 3D texture
  72052. * @param texture defines the texture to update
  72053. * @param data defines the data to store
  72054. * @param format defines the data format
  72055. * @param invertY defines if data must be stored with Y axis inverted
  72056. */
  72057. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  72058. /**
  72059. * Update a raw 3D texture
  72060. * @param texture defines the texture to update
  72061. * @param data defines the data to store
  72062. * @param format defines the data format
  72063. * @param invertY defines if data must be stored with Y axis inverted
  72064. * @param compression defines the used compression (can be null)
  72065. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  72066. */
  72067. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  72068. }
  72069. }
  72070. declare module BABYLON {
  72071. /**
  72072. * Raw texture can help creating a texture directly from an array of data.
  72073. * This can be super useful if you either get the data from an uncompressed source or
  72074. * if you wish to create your texture pixel by pixel.
  72075. */
  72076. export class RawTexture extends Texture {
  72077. /**
  72078. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72079. */
  72080. format: number;
  72081. private _engine;
  72082. /**
  72083. * Instantiates a new RawTexture.
  72084. * Raw texture can help creating a texture directly from an array of data.
  72085. * This can be super useful if you either get the data from an uncompressed source or
  72086. * if you wish to create your texture pixel by pixel.
  72087. * @param data define the array of data to use to create the texture
  72088. * @param width define the width of the texture
  72089. * @param height define the height of the texture
  72090. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72091. * @param scene define the scene the texture belongs to
  72092. * @param generateMipMaps define whether mip maps should be generated or not
  72093. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72094. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72095. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72096. */
  72097. constructor(data: ArrayBufferView, width: number, height: number,
  72098. /**
  72099. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72100. */
  72101. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  72102. /**
  72103. * Updates the texture underlying data.
  72104. * @param data Define the new data of the texture
  72105. */
  72106. update(data: ArrayBufferView): void;
  72107. /**
  72108. * Creates a luminance texture from some data.
  72109. * @param data Define the texture data
  72110. * @param width Define the width of the texture
  72111. * @param height Define the height of the texture
  72112. * @param scene Define the scene the texture belongs to
  72113. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72114. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72115. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72116. * @returns the luminance texture
  72117. */
  72118. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72119. /**
  72120. * Creates a luminance alpha texture from some data.
  72121. * @param data Define the texture data
  72122. * @param width Define the width of the texture
  72123. * @param height Define the height of the texture
  72124. * @param scene Define the scene the texture belongs to
  72125. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72126. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72127. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72128. * @returns the luminance alpha texture
  72129. */
  72130. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72131. /**
  72132. * Creates an alpha texture from some data.
  72133. * @param data Define the texture data
  72134. * @param width Define the width of the texture
  72135. * @param height Define the height of the texture
  72136. * @param scene Define the scene the texture belongs to
  72137. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72138. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72139. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72140. * @returns the alpha texture
  72141. */
  72142. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72143. /**
  72144. * Creates a RGB texture from some data.
  72145. * @param data Define the texture data
  72146. * @param width Define the width of the texture
  72147. * @param height Define the height of the texture
  72148. * @param scene Define the scene the texture belongs to
  72149. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72150. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72151. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72152. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72153. * @returns the RGB alpha texture
  72154. */
  72155. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72156. /**
  72157. * Creates a RGBA texture from some data.
  72158. * @param data Define the texture data
  72159. * @param width Define the width of the texture
  72160. * @param height Define the height of the texture
  72161. * @param scene Define the scene the texture belongs to
  72162. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72163. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72164. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72165. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72166. * @returns the RGBA texture
  72167. */
  72168. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72169. /**
  72170. * Creates a R texture from some data.
  72171. * @param data Define the texture data
  72172. * @param width Define the width of the texture
  72173. * @param height Define the height of the texture
  72174. * @param scene Define the scene the texture belongs to
  72175. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72176. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72177. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72178. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72179. * @returns the R texture
  72180. */
  72181. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72182. }
  72183. }
  72184. declare module BABYLON {
  72185. /**
  72186. * Defines a runtime animation
  72187. */
  72188. export class RuntimeAnimation {
  72189. private _events;
  72190. /**
  72191. * The current frame of the runtime animation
  72192. */
  72193. private _currentFrame;
  72194. /**
  72195. * The animation used by the runtime animation
  72196. */
  72197. private _animation;
  72198. /**
  72199. * The target of the runtime animation
  72200. */
  72201. private _target;
  72202. /**
  72203. * The initiating animatable
  72204. */
  72205. private _host;
  72206. /**
  72207. * The original value of the runtime animation
  72208. */
  72209. private _originalValue;
  72210. /**
  72211. * The original blend value of the runtime animation
  72212. */
  72213. private _originalBlendValue;
  72214. /**
  72215. * The offsets cache of the runtime animation
  72216. */
  72217. private _offsetsCache;
  72218. /**
  72219. * The high limits cache of the runtime animation
  72220. */
  72221. private _highLimitsCache;
  72222. /**
  72223. * Specifies if the runtime animation has been stopped
  72224. */
  72225. private _stopped;
  72226. /**
  72227. * The blending factor of the runtime animation
  72228. */
  72229. private _blendingFactor;
  72230. /**
  72231. * The BabylonJS scene
  72232. */
  72233. private _scene;
  72234. /**
  72235. * The current value of the runtime animation
  72236. */
  72237. private _currentValue;
  72238. /** @hidden */
  72239. _animationState: _IAnimationState;
  72240. /**
  72241. * The active target of the runtime animation
  72242. */
  72243. private _activeTargets;
  72244. private _currentActiveTarget;
  72245. private _directTarget;
  72246. /**
  72247. * The target path of the runtime animation
  72248. */
  72249. private _targetPath;
  72250. /**
  72251. * The weight of the runtime animation
  72252. */
  72253. private _weight;
  72254. /**
  72255. * The ratio offset of the runtime animation
  72256. */
  72257. private _ratioOffset;
  72258. /**
  72259. * The previous delay of the runtime animation
  72260. */
  72261. private _previousDelay;
  72262. /**
  72263. * The previous ratio of the runtime animation
  72264. */
  72265. private _previousRatio;
  72266. private _enableBlending;
  72267. private _keys;
  72268. private _minFrame;
  72269. private _maxFrame;
  72270. private _minValue;
  72271. private _maxValue;
  72272. private _targetIsArray;
  72273. /**
  72274. * Gets the current frame of the runtime animation
  72275. */
  72276. readonly currentFrame: number;
  72277. /**
  72278. * Gets the weight of the runtime animation
  72279. */
  72280. readonly weight: number;
  72281. /**
  72282. * Gets the current value of the runtime animation
  72283. */
  72284. readonly currentValue: any;
  72285. /**
  72286. * Gets the target path of the runtime animation
  72287. */
  72288. readonly targetPath: string;
  72289. /**
  72290. * Gets the actual target of the runtime animation
  72291. */
  72292. readonly target: any;
  72293. /** @hidden */
  72294. _onLoop: () => void;
  72295. /**
  72296. * Create a new RuntimeAnimation object
  72297. * @param target defines the target of the animation
  72298. * @param animation defines the source animation object
  72299. * @param scene defines the hosting scene
  72300. * @param host defines the initiating Animatable
  72301. */
  72302. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  72303. private _preparePath;
  72304. /**
  72305. * Gets the animation from the runtime animation
  72306. */
  72307. readonly animation: Animation;
  72308. /**
  72309. * Resets the runtime animation to the beginning
  72310. * @param restoreOriginal defines whether to restore the target property to the original value
  72311. */
  72312. reset(restoreOriginal?: boolean): void;
  72313. /**
  72314. * Specifies if the runtime animation is stopped
  72315. * @returns Boolean specifying if the runtime animation is stopped
  72316. */
  72317. isStopped(): boolean;
  72318. /**
  72319. * Disposes of the runtime animation
  72320. */
  72321. dispose(): void;
  72322. /**
  72323. * Apply the interpolated value to the target
  72324. * @param currentValue defines the value computed by the animation
  72325. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  72326. */
  72327. setValue(currentValue: any, weight: number): void;
  72328. private _getOriginalValues;
  72329. private _setValue;
  72330. /**
  72331. * Gets the loop pmode of the runtime animation
  72332. * @returns Loop Mode
  72333. */
  72334. private _getCorrectLoopMode;
  72335. /**
  72336. * Move the current animation to a given frame
  72337. * @param frame defines the frame to move to
  72338. */
  72339. goToFrame(frame: number): void;
  72340. /**
  72341. * @hidden Internal use only
  72342. */
  72343. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  72344. /**
  72345. * Execute the current animation
  72346. * @param delay defines the delay to add to the current frame
  72347. * @param from defines the lower bound of the animation range
  72348. * @param to defines the upper bound of the animation range
  72349. * @param loop defines if the current animation must loop
  72350. * @param speedRatio defines the current speed ratio
  72351. * @param weight defines the weight of the animation (default is -1 so no weight)
  72352. * @param onLoop optional callback called when animation loops
  72353. * @returns a boolean indicating if the animation is running
  72354. */
  72355. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  72356. }
  72357. }
  72358. declare module BABYLON {
  72359. /**
  72360. * Class used to store an actual running animation
  72361. */
  72362. export class Animatable {
  72363. /** defines the target object */
  72364. target: any;
  72365. /** defines the starting frame number (default is 0) */
  72366. fromFrame: number;
  72367. /** defines the ending frame number (default is 100) */
  72368. toFrame: number;
  72369. /** defines if the animation must loop (default is false) */
  72370. loopAnimation: boolean;
  72371. /** defines a callback to call when animation ends if it is not looping */
  72372. onAnimationEnd?: (() => void) | null | undefined;
  72373. /** defines a callback to call when animation loops */
  72374. onAnimationLoop?: (() => void) | null | undefined;
  72375. private _localDelayOffset;
  72376. private _pausedDelay;
  72377. private _runtimeAnimations;
  72378. private _paused;
  72379. private _scene;
  72380. private _speedRatio;
  72381. private _weight;
  72382. private _syncRoot;
  72383. /**
  72384. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  72385. * This will only apply for non looping animation (default is true)
  72386. */
  72387. disposeOnEnd: boolean;
  72388. /**
  72389. * Gets a boolean indicating if the animation has started
  72390. */
  72391. animationStarted: boolean;
  72392. /**
  72393. * Observer raised when the animation ends
  72394. */
  72395. onAnimationEndObservable: Observable<Animatable>;
  72396. /**
  72397. * Observer raised when the animation loops
  72398. */
  72399. onAnimationLoopObservable: Observable<Animatable>;
  72400. /**
  72401. * Gets the root Animatable used to synchronize and normalize animations
  72402. */
  72403. readonly syncRoot: Nullable<Animatable>;
  72404. /**
  72405. * Gets the current frame of the first RuntimeAnimation
  72406. * Used to synchronize Animatables
  72407. */
  72408. readonly masterFrame: number;
  72409. /**
  72410. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  72411. */
  72412. weight: number;
  72413. /**
  72414. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  72415. */
  72416. speedRatio: number;
  72417. /**
  72418. * Creates a new Animatable
  72419. * @param scene defines the hosting scene
  72420. * @param target defines the target object
  72421. * @param fromFrame defines the starting frame number (default is 0)
  72422. * @param toFrame defines the ending frame number (default is 100)
  72423. * @param loopAnimation defines if the animation must loop (default is false)
  72424. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  72425. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  72426. * @param animations defines a group of animation to add to the new Animatable
  72427. * @param onAnimationLoop defines a callback to call when animation loops
  72428. */
  72429. constructor(scene: Scene,
  72430. /** defines the target object */
  72431. target: any,
  72432. /** defines the starting frame number (default is 0) */
  72433. fromFrame?: number,
  72434. /** defines the ending frame number (default is 100) */
  72435. toFrame?: number,
  72436. /** defines if the animation must loop (default is false) */
  72437. loopAnimation?: boolean, speedRatio?: number,
  72438. /** defines a callback to call when animation ends if it is not looping */
  72439. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  72440. /** defines a callback to call when animation loops */
  72441. onAnimationLoop?: (() => void) | null | undefined);
  72442. /**
  72443. * Synchronize and normalize current Animatable with a source Animatable
  72444. * This is useful when using animation weights and when animations are not of the same length
  72445. * @param root defines the root Animatable to synchronize with
  72446. * @returns the current Animatable
  72447. */
  72448. syncWith(root: Animatable): Animatable;
  72449. /**
  72450. * Gets the list of runtime animations
  72451. * @returns an array of RuntimeAnimation
  72452. */
  72453. getAnimations(): RuntimeAnimation[];
  72454. /**
  72455. * Adds more animations to the current animatable
  72456. * @param target defines the target of the animations
  72457. * @param animations defines the new animations to add
  72458. */
  72459. appendAnimations(target: any, animations: Animation[]): void;
  72460. /**
  72461. * Gets the source animation for a specific property
  72462. * @param property defines the propertyu to look for
  72463. * @returns null or the source animation for the given property
  72464. */
  72465. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  72466. /**
  72467. * Gets the runtime animation for a specific property
  72468. * @param property defines the propertyu to look for
  72469. * @returns null or the runtime animation for the given property
  72470. */
  72471. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  72472. /**
  72473. * Resets the animatable to its original state
  72474. */
  72475. reset(): void;
  72476. /**
  72477. * Allows the animatable to blend with current running animations
  72478. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72479. * @param blendingSpeed defines the blending speed to use
  72480. */
  72481. enableBlending(blendingSpeed: number): void;
  72482. /**
  72483. * Disable animation blending
  72484. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72485. */
  72486. disableBlending(): void;
  72487. /**
  72488. * Jump directly to a given frame
  72489. * @param frame defines the frame to jump to
  72490. */
  72491. goToFrame(frame: number): void;
  72492. /**
  72493. * Pause the animation
  72494. */
  72495. pause(): void;
  72496. /**
  72497. * Restart the animation
  72498. */
  72499. restart(): void;
  72500. private _raiseOnAnimationEnd;
  72501. /**
  72502. * Stop and delete the current animation
  72503. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  72504. * @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)
  72505. */
  72506. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  72507. /**
  72508. * Wait asynchronously for the animation to end
  72509. * @returns a promise which will be fullfilled when the animation ends
  72510. */
  72511. waitAsync(): Promise<Animatable>;
  72512. /** @hidden */
  72513. _animate(delay: number): boolean;
  72514. }
  72515. interface Scene {
  72516. /** @hidden */
  72517. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  72518. /** @hidden */
  72519. _processLateAnimationBindingsForMatrices(holder: {
  72520. totalWeight: number;
  72521. animations: RuntimeAnimation[];
  72522. originalValue: Matrix;
  72523. }): any;
  72524. /** @hidden */
  72525. _processLateAnimationBindingsForQuaternions(holder: {
  72526. totalWeight: number;
  72527. animations: RuntimeAnimation[];
  72528. originalValue: Quaternion;
  72529. }, refQuaternion: Quaternion): Quaternion;
  72530. /** @hidden */
  72531. _processLateAnimationBindings(): void;
  72532. /**
  72533. * Will start the animation sequence of a given target
  72534. * @param target defines the target
  72535. * @param from defines from which frame should animation start
  72536. * @param to defines until which frame should animation run.
  72537. * @param weight defines the weight to apply to the animation (1.0 by default)
  72538. * @param loop defines if the animation loops
  72539. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72540. * @param onAnimationEnd defines the function to be executed when the animation ends
  72541. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72542. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72543. * @param onAnimationLoop defines the callback to call when an animation loops
  72544. * @returns the animatable object created for this animation
  72545. */
  72546. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72547. /**
  72548. * Will start the animation sequence of a given target
  72549. * @param target defines the target
  72550. * @param from defines from which frame should animation start
  72551. * @param to defines until which frame should animation run.
  72552. * @param loop defines if the animation loops
  72553. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72554. * @param onAnimationEnd defines the function to be executed when the animation ends
  72555. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72556. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72557. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  72558. * @param onAnimationLoop defines the callback to call when an animation loops
  72559. * @returns the animatable object created for this animation
  72560. */
  72561. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72562. /**
  72563. * Will start the animation sequence of a given target and its hierarchy
  72564. * @param target defines the target
  72565. * @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.
  72566. * @param from defines from which frame should animation start
  72567. * @param to defines until which frame should animation run.
  72568. * @param loop defines if the animation loops
  72569. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72570. * @param onAnimationEnd defines the function to be executed when the animation ends
  72571. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72572. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72573. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72574. * @param onAnimationLoop defines the callback to call when an animation loops
  72575. * @returns the list of created animatables
  72576. */
  72577. 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[];
  72578. /**
  72579. * Begin a new animation on a given node
  72580. * @param target defines the target where the animation will take place
  72581. * @param animations defines the list of animations to start
  72582. * @param from defines the initial value
  72583. * @param to defines the final value
  72584. * @param loop defines if you want animation to loop (off by default)
  72585. * @param speedRatio defines the speed ratio to apply to all animations
  72586. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72587. * @param onAnimationLoop defines the callback to call when an animation loops
  72588. * @returns the list of created animatables
  72589. */
  72590. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  72591. /**
  72592. * Begin a new animation on a given node and its hierarchy
  72593. * @param target defines the root node where the animation will take place
  72594. * @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.
  72595. * @param animations defines the list of animations to start
  72596. * @param from defines the initial value
  72597. * @param to defines the final value
  72598. * @param loop defines if you want animation to loop (off by default)
  72599. * @param speedRatio defines the speed ratio to apply to all animations
  72600. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72601. * @param onAnimationLoop defines the callback to call when an animation loops
  72602. * @returns the list of animatables created for all nodes
  72603. */
  72604. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  72605. /**
  72606. * Gets the animatable associated with a specific target
  72607. * @param target defines the target of the animatable
  72608. * @returns the required animatable if found
  72609. */
  72610. getAnimatableByTarget(target: any): Nullable<Animatable>;
  72611. /**
  72612. * Gets all animatables associated with a given target
  72613. * @param target defines the target to look animatables for
  72614. * @returns an array of Animatables
  72615. */
  72616. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  72617. /**
  72618. * Stops and removes all animations that have been applied to the scene
  72619. */
  72620. stopAllAnimations(): void;
  72621. }
  72622. interface Bone {
  72623. /**
  72624. * Copy an animation range from another bone
  72625. * @param source defines the source bone
  72626. * @param rangeName defines the range name to copy
  72627. * @param frameOffset defines the frame offset
  72628. * @param rescaleAsRequired defines if rescaling must be applied if required
  72629. * @param skelDimensionsRatio defines the scaling ratio
  72630. * @returns true if operation was successful
  72631. */
  72632. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  72633. }
  72634. }
  72635. declare module BABYLON {
  72636. /**
  72637. * Class used to handle skinning animations
  72638. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  72639. */
  72640. export class Skeleton implements IAnimatable {
  72641. /** defines the skeleton name */
  72642. name: string;
  72643. /** defines the skeleton Id */
  72644. id: string;
  72645. /**
  72646. * Defines the list of child bones
  72647. */
  72648. bones: Bone[];
  72649. /**
  72650. * Defines an estimate of the dimension of the skeleton at rest
  72651. */
  72652. dimensionsAtRest: Vector3;
  72653. /**
  72654. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  72655. */
  72656. needInitialSkinMatrix: boolean;
  72657. /**
  72658. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  72659. */
  72660. overrideMesh: Nullable<AbstractMesh>;
  72661. /**
  72662. * Gets the list of animations attached to this skeleton
  72663. */
  72664. animations: Array<Animation>;
  72665. private _scene;
  72666. private _isDirty;
  72667. private _transformMatrices;
  72668. private _transformMatrixTexture;
  72669. private _meshesWithPoseMatrix;
  72670. private _animatables;
  72671. private _identity;
  72672. private _synchronizedWithMesh;
  72673. private _ranges;
  72674. private _lastAbsoluteTransformsUpdateId;
  72675. private _canUseTextureForBones;
  72676. private _uniqueId;
  72677. /** @hidden */
  72678. _numBonesWithLinkedTransformNode: number;
  72679. /** @hidden */
  72680. _hasWaitingData: Nullable<boolean>;
  72681. /**
  72682. * Specifies if the skeleton should be serialized
  72683. */
  72684. doNotSerialize: boolean;
  72685. private _useTextureToStoreBoneMatrices;
  72686. /**
  72687. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  72688. * Please note that this option is not available if the hardware does not support it
  72689. */
  72690. useTextureToStoreBoneMatrices: boolean;
  72691. private _animationPropertiesOverride;
  72692. /**
  72693. * Gets or sets the animation properties override
  72694. */
  72695. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72696. /**
  72697. * List of inspectable custom properties (used by the Inspector)
  72698. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72699. */
  72700. inspectableCustomProperties: IInspectable[];
  72701. /**
  72702. * An observable triggered before computing the skeleton's matrices
  72703. */
  72704. onBeforeComputeObservable: Observable<Skeleton>;
  72705. /**
  72706. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  72707. */
  72708. readonly isUsingTextureForMatrices: boolean;
  72709. /**
  72710. * Gets the unique ID of this skeleton
  72711. */
  72712. readonly uniqueId: number;
  72713. /**
  72714. * Creates a new skeleton
  72715. * @param name defines the skeleton name
  72716. * @param id defines the skeleton Id
  72717. * @param scene defines the hosting scene
  72718. */
  72719. constructor(
  72720. /** defines the skeleton name */
  72721. name: string,
  72722. /** defines the skeleton Id */
  72723. id: string, scene: Scene);
  72724. /**
  72725. * Gets the current object class name.
  72726. * @return the class name
  72727. */
  72728. getClassName(): string;
  72729. /**
  72730. * Returns an array containing the root bones
  72731. * @returns an array containing the root bones
  72732. */
  72733. getChildren(): Array<Bone>;
  72734. /**
  72735. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  72736. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72737. * @returns a Float32Array containing matrices data
  72738. */
  72739. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  72740. /**
  72741. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  72742. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72743. * @returns a raw texture containing the data
  72744. */
  72745. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  72746. /**
  72747. * Gets the current hosting scene
  72748. * @returns a scene object
  72749. */
  72750. getScene(): Scene;
  72751. /**
  72752. * Gets a string representing the current skeleton data
  72753. * @param fullDetails defines a boolean indicating if we want a verbose version
  72754. * @returns a string representing the current skeleton data
  72755. */
  72756. toString(fullDetails?: boolean): string;
  72757. /**
  72758. * Get bone's index searching by name
  72759. * @param name defines bone's name to search for
  72760. * @return the indice of the bone. Returns -1 if not found
  72761. */
  72762. getBoneIndexByName(name: string): number;
  72763. /**
  72764. * Creater a new animation range
  72765. * @param name defines the name of the range
  72766. * @param from defines the start key
  72767. * @param to defines the end key
  72768. */
  72769. createAnimationRange(name: string, from: number, to: number): void;
  72770. /**
  72771. * Delete a specific animation range
  72772. * @param name defines the name of the range
  72773. * @param deleteFrames defines if frames must be removed as well
  72774. */
  72775. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  72776. /**
  72777. * Gets a specific animation range
  72778. * @param name defines the name of the range to look for
  72779. * @returns the requested animation range or null if not found
  72780. */
  72781. getAnimationRange(name: string): Nullable<AnimationRange>;
  72782. /**
  72783. * Gets the list of all animation ranges defined on this skeleton
  72784. * @returns an array
  72785. */
  72786. getAnimationRanges(): Nullable<AnimationRange>[];
  72787. /**
  72788. * Copy animation range from a source skeleton.
  72789. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  72790. * @param source defines the source skeleton
  72791. * @param name defines the name of the range to copy
  72792. * @param rescaleAsRequired defines if rescaling must be applied if required
  72793. * @returns true if operation was successful
  72794. */
  72795. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  72796. /**
  72797. * Forces the skeleton to go to rest pose
  72798. */
  72799. returnToRest(): void;
  72800. private _getHighestAnimationFrame;
  72801. /**
  72802. * Begin a specific animation range
  72803. * @param name defines the name of the range to start
  72804. * @param loop defines if looping must be turned on (false by default)
  72805. * @param speedRatio defines the speed ratio to apply (1 by default)
  72806. * @param onAnimationEnd defines a callback which will be called when animation will end
  72807. * @returns a new animatable
  72808. */
  72809. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  72810. /** @hidden */
  72811. _markAsDirty(): void;
  72812. /** @hidden */
  72813. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72814. /** @hidden */
  72815. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72816. private _computeTransformMatrices;
  72817. /**
  72818. * Build all resources required to render a skeleton
  72819. */
  72820. prepare(): void;
  72821. /**
  72822. * Gets the list of animatables currently running for this skeleton
  72823. * @returns an array of animatables
  72824. */
  72825. getAnimatables(): IAnimatable[];
  72826. /**
  72827. * Clone the current skeleton
  72828. * @param name defines the name of the new skeleton
  72829. * @param id defines the id of the new skeleton
  72830. * @returns the new skeleton
  72831. */
  72832. clone(name: string, id: string): Skeleton;
  72833. /**
  72834. * Enable animation blending for this skeleton
  72835. * @param blendingSpeed defines the blending speed to apply
  72836. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72837. */
  72838. enableBlending(blendingSpeed?: number): void;
  72839. /**
  72840. * Releases all resources associated with the current skeleton
  72841. */
  72842. dispose(): void;
  72843. /**
  72844. * Serialize the skeleton in a JSON object
  72845. * @returns a JSON object
  72846. */
  72847. serialize(): any;
  72848. /**
  72849. * Creates a new skeleton from serialized data
  72850. * @param parsedSkeleton defines the serialized data
  72851. * @param scene defines the hosting scene
  72852. * @returns a new skeleton
  72853. */
  72854. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  72855. /**
  72856. * Compute all node absolute transforms
  72857. * @param forceUpdate defines if computation must be done even if cache is up to date
  72858. */
  72859. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  72860. /**
  72861. * Gets the root pose matrix
  72862. * @returns a matrix
  72863. */
  72864. getPoseMatrix(): Nullable<Matrix>;
  72865. /**
  72866. * Sorts bones per internal index
  72867. */
  72868. sortBones(): void;
  72869. private _sortBones;
  72870. }
  72871. }
  72872. declare module BABYLON {
  72873. /**
  72874. * Defines a target to use with MorphTargetManager
  72875. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  72876. */
  72877. export class MorphTarget implements IAnimatable {
  72878. /** defines the name of the target */
  72879. name: string;
  72880. /**
  72881. * Gets or sets the list of animations
  72882. */
  72883. animations: Animation[];
  72884. private _scene;
  72885. private _positions;
  72886. private _normals;
  72887. private _tangents;
  72888. private _uvs;
  72889. private _influence;
  72890. /**
  72891. * Observable raised when the influence changes
  72892. */
  72893. onInfluenceChanged: Observable<boolean>;
  72894. /** @hidden */
  72895. _onDataLayoutChanged: Observable<void>;
  72896. /**
  72897. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  72898. */
  72899. influence: number;
  72900. /**
  72901. * Gets or sets the id of the morph Target
  72902. */
  72903. id: string;
  72904. private _animationPropertiesOverride;
  72905. /**
  72906. * Gets or sets the animation properties override
  72907. */
  72908. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72909. /**
  72910. * Creates a new MorphTarget
  72911. * @param name defines the name of the target
  72912. * @param influence defines the influence to use
  72913. * @param scene defines the scene the morphtarget belongs to
  72914. */
  72915. constructor(
  72916. /** defines the name of the target */
  72917. name: string, influence?: number, scene?: Nullable<Scene>);
  72918. /**
  72919. * Gets a boolean defining if the target contains position data
  72920. */
  72921. readonly hasPositions: boolean;
  72922. /**
  72923. * Gets a boolean defining if the target contains normal data
  72924. */
  72925. readonly hasNormals: boolean;
  72926. /**
  72927. * Gets a boolean defining if the target contains tangent data
  72928. */
  72929. readonly hasTangents: boolean;
  72930. /**
  72931. * Gets a boolean defining if the target contains texture coordinates data
  72932. */
  72933. readonly hasUVs: boolean;
  72934. /**
  72935. * Affects position data to this target
  72936. * @param data defines the position data to use
  72937. */
  72938. setPositions(data: Nullable<FloatArray>): void;
  72939. /**
  72940. * Gets the position data stored in this target
  72941. * @returns a FloatArray containing the position data (or null if not present)
  72942. */
  72943. getPositions(): Nullable<FloatArray>;
  72944. /**
  72945. * Affects normal data to this target
  72946. * @param data defines the normal data to use
  72947. */
  72948. setNormals(data: Nullable<FloatArray>): void;
  72949. /**
  72950. * Gets the normal data stored in this target
  72951. * @returns a FloatArray containing the normal data (or null if not present)
  72952. */
  72953. getNormals(): Nullable<FloatArray>;
  72954. /**
  72955. * Affects tangent data to this target
  72956. * @param data defines the tangent data to use
  72957. */
  72958. setTangents(data: Nullable<FloatArray>): void;
  72959. /**
  72960. * Gets the tangent data stored in this target
  72961. * @returns a FloatArray containing the tangent data (or null if not present)
  72962. */
  72963. getTangents(): Nullable<FloatArray>;
  72964. /**
  72965. * Affects texture coordinates data to this target
  72966. * @param data defines the texture coordinates data to use
  72967. */
  72968. setUVs(data: Nullable<FloatArray>): void;
  72969. /**
  72970. * Gets the texture coordinates data stored in this target
  72971. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  72972. */
  72973. getUVs(): Nullable<FloatArray>;
  72974. /**
  72975. * Serializes the current target into a Serialization object
  72976. * @returns the serialized object
  72977. */
  72978. serialize(): any;
  72979. /**
  72980. * Returns the string "MorphTarget"
  72981. * @returns "MorphTarget"
  72982. */
  72983. getClassName(): string;
  72984. /**
  72985. * Creates a new target from serialized data
  72986. * @param serializationObject defines the serialized data to use
  72987. * @returns a new MorphTarget
  72988. */
  72989. static Parse(serializationObject: any): MorphTarget;
  72990. /**
  72991. * Creates a MorphTarget from mesh data
  72992. * @param mesh defines the source mesh
  72993. * @param name defines the name to use for the new target
  72994. * @param influence defines the influence to attach to the target
  72995. * @returns a new MorphTarget
  72996. */
  72997. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  72998. }
  72999. }
  73000. declare module BABYLON {
  73001. /**
  73002. * This class is used to deform meshes using morphing between different targets
  73003. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73004. */
  73005. export class MorphTargetManager {
  73006. private _targets;
  73007. private _targetInfluenceChangedObservers;
  73008. private _targetDataLayoutChangedObservers;
  73009. private _activeTargets;
  73010. private _scene;
  73011. private _influences;
  73012. private _supportsNormals;
  73013. private _supportsTangents;
  73014. private _supportsUVs;
  73015. private _vertexCount;
  73016. private _uniqueId;
  73017. private _tempInfluences;
  73018. /**
  73019. * Gets or sets a boolean indicating if normals must be morphed
  73020. */
  73021. enableNormalMorphing: boolean;
  73022. /**
  73023. * Gets or sets a boolean indicating if tangents must be morphed
  73024. */
  73025. enableTangentMorphing: boolean;
  73026. /**
  73027. * Gets or sets a boolean indicating if UV must be morphed
  73028. */
  73029. enableUVMorphing: boolean;
  73030. /**
  73031. * Creates a new MorphTargetManager
  73032. * @param scene defines the current scene
  73033. */
  73034. constructor(scene?: Nullable<Scene>);
  73035. /**
  73036. * Gets the unique ID of this manager
  73037. */
  73038. readonly uniqueId: number;
  73039. /**
  73040. * Gets the number of vertices handled by this manager
  73041. */
  73042. readonly vertexCount: number;
  73043. /**
  73044. * Gets a boolean indicating if this manager supports morphing of normals
  73045. */
  73046. readonly supportsNormals: boolean;
  73047. /**
  73048. * Gets a boolean indicating if this manager supports morphing of tangents
  73049. */
  73050. readonly supportsTangents: boolean;
  73051. /**
  73052. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  73053. */
  73054. readonly supportsUVs: boolean;
  73055. /**
  73056. * Gets the number of targets stored in this manager
  73057. */
  73058. readonly numTargets: number;
  73059. /**
  73060. * Gets the number of influencers (ie. the number of targets with influences > 0)
  73061. */
  73062. readonly numInfluencers: number;
  73063. /**
  73064. * Gets the list of influences (one per target)
  73065. */
  73066. readonly influences: Float32Array;
  73067. /**
  73068. * Gets the active target at specified index. An active target is a target with an influence > 0
  73069. * @param index defines the index to check
  73070. * @returns the requested target
  73071. */
  73072. getActiveTarget(index: number): MorphTarget;
  73073. /**
  73074. * Gets the target at specified index
  73075. * @param index defines the index to check
  73076. * @returns the requested target
  73077. */
  73078. getTarget(index: number): MorphTarget;
  73079. /**
  73080. * Add a new target to this manager
  73081. * @param target defines the target to add
  73082. */
  73083. addTarget(target: MorphTarget): void;
  73084. /**
  73085. * Removes a target from the manager
  73086. * @param target defines the target to remove
  73087. */
  73088. removeTarget(target: MorphTarget): void;
  73089. /**
  73090. * Serializes the current manager into a Serialization object
  73091. * @returns the serialized object
  73092. */
  73093. serialize(): any;
  73094. private _syncActiveTargets;
  73095. /**
  73096. * Syncrhonize the targets with all the meshes using this morph target manager
  73097. */
  73098. synchronize(): void;
  73099. /**
  73100. * Creates a new MorphTargetManager from serialized data
  73101. * @param serializationObject defines the serialized data
  73102. * @param scene defines the hosting scene
  73103. * @returns the new MorphTargetManager
  73104. */
  73105. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  73106. }
  73107. }
  73108. declare module BABYLON {
  73109. /**
  73110. * Groups all the scene component constants in one place to ease maintenance.
  73111. * @hidden
  73112. */
  73113. export class SceneComponentConstants {
  73114. static readonly NAME_EFFECTLAYER: string;
  73115. static readonly NAME_LAYER: string;
  73116. static readonly NAME_LENSFLARESYSTEM: string;
  73117. static readonly NAME_BOUNDINGBOXRENDERER: string;
  73118. static readonly NAME_PARTICLESYSTEM: string;
  73119. static readonly NAME_GAMEPAD: string;
  73120. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  73121. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  73122. static readonly NAME_DEPTHRENDERER: string;
  73123. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  73124. static readonly NAME_SPRITE: string;
  73125. static readonly NAME_OUTLINERENDERER: string;
  73126. static readonly NAME_PROCEDURALTEXTURE: string;
  73127. static readonly NAME_SHADOWGENERATOR: string;
  73128. static readonly NAME_OCTREE: string;
  73129. static readonly NAME_PHYSICSENGINE: string;
  73130. static readonly NAME_AUDIO: string;
  73131. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  73132. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73133. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  73134. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73135. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  73136. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  73137. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  73138. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  73139. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  73140. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  73141. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  73142. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  73143. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  73144. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  73145. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  73146. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  73147. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  73148. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  73149. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  73150. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  73151. static readonly STEP_AFTERRENDER_AUDIO: number;
  73152. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  73153. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  73154. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  73155. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  73156. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  73157. static readonly STEP_POINTERMOVE_SPRITE: number;
  73158. static readonly STEP_POINTERDOWN_SPRITE: number;
  73159. static readonly STEP_POINTERUP_SPRITE: number;
  73160. }
  73161. /**
  73162. * This represents a scene component.
  73163. *
  73164. * This is used to decouple the dependency the scene is having on the different workloads like
  73165. * layers, post processes...
  73166. */
  73167. export interface ISceneComponent {
  73168. /**
  73169. * The name of the component. Each component must have a unique name.
  73170. */
  73171. name: string;
  73172. /**
  73173. * The scene the component belongs to.
  73174. */
  73175. scene: Scene;
  73176. /**
  73177. * Register the component to one instance of a scene.
  73178. */
  73179. register(): void;
  73180. /**
  73181. * Rebuilds the elements related to this component in case of
  73182. * context lost for instance.
  73183. */
  73184. rebuild(): void;
  73185. /**
  73186. * Disposes the component and the associated ressources.
  73187. */
  73188. dispose(): void;
  73189. }
  73190. /**
  73191. * This represents a SERIALIZABLE scene component.
  73192. *
  73193. * This extends Scene Component to add Serialization methods on top.
  73194. */
  73195. export interface ISceneSerializableComponent extends ISceneComponent {
  73196. /**
  73197. * Adds all the elements from the container to the scene
  73198. * @param container the container holding the elements
  73199. */
  73200. addFromContainer(container: AbstractScene): void;
  73201. /**
  73202. * Removes all the elements in the container from the scene
  73203. * @param container contains the elements to remove
  73204. * @param dispose if the removed element should be disposed (default: false)
  73205. */
  73206. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73207. /**
  73208. * Serializes the component data to the specified json object
  73209. * @param serializationObject The object to serialize to
  73210. */
  73211. serialize(serializationObject: any): void;
  73212. }
  73213. /**
  73214. * Strong typing of a Mesh related stage step action
  73215. */
  73216. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  73217. /**
  73218. * Strong typing of a Evaluate Sub Mesh related stage step action
  73219. */
  73220. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  73221. /**
  73222. * Strong typing of a Active Mesh related stage step action
  73223. */
  73224. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  73225. /**
  73226. * Strong typing of a Camera related stage step action
  73227. */
  73228. export type CameraStageAction = (camera: Camera) => void;
  73229. /**
  73230. * Strong typing of a Camera Frame buffer related stage step action
  73231. */
  73232. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  73233. /**
  73234. * Strong typing of a Render Target related stage step action
  73235. */
  73236. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  73237. /**
  73238. * Strong typing of a RenderingGroup related stage step action
  73239. */
  73240. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  73241. /**
  73242. * Strong typing of a Mesh Render related stage step action
  73243. */
  73244. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  73245. /**
  73246. * Strong typing of a simple stage step action
  73247. */
  73248. export type SimpleStageAction = () => void;
  73249. /**
  73250. * Strong typing of a render target action.
  73251. */
  73252. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  73253. /**
  73254. * Strong typing of a pointer move action.
  73255. */
  73256. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  73257. /**
  73258. * Strong typing of a pointer up/down action.
  73259. */
  73260. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  73261. /**
  73262. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  73263. * @hidden
  73264. */
  73265. export class Stage<T extends Function> extends Array<{
  73266. index: number;
  73267. component: ISceneComponent;
  73268. action: T;
  73269. }> {
  73270. /**
  73271. * Hide ctor from the rest of the world.
  73272. * @param items The items to add.
  73273. */
  73274. private constructor();
  73275. /**
  73276. * Creates a new Stage.
  73277. * @returns A new instance of a Stage
  73278. */
  73279. static Create<T extends Function>(): Stage<T>;
  73280. /**
  73281. * Registers a step in an ordered way in the targeted stage.
  73282. * @param index Defines the position to register the step in
  73283. * @param component Defines the component attached to the step
  73284. * @param action Defines the action to launch during the step
  73285. */
  73286. registerStep(index: number, component: ISceneComponent, action: T): void;
  73287. /**
  73288. * Clears all the steps from the stage.
  73289. */
  73290. clear(): void;
  73291. }
  73292. }
  73293. declare module BABYLON {
  73294. /**
  73295. * Class used to represent a specific level of detail of a mesh
  73296. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  73297. */
  73298. export class MeshLODLevel {
  73299. /** Defines the distance where this level should star being displayed */
  73300. distance: number;
  73301. /** Defines the mesh to use to render this level */
  73302. mesh: Nullable<Mesh>;
  73303. /**
  73304. * Creates a new LOD level
  73305. * @param distance defines the distance where this level should star being displayed
  73306. * @param mesh defines the mesh to use to render this level
  73307. */
  73308. constructor(
  73309. /** Defines the distance where this level should star being displayed */
  73310. distance: number,
  73311. /** Defines the mesh to use to render this level */
  73312. mesh: Nullable<Mesh>);
  73313. }
  73314. }
  73315. declare module BABYLON {
  73316. /**
  73317. * Interface describing all the common properties and methods a shadow light needs to implement.
  73318. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73319. * as well as binding the different shadow properties to the effects.
  73320. */
  73321. export interface IShadowLight extends Light {
  73322. /**
  73323. * The light id in the scene (used in scene.findLighById for instance)
  73324. */
  73325. id: string;
  73326. /**
  73327. * The position the shdow will be casted from.
  73328. */
  73329. position: Vector3;
  73330. /**
  73331. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73332. */
  73333. direction: Vector3;
  73334. /**
  73335. * The transformed position. Position of the light in world space taking parenting in account.
  73336. */
  73337. transformedPosition: Vector3;
  73338. /**
  73339. * The transformed direction. Direction of the light in world space taking parenting in account.
  73340. */
  73341. transformedDirection: Vector3;
  73342. /**
  73343. * The friendly name of the light in the scene.
  73344. */
  73345. name: string;
  73346. /**
  73347. * Defines the shadow projection clipping minimum z value.
  73348. */
  73349. shadowMinZ: number;
  73350. /**
  73351. * Defines the shadow projection clipping maximum z value.
  73352. */
  73353. shadowMaxZ: number;
  73354. /**
  73355. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73356. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73357. */
  73358. computeTransformedInformation(): boolean;
  73359. /**
  73360. * Gets the scene the light belongs to.
  73361. * @returns The scene
  73362. */
  73363. getScene(): Scene;
  73364. /**
  73365. * Callback defining a custom Projection Matrix Builder.
  73366. * This can be used to override the default projection matrix computation.
  73367. */
  73368. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73369. /**
  73370. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73371. * @param matrix The materix to updated with the projection information
  73372. * @param viewMatrix The transform matrix of the light
  73373. * @param renderList The list of mesh to render in the map
  73374. * @returns The current light
  73375. */
  73376. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73377. /**
  73378. * Gets the current depth scale used in ESM.
  73379. * @returns The scale
  73380. */
  73381. getDepthScale(): number;
  73382. /**
  73383. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73384. * @returns true if a cube texture needs to be use
  73385. */
  73386. needCube(): boolean;
  73387. /**
  73388. * Detects if the projection matrix requires to be recomputed this frame.
  73389. * @returns true if it requires to be recomputed otherwise, false.
  73390. */
  73391. needProjectionMatrixCompute(): boolean;
  73392. /**
  73393. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73394. */
  73395. forceProjectionMatrixCompute(): void;
  73396. /**
  73397. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73398. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73399. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73400. */
  73401. getShadowDirection(faceIndex?: number): Vector3;
  73402. /**
  73403. * Gets the minZ used for shadow according to both the scene and the light.
  73404. * @param activeCamera The camera we are returning the min for
  73405. * @returns the depth min z
  73406. */
  73407. getDepthMinZ(activeCamera: Camera): number;
  73408. /**
  73409. * Gets the maxZ used for shadow according to both the scene and the light.
  73410. * @param activeCamera The camera we are returning the max for
  73411. * @returns the depth max z
  73412. */
  73413. getDepthMaxZ(activeCamera: Camera): number;
  73414. }
  73415. /**
  73416. * Base implementation IShadowLight
  73417. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73418. */
  73419. export abstract class ShadowLight extends Light implements IShadowLight {
  73420. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73421. protected _position: Vector3;
  73422. protected _setPosition(value: Vector3): void;
  73423. /**
  73424. * Sets the position the shadow will be casted from. Also use as the light position for both
  73425. * point and spot lights.
  73426. */
  73427. /**
  73428. * Sets the position the shadow will be casted from. Also use as the light position for both
  73429. * point and spot lights.
  73430. */
  73431. position: Vector3;
  73432. protected _direction: Vector3;
  73433. protected _setDirection(value: Vector3): void;
  73434. /**
  73435. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73436. * Also use as the light direction on spot and directional lights.
  73437. */
  73438. /**
  73439. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73440. * Also use as the light direction on spot and directional lights.
  73441. */
  73442. direction: Vector3;
  73443. private _shadowMinZ;
  73444. /**
  73445. * Gets the shadow projection clipping minimum z value.
  73446. */
  73447. /**
  73448. * Sets the shadow projection clipping minimum z value.
  73449. */
  73450. shadowMinZ: number;
  73451. private _shadowMaxZ;
  73452. /**
  73453. * Sets the shadow projection clipping maximum z value.
  73454. */
  73455. /**
  73456. * Gets the shadow projection clipping maximum z value.
  73457. */
  73458. shadowMaxZ: number;
  73459. /**
  73460. * Callback defining a custom Projection Matrix Builder.
  73461. * This can be used to override the default projection matrix computation.
  73462. */
  73463. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73464. /**
  73465. * The transformed position. Position of the light in world space taking parenting in account.
  73466. */
  73467. transformedPosition: Vector3;
  73468. /**
  73469. * The transformed direction. Direction of the light in world space taking parenting in account.
  73470. */
  73471. transformedDirection: Vector3;
  73472. private _needProjectionMatrixCompute;
  73473. /**
  73474. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73475. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73476. */
  73477. computeTransformedInformation(): boolean;
  73478. /**
  73479. * Return the depth scale used for the shadow map.
  73480. * @returns the depth scale.
  73481. */
  73482. getDepthScale(): number;
  73483. /**
  73484. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73485. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73486. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73487. */
  73488. getShadowDirection(faceIndex?: number): Vector3;
  73489. /**
  73490. * Returns the ShadowLight absolute position in the World.
  73491. * @returns the position vector in world space
  73492. */
  73493. getAbsolutePosition(): Vector3;
  73494. /**
  73495. * Sets the ShadowLight direction toward the passed target.
  73496. * @param target The point to target in local space
  73497. * @returns the updated ShadowLight direction
  73498. */
  73499. setDirectionToTarget(target: Vector3): Vector3;
  73500. /**
  73501. * Returns the light rotation in euler definition.
  73502. * @returns the x y z rotation in local space.
  73503. */
  73504. getRotation(): Vector3;
  73505. /**
  73506. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73507. * @returns true if a cube texture needs to be use
  73508. */
  73509. needCube(): boolean;
  73510. /**
  73511. * Detects if the projection matrix requires to be recomputed this frame.
  73512. * @returns true if it requires to be recomputed otherwise, false.
  73513. */
  73514. needProjectionMatrixCompute(): boolean;
  73515. /**
  73516. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73517. */
  73518. forceProjectionMatrixCompute(): void;
  73519. /** @hidden */
  73520. _initCache(): void;
  73521. /** @hidden */
  73522. _isSynchronized(): boolean;
  73523. /**
  73524. * Computes the world matrix of the node
  73525. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73526. * @returns the world matrix
  73527. */
  73528. computeWorldMatrix(force?: boolean): Matrix;
  73529. /**
  73530. * Gets the minZ used for shadow according to both the scene and the light.
  73531. * @param activeCamera The camera we are returning the min for
  73532. * @returns the depth min z
  73533. */
  73534. getDepthMinZ(activeCamera: Camera): number;
  73535. /**
  73536. * Gets the maxZ used for shadow according to both the scene and the light.
  73537. * @param activeCamera The camera we are returning the max for
  73538. * @returns the depth max z
  73539. */
  73540. getDepthMaxZ(activeCamera: Camera): number;
  73541. /**
  73542. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73543. * @param matrix The materix to updated with the projection information
  73544. * @param viewMatrix The transform matrix of the light
  73545. * @param renderList The list of mesh to render in the map
  73546. * @returns The current light
  73547. */
  73548. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73549. }
  73550. }
  73551. declare module BABYLON {
  73552. /**
  73553. * "Static Class" containing the most commonly used helper while dealing with material for
  73554. * rendering purpose.
  73555. *
  73556. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73557. *
  73558. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73559. */
  73560. export class MaterialHelper {
  73561. /**
  73562. * Bind the current view position to an effect.
  73563. * @param effect The effect to be bound
  73564. * @param scene The scene the eyes position is used from
  73565. */
  73566. static BindEyePosition(effect: Effect, scene: Scene): void;
  73567. /**
  73568. * Helps preparing the defines values about the UVs in used in the effect.
  73569. * UVs are shared as much as we can accross channels in the shaders.
  73570. * @param texture The texture we are preparing the UVs for
  73571. * @param defines The defines to update
  73572. * @param key The channel key "diffuse", "specular"... used in the shader
  73573. */
  73574. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73575. /**
  73576. * Binds a texture matrix value to its corrsponding uniform
  73577. * @param texture The texture to bind the matrix for
  73578. * @param uniformBuffer The uniform buffer receivin the data
  73579. * @param key The channel key "diffuse", "specular"... used in the shader
  73580. */
  73581. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73582. /**
  73583. * Gets the current status of the fog (should it be enabled?)
  73584. * @param mesh defines the mesh to evaluate for fog support
  73585. * @param scene defines the hosting scene
  73586. * @returns true if fog must be enabled
  73587. */
  73588. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73589. /**
  73590. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73591. * @param mesh defines the current mesh
  73592. * @param scene defines the current scene
  73593. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73594. * @param pointsCloud defines if point cloud rendering has to be turned on
  73595. * @param fogEnabled defines if fog has to be turned on
  73596. * @param alphaTest defines if alpha testing has to be turned on
  73597. * @param defines defines the current list of defines
  73598. */
  73599. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73600. /**
  73601. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73602. * @param scene defines the current scene
  73603. * @param engine defines the current engine
  73604. * @param defines specifies the list of active defines
  73605. * @param useInstances defines if instances have to be turned on
  73606. * @param useClipPlane defines if clip plane have to be turned on
  73607. */
  73608. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73609. /**
  73610. * Prepares the defines for bones
  73611. * @param mesh The mesh containing the geometry data we will draw
  73612. * @param defines The defines to update
  73613. */
  73614. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73615. /**
  73616. * Prepares the defines for morph targets
  73617. * @param mesh The mesh containing the geometry data we will draw
  73618. * @param defines The defines to update
  73619. */
  73620. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73621. /**
  73622. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73623. * @param mesh The mesh containing the geometry data we will draw
  73624. * @param defines The defines to update
  73625. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73626. * @param useBones Precise whether bones should be used or not (override mesh info)
  73627. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73628. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73629. * @returns false if defines are considered not dirty and have not been checked
  73630. */
  73631. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73632. /**
  73633. * Prepares the defines related to multiview
  73634. * @param scene The scene we are intending to draw
  73635. * @param defines The defines to update
  73636. */
  73637. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73638. /**
  73639. * Prepares the defines related to the light information passed in parameter
  73640. * @param scene The scene we are intending to draw
  73641. * @param mesh The mesh the effect is compiling for
  73642. * @param light The light the effect is compiling for
  73643. * @param lightIndex The index of the light
  73644. * @param defines The defines to update
  73645. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73646. * @param state Defines the current state regarding what is needed (normals, etc...)
  73647. */
  73648. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73649. needNormals: boolean;
  73650. needRebuild: boolean;
  73651. shadowEnabled: boolean;
  73652. specularEnabled: boolean;
  73653. lightmapMode: boolean;
  73654. }): void;
  73655. /**
  73656. * Prepares the defines related to the light information passed in parameter
  73657. * @param scene The scene we are intending to draw
  73658. * @param mesh The mesh the effect is compiling for
  73659. * @param defines The defines to update
  73660. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73661. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73662. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73663. * @returns true if normals will be required for the rest of the effect
  73664. */
  73665. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73666. /**
  73667. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73668. * @param lightIndex defines the light index
  73669. * @param uniformsList The uniform list
  73670. * @param samplersList The sampler list
  73671. * @param projectedLightTexture defines if projected texture must be used
  73672. * @param uniformBuffersList defines an optional list of uniform buffers
  73673. */
  73674. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73675. /**
  73676. * Prepares the uniforms and samplers list to be used in the effect
  73677. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73678. * @param samplersList The sampler list
  73679. * @param defines The defines helping in the list generation
  73680. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73681. */
  73682. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73683. /**
  73684. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73685. * @param defines The defines to update while falling back
  73686. * @param fallbacks The authorized effect fallbacks
  73687. * @param maxSimultaneousLights The maximum number of lights allowed
  73688. * @param rank the current rank of the Effect
  73689. * @returns The newly affected rank
  73690. */
  73691. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73692. private static _TmpMorphInfluencers;
  73693. /**
  73694. * Prepares the list of attributes required for morph targets according to the effect defines.
  73695. * @param attribs The current list of supported attribs
  73696. * @param mesh The mesh to prepare the morph targets attributes for
  73697. * @param influencers The number of influencers
  73698. */
  73699. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73700. /**
  73701. * Prepares the list of attributes required for morph targets according to the effect defines.
  73702. * @param attribs The current list of supported attribs
  73703. * @param mesh The mesh to prepare the morph targets attributes for
  73704. * @param defines The current Defines of the effect
  73705. */
  73706. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73707. /**
  73708. * Prepares the list of attributes required for bones according to the effect defines.
  73709. * @param attribs The current list of supported attribs
  73710. * @param mesh The mesh to prepare the bones attributes for
  73711. * @param defines The current Defines of the effect
  73712. * @param fallbacks The current efffect fallback strategy
  73713. */
  73714. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73715. /**
  73716. * Check and prepare the list of attributes required for instances according to the effect defines.
  73717. * @param attribs The current list of supported attribs
  73718. * @param defines The current MaterialDefines of the effect
  73719. */
  73720. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73721. /**
  73722. * Add the list of attributes required for instances to the attribs array.
  73723. * @param attribs The current list of supported attribs
  73724. */
  73725. static PushAttributesForInstances(attribs: string[]): void;
  73726. /**
  73727. * Binds the light shadow information to the effect for the given mesh.
  73728. * @param light The light containing the generator
  73729. * @param scene The scene the lights belongs to
  73730. * @param mesh The mesh we are binding the information to render
  73731. * @param lightIndex The light index in the effect used to render the mesh
  73732. * @param effect The effect we are binding the data to
  73733. */
  73734. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73735. /**
  73736. * Binds the light information to the effect.
  73737. * @param light The light containing the generator
  73738. * @param effect The effect we are binding the data to
  73739. * @param lightIndex The light index in the effect used to render
  73740. */
  73741. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73742. /**
  73743. * Binds the lights information from the scene to the effect for the given mesh.
  73744. * @param light Light to bind
  73745. * @param lightIndex Light index
  73746. * @param scene The scene where the light belongs to
  73747. * @param mesh The mesh we are binding the information to render
  73748. * @param effect The effect we are binding the data to
  73749. * @param useSpecular Defines if specular is supported
  73750. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73751. */
  73752. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  73753. /**
  73754. * Binds the lights information from the scene to the effect for the given mesh.
  73755. * @param scene The scene the lights belongs to
  73756. * @param mesh The mesh we are binding the information to render
  73757. * @param effect The effect we are binding the data to
  73758. * @param defines The generated defines for the effect
  73759. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73760. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73761. */
  73762. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73763. private static _tempFogColor;
  73764. /**
  73765. * Binds the fog information from the scene to the effect for the given mesh.
  73766. * @param scene The scene the lights belongs to
  73767. * @param mesh The mesh we are binding the information to render
  73768. * @param effect The effect we are binding the data to
  73769. * @param linearSpace Defines if the fog effect is applied in linear space
  73770. */
  73771. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73772. /**
  73773. * Binds the bones information from the mesh to the effect.
  73774. * @param mesh The mesh we are binding the information to render
  73775. * @param effect The effect we are binding the data to
  73776. */
  73777. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73778. /**
  73779. * Binds the morph targets information from the mesh to the effect.
  73780. * @param abstractMesh The mesh we are binding the information to render
  73781. * @param effect The effect we are binding the data to
  73782. */
  73783. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73784. /**
  73785. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73786. * @param defines The generated defines used in the effect
  73787. * @param effect The effect we are binding the data to
  73788. * @param scene The scene we are willing to render with logarithmic scale for
  73789. */
  73790. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73791. /**
  73792. * Binds the clip plane information from the scene to the effect.
  73793. * @param scene The scene the clip plane information are extracted from
  73794. * @param effect The effect we are binding the data to
  73795. */
  73796. static BindClipPlane(effect: Effect, scene: Scene): void;
  73797. }
  73798. }
  73799. declare module BABYLON {
  73800. /** @hidden */
  73801. export var packingFunctions: {
  73802. name: string;
  73803. shader: string;
  73804. };
  73805. }
  73806. declare module BABYLON {
  73807. /** @hidden */
  73808. export var shadowMapPixelShader: {
  73809. name: string;
  73810. shader: string;
  73811. };
  73812. }
  73813. declare module BABYLON {
  73814. /** @hidden */
  73815. export var bonesDeclaration: {
  73816. name: string;
  73817. shader: string;
  73818. };
  73819. }
  73820. declare module BABYLON {
  73821. /** @hidden */
  73822. export var morphTargetsVertexGlobalDeclaration: {
  73823. name: string;
  73824. shader: string;
  73825. };
  73826. }
  73827. declare module BABYLON {
  73828. /** @hidden */
  73829. export var morphTargetsVertexDeclaration: {
  73830. name: string;
  73831. shader: string;
  73832. };
  73833. }
  73834. declare module BABYLON {
  73835. /** @hidden */
  73836. export var instancesDeclaration: {
  73837. name: string;
  73838. shader: string;
  73839. };
  73840. }
  73841. declare module BABYLON {
  73842. /** @hidden */
  73843. export var helperFunctions: {
  73844. name: string;
  73845. shader: string;
  73846. };
  73847. }
  73848. declare module BABYLON {
  73849. /** @hidden */
  73850. export var morphTargetsVertex: {
  73851. name: string;
  73852. shader: string;
  73853. };
  73854. }
  73855. declare module BABYLON {
  73856. /** @hidden */
  73857. export var instancesVertex: {
  73858. name: string;
  73859. shader: string;
  73860. };
  73861. }
  73862. declare module BABYLON {
  73863. /** @hidden */
  73864. export var bonesVertex: {
  73865. name: string;
  73866. shader: string;
  73867. };
  73868. }
  73869. declare module BABYLON {
  73870. /** @hidden */
  73871. export var shadowMapVertexShader: {
  73872. name: string;
  73873. shader: string;
  73874. };
  73875. }
  73876. declare module BABYLON {
  73877. /** @hidden */
  73878. export var depthBoxBlurPixelShader: {
  73879. name: string;
  73880. shader: string;
  73881. };
  73882. }
  73883. declare module BABYLON {
  73884. /**
  73885. * Defines the options associated with the creation of a custom shader for a shadow generator.
  73886. */
  73887. export interface ICustomShaderOptions {
  73888. /**
  73889. * Gets or sets the custom shader name to use
  73890. */
  73891. shaderName: string;
  73892. /**
  73893. * The list of attribute names used in the shader
  73894. */
  73895. attributes?: string[];
  73896. /**
  73897. * The list of unifrom names used in the shader
  73898. */
  73899. uniforms?: string[];
  73900. /**
  73901. * The list of sampler names used in the shader
  73902. */
  73903. samplers?: string[];
  73904. /**
  73905. * The list of defines used in the shader
  73906. */
  73907. defines?: string[];
  73908. }
  73909. /**
  73910. * Interface to implement to create a shadow generator compatible with BJS.
  73911. */
  73912. export interface IShadowGenerator {
  73913. /**
  73914. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73915. * @returns The render target texture if present otherwise, null
  73916. */
  73917. getShadowMap(): Nullable<RenderTargetTexture>;
  73918. /**
  73919. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73920. * @returns The render target texture if the shadow map is present otherwise, null
  73921. */
  73922. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73923. /**
  73924. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73925. * @param subMesh The submesh we want to render in the shadow map
  73926. * @param useInstances Defines wether will draw in the map using instances
  73927. * @returns true if ready otherwise, false
  73928. */
  73929. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73930. /**
  73931. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73932. * @param defines Defines of the material we want to update
  73933. * @param lightIndex Index of the light in the enabled light list of the material
  73934. */
  73935. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73936. /**
  73937. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73938. * defined in the generator but impacting the effect).
  73939. * It implies the unifroms available on the materials are the standard BJS ones.
  73940. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73941. * @param effect The effect we are binfing the information for
  73942. */
  73943. bindShadowLight(lightIndex: string, effect: Effect): void;
  73944. /**
  73945. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73946. * (eq to shadow prjection matrix * light transform matrix)
  73947. * @returns The transform matrix used to create the shadow map
  73948. */
  73949. getTransformMatrix(): Matrix;
  73950. /**
  73951. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73952. * Cube and 2D textures for instance.
  73953. */
  73954. recreateShadowMap(): void;
  73955. /**
  73956. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73957. * @param onCompiled Callback triggered at the and of the effects compilation
  73958. * @param options Sets of optional options forcing the compilation with different modes
  73959. */
  73960. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73961. useInstances: boolean;
  73962. }>): void;
  73963. /**
  73964. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73965. * @param options Sets of optional options forcing the compilation with different modes
  73966. * @returns A promise that resolves when the compilation completes
  73967. */
  73968. forceCompilationAsync(options?: Partial<{
  73969. useInstances: boolean;
  73970. }>): Promise<void>;
  73971. /**
  73972. * Serializes the shadow generator setup to a json object.
  73973. * @returns The serialized JSON object
  73974. */
  73975. serialize(): any;
  73976. /**
  73977. * Disposes the Shadow map and related Textures and effects.
  73978. */
  73979. dispose(): void;
  73980. }
  73981. /**
  73982. * Default implementation IShadowGenerator.
  73983. * This is the main object responsible of generating shadows in the framework.
  73984. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73985. */
  73986. export class ShadowGenerator implements IShadowGenerator {
  73987. /**
  73988. * Shadow generator mode None: no filtering applied.
  73989. */
  73990. static readonly FILTER_NONE: number;
  73991. /**
  73992. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73993. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73994. */
  73995. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73996. /**
  73997. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73998. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73999. */
  74000. static readonly FILTER_POISSONSAMPLING: number;
  74001. /**
  74002. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  74003. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74004. */
  74005. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  74006. /**
  74007. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  74008. * edge artifacts on steep falloff.
  74009. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74010. */
  74011. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  74012. /**
  74013. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  74014. * edge artifacts on steep falloff.
  74015. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74016. */
  74017. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  74018. /**
  74019. * Shadow generator mode PCF: Percentage Closer Filtering
  74020. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74021. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  74022. */
  74023. static readonly FILTER_PCF: number;
  74024. /**
  74025. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  74026. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74027. * Contact Hardening
  74028. */
  74029. static readonly FILTER_PCSS: number;
  74030. /**
  74031. * Reserved for PCF and PCSS
  74032. * Highest Quality.
  74033. *
  74034. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  74035. *
  74036. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  74037. */
  74038. static readonly QUALITY_HIGH: number;
  74039. /**
  74040. * Reserved for PCF and PCSS
  74041. * Good tradeoff for quality/perf cross devices
  74042. *
  74043. * Execute PCF on a 3*3 kernel.
  74044. *
  74045. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  74046. */
  74047. static readonly QUALITY_MEDIUM: number;
  74048. /**
  74049. * Reserved for PCF and PCSS
  74050. * The lowest quality but the fastest.
  74051. *
  74052. * Execute PCF on a 1*1 kernel.
  74053. *
  74054. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  74055. */
  74056. static readonly QUALITY_LOW: number;
  74057. /** Gets or sets the custom shader name to use */
  74058. customShaderOptions: ICustomShaderOptions;
  74059. /**
  74060. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  74061. */
  74062. onBeforeShadowMapRenderObservable: Observable<Effect>;
  74063. /**
  74064. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  74065. */
  74066. onAfterShadowMapRenderObservable: Observable<Effect>;
  74067. /**
  74068. * Observable triggered before a mesh is rendered in the shadow map.
  74069. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  74070. */
  74071. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  74072. /**
  74073. * Observable triggered after a mesh is rendered in the shadow map.
  74074. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  74075. */
  74076. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  74077. private _bias;
  74078. /**
  74079. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  74080. */
  74081. /**
  74082. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  74083. */
  74084. bias: number;
  74085. private _normalBias;
  74086. /**
  74087. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74088. */
  74089. /**
  74090. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74091. */
  74092. normalBias: number;
  74093. private _blurBoxOffset;
  74094. /**
  74095. * Gets the blur box offset: offset applied during the blur pass.
  74096. * Only useful if useKernelBlur = false
  74097. */
  74098. /**
  74099. * Sets the blur box offset: offset applied during the blur pass.
  74100. * Only useful if useKernelBlur = false
  74101. */
  74102. blurBoxOffset: number;
  74103. private _blurScale;
  74104. /**
  74105. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  74106. * 2 means half of the size.
  74107. */
  74108. /**
  74109. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  74110. * 2 means half of the size.
  74111. */
  74112. blurScale: number;
  74113. private _blurKernel;
  74114. /**
  74115. * Gets the blur kernel: kernel size of the blur pass.
  74116. * Only useful if useKernelBlur = true
  74117. */
  74118. /**
  74119. * Sets the blur kernel: kernel size of the blur pass.
  74120. * Only useful if useKernelBlur = true
  74121. */
  74122. blurKernel: number;
  74123. private _useKernelBlur;
  74124. /**
  74125. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  74126. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74127. */
  74128. /**
  74129. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74130. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74131. */
  74132. useKernelBlur: boolean;
  74133. private _depthScale;
  74134. /**
  74135. * Gets the depth scale used in ESM mode.
  74136. */
  74137. /**
  74138. * Sets the depth scale used in ESM mode.
  74139. * This can override the scale stored on the light.
  74140. */
  74141. depthScale: number;
  74142. private _filter;
  74143. /**
  74144. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74145. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74146. */
  74147. /**
  74148. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74149. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74150. */
  74151. filter: number;
  74152. /**
  74153. * Gets if the current filter is set to Poisson Sampling.
  74154. */
  74155. /**
  74156. * Sets the current filter to Poisson Sampling.
  74157. */
  74158. usePoissonSampling: boolean;
  74159. /**
  74160. * Gets if the current filter is set to ESM.
  74161. */
  74162. /**
  74163. * Sets the current filter is to ESM.
  74164. */
  74165. useExponentialShadowMap: boolean;
  74166. /**
  74167. * Gets if the current filter is set to filtered ESM.
  74168. */
  74169. /**
  74170. * Gets if the current filter is set to filtered ESM.
  74171. */
  74172. useBlurExponentialShadowMap: boolean;
  74173. /**
  74174. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74175. * exponential to prevent steep falloff artifacts).
  74176. */
  74177. /**
  74178. * Sets the current filter to "close ESM" (using the inverse of the
  74179. * exponential to prevent steep falloff artifacts).
  74180. */
  74181. useCloseExponentialShadowMap: boolean;
  74182. /**
  74183. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74184. * exponential to prevent steep falloff artifacts).
  74185. */
  74186. /**
  74187. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74188. * exponential to prevent steep falloff artifacts).
  74189. */
  74190. useBlurCloseExponentialShadowMap: boolean;
  74191. /**
  74192. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74193. */
  74194. /**
  74195. * Sets the current filter to "PCF" (percentage closer filtering).
  74196. */
  74197. usePercentageCloserFiltering: boolean;
  74198. private _filteringQuality;
  74199. /**
  74200. * Gets the PCF or PCSS Quality.
  74201. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74202. */
  74203. /**
  74204. * Sets the PCF or PCSS Quality.
  74205. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74206. */
  74207. filteringQuality: number;
  74208. /**
  74209. * Gets if the current filter is set to "PCSS" (contact hardening).
  74210. */
  74211. /**
  74212. * Sets the current filter to "PCSS" (contact hardening).
  74213. */
  74214. useContactHardeningShadow: boolean;
  74215. private _contactHardeningLightSizeUVRatio;
  74216. /**
  74217. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74218. * Using a ratio helps keeping shape stability independently of the map size.
  74219. *
  74220. * It does not account for the light projection as it was having too much
  74221. * instability during the light setup or during light position changes.
  74222. *
  74223. * Only valid if useContactHardeningShadow is true.
  74224. */
  74225. /**
  74226. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74227. * Using a ratio helps keeping shape stability independently of the map size.
  74228. *
  74229. * It does not account for the light projection as it was having too much
  74230. * instability during the light setup or during light position changes.
  74231. *
  74232. * Only valid if useContactHardeningShadow is true.
  74233. */
  74234. contactHardeningLightSizeUVRatio: number;
  74235. private _darkness;
  74236. /** Gets or sets the actual darkness of a shadow */
  74237. darkness: number;
  74238. /**
  74239. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74240. * 0 means strongest and 1 would means no shadow.
  74241. * @returns the darkness.
  74242. */
  74243. getDarkness(): number;
  74244. /**
  74245. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74246. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74247. * @returns the shadow generator allowing fluent coding.
  74248. */
  74249. setDarkness(darkness: number): ShadowGenerator;
  74250. private _transparencyShadow;
  74251. /** Gets or sets the ability to have transparent shadow */
  74252. transparencyShadow: boolean;
  74253. /**
  74254. * Sets the ability to have transparent shadow (boolean).
  74255. * @param transparent True if transparent else False
  74256. * @returns the shadow generator allowing fluent coding
  74257. */
  74258. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74259. private _shadowMap;
  74260. private _shadowMap2;
  74261. /**
  74262. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74263. * @returns The render target texture if present otherwise, null
  74264. */
  74265. getShadowMap(): Nullable<RenderTargetTexture>;
  74266. /**
  74267. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74268. * @returns The render target texture if the shadow map is present otherwise, null
  74269. */
  74270. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74271. /**
  74272. * Gets the class name of that object
  74273. * @returns "ShadowGenerator"
  74274. */
  74275. getClassName(): string;
  74276. /**
  74277. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74278. * @param mesh Mesh to add
  74279. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74280. * @returns the Shadow Generator itself
  74281. */
  74282. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74283. /**
  74284. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74285. * @param mesh Mesh to remove
  74286. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74287. * @returns the Shadow Generator itself
  74288. */
  74289. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74290. /**
  74291. * Controls the extent to which the shadows fade out at the edge of the frustum
  74292. * Used only by directionals and spots
  74293. */
  74294. frustumEdgeFalloff: number;
  74295. private _light;
  74296. /**
  74297. * Returns the associated light object.
  74298. * @returns the light generating the shadow
  74299. */
  74300. getLight(): IShadowLight;
  74301. /**
  74302. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74303. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74304. * It might on the other hand introduce peter panning.
  74305. */
  74306. forceBackFacesOnly: boolean;
  74307. private _scene;
  74308. private _lightDirection;
  74309. private _effect;
  74310. private _viewMatrix;
  74311. private _projectionMatrix;
  74312. private _transformMatrix;
  74313. private _cachedPosition;
  74314. private _cachedDirection;
  74315. private _cachedDefines;
  74316. private _currentRenderID;
  74317. private _boxBlurPostprocess;
  74318. private _kernelBlurXPostprocess;
  74319. private _kernelBlurYPostprocess;
  74320. private _blurPostProcesses;
  74321. private _mapSize;
  74322. private _currentFaceIndex;
  74323. private _currentFaceIndexCache;
  74324. private _textureType;
  74325. private _defaultTextureMatrix;
  74326. /** @hidden */
  74327. static _SceneComponentInitialization: (scene: Scene) => void;
  74328. /**
  74329. * Creates a ShadowGenerator object.
  74330. * A ShadowGenerator is the required tool to use the shadows.
  74331. * Each light casting shadows needs to use its own ShadowGenerator.
  74332. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74333. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74334. * @param light The light object generating the shadows.
  74335. * @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.
  74336. */
  74337. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74338. private _initializeGenerator;
  74339. private _initializeShadowMap;
  74340. private _initializeBlurRTTAndPostProcesses;
  74341. private _renderForShadowMap;
  74342. private _renderSubMeshForShadowMap;
  74343. private _applyFilterValues;
  74344. /**
  74345. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74346. * @param onCompiled Callback triggered at the and of the effects compilation
  74347. * @param options Sets of optional options forcing the compilation with different modes
  74348. */
  74349. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74350. useInstances: boolean;
  74351. }>): void;
  74352. /**
  74353. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74354. * @param options Sets of optional options forcing the compilation with different modes
  74355. * @returns A promise that resolves when the compilation completes
  74356. */
  74357. forceCompilationAsync(options?: Partial<{
  74358. useInstances: boolean;
  74359. }>): Promise<void>;
  74360. /**
  74361. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74362. * @param subMesh The submesh we want to render in the shadow map
  74363. * @param useInstances Defines wether will draw in the map using instances
  74364. * @returns true if ready otherwise, false
  74365. */
  74366. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74367. /**
  74368. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74369. * @param defines Defines of the material we want to update
  74370. * @param lightIndex Index of the light in the enabled light list of the material
  74371. */
  74372. prepareDefines(defines: any, lightIndex: number): void;
  74373. /**
  74374. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74375. * defined in the generator but impacting the effect).
  74376. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74377. * @param effect The effect we are binfing the information for
  74378. */
  74379. bindShadowLight(lightIndex: string, effect: Effect): void;
  74380. /**
  74381. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74382. * (eq to shadow prjection matrix * light transform matrix)
  74383. * @returns The transform matrix used to create the shadow map
  74384. */
  74385. getTransformMatrix(): Matrix;
  74386. /**
  74387. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74388. * Cube and 2D textures for instance.
  74389. */
  74390. recreateShadowMap(): void;
  74391. private _disposeBlurPostProcesses;
  74392. private _disposeRTTandPostProcesses;
  74393. /**
  74394. * Disposes the ShadowGenerator.
  74395. * Returns nothing.
  74396. */
  74397. dispose(): void;
  74398. /**
  74399. * Serializes the shadow generator setup to a json object.
  74400. * @returns The serialized JSON object
  74401. */
  74402. serialize(): any;
  74403. /**
  74404. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74405. * @param parsedShadowGenerator The JSON object to parse
  74406. * @param scene The scene to create the shadow map for
  74407. * @returns The parsed shadow generator
  74408. */
  74409. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74410. }
  74411. }
  74412. declare module BABYLON {
  74413. /**
  74414. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74415. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74416. * 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.
  74417. */
  74418. export abstract class Light extends Node {
  74419. /**
  74420. * Falloff Default: light is falling off following the material specification:
  74421. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74422. */
  74423. static readonly FALLOFF_DEFAULT: number;
  74424. /**
  74425. * Falloff Physical: light is falling off following the inverse squared distance law.
  74426. */
  74427. static readonly FALLOFF_PHYSICAL: number;
  74428. /**
  74429. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74430. * to enhance interoperability with other engines.
  74431. */
  74432. static readonly FALLOFF_GLTF: number;
  74433. /**
  74434. * Falloff Standard: light is falling off like in the standard material
  74435. * to enhance interoperability with other materials.
  74436. */
  74437. static readonly FALLOFF_STANDARD: number;
  74438. /**
  74439. * If every light affecting the material is in this lightmapMode,
  74440. * material.lightmapTexture adds or multiplies
  74441. * (depends on material.useLightmapAsShadowmap)
  74442. * after every other light calculations.
  74443. */
  74444. static readonly LIGHTMAP_DEFAULT: number;
  74445. /**
  74446. * material.lightmapTexture as only diffuse lighting from this light
  74447. * adds only specular lighting from this light
  74448. * adds dynamic shadows
  74449. */
  74450. static readonly LIGHTMAP_SPECULAR: number;
  74451. /**
  74452. * material.lightmapTexture as only lighting
  74453. * no light calculation from this light
  74454. * only adds dynamic shadows from this light
  74455. */
  74456. static readonly LIGHTMAP_SHADOWSONLY: number;
  74457. /**
  74458. * Each light type uses the default quantity according to its type:
  74459. * point/spot lights use luminous intensity
  74460. * directional lights use illuminance
  74461. */
  74462. static readonly INTENSITYMODE_AUTOMATIC: number;
  74463. /**
  74464. * lumen (lm)
  74465. */
  74466. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74467. /**
  74468. * candela (lm/sr)
  74469. */
  74470. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74471. /**
  74472. * lux (lm/m^2)
  74473. */
  74474. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74475. /**
  74476. * nit (cd/m^2)
  74477. */
  74478. static readonly INTENSITYMODE_LUMINANCE: number;
  74479. /**
  74480. * Light type const id of the point light.
  74481. */
  74482. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74483. /**
  74484. * Light type const id of the directional light.
  74485. */
  74486. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74487. /**
  74488. * Light type const id of the spot light.
  74489. */
  74490. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74491. /**
  74492. * Light type const id of the hemispheric light.
  74493. */
  74494. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74495. /**
  74496. * Diffuse gives the basic color to an object.
  74497. */
  74498. diffuse: Color3;
  74499. /**
  74500. * Specular produces a highlight color on an object.
  74501. * Note: This is note affecting PBR materials.
  74502. */
  74503. specular: Color3;
  74504. /**
  74505. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74506. * falling off base on range or angle.
  74507. * This can be set to any values in Light.FALLOFF_x.
  74508. *
  74509. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74510. * other types of materials.
  74511. */
  74512. falloffType: number;
  74513. /**
  74514. * Strength of the light.
  74515. * Note: By default it is define in the framework own unit.
  74516. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74517. */
  74518. intensity: number;
  74519. private _range;
  74520. protected _inverseSquaredRange: number;
  74521. /**
  74522. * Defines how far from the source the light is impacting in scene units.
  74523. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74524. */
  74525. /**
  74526. * Defines how far from the source the light is impacting in scene units.
  74527. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74528. */
  74529. range: number;
  74530. /**
  74531. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74532. * of light.
  74533. */
  74534. private _photometricScale;
  74535. private _intensityMode;
  74536. /**
  74537. * Gets the photometric scale used to interpret the intensity.
  74538. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74539. */
  74540. /**
  74541. * Sets the photometric scale used to interpret the intensity.
  74542. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74543. */
  74544. intensityMode: number;
  74545. private _radius;
  74546. /**
  74547. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74548. */
  74549. /**
  74550. * sets the light radius used by PBR Materials to simulate soft area lights.
  74551. */
  74552. radius: number;
  74553. private _renderPriority;
  74554. /**
  74555. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74556. * exceeding the number allowed of the materials.
  74557. */
  74558. renderPriority: number;
  74559. private _shadowEnabled;
  74560. /**
  74561. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74562. * the current shadow generator.
  74563. */
  74564. /**
  74565. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74566. * the current shadow generator.
  74567. */
  74568. shadowEnabled: boolean;
  74569. private _includedOnlyMeshes;
  74570. /**
  74571. * Gets the only meshes impacted by this light.
  74572. */
  74573. /**
  74574. * Sets the only meshes impacted by this light.
  74575. */
  74576. includedOnlyMeshes: AbstractMesh[];
  74577. private _excludedMeshes;
  74578. /**
  74579. * Gets the meshes not impacted by this light.
  74580. */
  74581. /**
  74582. * Sets the meshes not impacted by this light.
  74583. */
  74584. excludedMeshes: AbstractMesh[];
  74585. private _excludeWithLayerMask;
  74586. /**
  74587. * Gets the layer id use to find what meshes are not impacted by the light.
  74588. * Inactive if 0
  74589. */
  74590. /**
  74591. * Sets the layer id use to find what meshes are not impacted by the light.
  74592. * Inactive if 0
  74593. */
  74594. excludeWithLayerMask: number;
  74595. private _includeOnlyWithLayerMask;
  74596. /**
  74597. * Gets the layer id use to find what meshes are impacted by the light.
  74598. * Inactive if 0
  74599. */
  74600. /**
  74601. * Sets the layer id use to find what meshes are impacted by the light.
  74602. * Inactive if 0
  74603. */
  74604. includeOnlyWithLayerMask: number;
  74605. private _lightmapMode;
  74606. /**
  74607. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74608. */
  74609. /**
  74610. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74611. */
  74612. lightmapMode: number;
  74613. /**
  74614. * Shadow generator associted to the light.
  74615. * @hidden Internal use only.
  74616. */
  74617. _shadowGenerator: Nullable<IShadowGenerator>;
  74618. /**
  74619. * @hidden Internal use only.
  74620. */
  74621. _excludedMeshesIds: string[];
  74622. /**
  74623. * @hidden Internal use only.
  74624. */
  74625. _includedOnlyMeshesIds: string[];
  74626. /**
  74627. * The current light unifom buffer.
  74628. * @hidden Internal use only.
  74629. */
  74630. _uniformBuffer: UniformBuffer;
  74631. /**
  74632. * Creates a Light object in the scene.
  74633. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74634. * @param name The firendly name of the light
  74635. * @param scene The scene the light belongs too
  74636. */
  74637. constructor(name: string, scene: Scene);
  74638. protected abstract _buildUniformLayout(): void;
  74639. /**
  74640. * Sets the passed Effect "effect" with the Light information.
  74641. * @param effect The effect to update
  74642. * @param lightIndex The index of the light in the effect to update
  74643. * @returns The light
  74644. */
  74645. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74646. /**
  74647. * Returns the string "Light".
  74648. * @returns the class name
  74649. */
  74650. getClassName(): string;
  74651. /** @hidden */
  74652. readonly _isLight: boolean;
  74653. /**
  74654. * Converts the light information to a readable string for debug purpose.
  74655. * @param fullDetails Supports for multiple levels of logging within scene loading
  74656. * @returns the human readable light info
  74657. */
  74658. toString(fullDetails?: boolean): string;
  74659. /** @hidden */
  74660. protected _syncParentEnabledState(): void;
  74661. /**
  74662. * Set the enabled state of this node.
  74663. * @param value - the new enabled state
  74664. */
  74665. setEnabled(value: boolean): void;
  74666. /**
  74667. * Returns the Light associated shadow generator if any.
  74668. * @return the associated shadow generator.
  74669. */
  74670. getShadowGenerator(): Nullable<IShadowGenerator>;
  74671. /**
  74672. * Returns a Vector3, the absolute light position in the World.
  74673. * @returns the world space position of the light
  74674. */
  74675. getAbsolutePosition(): Vector3;
  74676. /**
  74677. * Specifies if the light will affect the passed mesh.
  74678. * @param mesh The mesh to test against the light
  74679. * @return true the mesh is affected otherwise, false.
  74680. */
  74681. canAffectMesh(mesh: AbstractMesh): boolean;
  74682. /**
  74683. * Sort function to order lights for rendering.
  74684. * @param a First Light object to compare to second.
  74685. * @param b Second Light object to compare first.
  74686. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74687. */
  74688. static CompareLightsPriority(a: Light, b: Light): number;
  74689. /**
  74690. * Releases resources associated with this node.
  74691. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74692. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74693. */
  74694. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74695. /**
  74696. * Returns the light type ID (integer).
  74697. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74698. */
  74699. getTypeID(): number;
  74700. /**
  74701. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74702. * @returns the scaled intensity in intensity mode unit
  74703. */
  74704. getScaledIntensity(): number;
  74705. /**
  74706. * Returns a new Light object, named "name", from the current one.
  74707. * @param name The name of the cloned light
  74708. * @returns the new created light
  74709. */
  74710. clone(name: string): Nullable<Light>;
  74711. /**
  74712. * Serializes the current light into a Serialization object.
  74713. * @returns the serialized object.
  74714. */
  74715. serialize(): any;
  74716. /**
  74717. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74718. * This new light is named "name" and added to the passed scene.
  74719. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74720. * @param name The friendly name of the light
  74721. * @param scene The scene the new light will belong to
  74722. * @returns the constructor function
  74723. */
  74724. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74725. /**
  74726. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74727. * @param parsedLight The JSON representation of the light
  74728. * @param scene The scene to create the parsed light in
  74729. * @returns the created light after parsing
  74730. */
  74731. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74732. private _hookArrayForExcluded;
  74733. private _hookArrayForIncludedOnly;
  74734. private _resyncMeshes;
  74735. /**
  74736. * Forces the meshes to update their light related information in their rendering used effects
  74737. * @hidden Internal Use Only
  74738. */
  74739. _markMeshesAsLightDirty(): void;
  74740. /**
  74741. * Recomputes the cached photometric scale if needed.
  74742. */
  74743. private _computePhotometricScale;
  74744. /**
  74745. * Returns the Photometric Scale according to the light type and intensity mode.
  74746. */
  74747. private _getPhotometricScale;
  74748. /**
  74749. * Reorder the light in the scene according to their defined priority.
  74750. * @hidden Internal Use Only
  74751. */
  74752. _reorderLightsInScene(): void;
  74753. /**
  74754. * Prepares the list of defines specific to the light type.
  74755. * @param defines the list of defines
  74756. * @param lightIndex defines the index of the light for the effect
  74757. */
  74758. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74759. }
  74760. }
  74761. declare module BABYLON {
  74762. /**
  74763. * Creates an instance based on a source mesh.
  74764. */
  74765. export class InstancedMesh extends AbstractMesh {
  74766. private _sourceMesh;
  74767. private _currentLOD;
  74768. /** @hidden */
  74769. _indexInSourceMeshInstanceArray: number;
  74770. constructor(name: string, source: Mesh);
  74771. /**
  74772. * Returns the string "InstancedMesh".
  74773. */
  74774. getClassName(): string;
  74775. /** Gets the list of lights affecting that mesh */
  74776. readonly lightSources: Light[];
  74777. _resyncLightSources(): void;
  74778. _resyncLighSource(light: Light): void;
  74779. _removeLightSource(light: Light): void;
  74780. /**
  74781. * If the source mesh receives shadows
  74782. */
  74783. readonly receiveShadows: boolean;
  74784. /**
  74785. * The material of the source mesh
  74786. */
  74787. readonly material: Nullable<Material>;
  74788. /**
  74789. * Visibility of the source mesh
  74790. */
  74791. readonly visibility: number;
  74792. /**
  74793. * Skeleton of the source mesh
  74794. */
  74795. readonly skeleton: Nullable<Skeleton>;
  74796. /**
  74797. * Rendering ground id of the source mesh
  74798. */
  74799. renderingGroupId: number;
  74800. /**
  74801. * Returns the total number of vertices (integer).
  74802. */
  74803. getTotalVertices(): number;
  74804. /**
  74805. * Returns a positive integer : the total number of indices in this mesh geometry.
  74806. * @returns the numner of indices or zero if the mesh has no geometry.
  74807. */
  74808. getTotalIndices(): number;
  74809. /**
  74810. * The source mesh of the instance
  74811. */
  74812. readonly sourceMesh: Mesh;
  74813. /**
  74814. * Is this node ready to be used/rendered
  74815. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74816. * @return {boolean} is it ready
  74817. */
  74818. isReady(completeCheck?: boolean): boolean;
  74819. /**
  74820. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74821. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74822. * @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.
  74823. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74824. */
  74825. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74826. /**
  74827. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74828. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74829. * The `data` are either a numeric array either a Float32Array.
  74830. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74831. * 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).
  74832. * Note that a new underlying VertexBuffer object is created each call.
  74833. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74834. *
  74835. * Possible `kind` values :
  74836. * - VertexBuffer.PositionKind
  74837. * - VertexBuffer.UVKind
  74838. * - VertexBuffer.UV2Kind
  74839. * - VertexBuffer.UV3Kind
  74840. * - VertexBuffer.UV4Kind
  74841. * - VertexBuffer.UV5Kind
  74842. * - VertexBuffer.UV6Kind
  74843. * - VertexBuffer.ColorKind
  74844. * - VertexBuffer.MatricesIndicesKind
  74845. * - VertexBuffer.MatricesIndicesExtraKind
  74846. * - VertexBuffer.MatricesWeightsKind
  74847. * - VertexBuffer.MatricesWeightsExtraKind
  74848. *
  74849. * Returns the Mesh.
  74850. */
  74851. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74852. /**
  74853. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74854. * If the mesh has no geometry, it is simply returned as it is.
  74855. * The `data` are either a numeric array either a Float32Array.
  74856. * No new underlying VertexBuffer object is created.
  74857. * 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.
  74858. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74859. *
  74860. * Possible `kind` values :
  74861. * - VertexBuffer.PositionKind
  74862. * - VertexBuffer.UVKind
  74863. * - VertexBuffer.UV2Kind
  74864. * - VertexBuffer.UV3Kind
  74865. * - VertexBuffer.UV4Kind
  74866. * - VertexBuffer.UV5Kind
  74867. * - VertexBuffer.UV6Kind
  74868. * - VertexBuffer.ColorKind
  74869. * - VertexBuffer.MatricesIndicesKind
  74870. * - VertexBuffer.MatricesIndicesExtraKind
  74871. * - VertexBuffer.MatricesWeightsKind
  74872. * - VertexBuffer.MatricesWeightsExtraKind
  74873. *
  74874. * Returns the Mesh.
  74875. */
  74876. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74877. /**
  74878. * Sets the mesh indices.
  74879. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74880. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74881. * This method creates a new index buffer each call.
  74882. * Returns the Mesh.
  74883. */
  74884. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74885. /**
  74886. * Boolean : True if the mesh owns the requested kind of data.
  74887. */
  74888. isVerticesDataPresent(kind: string): boolean;
  74889. /**
  74890. * Returns an array of indices (IndicesArray).
  74891. */
  74892. getIndices(): Nullable<IndicesArray>;
  74893. readonly _positions: Nullable<Vector3[]>;
  74894. /**
  74895. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74896. * This means the mesh underlying bounding box and sphere are recomputed.
  74897. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74898. * @returns the current mesh
  74899. */
  74900. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74901. /** @hidden */
  74902. _preActivate(): InstancedMesh;
  74903. /** @hidden */
  74904. _activate(renderId: number, intermediateRendering: boolean): boolean;
  74905. /** @hidden */
  74906. _postActivate(): void;
  74907. getWorldMatrix(): Matrix;
  74908. readonly isAnInstance: boolean;
  74909. /**
  74910. * Returns the current associated LOD AbstractMesh.
  74911. */
  74912. getLOD(camera: Camera): AbstractMesh;
  74913. /** @hidden */
  74914. _syncSubMeshes(): InstancedMesh;
  74915. /** @hidden */
  74916. _generatePointsArray(): boolean;
  74917. /**
  74918. * Creates a new InstancedMesh from the current mesh.
  74919. * - name (string) : the cloned mesh name
  74920. * - newParent (optional Node) : the optional Node to parent the clone to.
  74921. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74922. *
  74923. * Returns the clone.
  74924. */
  74925. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74926. /**
  74927. * Disposes the InstancedMesh.
  74928. * Returns nothing.
  74929. */
  74930. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74931. }
  74932. }
  74933. declare module BABYLON {
  74934. /**
  74935. * Defines the options associated with the creation of a shader material.
  74936. */
  74937. export interface IShaderMaterialOptions {
  74938. /**
  74939. * Does the material work in alpha blend mode
  74940. */
  74941. needAlphaBlending: boolean;
  74942. /**
  74943. * Does the material work in alpha test mode
  74944. */
  74945. needAlphaTesting: boolean;
  74946. /**
  74947. * The list of attribute names used in the shader
  74948. */
  74949. attributes: string[];
  74950. /**
  74951. * The list of unifrom names used in the shader
  74952. */
  74953. uniforms: string[];
  74954. /**
  74955. * The list of UBO names used in the shader
  74956. */
  74957. uniformBuffers: string[];
  74958. /**
  74959. * The list of sampler names used in the shader
  74960. */
  74961. samplers: string[];
  74962. /**
  74963. * The list of defines used in the shader
  74964. */
  74965. defines: string[];
  74966. }
  74967. /**
  74968. * 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.
  74969. *
  74970. * This returned material effects how the mesh will look based on the code in the shaders.
  74971. *
  74972. * @see http://doc.babylonjs.com/how_to/shader_material
  74973. */
  74974. export class ShaderMaterial extends Material {
  74975. private _shaderPath;
  74976. private _options;
  74977. private _textures;
  74978. private _textureArrays;
  74979. private _floats;
  74980. private _ints;
  74981. private _floatsArrays;
  74982. private _colors3;
  74983. private _colors3Arrays;
  74984. private _colors4;
  74985. private _colors4Arrays;
  74986. private _vectors2;
  74987. private _vectors3;
  74988. private _vectors4;
  74989. private _matrices;
  74990. private _matrices3x3;
  74991. private _matrices2x2;
  74992. private _vectors2Arrays;
  74993. private _vectors3Arrays;
  74994. private _vectors4Arrays;
  74995. private _cachedWorldViewMatrix;
  74996. private _cachedWorldViewProjectionMatrix;
  74997. private _renderId;
  74998. /**
  74999. * Instantiate a new shader material.
  75000. * 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.
  75001. * This returned material effects how the mesh will look based on the code in the shaders.
  75002. * @see http://doc.babylonjs.com/how_to/shader_material
  75003. * @param name Define the name of the material in the scene
  75004. * @param scene Define the scene the material belongs to
  75005. * @param shaderPath Defines the route to the shader code in one of three ways:
  75006. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  75007. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  75008. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  75009. * @param options Define the options used to create the shader
  75010. */
  75011. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  75012. /**
  75013. * Gets the options used to compile the shader.
  75014. * They can be modified to trigger a new compilation
  75015. */
  75016. readonly options: IShaderMaterialOptions;
  75017. /**
  75018. * Gets the current class name of the material e.g. "ShaderMaterial"
  75019. * Mainly use in serialization.
  75020. * @returns the class name
  75021. */
  75022. getClassName(): string;
  75023. /**
  75024. * Specifies if the material will require alpha blending
  75025. * @returns a boolean specifying if alpha blending is needed
  75026. */
  75027. needAlphaBlending(): boolean;
  75028. /**
  75029. * Specifies if this material should be rendered in alpha test mode
  75030. * @returns a boolean specifying if an alpha test is needed.
  75031. */
  75032. needAlphaTesting(): boolean;
  75033. private _checkUniform;
  75034. /**
  75035. * Set a texture in the shader.
  75036. * @param name Define the name of the uniform samplers as defined in the shader
  75037. * @param texture Define the texture to bind to this sampler
  75038. * @return the material itself allowing "fluent" like uniform updates
  75039. */
  75040. setTexture(name: string, texture: Texture): ShaderMaterial;
  75041. /**
  75042. * Set a texture array in the shader.
  75043. * @param name Define the name of the uniform sampler array as defined in the shader
  75044. * @param textures Define the list of textures to bind to this sampler
  75045. * @return the material itself allowing "fluent" like uniform updates
  75046. */
  75047. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  75048. /**
  75049. * Set a float in the shader.
  75050. * @param name Define the name of the uniform as defined in the shader
  75051. * @param value Define the value to give to the uniform
  75052. * @return the material itself allowing "fluent" like uniform updates
  75053. */
  75054. setFloat(name: string, value: number): ShaderMaterial;
  75055. /**
  75056. * Set a int in the shader.
  75057. * @param name Define the name of the uniform as defined in the shader
  75058. * @param value Define the value to give to the uniform
  75059. * @return the material itself allowing "fluent" like uniform updates
  75060. */
  75061. setInt(name: string, value: number): ShaderMaterial;
  75062. /**
  75063. * Set an array of floats in the shader.
  75064. * @param name Define the name of the uniform as defined in the shader
  75065. * @param value Define the value to give to the uniform
  75066. * @return the material itself allowing "fluent" like uniform updates
  75067. */
  75068. setFloats(name: string, value: number[]): ShaderMaterial;
  75069. /**
  75070. * Set a vec3 in the shader from a Color3.
  75071. * @param name Define the name of the uniform as defined in the shader
  75072. * @param value Define the value to give to the uniform
  75073. * @return the material itself allowing "fluent" like uniform updates
  75074. */
  75075. setColor3(name: string, value: Color3): ShaderMaterial;
  75076. /**
  75077. * Set a vec3 array in the shader from a Color3 array.
  75078. * @param name Define the name of the uniform as defined in the shader
  75079. * @param value Define the value to give to the uniform
  75080. * @return the material itself allowing "fluent" like uniform updates
  75081. */
  75082. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75083. /**
  75084. * Set a vec4 in the shader from a Color4.
  75085. * @param name Define the name of the uniform as defined in the shader
  75086. * @param value Define the value to give to the uniform
  75087. * @return the material itself allowing "fluent" like uniform updates
  75088. */
  75089. setColor4(name: string, value: Color4): ShaderMaterial;
  75090. /**
  75091. * Set a vec4 array in the shader from a Color4 array.
  75092. * @param name Define the name of the uniform as defined in the shader
  75093. * @param value Define the value to give to the uniform
  75094. * @return the material itself allowing "fluent" like uniform updates
  75095. */
  75096. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  75097. /**
  75098. * Set a vec2 in the shader from a Vector2.
  75099. * @param name Define the name of the uniform as defined in the shader
  75100. * @param value Define the value to give to the uniform
  75101. * @return the material itself allowing "fluent" like uniform updates
  75102. */
  75103. setVector2(name: string, value: Vector2): ShaderMaterial;
  75104. /**
  75105. * Set a vec3 in the shader from a Vector3.
  75106. * @param name Define the name of the uniform as defined in the shader
  75107. * @param value Define the value to give to the uniform
  75108. * @return the material itself allowing "fluent" like uniform updates
  75109. */
  75110. setVector3(name: string, value: Vector3): ShaderMaterial;
  75111. /**
  75112. * Set a vec4 in the shader from a Vector4.
  75113. * @param name Define the name of the uniform as defined in the shader
  75114. * @param value Define the value to give to the uniform
  75115. * @return the material itself allowing "fluent" like uniform updates
  75116. */
  75117. setVector4(name: string, value: Vector4): ShaderMaterial;
  75118. /**
  75119. * Set a mat4 in the shader from a Matrix.
  75120. * @param name Define the name of the uniform as defined in the shader
  75121. * @param value Define the value to give to the uniform
  75122. * @return the material itself allowing "fluent" like uniform updates
  75123. */
  75124. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75125. /**
  75126. * Set a mat3 in the shader from a Float32Array.
  75127. * @param name Define the name of the uniform as defined in the shader
  75128. * @param value Define the value to give to the uniform
  75129. * @return the material itself allowing "fluent" like uniform updates
  75130. */
  75131. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75132. /**
  75133. * Set a mat2 in the shader from a Float32Array.
  75134. * @param name Define the name of the uniform as defined in the shader
  75135. * @param value Define the value to give to the uniform
  75136. * @return the material itself allowing "fluent" like uniform updates
  75137. */
  75138. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75139. /**
  75140. * Set a vec2 array in the shader from a number array.
  75141. * @param name Define the name of the uniform as defined in the shader
  75142. * @param value Define the value to give to the uniform
  75143. * @return the material itself allowing "fluent" like uniform updates
  75144. */
  75145. setArray2(name: string, value: number[]): ShaderMaterial;
  75146. /**
  75147. * Set a vec3 array in the shader from a number array.
  75148. * @param name Define the name of the uniform as defined in the shader
  75149. * @param value Define the value to give to the uniform
  75150. * @return the material itself allowing "fluent" like uniform updates
  75151. */
  75152. setArray3(name: string, value: number[]): ShaderMaterial;
  75153. /**
  75154. * Set a vec4 array in the shader from a number array.
  75155. * @param name Define the name of the uniform as defined in the shader
  75156. * @param value Define the value to give to the uniform
  75157. * @return the material itself allowing "fluent" like uniform updates
  75158. */
  75159. setArray4(name: string, value: number[]): ShaderMaterial;
  75160. private _checkCache;
  75161. /**
  75162. * Specifies that the submesh is ready to be used
  75163. * @param mesh defines the mesh to check
  75164. * @param subMesh defines which submesh to check
  75165. * @param useInstances specifies that instances should be used
  75166. * @returns a boolean indicating that the submesh is ready or not
  75167. */
  75168. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75169. /**
  75170. * Checks if the material is ready to render the requested mesh
  75171. * @param mesh Define the mesh to render
  75172. * @param useInstances Define whether or not the material is used with instances
  75173. * @returns true if ready, otherwise false
  75174. */
  75175. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75176. /**
  75177. * Binds the world matrix to the material
  75178. * @param world defines the world transformation matrix
  75179. */
  75180. bindOnlyWorldMatrix(world: Matrix): void;
  75181. /**
  75182. * Binds the material to the mesh
  75183. * @param world defines the world transformation matrix
  75184. * @param mesh defines the mesh to bind the material to
  75185. */
  75186. bind(world: Matrix, mesh?: Mesh): void;
  75187. /**
  75188. * Gets the active textures from the material
  75189. * @returns an array of textures
  75190. */
  75191. getActiveTextures(): BaseTexture[];
  75192. /**
  75193. * Specifies if the material uses a texture
  75194. * @param texture defines the texture to check against the material
  75195. * @returns a boolean specifying if the material uses the texture
  75196. */
  75197. hasTexture(texture: BaseTexture): boolean;
  75198. /**
  75199. * Makes a duplicate of the material, and gives it a new name
  75200. * @param name defines the new name for the duplicated material
  75201. * @returns the cloned material
  75202. */
  75203. clone(name: string): ShaderMaterial;
  75204. /**
  75205. * Disposes the material
  75206. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75207. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75208. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75209. */
  75210. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75211. /**
  75212. * Serializes this material in a JSON representation
  75213. * @returns the serialized material object
  75214. */
  75215. serialize(): any;
  75216. /**
  75217. * Creates a shader material from parsed shader material data
  75218. * @param source defines the JSON represnetation of the material
  75219. * @param scene defines the hosting scene
  75220. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75221. * @returns a new material
  75222. */
  75223. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75224. }
  75225. }
  75226. declare module BABYLON {
  75227. /** @hidden */
  75228. export var clipPlaneFragmentDeclaration: {
  75229. name: string;
  75230. shader: string;
  75231. };
  75232. }
  75233. declare module BABYLON {
  75234. /** @hidden */
  75235. export var clipPlaneFragment: {
  75236. name: string;
  75237. shader: string;
  75238. };
  75239. }
  75240. declare module BABYLON {
  75241. /** @hidden */
  75242. export var colorPixelShader: {
  75243. name: string;
  75244. shader: string;
  75245. };
  75246. }
  75247. declare module BABYLON {
  75248. /** @hidden */
  75249. export var clipPlaneVertexDeclaration: {
  75250. name: string;
  75251. shader: string;
  75252. };
  75253. }
  75254. declare module BABYLON {
  75255. /** @hidden */
  75256. export var clipPlaneVertex: {
  75257. name: string;
  75258. shader: string;
  75259. };
  75260. }
  75261. declare module BABYLON {
  75262. /** @hidden */
  75263. export var colorVertexShader: {
  75264. name: string;
  75265. shader: string;
  75266. };
  75267. }
  75268. declare module BABYLON {
  75269. /**
  75270. * Line mesh
  75271. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75272. */
  75273. export class LinesMesh extends Mesh {
  75274. /**
  75275. * If vertex color should be applied to the mesh
  75276. */
  75277. readonly useVertexColor?: boolean | undefined;
  75278. /**
  75279. * If vertex alpha should be applied to the mesh
  75280. */
  75281. readonly useVertexAlpha?: boolean | undefined;
  75282. /**
  75283. * Color of the line (Default: White)
  75284. */
  75285. color: Color3;
  75286. /**
  75287. * Alpha of the line (Default: 1)
  75288. */
  75289. alpha: number;
  75290. /**
  75291. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75292. * This margin is expressed in world space coordinates, so its value may vary.
  75293. * Default value is 0.1
  75294. */
  75295. intersectionThreshold: number;
  75296. private _colorShader;
  75297. private color4;
  75298. /**
  75299. * Creates a new LinesMesh
  75300. * @param name defines the name
  75301. * @param scene defines the hosting scene
  75302. * @param parent defines the parent mesh if any
  75303. * @param source defines the optional source LinesMesh used to clone data from
  75304. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75305. * When false, achieved by calling a clone(), also passing False.
  75306. * This will make creation of children, recursive.
  75307. * @param useVertexColor defines if this LinesMesh supports vertex color
  75308. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75309. */
  75310. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75311. /**
  75312. * If vertex color should be applied to the mesh
  75313. */
  75314. useVertexColor?: boolean | undefined,
  75315. /**
  75316. * If vertex alpha should be applied to the mesh
  75317. */
  75318. useVertexAlpha?: boolean | undefined);
  75319. private _addClipPlaneDefine;
  75320. private _removeClipPlaneDefine;
  75321. isReady(): boolean;
  75322. /**
  75323. * Returns the string "LineMesh"
  75324. */
  75325. getClassName(): string;
  75326. /**
  75327. * @hidden
  75328. */
  75329. /**
  75330. * @hidden
  75331. */
  75332. material: Material;
  75333. /**
  75334. * @hidden
  75335. */
  75336. readonly checkCollisions: boolean;
  75337. /** @hidden */
  75338. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75339. /** @hidden */
  75340. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75341. /**
  75342. * Disposes of the line mesh
  75343. * @param doNotRecurse If children should be disposed
  75344. */
  75345. dispose(doNotRecurse?: boolean): void;
  75346. /**
  75347. * Returns a new LineMesh object cloned from the current one.
  75348. */
  75349. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75350. /**
  75351. * Creates a new InstancedLinesMesh object from the mesh model.
  75352. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75353. * @param name defines the name of the new instance
  75354. * @returns a new InstancedLinesMesh
  75355. */
  75356. createInstance(name: string): InstancedLinesMesh;
  75357. }
  75358. /**
  75359. * Creates an instance based on a source LinesMesh
  75360. */
  75361. export class InstancedLinesMesh extends InstancedMesh {
  75362. /**
  75363. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75364. * This margin is expressed in world space coordinates, so its value may vary.
  75365. * Initilized with the intersectionThreshold value of the source LinesMesh
  75366. */
  75367. intersectionThreshold: number;
  75368. constructor(name: string, source: LinesMesh);
  75369. /**
  75370. * Returns the string "InstancedLinesMesh".
  75371. */
  75372. getClassName(): string;
  75373. }
  75374. }
  75375. declare module BABYLON {
  75376. /**
  75377. * Mesh representing the gorund
  75378. */
  75379. export class GroundMesh extends Mesh {
  75380. /** If octree should be generated */
  75381. generateOctree: boolean;
  75382. private _heightQuads;
  75383. /** @hidden */
  75384. _subdivisionsX: number;
  75385. /** @hidden */
  75386. _subdivisionsY: number;
  75387. /** @hidden */
  75388. _width: number;
  75389. /** @hidden */
  75390. _height: number;
  75391. /** @hidden */
  75392. _minX: number;
  75393. /** @hidden */
  75394. _maxX: number;
  75395. /** @hidden */
  75396. _minZ: number;
  75397. /** @hidden */
  75398. _maxZ: number;
  75399. constructor(name: string, scene: Scene);
  75400. /**
  75401. * "GroundMesh"
  75402. * @returns "GroundMesh"
  75403. */
  75404. getClassName(): string;
  75405. /**
  75406. * The minimum of x and y subdivisions
  75407. */
  75408. readonly subdivisions: number;
  75409. /**
  75410. * X subdivisions
  75411. */
  75412. readonly subdivisionsX: number;
  75413. /**
  75414. * Y subdivisions
  75415. */
  75416. readonly subdivisionsY: number;
  75417. /**
  75418. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75419. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75420. * @param chunksCount the number of subdivisions for x and y
  75421. * @param octreeBlocksSize (Default: 32)
  75422. */
  75423. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75424. /**
  75425. * Returns a height (y) value in the Worl system :
  75426. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75427. * @param x x coordinate
  75428. * @param z z coordinate
  75429. * @returns the ground y position if (x, z) are outside the ground surface.
  75430. */
  75431. getHeightAtCoordinates(x: number, z: number): number;
  75432. /**
  75433. * Returns a normalized vector (Vector3) orthogonal to the ground
  75434. * at the ground coordinates (x, z) expressed in the World system.
  75435. * @param x x coordinate
  75436. * @param z z coordinate
  75437. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75438. */
  75439. getNormalAtCoordinates(x: number, z: number): Vector3;
  75440. /**
  75441. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75442. * at the ground coordinates (x, z) expressed in the World system.
  75443. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75444. * @param x x coordinate
  75445. * @param z z coordinate
  75446. * @param ref vector to store the result
  75447. * @returns the GroundMesh.
  75448. */
  75449. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75450. /**
  75451. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75452. * if the ground has been updated.
  75453. * This can be used in the render loop.
  75454. * @returns the GroundMesh.
  75455. */
  75456. updateCoordinateHeights(): GroundMesh;
  75457. private _getFacetAt;
  75458. private _initHeightQuads;
  75459. private _computeHeightQuads;
  75460. /**
  75461. * Serializes this ground mesh
  75462. * @param serializationObject object to write serialization to
  75463. */
  75464. serialize(serializationObject: any): void;
  75465. /**
  75466. * Parses a serialized ground mesh
  75467. * @param parsedMesh the serialized mesh
  75468. * @param scene the scene to create the ground mesh in
  75469. * @returns the created ground mesh
  75470. */
  75471. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75472. }
  75473. }
  75474. declare module BABYLON {
  75475. /**
  75476. * Interface for Physics-Joint data
  75477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75478. */
  75479. export interface PhysicsJointData {
  75480. /**
  75481. * The main pivot of the joint
  75482. */
  75483. mainPivot?: Vector3;
  75484. /**
  75485. * The connected pivot of the joint
  75486. */
  75487. connectedPivot?: Vector3;
  75488. /**
  75489. * The main axis of the joint
  75490. */
  75491. mainAxis?: Vector3;
  75492. /**
  75493. * The connected axis of the joint
  75494. */
  75495. connectedAxis?: Vector3;
  75496. /**
  75497. * The collision of the joint
  75498. */
  75499. collision?: boolean;
  75500. /**
  75501. * Native Oimo/Cannon/Energy data
  75502. */
  75503. nativeParams?: any;
  75504. }
  75505. /**
  75506. * This is a holder class for the physics joint created by the physics plugin
  75507. * It holds a set of functions to control the underlying joint
  75508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75509. */
  75510. export class PhysicsJoint {
  75511. /**
  75512. * The type of the physics joint
  75513. */
  75514. type: number;
  75515. /**
  75516. * The data for the physics joint
  75517. */
  75518. jointData: PhysicsJointData;
  75519. private _physicsJoint;
  75520. protected _physicsPlugin: IPhysicsEnginePlugin;
  75521. /**
  75522. * Initializes the physics joint
  75523. * @param type The type of the physics joint
  75524. * @param jointData The data for the physics joint
  75525. */
  75526. constructor(
  75527. /**
  75528. * The type of the physics joint
  75529. */
  75530. type: number,
  75531. /**
  75532. * The data for the physics joint
  75533. */
  75534. jointData: PhysicsJointData);
  75535. /**
  75536. * Gets the physics joint
  75537. */
  75538. /**
  75539. * Sets the physics joint
  75540. */
  75541. physicsJoint: any;
  75542. /**
  75543. * Sets the physics plugin
  75544. */
  75545. physicsPlugin: IPhysicsEnginePlugin;
  75546. /**
  75547. * Execute a function that is physics-plugin specific.
  75548. * @param {Function} func the function that will be executed.
  75549. * It accepts two parameters: the physics world and the physics joint
  75550. */
  75551. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75552. /**
  75553. * Distance-Joint type
  75554. */
  75555. static DistanceJoint: number;
  75556. /**
  75557. * Hinge-Joint type
  75558. */
  75559. static HingeJoint: number;
  75560. /**
  75561. * Ball-and-Socket joint type
  75562. */
  75563. static BallAndSocketJoint: number;
  75564. /**
  75565. * Wheel-Joint type
  75566. */
  75567. static WheelJoint: number;
  75568. /**
  75569. * Slider-Joint type
  75570. */
  75571. static SliderJoint: number;
  75572. /**
  75573. * Prismatic-Joint type
  75574. */
  75575. static PrismaticJoint: number;
  75576. /**
  75577. * Universal-Joint type
  75578. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75579. */
  75580. static UniversalJoint: number;
  75581. /**
  75582. * Hinge-Joint 2 type
  75583. */
  75584. static Hinge2Joint: number;
  75585. /**
  75586. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75587. */
  75588. static PointToPointJoint: number;
  75589. /**
  75590. * Spring-Joint type
  75591. */
  75592. static SpringJoint: number;
  75593. /**
  75594. * Lock-Joint type
  75595. */
  75596. static LockJoint: number;
  75597. }
  75598. /**
  75599. * A class representing a physics distance joint
  75600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75601. */
  75602. export class DistanceJoint extends PhysicsJoint {
  75603. /**
  75604. *
  75605. * @param jointData The data for the Distance-Joint
  75606. */
  75607. constructor(jointData: DistanceJointData);
  75608. /**
  75609. * Update the predefined distance.
  75610. * @param maxDistance The maximum preferred distance
  75611. * @param minDistance The minimum preferred distance
  75612. */
  75613. updateDistance(maxDistance: number, minDistance?: number): void;
  75614. }
  75615. /**
  75616. * Represents a Motor-Enabled Joint
  75617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75618. */
  75619. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75620. /**
  75621. * Initializes the Motor-Enabled Joint
  75622. * @param type The type of the joint
  75623. * @param jointData The physica joint data for the joint
  75624. */
  75625. constructor(type: number, jointData: PhysicsJointData);
  75626. /**
  75627. * Set the motor values.
  75628. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75629. * @param force the force to apply
  75630. * @param maxForce max force for this motor.
  75631. */
  75632. setMotor(force?: number, maxForce?: number): void;
  75633. /**
  75634. * Set the motor's limits.
  75635. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75636. * @param upperLimit The upper limit of the motor
  75637. * @param lowerLimit The lower limit of the motor
  75638. */
  75639. setLimit(upperLimit: number, lowerLimit?: number): void;
  75640. }
  75641. /**
  75642. * This class represents a single physics Hinge-Joint
  75643. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75644. */
  75645. export class HingeJoint extends MotorEnabledJoint {
  75646. /**
  75647. * Initializes the Hinge-Joint
  75648. * @param jointData The joint data for the Hinge-Joint
  75649. */
  75650. constructor(jointData: PhysicsJointData);
  75651. /**
  75652. * Set the motor values.
  75653. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75654. * @param {number} force the force to apply
  75655. * @param {number} maxForce max force for this motor.
  75656. */
  75657. setMotor(force?: number, maxForce?: number): void;
  75658. /**
  75659. * Set the motor's limits.
  75660. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75661. * @param upperLimit The upper limit of the motor
  75662. * @param lowerLimit The lower limit of the motor
  75663. */
  75664. setLimit(upperLimit: number, lowerLimit?: number): void;
  75665. }
  75666. /**
  75667. * This class represents a dual hinge physics joint (same as wheel joint)
  75668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75669. */
  75670. export class Hinge2Joint extends MotorEnabledJoint {
  75671. /**
  75672. * Initializes the Hinge2-Joint
  75673. * @param jointData The joint data for the Hinge2-Joint
  75674. */
  75675. constructor(jointData: PhysicsJointData);
  75676. /**
  75677. * Set the motor values.
  75678. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75679. * @param {number} targetSpeed the speed the motor is to reach
  75680. * @param {number} maxForce max force for this motor.
  75681. * @param {motorIndex} the motor's index, 0 or 1.
  75682. */
  75683. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  75684. /**
  75685. * Set the motor limits.
  75686. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75687. * @param {number} upperLimit the upper limit
  75688. * @param {number} lowerLimit lower limit
  75689. * @param {motorIndex} the motor's index, 0 or 1.
  75690. */
  75691. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75692. }
  75693. /**
  75694. * Interface for a motor enabled joint
  75695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75696. */
  75697. export interface IMotorEnabledJoint {
  75698. /**
  75699. * Physics joint
  75700. */
  75701. physicsJoint: any;
  75702. /**
  75703. * Sets the motor of the motor-enabled joint
  75704. * @param force The force of the motor
  75705. * @param maxForce The maximum force of the motor
  75706. * @param motorIndex The index of the motor
  75707. */
  75708. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  75709. /**
  75710. * Sets the limit of the motor
  75711. * @param upperLimit The upper limit of the motor
  75712. * @param lowerLimit The lower limit of the motor
  75713. * @param motorIndex The index of the motor
  75714. */
  75715. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75716. }
  75717. /**
  75718. * Joint data for a Distance-Joint
  75719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75720. */
  75721. export interface DistanceJointData extends PhysicsJointData {
  75722. /**
  75723. * Max distance the 2 joint objects can be apart
  75724. */
  75725. maxDistance: number;
  75726. }
  75727. /**
  75728. * Joint data from a spring joint
  75729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75730. */
  75731. export interface SpringJointData extends PhysicsJointData {
  75732. /**
  75733. * Length of the spring
  75734. */
  75735. length: number;
  75736. /**
  75737. * Stiffness of the spring
  75738. */
  75739. stiffness: number;
  75740. /**
  75741. * Damping of the spring
  75742. */
  75743. damping: number;
  75744. /** this callback will be called when applying the force to the impostors. */
  75745. forceApplicationCallback: () => void;
  75746. }
  75747. }
  75748. declare module BABYLON {
  75749. /**
  75750. * Holds the data for the raycast result
  75751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75752. */
  75753. export class PhysicsRaycastResult {
  75754. private _hasHit;
  75755. private _hitDistance;
  75756. private _hitNormalWorld;
  75757. private _hitPointWorld;
  75758. private _rayFromWorld;
  75759. private _rayToWorld;
  75760. /**
  75761. * Gets if there was a hit
  75762. */
  75763. readonly hasHit: boolean;
  75764. /**
  75765. * Gets the distance from the hit
  75766. */
  75767. readonly hitDistance: number;
  75768. /**
  75769. * Gets the hit normal/direction in the world
  75770. */
  75771. readonly hitNormalWorld: Vector3;
  75772. /**
  75773. * Gets the hit point in the world
  75774. */
  75775. readonly hitPointWorld: Vector3;
  75776. /**
  75777. * Gets the ray "start point" of the ray in the world
  75778. */
  75779. readonly rayFromWorld: Vector3;
  75780. /**
  75781. * Gets the ray "end point" of the ray in the world
  75782. */
  75783. readonly rayToWorld: Vector3;
  75784. /**
  75785. * Sets the hit data (normal & point in world space)
  75786. * @param hitNormalWorld defines the normal in world space
  75787. * @param hitPointWorld defines the point in world space
  75788. */
  75789. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  75790. /**
  75791. * Sets the distance from the start point to the hit point
  75792. * @param distance
  75793. */
  75794. setHitDistance(distance: number): void;
  75795. /**
  75796. * Calculates the distance manually
  75797. */
  75798. calculateHitDistance(): void;
  75799. /**
  75800. * Resets all the values to default
  75801. * @param from The from point on world space
  75802. * @param to The to point on world space
  75803. */
  75804. reset(from?: Vector3, to?: Vector3): void;
  75805. }
  75806. /**
  75807. * Interface for the size containing width and height
  75808. */
  75809. interface IXYZ {
  75810. /**
  75811. * X
  75812. */
  75813. x: number;
  75814. /**
  75815. * Y
  75816. */
  75817. y: number;
  75818. /**
  75819. * Z
  75820. */
  75821. z: number;
  75822. }
  75823. }
  75824. declare module BABYLON {
  75825. /**
  75826. * Interface used to describe a physics joint
  75827. */
  75828. export interface PhysicsImpostorJoint {
  75829. /** Defines the main impostor to which the joint is linked */
  75830. mainImpostor: PhysicsImpostor;
  75831. /** Defines the impostor that is connected to the main impostor using this joint */
  75832. connectedImpostor: PhysicsImpostor;
  75833. /** Defines the joint itself */
  75834. joint: PhysicsJoint;
  75835. }
  75836. /** @hidden */
  75837. export interface IPhysicsEnginePlugin {
  75838. world: any;
  75839. name: string;
  75840. setGravity(gravity: Vector3): void;
  75841. setTimeStep(timeStep: number): void;
  75842. getTimeStep(): number;
  75843. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  75844. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75845. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75846. generatePhysicsBody(impostor: PhysicsImpostor): void;
  75847. removePhysicsBody(impostor: PhysicsImpostor): void;
  75848. generateJoint(joint: PhysicsImpostorJoint): void;
  75849. removeJoint(joint: PhysicsImpostorJoint): void;
  75850. isSupported(): boolean;
  75851. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  75852. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  75853. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75854. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75855. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75856. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75857. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  75858. getBodyMass(impostor: PhysicsImpostor): number;
  75859. getBodyFriction(impostor: PhysicsImpostor): number;
  75860. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  75861. getBodyRestitution(impostor: PhysicsImpostor): number;
  75862. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  75863. getBodyPressure?(impostor: PhysicsImpostor): number;
  75864. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  75865. getBodyStiffness?(impostor: PhysicsImpostor): number;
  75866. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  75867. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  75868. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  75869. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  75870. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  75871. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  75872. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  75873. sleepBody(impostor: PhysicsImpostor): void;
  75874. wakeUpBody(impostor: PhysicsImpostor): void;
  75875. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  75876. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  75877. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  75878. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75879. getRadius(impostor: PhysicsImpostor): number;
  75880. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  75881. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  75882. dispose(): void;
  75883. }
  75884. /**
  75885. * Interface used to define a physics engine
  75886. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  75887. */
  75888. export interface IPhysicsEngine {
  75889. /**
  75890. * Gets the gravity vector used by the simulation
  75891. */
  75892. gravity: Vector3;
  75893. /**
  75894. * Sets the gravity vector used by the simulation
  75895. * @param gravity defines the gravity vector to use
  75896. */
  75897. setGravity(gravity: Vector3): void;
  75898. /**
  75899. * Set the time step of the physics engine.
  75900. * Default is 1/60.
  75901. * To slow it down, enter 1/600 for example.
  75902. * To speed it up, 1/30
  75903. * @param newTimeStep the new timestep to apply to this world.
  75904. */
  75905. setTimeStep(newTimeStep: number): void;
  75906. /**
  75907. * Get the time step of the physics engine.
  75908. * @returns the current time step
  75909. */
  75910. getTimeStep(): number;
  75911. /**
  75912. * Release all resources
  75913. */
  75914. dispose(): void;
  75915. /**
  75916. * Gets the name of the current physics plugin
  75917. * @returns the name of the plugin
  75918. */
  75919. getPhysicsPluginName(): string;
  75920. /**
  75921. * Adding a new impostor for the impostor tracking.
  75922. * This will be done by the impostor itself.
  75923. * @param impostor the impostor to add
  75924. */
  75925. addImpostor(impostor: PhysicsImpostor): void;
  75926. /**
  75927. * Remove an impostor from the engine.
  75928. * This impostor and its mesh will not longer be updated by the physics engine.
  75929. * @param impostor the impostor to remove
  75930. */
  75931. removeImpostor(impostor: PhysicsImpostor): void;
  75932. /**
  75933. * Add a joint to the physics engine
  75934. * @param mainImpostor defines the main impostor to which the joint is added.
  75935. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  75936. * @param joint defines the joint that will connect both impostors.
  75937. */
  75938. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75939. /**
  75940. * Removes a joint from the simulation
  75941. * @param mainImpostor defines the impostor used with the joint
  75942. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  75943. * @param joint defines the joint to remove
  75944. */
  75945. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75946. /**
  75947. * Gets the current plugin used to run the simulation
  75948. * @returns current plugin
  75949. */
  75950. getPhysicsPlugin(): IPhysicsEnginePlugin;
  75951. /**
  75952. * Gets the list of physic impostors
  75953. * @returns an array of PhysicsImpostor
  75954. */
  75955. getImpostors(): Array<PhysicsImpostor>;
  75956. /**
  75957. * Gets the impostor for a physics enabled object
  75958. * @param object defines the object impersonated by the impostor
  75959. * @returns the PhysicsImpostor or null if not found
  75960. */
  75961. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  75962. /**
  75963. * Gets the impostor for a physics body object
  75964. * @param body defines physics body used by the impostor
  75965. * @returns the PhysicsImpostor or null if not found
  75966. */
  75967. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  75968. /**
  75969. * Does a raycast in the physics world
  75970. * @param from when should the ray start?
  75971. * @param to when should the ray end?
  75972. * @returns PhysicsRaycastResult
  75973. */
  75974. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  75975. /**
  75976. * Called by the scene. No need to call it.
  75977. * @param delta defines the timespam between frames
  75978. */
  75979. _step(delta: number): void;
  75980. }
  75981. }
  75982. declare module BABYLON {
  75983. /**
  75984. * The interface for the physics imposter parameters
  75985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75986. */
  75987. export interface PhysicsImpostorParameters {
  75988. /**
  75989. * The mass of the physics imposter
  75990. */
  75991. mass: number;
  75992. /**
  75993. * The friction of the physics imposter
  75994. */
  75995. friction?: number;
  75996. /**
  75997. * The coefficient of restitution of the physics imposter
  75998. */
  75999. restitution?: number;
  76000. /**
  76001. * The native options of the physics imposter
  76002. */
  76003. nativeOptions?: any;
  76004. /**
  76005. * Specifies if the parent should be ignored
  76006. */
  76007. ignoreParent?: boolean;
  76008. /**
  76009. * Specifies if bi-directional transformations should be disabled
  76010. */
  76011. disableBidirectionalTransformation?: boolean;
  76012. /**
  76013. * The pressure inside the physics imposter, soft object only
  76014. */
  76015. pressure?: number;
  76016. /**
  76017. * The stiffness the physics imposter, soft object only
  76018. */
  76019. stiffness?: number;
  76020. /**
  76021. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  76022. */
  76023. velocityIterations?: number;
  76024. /**
  76025. * The number of iterations used in maintaining consistent vertex positions, soft object only
  76026. */
  76027. positionIterations?: number;
  76028. /**
  76029. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  76030. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  76031. * Add to fix multiple points
  76032. */
  76033. fixedPoints?: number;
  76034. /**
  76035. * The collision margin around a soft object
  76036. */
  76037. margin?: number;
  76038. /**
  76039. * The collision margin around a soft object
  76040. */
  76041. damping?: number;
  76042. /**
  76043. * The path for a rope based on an extrusion
  76044. */
  76045. path?: any;
  76046. /**
  76047. * The shape of an extrusion used for a rope based on an extrusion
  76048. */
  76049. shape?: any;
  76050. }
  76051. /**
  76052. * Interface for a physics-enabled object
  76053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76054. */
  76055. export interface IPhysicsEnabledObject {
  76056. /**
  76057. * The position of the physics-enabled object
  76058. */
  76059. position: Vector3;
  76060. /**
  76061. * The rotation of the physics-enabled object
  76062. */
  76063. rotationQuaternion: Nullable<Quaternion>;
  76064. /**
  76065. * The scale of the physics-enabled object
  76066. */
  76067. scaling: Vector3;
  76068. /**
  76069. * The rotation of the physics-enabled object
  76070. */
  76071. rotation?: Vector3;
  76072. /**
  76073. * The parent of the physics-enabled object
  76074. */
  76075. parent?: any;
  76076. /**
  76077. * The bounding info of the physics-enabled object
  76078. * @returns The bounding info of the physics-enabled object
  76079. */
  76080. getBoundingInfo(): BoundingInfo;
  76081. /**
  76082. * Computes the world matrix
  76083. * @param force Specifies if the world matrix should be computed by force
  76084. * @returns A world matrix
  76085. */
  76086. computeWorldMatrix(force: boolean): Matrix;
  76087. /**
  76088. * Gets the world matrix
  76089. * @returns A world matrix
  76090. */
  76091. getWorldMatrix?(): Matrix;
  76092. /**
  76093. * Gets the child meshes
  76094. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76095. * @returns An array of abstract meshes
  76096. */
  76097. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76098. /**
  76099. * Gets the vertex data
  76100. * @param kind The type of vertex data
  76101. * @returns A nullable array of numbers, or a float32 array
  76102. */
  76103. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76104. /**
  76105. * Gets the indices from the mesh
  76106. * @returns A nullable array of index arrays
  76107. */
  76108. getIndices?(): Nullable<IndicesArray>;
  76109. /**
  76110. * Gets the scene from the mesh
  76111. * @returns the indices array or null
  76112. */
  76113. getScene?(): Scene;
  76114. /**
  76115. * Gets the absolute position from the mesh
  76116. * @returns the absolute position
  76117. */
  76118. getAbsolutePosition(): Vector3;
  76119. /**
  76120. * Gets the absolute pivot point from the mesh
  76121. * @returns the absolute pivot point
  76122. */
  76123. getAbsolutePivotPoint(): Vector3;
  76124. /**
  76125. * Rotates the mesh
  76126. * @param axis The axis of rotation
  76127. * @param amount The amount of rotation
  76128. * @param space The space of the rotation
  76129. * @returns The rotation transform node
  76130. */
  76131. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76132. /**
  76133. * Translates the mesh
  76134. * @param axis The axis of translation
  76135. * @param distance The distance of translation
  76136. * @param space The space of the translation
  76137. * @returns The transform node
  76138. */
  76139. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76140. /**
  76141. * Sets the absolute position of the mesh
  76142. * @param absolutePosition The absolute position of the mesh
  76143. * @returns The transform node
  76144. */
  76145. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76146. /**
  76147. * Gets the class name of the mesh
  76148. * @returns The class name
  76149. */
  76150. getClassName(): string;
  76151. }
  76152. /**
  76153. * Represents a physics imposter
  76154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76155. */
  76156. export class PhysicsImpostor {
  76157. /**
  76158. * The physics-enabled object used as the physics imposter
  76159. */
  76160. object: IPhysicsEnabledObject;
  76161. /**
  76162. * The type of the physics imposter
  76163. */
  76164. type: number;
  76165. private _options;
  76166. private _scene?;
  76167. /**
  76168. * The default object size of the imposter
  76169. */
  76170. static DEFAULT_OBJECT_SIZE: Vector3;
  76171. /**
  76172. * The identity quaternion of the imposter
  76173. */
  76174. static IDENTITY_QUATERNION: Quaternion;
  76175. /** @hidden */
  76176. _pluginData: any;
  76177. private _physicsEngine;
  76178. private _physicsBody;
  76179. private _bodyUpdateRequired;
  76180. private _onBeforePhysicsStepCallbacks;
  76181. private _onAfterPhysicsStepCallbacks;
  76182. /** @hidden */
  76183. _onPhysicsCollideCallbacks: Array<{
  76184. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76185. otherImpostors: Array<PhysicsImpostor>;
  76186. }>;
  76187. private _deltaPosition;
  76188. private _deltaRotation;
  76189. private _deltaRotationConjugated;
  76190. /** @hidden */
  76191. _isFromLine: boolean;
  76192. private _parent;
  76193. private _isDisposed;
  76194. private static _tmpVecs;
  76195. private static _tmpQuat;
  76196. /**
  76197. * Specifies if the physics imposter is disposed
  76198. */
  76199. readonly isDisposed: boolean;
  76200. /**
  76201. * Gets the mass of the physics imposter
  76202. */
  76203. mass: number;
  76204. /**
  76205. * Gets the coefficient of friction
  76206. */
  76207. /**
  76208. * Sets the coefficient of friction
  76209. */
  76210. friction: number;
  76211. /**
  76212. * Gets the coefficient of restitution
  76213. */
  76214. /**
  76215. * Sets the coefficient of restitution
  76216. */
  76217. restitution: number;
  76218. /**
  76219. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  76220. */
  76221. /**
  76222. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  76223. */
  76224. pressure: number;
  76225. /**
  76226. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76227. */
  76228. /**
  76229. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76230. */
  76231. stiffness: number;
  76232. /**
  76233. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76234. */
  76235. /**
  76236. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76237. */
  76238. velocityIterations: number;
  76239. /**
  76240. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76241. */
  76242. /**
  76243. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76244. */
  76245. positionIterations: number;
  76246. /**
  76247. * The unique id of the physics imposter
  76248. * set by the physics engine when adding this impostor to the array
  76249. */
  76250. uniqueId: number;
  76251. /**
  76252. * @hidden
  76253. */
  76254. soft: boolean;
  76255. /**
  76256. * @hidden
  76257. */
  76258. segments: number;
  76259. private _joints;
  76260. /**
  76261. * Initializes the physics imposter
  76262. * @param object The physics-enabled object used as the physics imposter
  76263. * @param type The type of the physics imposter
  76264. * @param _options The options for the physics imposter
  76265. * @param _scene The Babylon scene
  76266. */
  76267. constructor(
  76268. /**
  76269. * The physics-enabled object used as the physics imposter
  76270. */
  76271. object: IPhysicsEnabledObject,
  76272. /**
  76273. * The type of the physics imposter
  76274. */
  76275. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76276. /**
  76277. * This function will completly initialize this impostor.
  76278. * It will create a new body - but only if this mesh has no parent.
  76279. * If it has, this impostor will not be used other than to define the impostor
  76280. * of the child mesh.
  76281. * @hidden
  76282. */
  76283. _init(): void;
  76284. private _getPhysicsParent;
  76285. /**
  76286. * Should a new body be generated.
  76287. * @returns boolean specifying if body initialization is required
  76288. */
  76289. isBodyInitRequired(): boolean;
  76290. /**
  76291. * Sets the updated scaling
  76292. * @param updated Specifies if the scaling is updated
  76293. */
  76294. setScalingUpdated(): void;
  76295. /**
  76296. * Force a regeneration of this or the parent's impostor's body.
  76297. * Use under cautious - This will remove all joints already implemented.
  76298. */
  76299. forceUpdate(): void;
  76300. /**
  76301. * Gets the body that holds this impostor. Either its own, or its parent.
  76302. */
  76303. /**
  76304. * Set the physics body. Used mainly by the physics engine/plugin
  76305. */
  76306. physicsBody: any;
  76307. /**
  76308. * Get the parent of the physics imposter
  76309. * @returns Physics imposter or null
  76310. */
  76311. /**
  76312. * Sets the parent of the physics imposter
  76313. */
  76314. parent: Nullable<PhysicsImpostor>;
  76315. /**
  76316. * Resets the update flags
  76317. */
  76318. resetUpdateFlags(): void;
  76319. /**
  76320. * Gets the object extend size
  76321. * @returns the object extend size
  76322. */
  76323. getObjectExtendSize(): Vector3;
  76324. /**
  76325. * Gets the object center
  76326. * @returns The object center
  76327. */
  76328. getObjectCenter(): Vector3;
  76329. /**
  76330. * Get a specific parametes from the options parameter
  76331. * @param paramName The object parameter name
  76332. * @returns The object parameter
  76333. */
  76334. getParam(paramName: string): any;
  76335. /**
  76336. * Sets a specific parameter in the options given to the physics plugin
  76337. * @param paramName The parameter name
  76338. * @param value The value of the parameter
  76339. */
  76340. setParam(paramName: string, value: number): void;
  76341. /**
  76342. * Specifically change the body's mass option. Won't recreate the physics body object
  76343. * @param mass The mass of the physics imposter
  76344. */
  76345. setMass(mass: number): void;
  76346. /**
  76347. * Gets the linear velocity
  76348. * @returns linear velocity or null
  76349. */
  76350. getLinearVelocity(): Nullable<Vector3>;
  76351. /**
  76352. * Sets the linear velocity
  76353. * @param velocity linear velocity or null
  76354. */
  76355. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76356. /**
  76357. * Gets the angular velocity
  76358. * @returns angular velocity or null
  76359. */
  76360. getAngularVelocity(): Nullable<Vector3>;
  76361. /**
  76362. * Sets the angular velocity
  76363. * @param velocity The velocity or null
  76364. */
  76365. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76366. /**
  76367. * Execute a function with the physics plugin native code
  76368. * Provide a function the will have two variables - the world object and the physics body object
  76369. * @param func The function to execute with the physics plugin native code
  76370. */
  76371. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76372. /**
  76373. * Register a function that will be executed before the physics world is stepping forward
  76374. * @param func The function to execute before the physics world is stepped forward
  76375. */
  76376. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76377. /**
  76378. * Unregister a function that will be executed before the physics world is stepping forward
  76379. * @param func The function to execute before the physics world is stepped forward
  76380. */
  76381. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76382. /**
  76383. * Register a function that will be executed after the physics step
  76384. * @param func The function to execute after physics step
  76385. */
  76386. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76387. /**
  76388. * Unregisters a function that will be executed after the physics step
  76389. * @param func The function to execute after physics step
  76390. */
  76391. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76392. /**
  76393. * register a function that will be executed when this impostor collides against a different body
  76394. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76395. * @param func Callback that is executed on collision
  76396. */
  76397. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76398. /**
  76399. * Unregisters the physics imposter on contact
  76400. * @param collideAgainst The physics object to collide against
  76401. * @param func Callback to execute on collision
  76402. */
  76403. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76404. private _tmpQuat;
  76405. private _tmpQuat2;
  76406. /**
  76407. * Get the parent rotation
  76408. * @returns The parent rotation
  76409. */
  76410. getParentsRotation(): Quaternion;
  76411. /**
  76412. * this function is executed by the physics engine.
  76413. */
  76414. beforeStep: () => void;
  76415. /**
  76416. * this function is executed by the physics engine
  76417. */
  76418. afterStep: () => void;
  76419. /**
  76420. * Legacy collision detection event support
  76421. */
  76422. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76423. /**
  76424. * event and body object due to cannon's event-based architecture.
  76425. */
  76426. onCollide: (e: {
  76427. body: any;
  76428. }) => void;
  76429. /**
  76430. * Apply a force
  76431. * @param force The force to apply
  76432. * @param contactPoint The contact point for the force
  76433. * @returns The physics imposter
  76434. */
  76435. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76436. /**
  76437. * Apply an impulse
  76438. * @param force The impulse force
  76439. * @param contactPoint The contact point for the impulse force
  76440. * @returns The physics imposter
  76441. */
  76442. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76443. /**
  76444. * A help function to create a joint
  76445. * @param otherImpostor A physics imposter used to create a joint
  76446. * @param jointType The type of joint
  76447. * @param jointData The data for the joint
  76448. * @returns The physics imposter
  76449. */
  76450. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76451. /**
  76452. * Add a joint to this impostor with a different impostor
  76453. * @param otherImpostor A physics imposter used to add a joint
  76454. * @param joint The joint to add
  76455. * @returns The physics imposter
  76456. */
  76457. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76458. /**
  76459. * Add an anchor to a cloth impostor
  76460. * @param otherImpostor rigid impostor to anchor to
  76461. * @param width ratio across width from 0 to 1
  76462. * @param height ratio up height from 0 to 1
  76463. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  76464. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  76465. * @returns impostor the soft imposter
  76466. */
  76467. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76468. /**
  76469. * Add a hook to a rope impostor
  76470. * @param otherImpostor rigid impostor to anchor to
  76471. * @param length ratio across rope from 0 to 1
  76472. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  76473. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  76474. * @returns impostor the rope imposter
  76475. */
  76476. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76477. /**
  76478. * Will keep this body still, in a sleep mode.
  76479. * @returns the physics imposter
  76480. */
  76481. sleep(): PhysicsImpostor;
  76482. /**
  76483. * Wake the body up.
  76484. * @returns The physics imposter
  76485. */
  76486. wakeUp(): PhysicsImpostor;
  76487. /**
  76488. * Clones the physics imposter
  76489. * @param newObject The physics imposter clones to this physics-enabled object
  76490. * @returns A nullable physics imposter
  76491. */
  76492. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76493. /**
  76494. * Disposes the physics imposter
  76495. */
  76496. dispose(): void;
  76497. /**
  76498. * Sets the delta position
  76499. * @param position The delta position amount
  76500. */
  76501. setDeltaPosition(position: Vector3): void;
  76502. /**
  76503. * Sets the delta rotation
  76504. * @param rotation The delta rotation amount
  76505. */
  76506. setDeltaRotation(rotation: Quaternion): void;
  76507. /**
  76508. * Gets the box size of the physics imposter and stores the result in the input parameter
  76509. * @param result Stores the box size
  76510. * @returns The physics imposter
  76511. */
  76512. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76513. /**
  76514. * Gets the radius of the physics imposter
  76515. * @returns Radius of the physics imposter
  76516. */
  76517. getRadius(): number;
  76518. /**
  76519. * Sync a bone with this impostor
  76520. * @param bone The bone to sync to the impostor.
  76521. * @param boneMesh The mesh that the bone is influencing.
  76522. * @param jointPivot The pivot of the joint / bone in local space.
  76523. * @param distToJoint Optional distance from the impostor to the joint.
  76524. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76525. */
  76526. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76527. /**
  76528. * Sync impostor to a bone
  76529. * @param bone The bone that the impostor will be synced to.
  76530. * @param boneMesh The mesh that the bone is influencing.
  76531. * @param jointPivot The pivot of the joint / bone in local space.
  76532. * @param distToJoint Optional distance from the impostor to the joint.
  76533. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76534. * @param boneAxis Optional vector3 axis the bone is aligned with
  76535. */
  76536. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76537. /**
  76538. * No-Imposter type
  76539. */
  76540. static NoImpostor: number;
  76541. /**
  76542. * Sphere-Imposter type
  76543. */
  76544. static SphereImpostor: number;
  76545. /**
  76546. * Box-Imposter type
  76547. */
  76548. static BoxImpostor: number;
  76549. /**
  76550. * Plane-Imposter type
  76551. */
  76552. static PlaneImpostor: number;
  76553. /**
  76554. * Mesh-imposter type
  76555. */
  76556. static MeshImpostor: number;
  76557. /**
  76558. * Capsule-Impostor type (Ammo.js plugin only)
  76559. */
  76560. static CapsuleImpostor: number;
  76561. /**
  76562. * Cylinder-Imposter type
  76563. */
  76564. static CylinderImpostor: number;
  76565. /**
  76566. * Particle-Imposter type
  76567. */
  76568. static ParticleImpostor: number;
  76569. /**
  76570. * Heightmap-Imposter type
  76571. */
  76572. static HeightmapImpostor: number;
  76573. /**
  76574. * ConvexHull-Impostor type (Ammo.js plugin only)
  76575. */
  76576. static ConvexHullImpostor: number;
  76577. /**
  76578. * Rope-Imposter type
  76579. */
  76580. static RopeImpostor: number;
  76581. /**
  76582. * Cloth-Imposter type
  76583. */
  76584. static ClothImpostor: number;
  76585. /**
  76586. * Softbody-Imposter type
  76587. */
  76588. static SoftbodyImpostor: number;
  76589. }
  76590. }
  76591. declare module BABYLON {
  76592. /**
  76593. * @hidden
  76594. **/
  76595. export class _CreationDataStorage {
  76596. closePath?: boolean;
  76597. closeArray?: boolean;
  76598. idx: number[];
  76599. dashSize: number;
  76600. gapSize: number;
  76601. path3D: Path3D;
  76602. pathArray: Vector3[][];
  76603. arc: number;
  76604. radius: number;
  76605. cap: number;
  76606. tessellation: number;
  76607. }
  76608. /**
  76609. * @hidden
  76610. **/
  76611. class _InstanceDataStorage {
  76612. visibleInstances: any;
  76613. batchCache: _InstancesBatch;
  76614. instancesBufferSize: number;
  76615. instancesBuffer: Nullable<Buffer>;
  76616. instancesData: Float32Array;
  76617. overridenInstanceCount: number;
  76618. isFrozen: boolean;
  76619. previousBatch: Nullable<_InstancesBatch>;
  76620. hardwareInstancedRendering: boolean;
  76621. sideOrientation: number;
  76622. }
  76623. /**
  76624. * @hidden
  76625. **/
  76626. export class _InstancesBatch {
  76627. mustReturn: boolean;
  76628. visibleInstances: Nullable<InstancedMesh[]>[];
  76629. renderSelf: boolean[];
  76630. hardwareInstancedRendering: boolean[];
  76631. }
  76632. /**
  76633. * Class used to represent renderable models
  76634. */
  76635. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76636. /**
  76637. * Mesh side orientation : usually the external or front surface
  76638. */
  76639. static readonly FRONTSIDE: number;
  76640. /**
  76641. * Mesh side orientation : usually the internal or back surface
  76642. */
  76643. static readonly BACKSIDE: number;
  76644. /**
  76645. * Mesh side orientation : both internal and external or front and back surfaces
  76646. */
  76647. static readonly DOUBLESIDE: number;
  76648. /**
  76649. * Mesh side orientation : by default, `FRONTSIDE`
  76650. */
  76651. static readonly DEFAULTSIDE: number;
  76652. /**
  76653. * Mesh cap setting : no cap
  76654. */
  76655. static readonly NO_CAP: number;
  76656. /**
  76657. * Mesh cap setting : one cap at the beginning of the mesh
  76658. */
  76659. static readonly CAP_START: number;
  76660. /**
  76661. * Mesh cap setting : one cap at the end of the mesh
  76662. */
  76663. static readonly CAP_END: number;
  76664. /**
  76665. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76666. */
  76667. static readonly CAP_ALL: number;
  76668. /**
  76669. * Mesh pattern setting : no flip or rotate
  76670. */
  76671. static readonly NO_FLIP: number;
  76672. /**
  76673. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  76674. */
  76675. static readonly FLIP_TILE: number;
  76676. /**
  76677. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  76678. */
  76679. static readonly ROTATE_TILE: number;
  76680. /**
  76681. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  76682. */
  76683. static readonly FLIP_ROW: number;
  76684. /**
  76685. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  76686. */
  76687. static readonly ROTATE_ROW: number;
  76688. /**
  76689. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  76690. */
  76691. static readonly FLIP_N_ROTATE_TILE: number;
  76692. /**
  76693. * Mesh pattern setting : rotate pattern and rotate
  76694. */
  76695. static readonly FLIP_N_ROTATE_ROW: number;
  76696. /**
  76697. * Mesh tile positioning : part tiles same on left/right or top/bottom
  76698. */
  76699. static readonly CENTER: number;
  76700. /**
  76701. * Mesh tile positioning : part tiles on left
  76702. */
  76703. static readonly LEFT: number;
  76704. /**
  76705. * Mesh tile positioning : part tiles on right
  76706. */
  76707. static readonly RIGHT: number;
  76708. /**
  76709. * Mesh tile positioning : part tiles on top
  76710. */
  76711. static readonly TOP: number;
  76712. /**
  76713. * Mesh tile positioning : part tiles on bottom
  76714. */
  76715. static readonly BOTTOM: number;
  76716. /**
  76717. * Gets the default side orientation.
  76718. * @param orientation the orientation to value to attempt to get
  76719. * @returns the default orientation
  76720. * @hidden
  76721. */
  76722. static _GetDefaultSideOrientation(orientation?: number): number;
  76723. private _internalMeshDataInfo;
  76724. /**
  76725. * An event triggered before rendering the mesh
  76726. */
  76727. readonly onBeforeRenderObservable: Observable<Mesh>;
  76728. /**
  76729. * An event triggered before binding the mesh
  76730. */
  76731. readonly onBeforeBindObservable: Observable<Mesh>;
  76732. /**
  76733. * An event triggered after rendering the mesh
  76734. */
  76735. readonly onAfterRenderObservable: Observable<Mesh>;
  76736. /**
  76737. * An event triggered before drawing the mesh
  76738. */
  76739. readonly onBeforeDrawObservable: Observable<Mesh>;
  76740. private _onBeforeDrawObserver;
  76741. /**
  76742. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  76743. */
  76744. onBeforeDraw: () => void;
  76745. /**
  76746. * Gets the delay loading state of the mesh (when delay loading is turned on)
  76747. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  76748. */
  76749. delayLoadState: number;
  76750. /**
  76751. * Gets the list of instances created from this mesh
  76752. * it is not supposed to be modified manually.
  76753. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  76754. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76755. */
  76756. instances: InstancedMesh[];
  76757. /**
  76758. * Gets the file containing delay loading data for this mesh
  76759. */
  76760. delayLoadingFile: string;
  76761. /** @hidden */
  76762. _binaryInfo: any;
  76763. /**
  76764. * User defined function used to change how LOD level selection is done
  76765. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76766. */
  76767. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  76768. /**
  76769. * Gets or sets the morph target manager
  76770. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76771. */
  76772. morphTargetManager: Nullable<MorphTargetManager>;
  76773. /** @hidden */
  76774. _creationDataStorage: Nullable<_CreationDataStorage>;
  76775. /** @hidden */
  76776. _geometry: Nullable<Geometry>;
  76777. /** @hidden */
  76778. _delayInfo: Array<string>;
  76779. /** @hidden */
  76780. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  76781. /** @hidden */
  76782. _instanceDataStorage: _InstanceDataStorage;
  76783. private _effectiveMaterial;
  76784. /** @hidden */
  76785. _shouldGenerateFlatShading: boolean;
  76786. /** @hidden */
  76787. _originalBuilderSideOrientation: number;
  76788. /**
  76789. * Use this property to change the original side orientation defined at construction time
  76790. */
  76791. overrideMaterialSideOrientation: Nullable<number>;
  76792. /**
  76793. * Gets the source mesh (the one used to clone this one from)
  76794. */
  76795. readonly source: Nullable<Mesh>;
  76796. /**
  76797. * Gets or sets a boolean indicating that this mesh does not use index buffer
  76798. */
  76799. isUnIndexed: boolean;
  76800. /**
  76801. * @constructor
  76802. * @param name The value used by scene.getMeshByName() to do a lookup.
  76803. * @param scene The scene to add this mesh to.
  76804. * @param parent The parent of this mesh, if it has one
  76805. * @param source An optional Mesh from which geometry is shared, cloned.
  76806. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76807. * When false, achieved by calling a clone(), also passing False.
  76808. * This will make creation of children, recursive.
  76809. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  76810. */
  76811. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  76812. /**
  76813. * Gets the class name
  76814. * @returns the string "Mesh".
  76815. */
  76816. getClassName(): string;
  76817. /** @hidden */
  76818. readonly _isMesh: boolean;
  76819. /**
  76820. * Returns a description of this mesh
  76821. * @param fullDetails define if full details about this mesh must be used
  76822. * @returns a descriptive string representing this mesh
  76823. */
  76824. toString(fullDetails?: boolean): string;
  76825. /** @hidden */
  76826. _unBindEffect(): void;
  76827. /**
  76828. * Gets a boolean indicating if this mesh has LOD
  76829. */
  76830. readonly hasLODLevels: boolean;
  76831. /**
  76832. * Gets the list of MeshLODLevel associated with the current mesh
  76833. * @returns an array of MeshLODLevel
  76834. */
  76835. getLODLevels(): MeshLODLevel[];
  76836. private _sortLODLevels;
  76837. /**
  76838. * Add a mesh as LOD level triggered at the given distance.
  76839. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76840. * @param distance The distance from the center of the object to show this level
  76841. * @param mesh The mesh to be added as LOD level (can be null)
  76842. * @return This mesh (for chaining)
  76843. */
  76844. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  76845. /**
  76846. * Returns the LOD level mesh at the passed distance or null if not found.
  76847. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76848. * @param distance The distance from the center of the object to show this level
  76849. * @returns a Mesh or `null`
  76850. */
  76851. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  76852. /**
  76853. * Remove a mesh from the LOD array
  76854. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76855. * @param mesh defines the mesh to be removed
  76856. * @return This mesh (for chaining)
  76857. */
  76858. removeLODLevel(mesh: Mesh): Mesh;
  76859. /**
  76860. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  76861. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76862. * @param camera defines the camera to use to compute distance
  76863. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  76864. * @return This mesh (for chaining)
  76865. */
  76866. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  76867. /**
  76868. * Gets the mesh internal Geometry object
  76869. */
  76870. readonly geometry: Nullable<Geometry>;
  76871. /**
  76872. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  76873. * @returns the total number of vertices
  76874. */
  76875. getTotalVertices(): number;
  76876. /**
  76877. * Returns the content of an associated vertex buffer
  76878. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76879. * - VertexBuffer.PositionKind
  76880. * - VertexBuffer.UVKind
  76881. * - VertexBuffer.UV2Kind
  76882. * - VertexBuffer.UV3Kind
  76883. * - VertexBuffer.UV4Kind
  76884. * - VertexBuffer.UV5Kind
  76885. * - VertexBuffer.UV6Kind
  76886. * - VertexBuffer.ColorKind
  76887. * - VertexBuffer.MatricesIndicesKind
  76888. * - VertexBuffer.MatricesIndicesExtraKind
  76889. * - VertexBuffer.MatricesWeightsKind
  76890. * - VertexBuffer.MatricesWeightsExtraKind
  76891. * @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
  76892. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  76893. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  76894. */
  76895. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  76896. /**
  76897. * Returns the mesh VertexBuffer object from the requested `kind`
  76898. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76899. * - VertexBuffer.PositionKind
  76900. * - VertexBuffer.NormalKind
  76901. * - VertexBuffer.UVKind
  76902. * - VertexBuffer.UV2Kind
  76903. * - VertexBuffer.UV3Kind
  76904. * - VertexBuffer.UV4Kind
  76905. * - VertexBuffer.UV5Kind
  76906. * - VertexBuffer.UV6Kind
  76907. * - VertexBuffer.ColorKind
  76908. * - VertexBuffer.MatricesIndicesKind
  76909. * - VertexBuffer.MatricesIndicesExtraKind
  76910. * - VertexBuffer.MatricesWeightsKind
  76911. * - VertexBuffer.MatricesWeightsExtraKind
  76912. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  76913. */
  76914. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  76915. /**
  76916. * Tests if a specific vertex buffer is associated with this mesh
  76917. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76918. * - VertexBuffer.PositionKind
  76919. * - VertexBuffer.NormalKind
  76920. * - VertexBuffer.UVKind
  76921. * - VertexBuffer.UV2Kind
  76922. * - VertexBuffer.UV3Kind
  76923. * - VertexBuffer.UV4Kind
  76924. * - VertexBuffer.UV5Kind
  76925. * - VertexBuffer.UV6Kind
  76926. * - VertexBuffer.ColorKind
  76927. * - VertexBuffer.MatricesIndicesKind
  76928. * - VertexBuffer.MatricesIndicesExtraKind
  76929. * - VertexBuffer.MatricesWeightsKind
  76930. * - VertexBuffer.MatricesWeightsExtraKind
  76931. * @returns a boolean
  76932. */
  76933. isVerticesDataPresent(kind: string): boolean;
  76934. /**
  76935. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  76936. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76937. * - VertexBuffer.PositionKind
  76938. * - VertexBuffer.UVKind
  76939. * - VertexBuffer.UV2Kind
  76940. * - VertexBuffer.UV3Kind
  76941. * - VertexBuffer.UV4Kind
  76942. * - VertexBuffer.UV5Kind
  76943. * - VertexBuffer.UV6Kind
  76944. * - VertexBuffer.ColorKind
  76945. * - VertexBuffer.MatricesIndicesKind
  76946. * - VertexBuffer.MatricesIndicesExtraKind
  76947. * - VertexBuffer.MatricesWeightsKind
  76948. * - VertexBuffer.MatricesWeightsExtraKind
  76949. * @returns a boolean
  76950. */
  76951. isVertexBufferUpdatable(kind: string): boolean;
  76952. /**
  76953. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  76954. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76955. * - VertexBuffer.PositionKind
  76956. * - VertexBuffer.NormalKind
  76957. * - VertexBuffer.UVKind
  76958. * - VertexBuffer.UV2Kind
  76959. * - VertexBuffer.UV3Kind
  76960. * - VertexBuffer.UV4Kind
  76961. * - VertexBuffer.UV5Kind
  76962. * - VertexBuffer.UV6Kind
  76963. * - VertexBuffer.ColorKind
  76964. * - VertexBuffer.MatricesIndicesKind
  76965. * - VertexBuffer.MatricesIndicesExtraKind
  76966. * - VertexBuffer.MatricesWeightsKind
  76967. * - VertexBuffer.MatricesWeightsExtraKind
  76968. * @returns an array of strings
  76969. */
  76970. getVerticesDataKinds(): string[];
  76971. /**
  76972. * Returns a positive integer : the total number of indices in this mesh geometry.
  76973. * @returns the numner of indices or zero if the mesh has no geometry.
  76974. */
  76975. getTotalIndices(): number;
  76976. /**
  76977. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76978. * @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.
  76979. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  76980. * @returns the indices array or an empty array if the mesh has no geometry
  76981. */
  76982. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  76983. readonly isBlocked: boolean;
  76984. /**
  76985. * Determine if the current mesh is ready to be rendered
  76986. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76987. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  76988. * @returns true if all associated assets are ready (material, textures, shaders)
  76989. */
  76990. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  76991. /**
  76992. * 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.
  76993. */
  76994. readonly areNormalsFrozen: boolean;
  76995. /**
  76996. * 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.
  76997. * @returns the current mesh
  76998. */
  76999. freezeNormals(): Mesh;
  77000. /**
  77001. * 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
  77002. * @returns the current mesh
  77003. */
  77004. unfreezeNormals(): Mesh;
  77005. /**
  77006. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77007. */
  77008. overridenInstanceCount: number;
  77009. /** @hidden */
  77010. _preActivate(): Mesh;
  77011. /** @hidden */
  77012. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77013. /** @hidden */
  77014. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77015. /**
  77016. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77017. * This means the mesh underlying bounding box and sphere are recomputed.
  77018. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77019. * @returns the current mesh
  77020. */
  77021. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77022. /** @hidden */
  77023. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77024. /**
  77025. * This function will subdivide the mesh into multiple submeshes
  77026. * @param count defines the expected number of submeshes
  77027. */
  77028. subdivide(count: number): void;
  77029. /**
  77030. * Copy a FloatArray into a specific associated vertex buffer
  77031. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77032. * - VertexBuffer.PositionKind
  77033. * - VertexBuffer.UVKind
  77034. * - VertexBuffer.UV2Kind
  77035. * - VertexBuffer.UV3Kind
  77036. * - VertexBuffer.UV4Kind
  77037. * - VertexBuffer.UV5Kind
  77038. * - VertexBuffer.UV6Kind
  77039. * - VertexBuffer.ColorKind
  77040. * - VertexBuffer.MatricesIndicesKind
  77041. * - VertexBuffer.MatricesIndicesExtraKind
  77042. * - VertexBuffer.MatricesWeightsKind
  77043. * - VertexBuffer.MatricesWeightsExtraKind
  77044. * @param data defines the data source
  77045. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77046. * @param stride defines the data stride size (can be null)
  77047. * @returns the current mesh
  77048. */
  77049. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77050. /**
  77051. * Flags an associated vertex buffer as updatable
  77052. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77053. * - VertexBuffer.PositionKind
  77054. * - VertexBuffer.UVKind
  77055. * - VertexBuffer.UV2Kind
  77056. * - VertexBuffer.UV3Kind
  77057. * - VertexBuffer.UV4Kind
  77058. * - VertexBuffer.UV5Kind
  77059. * - VertexBuffer.UV6Kind
  77060. * - VertexBuffer.ColorKind
  77061. * - VertexBuffer.MatricesIndicesKind
  77062. * - VertexBuffer.MatricesIndicesExtraKind
  77063. * - VertexBuffer.MatricesWeightsKind
  77064. * - VertexBuffer.MatricesWeightsExtraKind
  77065. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77066. */
  77067. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77068. /**
  77069. * Sets the mesh global Vertex Buffer
  77070. * @param buffer defines the buffer to use
  77071. * @returns the current mesh
  77072. */
  77073. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77074. /**
  77075. * Update a specific associated vertex buffer
  77076. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77077. * - VertexBuffer.PositionKind
  77078. * - VertexBuffer.UVKind
  77079. * - VertexBuffer.UV2Kind
  77080. * - VertexBuffer.UV3Kind
  77081. * - VertexBuffer.UV4Kind
  77082. * - VertexBuffer.UV5Kind
  77083. * - VertexBuffer.UV6Kind
  77084. * - VertexBuffer.ColorKind
  77085. * - VertexBuffer.MatricesIndicesKind
  77086. * - VertexBuffer.MatricesIndicesExtraKind
  77087. * - VertexBuffer.MatricesWeightsKind
  77088. * - VertexBuffer.MatricesWeightsExtraKind
  77089. * @param data defines the data source
  77090. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77091. * @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)
  77092. * @returns the current mesh
  77093. */
  77094. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77095. /**
  77096. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77097. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77098. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77099. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77100. * @returns the current mesh
  77101. */
  77102. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77103. /**
  77104. * Creates a un-shared specific occurence of the geometry for the mesh.
  77105. * @returns the current mesh
  77106. */
  77107. makeGeometryUnique(): Mesh;
  77108. /**
  77109. * Set the index buffer of this mesh
  77110. * @param indices defines the source data
  77111. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77112. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77113. * @returns the current mesh
  77114. */
  77115. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77116. /**
  77117. * Update the current index buffer
  77118. * @param indices defines the source data
  77119. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77120. * @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)
  77121. * @returns the current mesh
  77122. */
  77123. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  77124. /**
  77125. * Invert the geometry to move from a right handed system to a left handed one.
  77126. * @returns the current mesh
  77127. */
  77128. toLeftHanded(): Mesh;
  77129. /** @hidden */
  77130. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77131. /** @hidden */
  77132. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  77133. /**
  77134. * Registers for this mesh a javascript function called just before the rendering process
  77135. * @param func defines the function to call before rendering this mesh
  77136. * @returns the current mesh
  77137. */
  77138. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77139. /**
  77140. * Disposes a previously registered javascript function called before the rendering
  77141. * @param func defines the function to remove
  77142. * @returns the current mesh
  77143. */
  77144. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77145. /**
  77146. * Registers for this mesh a javascript function called just after the rendering is complete
  77147. * @param func defines the function to call after rendering this mesh
  77148. * @returns the current mesh
  77149. */
  77150. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77151. /**
  77152. * Disposes a previously registered javascript function called after the rendering.
  77153. * @param func defines the function to remove
  77154. * @returns the current mesh
  77155. */
  77156. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77157. /** @hidden */
  77158. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77159. /** @hidden */
  77160. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77161. /** @hidden */
  77162. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77163. /** @hidden */
  77164. _rebuild(): void;
  77165. /** @hidden */
  77166. _freeze(): void;
  77167. /** @hidden */
  77168. _unFreeze(): void;
  77169. /**
  77170. * 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
  77171. * @param subMesh defines the subMesh to render
  77172. * @param enableAlphaMode defines if alpha mode can be changed
  77173. * @returns the current mesh
  77174. */
  77175. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77176. private _onBeforeDraw;
  77177. /**
  77178. * Renormalize the mesh and patch it up if there are no weights
  77179. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77180. * However in the case of zero weights then we set just a single influence to 1.
  77181. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77182. */
  77183. cleanMatrixWeights(): void;
  77184. private normalizeSkinFourWeights;
  77185. private normalizeSkinWeightsAndExtra;
  77186. /**
  77187. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77188. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77189. * the user know there was an issue with importing the mesh
  77190. * @returns a validation object with skinned, valid and report string
  77191. */
  77192. validateSkinning(): {
  77193. skinned: boolean;
  77194. valid: boolean;
  77195. report: string;
  77196. };
  77197. /** @hidden */
  77198. _checkDelayState(): Mesh;
  77199. private _queueLoad;
  77200. /**
  77201. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77202. * A mesh is in the frustum if its bounding box intersects the frustum
  77203. * @param frustumPlanes defines the frustum to test
  77204. * @returns true if the mesh is in the frustum planes
  77205. */
  77206. isInFrustum(frustumPlanes: Plane[]): boolean;
  77207. /**
  77208. * Sets the mesh material by the material or multiMaterial `id` property
  77209. * @param id is a string identifying the material or the multiMaterial
  77210. * @returns the current mesh
  77211. */
  77212. setMaterialByID(id: string): Mesh;
  77213. /**
  77214. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77215. * @returns an array of IAnimatable
  77216. */
  77217. getAnimatables(): IAnimatable[];
  77218. /**
  77219. * Modifies the mesh geometry according to the passed transformation matrix.
  77220. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77221. * The mesh normals are modified using the same transformation.
  77222. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77223. * @param transform defines the transform matrix to use
  77224. * @see http://doc.babylonjs.com/resources/baking_transformations
  77225. * @returns the current mesh
  77226. */
  77227. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77228. /**
  77229. * Modifies the mesh geometry according to its own current World Matrix.
  77230. * The mesh World Matrix is then reset.
  77231. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77232. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77233. * @see http://doc.babylonjs.com/resources/baking_transformations
  77234. * @returns the current mesh
  77235. */
  77236. bakeCurrentTransformIntoVertices(): Mesh;
  77237. /** @hidden */
  77238. readonly _positions: Nullable<Vector3[]>;
  77239. /** @hidden */
  77240. _resetPointsArrayCache(): Mesh;
  77241. /** @hidden */
  77242. _generatePointsArray(): boolean;
  77243. /**
  77244. * Returns a new Mesh object generated from the current mesh properties.
  77245. * This method must not get confused with createInstance()
  77246. * @param name is a string, the name given to the new mesh
  77247. * @param newParent can be any Node object (default `null`)
  77248. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77249. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77250. * @returns a new mesh
  77251. */
  77252. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77253. /**
  77254. * Releases resources associated with this mesh.
  77255. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77256. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77257. */
  77258. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77259. /**
  77260. * Modifies the mesh geometry according to a displacement map.
  77261. * 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.
  77262. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77263. * @param url is a string, the URL from the image file is to be downloaded.
  77264. * @param minHeight is the lower limit of the displacement.
  77265. * @param maxHeight is the upper limit of the displacement.
  77266. * @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.
  77267. * @param uvOffset is an optional vector2 used to offset UV.
  77268. * @param uvScale is an optional vector2 used to scale UV.
  77269. * @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.
  77270. * @returns the Mesh.
  77271. */
  77272. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77273. /**
  77274. * Modifies the mesh geometry according to a displacementMap buffer.
  77275. * 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.
  77276. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77277. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77278. * @param heightMapWidth is the width of the buffer image.
  77279. * @param heightMapHeight is the height of the buffer image.
  77280. * @param minHeight is the lower limit of the displacement.
  77281. * @param maxHeight is the upper limit of the displacement.
  77282. * @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.
  77283. * @param uvOffset is an optional vector2 used to offset UV.
  77284. * @param uvScale is an optional vector2 used to scale UV.
  77285. * @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.
  77286. * @returns the Mesh.
  77287. */
  77288. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77289. /**
  77290. * Modify the mesh to get a flat shading rendering.
  77291. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77292. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77293. * @returns current mesh
  77294. */
  77295. convertToFlatShadedMesh(): Mesh;
  77296. /**
  77297. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77298. * In other words, more vertices, no more indices and a single bigger VBO.
  77299. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77300. * @returns current mesh
  77301. */
  77302. convertToUnIndexedMesh(): Mesh;
  77303. /**
  77304. * Inverses facet orientations.
  77305. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77306. * @param flipNormals will also inverts the normals
  77307. * @returns current mesh
  77308. */
  77309. flipFaces(flipNormals?: boolean): Mesh;
  77310. /**
  77311. * Increase the number of facets and hence vertices in a mesh
  77312. * Vertex normals are interpolated from existing vertex normals
  77313. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77314. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  77315. */
  77316. increaseVertices(numberPerEdge: number): void;
  77317. /**
  77318. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  77319. * This will undo any application of covertToFlatShadedMesh
  77320. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77321. */
  77322. forceSharedVertices(): void;
  77323. /** @hidden */
  77324. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77325. /** @hidden */
  77326. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77327. /**
  77328. * Creates a new InstancedMesh object from the mesh model.
  77329. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77330. * @param name defines the name of the new instance
  77331. * @returns a new InstancedMesh
  77332. */
  77333. createInstance(name: string): InstancedMesh;
  77334. /**
  77335. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77336. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77337. * @returns the current mesh
  77338. */
  77339. synchronizeInstances(): Mesh;
  77340. /**
  77341. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77342. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77343. * This should be used together with the simplification to avoid disappearing triangles.
  77344. * @param successCallback an optional success callback to be called after the optimization finished.
  77345. * @returns the current mesh
  77346. */
  77347. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77348. /**
  77349. * Serialize current mesh
  77350. * @param serializationObject defines the object which will receive the serialization data
  77351. */
  77352. serialize(serializationObject: any): void;
  77353. /** @hidden */
  77354. _syncGeometryWithMorphTargetManager(): void;
  77355. /** @hidden */
  77356. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77357. /**
  77358. * Returns a new Mesh object parsed from the source provided.
  77359. * @param parsedMesh is the source
  77360. * @param scene defines the hosting scene
  77361. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77362. * @returns a new Mesh
  77363. */
  77364. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77365. /**
  77366. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77367. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77368. * @param name defines the name of the mesh to create
  77369. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77370. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77371. * @param closePath creates a seam between the first and the last points of each path of the path array
  77372. * @param offset is taken in account only if the `pathArray` is containing a single path
  77373. * @param scene defines the hosting scene
  77374. * @param updatable defines if the mesh must be flagged as updatable
  77375. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77376. * @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)
  77377. * @returns a new Mesh
  77378. */
  77379. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77380. /**
  77381. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77382. * @param name defines the name of the mesh to create
  77383. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77384. * @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
  77385. * @param scene defines the hosting scene
  77386. * @param updatable defines if the mesh must be flagged as updatable
  77387. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77388. * @returns a new Mesh
  77389. */
  77390. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77391. /**
  77392. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77393. * @param name defines the name of the mesh to create
  77394. * @param size sets the size (float) of each box side (default 1)
  77395. * @param scene defines the hosting scene
  77396. * @param updatable defines if the mesh must be flagged as updatable
  77397. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77398. * @returns a new Mesh
  77399. */
  77400. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77401. /**
  77402. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77403. * @param name defines the name of the mesh to create
  77404. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77405. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77406. * @param scene defines the hosting scene
  77407. * @param updatable defines if the mesh must be flagged as updatable
  77408. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77409. * @returns a new Mesh
  77410. */
  77411. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77412. /**
  77413. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  77414. * @param name defines the name of the mesh to create
  77415. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77416. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77417. * @param scene defines the hosting scene
  77418. * @returns a new Mesh
  77419. */
  77420. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  77421. /**
  77422. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77423. * @param name defines the name of the mesh to create
  77424. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77425. * @param diameterTop set the top cap diameter (floats, default 1)
  77426. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77427. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77428. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77429. * @param scene defines the hosting scene
  77430. * @param updatable defines if the mesh must be flagged as updatable
  77431. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77432. * @returns a new Mesh
  77433. */
  77434. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77435. /**
  77436. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77437. * @param name defines the name of the mesh to create
  77438. * @param diameter sets the diameter size (float) of the torus (default 1)
  77439. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77440. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77441. * @param scene defines the hosting scene
  77442. * @param updatable defines if the mesh must be flagged as updatable
  77443. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77444. * @returns a new Mesh
  77445. */
  77446. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77447. /**
  77448. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77449. * @param name defines the name of the mesh to create
  77450. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77451. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77452. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77453. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77454. * @param p the number of windings on X axis (positive integers, default 2)
  77455. * @param q the number of windings on Y axis (positive integers, default 3)
  77456. * @param scene defines the hosting scene
  77457. * @param updatable defines if the mesh must be flagged as updatable
  77458. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77459. * @returns a new Mesh
  77460. */
  77461. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77462. /**
  77463. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77464. * @param name defines the name of the mesh to create
  77465. * @param points is an array successive Vector3
  77466. * @param scene defines the hosting scene
  77467. * @param updatable defines if the mesh must be flagged as updatable
  77468. * @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).
  77469. * @returns a new Mesh
  77470. */
  77471. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77472. /**
  77473. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77474. * @param name defines the name of the mesh to create
  77475. * @param points is an array successive Vector3
  77476. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77477. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77478. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77479. * @param scene defines the hosting scene
  77480. * @param updatable defines if the mesh must be flagged as updatable
  77481. * @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)
  77482. * @returns a new Mesh
  77483. */
  77484. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77485. /**
  77486. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77487. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77488. * 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.
  77489. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77490. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77491. * Remember you can only change the shape positions, not their number when updating a polygon.
  77492. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77493. * @param name defines the name of the mesh to create
  77494. * @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
  77495. * @param scene defines the hosting scene
  77496. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77497. * @param updatable defines if the mesh must be flagged as updatable
  77498. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77499. * @param earcutInjection can be used to inject your own earcut reference
  77500. * @returns a new Mesh
  77501. */
  77502. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77503. /**
  77504. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77505. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77506. * @param name defines the name of the mesh to create
  77507. * @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
  77508. * @param depth defines the height of extrusion
  77509. * @param scene defines the hosting scene
  77510. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77511. * @param updatable defines if the mesh must be flagged as updatable
  77512. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77513. * @param earcutInjection can be used to inject your own earcut reference
  77514. * @returns a new Mesh
  77515. */
  77516. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77517. /**
  77518. * Creates an extruded shape mesh.
  77519. * 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
  77520. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77521. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77522. * @param name defines the name of the mesh to create
  77523. * @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
  77524. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77525. * @param scale is the value to scale the shape
  77526. * @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
  77527. * @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
  77528. * @param scene defines the hosting scene
  77529. * @param updatable defines if the mesh must be flagged as updatable
  77530. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77531. * @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)
  77532. * @returns a new Mesh
  77533. */
  77534. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77535. /**
  77536. * Creates an custom extruded shape mesh.
  77537. * The custom extrusion is a parametric shape.
  77538. * It has no predefined shape. Its final shape will depend on the input parameters.
  77539. * Please consider using the same method from the MeshBuilder class instead
  77540. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77541. * @param name defines the name of the mesh to create
  77542. * @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
  77543. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77544. * @param scaleFunction is a custom Javascript function called on each path point
  77545. * @param rotationFunction is a custom Javascript function called on each path point
  77546. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77547. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77548. * @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
  77549. * @param scene defines the hosting scene
  77550. * @param updatable defines if the mesh must be flagged as updatable
  77551. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77552. * @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)
  77553. * @returns a new Mesh
  77554. */
  77555. 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;
  77556. /**
  77557. * Creates lathe mesh.
  77558. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77559. * Please consider using the same method from the MeshBuilder class instead
  77560. * @param name defines the name of the mesh to create
  77561. * @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
  77562. * @param radius is the radius value of the lathe
  77563. * @param tessellation is the side number of the lathe.
  77564. * @param scene defines the hosting scene
  77565. * @param updatable defines if the mesh must be flagged as updatable
  77566. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77567. * @returns a new Mesh
  77568. */
  77569. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77570. /**
  77571. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77572. * @param name defines the name of the mesh to create
  77573. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77574. * @param scene defines the hosting scene
  77575. * @param updatable defines if the mesh must be flagged as updatable
  77576. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77577. * @returns a new Mesh
  77578. */
  77579. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77580. /**
  77581. * Creates a ground mesh.
  77582. * Please consider using the same method from the MeshBuilder class instead
  77583. * @param name defines the name of the mesh to create
  77584. * @param width set the width of the ground
  77585. * @param height set the height of the ground
  77586. * @param subdivisions sets the number of subdivisions per side
  77587. * @param scene defines the hosting scene
  77588. * @param updatable defines if the mesh must be flagged as updatable
  77589. * @returns a new Mesh
  77590. */
  77591. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77592. /**
  77593. * Creates a tiled ground mesh.
  77594. * Please consider using the same method from the MeshBuilder class instead
  77595. * @param name defines the name of the mesh to create
  77596. * @param xmin set the ground minimum X coordinate
  77597. * @param zmin set the ground minimum Y coordinate
  77598. * @param xmax set the ground maximum X coordinate
  77599. * @param zmax set the ground maximum Z coordinate
  77600. * @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
  77601. * @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
  77602. * @param scene defines the hosting scene
  77603. * @param updatable defines if the mesh must be flagged as updatable
  77604. * @returns a new Mesh
  77605. */
  77606. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77607. w: number;
  77608. h: number;
  77609. }, precision: {
  77610. w: number;
  77611. h: number;
  77612. }, scene: Scene, updatable?: boolean): Mesh;
  77613. /**
  77614. * Creates a ground mesh from a height map.
  77615. * Please consider using the same method from the MeshBuilder class instead
  77616. * @see http://doc.babylonjs.com/babylon101/height_map
  77617. * @param name defines the name of the mesh to create
  77618. * @param url sets the URL of the height map image resource
  77619. * @param width set the ground width size
  77620. * @param height set the ground height size
  77621. * @param subdivisions sets the number of subdivision per side
  77622. * @param minHeight is the minimum altitude on the ground
  77623. * @param maxHeight is the maximum altitude on the ground
  77624. * @param scene defines the hosting scene
  77625. * @param updatable defines if the mesh must be flagged as updatable
  77626. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77627. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77628. * @returns a new Mesh
  77629. */
  77630. 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;
  77631. /**
  77632. * Creates a tube mesh.
  77633. * The tube is a parametric shape.
  77634. * It has no predefined shape. Its final shape will depend on the input parameters.
  77635. * Please consider using the same method from the MeshBuilder class instead
  77636. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77637. * @param name defines the name of the mesh to create
  77638. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77639. * @param radius sets the tube radius size
  77640. * @param tessellation is the number of sides on the tubular surface
  77641. * @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
  77642. * @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
  77643. * @param scene defines the hosting scene
  77644. * @param updatable defines if the mesh must be flagged as updatable
  77645. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77646. * @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)
  77647. * @returns a new Mesh
  77648. */
  77649. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77650. (i: number, distance: number): number;
  77651. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77652. /**
  77653. * Creates a polyhedron mesh.
  77654. * Please consider using the same method from the MeshBuilder class instead.
  77655. * * 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
  77656. * * The parameter `size` (positive float, default 1) sets the polygon size
  77657. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77658. * * 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`
  77659. * * 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
  77660. * * 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)`)
  77661. * * 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
  77662. * * 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
  77663. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77664. * * If you create a double-sided mesh, you can choose what parts of 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
  77665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77666. * @param name defines the name of the mesh to create
  77667. * @param options defines the options used to create the mesh
  77668. * @param scene defines the hosting scene
  77669. * @returns a new Mesh
  77670. */
  77671. static CreatePolyhedron(name: string, options: {
  77672. type?: number;
  77673. size?: number;
  77674. sizeX?: number;
  77675. sizeY?: number;
  77676. sizeZ?: number;
  77677. custom?: any;
  77678. faceUV?: Vector4[];
  77679. faceColors?: Color4[];
  77680. updatable?: boolean;
  77681. sideOrientation?: number;
  77682. }, scene: Scene): Mesh;
  77683. /**
  77684. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77685. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77686. * * 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`)
  77687. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77688. * * 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
  77689. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77690. * * If you create a double-sided mesh, you can choose what parts of 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
  77691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77692. * @param name defines the name of the mesh
  77693. * @param options defines the options used to create the mesh
  77694. * @param scene defines the hosting scene
  77695. * @returns a new Mesh
  77696. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77697. */
  77698. static CreateIcoSphere(name: string, options: {
  77699. radius?: number;
  77700. flat?: boolean;
  77701. subdivisions?: number;
  77702. sideOrientation?: number;
  77703. updatable?: boolean;
  77704. }, scene: Scene): Mesh;
  77705. /**
  77706. * Creates a decal mesh.
  77707. * Please consider using the same method from the MeshBuilder class instead.
  77708. * A decal is a mesh usually applied as a model onto the surface of another mesh
  77709. * @param name defines the name of the mesh
  77710. * @param sourceMesh defines the mesh receiving the decal
  77711. * @param position sets the position of the decal in world coordinates
  77712. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  77713. * @param size sets the decal scaling
  77714. * @param angle sets the angle to rotate the decal
  77715. * @returns a new Mesh
  77716. */
  77717. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  77718. /**
  77719. * Prepare internal position array for software CPU skinning
  77720. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  77721. */
  77722. setPositionsForCPUSkinning(): Float32Array;
  77723. /**
  77724. * Prepare internal normal array for software CPU skinning
  77725. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  77726. */
  77727. setNormalsForCPUSkinning(): Float32Array;
  77728. /**
  77729. * Updates the vertex buffer by applying transformation from the bones
  77730. * @param skeleton defines the skeleton to apply to current mesh
  77731. * @returns the current mesh
  77732. */
  77733. applySkeleton(skeleton: Skeleton): Mesh;
  77734. /**
  77735. * 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
  77736. * @param meshes defines the list of meshes to scan
  77737. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  77738. */
  77739. static MinMax(meshes: AbstractMesh[]): {
  77740. min: Vector3;
  77741. max: Vector3;
  77742. };
  77743. /**
  77744. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  77745. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  77746. * @returns a vector3
  77747. */
  77748. static Center(meshesOrMinMaxVector: {
  77749. min: Vector3;
  77750. max: Vector3;
  77751. } | AbstractMesh[]): Vector3;
  77752. /**
  77753. * Merge the array of meshes into a single mesh for performance reasons.
  77754. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  77755. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  77756. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  77757. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  77758. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  77759. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  77760. * @returns a new mesh
  77761. */
  77762. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  77763. /** @hidden */
  77764. addInstance(instance: InstancedMesh): void;
  77765. /** @hidden */
  77766. removeInstance(instance: InstancedMesh): void;
  77767. }
  77768. }
  77769. declare module BABYLON {
  77770. /**
  77771. * Interface used to define Action
  77772. */
  77773. export interface IAction {
  77774. /**
  77775. * Trigger for the action
  77776. */
  77777. trigger: number;
  77778. /** Options of the trigger */
  77779. triggerOptions: any;
  77780. /**
  77781. * Gets the trigger parameters
  77782. * @returns the trigger parameters
  77783. */
  77784. getTriggerParameter(): any;
  77785. /**
  77786. * Internal only - executes current action event
  77787. * @hidden
  77788. */
  77789. _executeCurrent(evt?: ActionEvent): void;
  77790. /**
  77791. * Serialize placeholder for child classes
  77792. * @param parent of child
  77793. * @returns the serialized object
  77794. */
  77795. serialize(parent: any): any;
  77796. /**
  77797. * Internal only
  77798. * @hidden
  77799. */
  77800. _prepare(): void;
  77801. /**
  77802. * Internal only - manager for action
  77803. * @hidden
  77804. */
  77805. _actionManager: AbstractActionManager;
  77806. /**
  77807. * Adds action to chain of actions, may be a DoNothingAction
  77808. * @param action defines the next action to execute
  77809. * @returns The action passed in
  77810. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77811. */
  77812. then(action: IAction): IAction;
  77813. }
  77814. /**
  77815. * The action to be carried out following a trigger
  77816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77817. */
  77818. export class Action implements IAction {
  77819. /** the trigger, with or without parameters, for the action */
  77820. triggerOptions: any;
  77821. /**
  77822. * Trigger for the action
  77823. */
  77824. trigger: number;
  77825. /**
  77826. * Internal only - manager for action
  77827. * @hidden
  77828. */
  77829. _actionManager: ActionManager;
  77830. private _nextActiveAction;
  77831. private _child;
  77832. private _condition?;
  77833. private _triggerParameter;
  77834. /**
  77835. * An event triggered prior to action being executed.
  77836. */
  77837. onBeforeExecuteObservable: Observable<Action>;
  77838. /**
  77839. * Creates a new Action
  77840. * @param triggerOptions the trigger, with or without parameters, for the action
  77841. * @param condition an optional determinant of action
  77842. */
  77843. constructor(
  77844. /** the trigger, with or without parameters, for the action */
  77845. triggerOptions: any, condition?: Condition);
  77846. /**
  77847. * Internal only
  77848. * @hidden
  77849. */
  77850. _prepare(): void;
  77851. /**
  77852. * Gets the trigger parameters
  77853. * @returns the trigger parameters
  77854. */
  77855. getTriggerParameter(): any;
  77856. /**
  77857. * Internal only - executes current action event
  77858. * @hidden
  77859. */
  77860. _executeCurrent(evt?: ActionEvent): void;
  77861. /**
  77862. * Execute placeholder for child classes
  77863. * @param evt optional action event
  77864. */
  77865. execute(evt?: ActionEvent): void;
  77866. /**
  77867. * Skips to next active action
  77868. */
  77869. skipToNextActiveAction(): void;
  77870. /**
  77871. * Adds action to chain of actions, may be a DoNothingAction
  77872. * @param action defines the next action to execute
  77873. * @returns The action passed in
  77874. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77875. */
  77876. then(action: Action): Action;
  77877. /**
  77878. * Internal only
  77879. * @hidden
  77880. */
  77881. _getProperty(propertyPath: string): string;
  77882. /**
  77883. * Internal only
  77884. * @hidden
  77885. */
  77886. _getEffectiveTarget(target: any, propertyPath: string): any;
  77887. /**
  77888. * Serialize placeholder for child classes
  77889. * @param parent of child
  77890. * @returns the serialized object
  77891. */
  77892. serialize(parent: any): any;
  77893. /**
  77894. * Internal only called by serialize
  77895. * @hidden
  77896. */
  77897. protected _serialize(serializedAction: any, parent?: any): any;
  77898. /**
  77899. * Internal only
  77900. * @hidden
  77901. */
  77902. static _SerializeValueAsString: (value: any) => string;
  77903. /**
  77904. * Internal only
  77905. * @hidden
  77906. */
  77907. static _GetTargetProperty: (target: Scene | Node) => {
  77908. name: string;
  77909. targetType: string;
  77910. value: string;
  77911. };
  77912. }
  77913. }
  77914. declare module BABYLON {
  77915. /**
  77916. * A Condition applied to an Action
  77917. */
  77918. export class Condition {
  77919. /**
  77920. * Internal only - manager for action
  77921. * @hidden
  77922. */
  77923. _actionManager: ActionManager;
  77924. /**
  77925. * Internal only
  77926. * @hidden
  77927. */
  77928. _evaluationId: number;
  77929. /**
  77930. * Internal only
  77931. * @hidden
  77932. */
  77933. _currentResult: boolean;
  77934. /**
  77935. * Creates a new Condition
  77936. * @param actionManager the manager of the action the condition is applied to
  77937. */
  77938. constructor(actionManager: ActionManager);
  77939. /**
  77940. * Check if the current condition is valid
  77941. * @returns a boolean
  77942. */
  77943. isValid(): boolean;
  77944. /**
  77945. * Internal only
  77946. * @hidden
  77947. */
  77948. _getProperty(propertyPath: string): string;
  77949. /**
  77950. * Internal only
  77951. * @hidden
  77952. */
  77953. _getEffectiveTarget(target: any, propertyPath: string): any;
  77954. /**
  77955. * Serialize placeholder for child classes
  77956. * @returns the serialized object
  77957. */
  77958. serialize(): any;
  77959. /**
  77960. * Internal only
  77961. * @hidden
  77962. */
  77963. protected _serialize(serializedCondition: any): any;
  77964. }
  77965. /**
  77966. * Defines specific conditional operators as extensions of Condition
  77967. */
  77968. export class ValueCondition extends Condition {
  77969. /** path to specify the property of the target the conditional operator uses */
  77970. propertyPath: string;
  77971. /** the value compared by the conditional operator against the current value of the property */
  77972. value: any;
  77973. /** the conditional operator, default ValueCondition.IsEqual */
  77974. operator: number;
  77975. /**
  77976. * Internal only
  77977. * @hidden
  77978. */
  77979. private static _IsEqual;
  77980. /**
  77981. * Internal only
  77982. * @hidden
  77983. */
  77984. private static _IsDifferent;
  77985. /**
  77986. * Internal only
  77987. * @hidden
  77988. */
  77989. private static _IsGreater;
  77990. /**
  77991. * Internal only
  77992. * @hidden
  77993. */
  77994. private static _IsLesser;
  77995. /**
  77996. * returns the number for IsEqual
  77997. */
  77998. static readonly IsEqual: number;
  77999. /**
  78000. * Returns the number for IsDifferent
  78001. */
  78002. static readonly IsDifferent: number;
  78003. /**
  78004. * Returns the number for IsGreater
  78005. */
  78006. static readonly IsGreater: number;
  78007. /**
  78008. * Returns the number for IsLesser
  78009. */
  78010. static readonly IsLesser: number;
  78011. /**
  78012. * Internal only The action manager for the condition
  78013. * @hidden
  78014. */
  78015. _actionManager: ActionManager;
  78016. /**
  78017. * Internal only
  78018. * @hidden
  78019. */
  78020. private _target;
  78021. /**
  78022. * Internal only
  78023. * @hidden
  78024. */
  78025. private _effectiveTarget;
  78026. /**
  78027. * Internal only
  78028. * @hidden
  78029. */
  78030. private _property;
  78031. /**
  78032. * Creates a new ValueCondition
  78033. * @param actionManager manager for the action the condition applies to
  78034. * @param target for the action
  78035. * @param propertyPath path to specify the property of the target the conditional operator uses
  78036. * @param value the value compared by the conditional operator against the current value of the property
  78037. * @param operator the conditional operator, default ValueCondition.IsEqual
  78038. */
  78039. constructor(actionManager: ActionManager, target: any,
  78040. /** path to specify the property of the target the conditional operator uses */
  78041. propertyPath: string,
  78042. /** the value compared by the conditional operator against the current value of the property */
  78043. value: any,
  78044. /** the conditional operator, default ValueCondition.IsEqual */
  78045. operator?: number);
  78046. /**
  78047. * Compares the given value with the property value for the specified conditional operator
  78048. * @returns the result of the comparison
  78049. */
  78050. isValid(): boolean;
  78051. /**
  78052. * Serialize the ValueCondition into a JSON compatible object
  78053. * @returns serialization object
  78054. */
  78055. serialize(): any;
  78056. /**
  78057. * Gets the name of the conditional operator for the ValueCondition
  78058. * @param operator the conditional operator
  78059. * @returns the name
  78060. */
  78061. static GetOperatorName(operator: number): string;
  78062. }
  78063. /**
  78064. * Defines a predicate condition as an extension of Condition
  78065. */
  78066. export class PredicateCondition extends Condition {
  78067. /** defines the predicate function used to validate the condition */
  78068. predicate: () => boolean;
  78069. /**
  78070. * Internal only - manager for action
  78071. * @hidden
  78072. */
  78073. _actionManager: ActionManager;
  78074. /**
  78075. * Creates a new PredicateCondition
  78076. * @param actionManager manager for the action the condition applies to
  78077. * @param predicate defines the predicate function used to validate the condition
  78078. */
  78079. constructor(actionManager: ActionManager,
  78080. /** defines the predicate function used to validate the condition */
  78081. predicate: () => boolean);
  78082. /**
  78083. * @returns the validity of the predicate condition
  78084. */
  78085. isValid(): boolean;
  78086. }
  78087. /**
  78088. * Defines a state condition as an extension of Condition
  78089. */
  78090. export class StateCondition extends Condition {
  78091. /** Value to compare with target state */
  78092. value: string;
  78093. /**
  78094. * Internal only - manager for action
  78095. * @hidden
  78096. */
  78097. _actionManager: ActionManager;
  78098. /**
  78099. * Internal only
  78100. * @hidden
  78101. */
  78102. private _target;
  78103. /**
  78104. * Creates a new StateCondition
  78105. * @param actionManager manager for the action the condition applies to
  78106. * @param target of the condition
  78107. * @param value to compare with target state
  78108. */
  78109. constructor(actionManager: ActionManager, target: any,
  78110. /** Value to compare with target state */
  78111. value: string);
  78112. /**
  78113. * Gets a boolean indicating if the current condition is met
  78114. * @returns the validity of the state
  78115. */
  78116. isValid(): boolean;
  78117. /**
  78118. * Serialize the StateCondition into a JSON compatible object
  78119. * @returns serialization object
  78120. */
  78121. serialize(): any;
  78122. }
  78123. }
  78124. declare module BABYLON {
  78125. /**
  78126. * This defines an action responsible to toggle a boolean once triggered.
  78127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78128. */
  78129. export class SwitchBooleanAction extends Action {
  78130. /**
  78131. * The path to the boolean property in the target object
  78132. */
  78133. propertyPath: string;
  78134. private _target;
  78135. private _effectiveTarget;
  78136. private _property;
  78137. /**
  78138. * Instantiate the action
  78139. * @param triggerOptions defines the trigger options
  78140. * @param target defines the object containing the boolean
  78141. * @param propertyPath defines the path to the boolean property in the target object
  78142. * @param condition defines the trigger related conditions
  78143. */
  78144. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78145. /** @hidden */
  78146. _prepare(): void;
  78147. /**
  78148. * Execute the action toggle the boolean value.
  78149. */
  78150. execute(): void;
  78151. /**
  78152. * Serializes the actions and its related information.
  78153. * @param parent defines the object to serialize in
  78154. * @returns the serialized object
  78155. */
  78156. serialize(parent: any): any;
  78157. }
  78158. /**
  78159. * This defines an action responsible to set a the state field of the target
  78160. * to a desired value once triggered.
  78161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78162. */
  78163. export class SetStateAction extends Action {
  78164. /**
  78165. * The value to store in the state field.
  78166. */
  78167. value: string;
  78168. private _target;
  78169. /**
  78170. * Instantiate the action
  78171. * @param triggerOptions defines the trigger options
  78172. * @param target defines the object containing the state property
  78173. * @param value defines the value to store in the state field
  78174. * @param condition defines the trigger related conditions
  78175. */
  78176. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78177. /**
  78178. * Execute the action and store the value on the target state property.
  78179. */
  78180. execute(): void;
  78181. /**
  78182. * Serializes the actions and its related information.
  78183. * @param parent defines the object to serialize in
  78184. * @returns the serialized object
  78185. */
  78186. serialize(parent: any): any;
  78187. }
  78188. /**
  78189. * This defines an action responsible to set a property of the target
  78190. * to a desired value once triggered.
  78191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78192. */
  78193. export class SetValueAction extends Action {
  78194. /**
  78195. * The path of the property to set in the target.
  78196. */
  78197. propertyPath: string;
  78198. /**
  78199. * The value to set in the property
  78200. */
  78201. value: any;
  78202. private _target;
  78203. private _effectiveTarget;
  78204. private _property;
  78205. /**
  78206. * Instantiate the action
  78207. * @param triggerOptions defines the trigger options
  78208. * @param target defines the object containing the property
  78209. * @param propertyPath defines the path of the property to set in the target
  78210. * @param value defines the value to set in the property
  78211. * @param condition defines the trigger related conditions
  78212. */
  78213. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78214. /** @hidden */
  78215. _prepare(): void;
  78216. /**
  78217. * Execute the action and set the targetted property to the desired value.
  78218. */
  78219. execute(): void;
  78220. /**
  78221. * Serializes the actions and its related information.
  78222. * @param parent defines the object to serialize in
  78223. * @returns the serialized object
  78224. */
  78225. serialize(parent: any): any;
  78226. }
  78227. /**
  78228. * This defines an action responsible to increment the target value
  78229. * to a desired value once triggered.
  78230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78231. */
  78232. export class IncrementValueAction extends Action {
  78233. /**
  78234. * The path of the property to increment in the target.
  78235. */
  78236. propertyPath: string;
  78237. /**
  78238. * The value we should increment the property by.
  78239. */
  78240. value: any;
  78241. private _target;
  78242. private _effectiveTarget;
  78243. private _property;
  78244. /**
  78245. * Instantiate the action
  78246. * @param triggerOptions defines the trigger options
  78247. * @param target defines the object containing the property
  78248. * @param propertyPath defines the path of the property to increment in the target
  78249. * @param value defines the value value we should increment the property by
  78250. * @param condition defines the trigger related conditions
  78251. */
  78252. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78253. /** @hidden */
  78254. _prepare(): void;
  78255. /**
  78256. * Execute the action and increment the target of the value amount.
  78257. */
  78258. execute(): void;
  78259. /**
  78260. * Serializes the actions and its related information.
  78261. * @param parent defines the object to serialize in
  78262. * @returns the serialized object
  78263. */
  78264. serialize(parent: any): any;
  78265. }
  78266. /**
  78267. * This defines an action responsible to start an animation once triggered.
  78268. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78269. */
  78270. export class PlayAnimationAction extends Action {
  78271. /**
  78272. * Where the animation should start (animation frame)
  78273. */
  78274. from: number;
  78275. /**
  78276. * Where the animation should stop (animation frame)
  78277. */
  78278. to: number;
  78279. /**
  78280. * Define if the animation should loop or stop after the first play.
  78281. */
  78282. loop?: boolean;
  78283. private _target;
  78284. /**
  78285. * Instantiate the action
  78286. * @param triggerOptions defines the trigger options
  78287. * @param target defines the target animation or animation name
  78288. * @param from defines from where the animation should start (animation frame)
  78289. * @param end defines where the animation should stop (animation frame)
  78290. * @param loop defines if the animation should loop or stop after the first play
  78291. * @param condition defines the trigger related conditions
  78292. */
  78293. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78294. /** @hidden */
  78295. _prepare(): void;
  78296. /**
  78297. * Execute the action and play the animation.
  78298. */
  78299. execute(): void;
  78300. /**
  78301. * Serializes the actions and its related information.
  78302. * @param parent defines the object to serialize in
  78303. * @returns the serialized object
  78304. */
  78305. serialize(parent: any): any;
  78306. }
  78307. /**
  78308. * This defines an action responsible to stop an animation once triggered.
  78309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78310. */
  78311. export class StopAnimationAction extends Action {
  78312. private _target;
  78313. /**
  78314. * Instantiate the action
  78315. * @param triggerOptions defines the trigger options
  78316. * @param target defines the target animation or animation name
  78317. * @param condition defines the trigger related conditions
  78318. */
  78319. constructor(triggerOptions: any, target: any, condition?: Condition);
  78320. /** @hidden */
  78321. _prepare(): void;
  78322. /**
  78323. * Execute the action and stop the animation.
  78324. */
  78325. execute(): void;
  78326. /**
  78327. * Serializes the actions and its related information.
  78328. * @param parent defines the object to serialize in
  78329. * @returns the serialized object
  78330. */
  78331. serialize(parent: any): any;
  78332. }
  78333. /**
  78334. * This defines an action responsible that does nothing once triggered.
  78335. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78336. */
  78337. export class DoNothingAction extends Action {
  78338. /**
  78339. * Instantiate the action
  78340. * @param triggerOptions defines the trigger options
  78341. * @param condition defines the trigger related conditions
  78342. */
  78343. constructor(triggerOptions?: any, condition?: Condition);
  78344. /**
  78345. * Execute the action and do nothing.
  78346. */
  78347. execute(): void;
  78348. /**
  78349. * Serializes the actions and its related information.
  78350. * @param parent defines the object to serialize in
  78351. * @returns the serialized object
  78352. */
  78353. serialize(parent: any): any;
  78354. }
  78355. /**
  78356. * This defines an action responsible to trigger several actions once triggered.
  78357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78358. */
  78359. export class CombineAction extends Action {
  78360. /**
  78361. * The list of aggregated animations to run.
  78362. */
  78363. children: Action[];
  78364. /**
  78365. * Instantiate the action
  78366. * @param triggerOptions defines the trigger options
  78367. * @param children defines the list of aggregated animations to run
  78368. * @param condition defines the trigger related conditions
  78369. */
  78370. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78371. /** @hidden */
  78372. _prepare(): void;
  78373. /**
  78374. * Execute the action and executes all the aggregated actions.
  78375. */
  78376. execute(evt: ActionEvent): void;
  78377. /**
  78378. * Serializes the actions and its related information.
  78379. * @param parent defines the object to serialize in
  78380. * @returns the serialized object
  78381. */
  78382. serialize(parent: any): any;
  78383. }
  78384. /**
  78385. * This defines an action responsible to run code (external event) once triggered.
  78386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78387. */
  78388. export class ExecuteCodeAction extends Action {
  78389. /**
  78390. * The callback function to run.
  78391. */
  78392. func: (evt: ActionEvent) => void;
  78393. /**
  78394. * Instantiate the action
  78395. * @param triggerOptions defines the trigger options
  78396. * @param func defines the callback function to run
  78397. * @param condition defines the trigger related conditions
  78398. */
  78399. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78400. /**
  78401. * Execute the action and run the attached code.
  78402. */
  78403. execute(evt: ActionEvent): void;
  78404. }
  78405. /**
  78406. * This defines an action responsible to set the parent property of the target once triggered.
  78407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78408. */
  78409. export class SetParentAction extends Action {
  78410. private _parent;
  78411. private _target;
  78412. /**
  78413. * Instantiate the action
  78414. * @param triggerOptions defines the trigger options
  78415. * @param target defines the target containing the parent property
  78416. * @param parent defines from where the animation should start (animation frame)
  78417. * @param condition defines the trigger related conditions
  78418. */
  78419. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78420. /** @hidden */
  78421. _prepare(): void;
  78422. /**
  78423. * Execute the action and set the parent property.
  78424. */
  78425. execute(): void;
  78426. /**
  78427. * Serializes the actions and its related information.
  78428. * @param parent defines the object to serialize in
  78429. * @returns the serialized object
  78430. */
  78431. serialize(parent: any): any;
  78432. }
  78433. }
  78434. declare module BABYLON {
  78435. /**
  78436. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78437. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78438. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78439. */
  78440. export class ActionManager extends AbstractActionManager {
  78441. /**
  78442. * Nothing
  78443. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78444. */
  78445. static readonly NothingTrigger: number;
  78446. /**
  78447. * On pick
  78448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78449. */
  78450. static readonly OnPickTrigger: number;
  78451. /**
  78452. * On left pick
  78453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78454. */
  78455. static readonly OnLeftPickTrigger: number;
  78456. /**
  78457. * On right pick
  78458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78459. */
  78460. static readonly OnRightPickTrigger: number;
  78461. /**
  78462. * On center pick
  78463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78464. */
  78465. static readonly OnCenterPickTrigger: number;
  78466. /**
  78467. * On pick down
  78468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78469. */
  78470. static readonly OnPickDownTrigger: number;
  78471. /**
  78472. * On double pick
  78473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78474. */
  78475. static readonly OnDoublePickTrigger: number;
  78476. /**
  78477. * On pick up
  78478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78479. */
  78480. static readonly OnPickUpTrigger: number;
  78481. /**
  78482. * On pick out.
  78483. * This trigger will only be raised if you also declared a OnPickDown
  78484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78485. */
  78486. static readonly OnPickOutTrigger: number;
  78487. /**
  78488. * On long press
  78489. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78490. */
  78491. static readonly OnLongPressTrigger: number;
  78492. /**
  78493. * On pointer over
  78494. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78495. */
  78496. static readonly OnPointerOverTrigger: number;
  78497. /**
  78498. * On pointer out
  78499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78500. */
  78501. static readonly OnPointerOutTrigger: number;
  78502. /**
  78503. * On every frame
  78504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78505. */
  78506. static readonly OnEveryFrameTrigger: number;
  78507. /**
  78508. * On intersection enter
  78509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78510. */
  78511. static readonly OnIntersectionEnterTrigger: number;
  78512. /**
  78513. * On intersection exit
  78514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78515. */
  78516. static readonly OnIntersectionExitTrigger: number;
  78517. /**
  78518. * On key down
  78519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78520. */
  78521. static readonly OnKeyDownTrigger: number;
  78522. /**
  78523. * On key up
  78524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78525. */
  78526. static readonly OnKeyUpTrigger: number;
  78527. private _scene;
  78528. /**
  78529. * Creates a new action manager
  78530. * @param scene defines the hosting scene
  78531. */
  78532. constructor(scene: Scene);
  78533. /**
  78534. * Releases all associated resources
  78535. */
  78536. dispose(): void;
  78537. /**
  78538. * Gets hosting scene
  78539. * @returns the hosting scene
  78540. */
  78541. getScene(): Scene;
  78542. /**
  78543. * Does this action manager handles actions of any of the given triggers
  78544. * @param triggers defines the triggers to be tested
  78545. * @return a boolean indicating whether one (or more) of the triggers is handled
  78546. */
  78547. hasSpecificTriggers(triggers: number[]): boolean;
  78548. /**
  78549. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78550. * speed.
  78551. * @param triggerA defines the trigger to be tested
  78552. * @param triggerB defines the trigger to be tested
  78553. * @return a boolean indicating whether one (or more) of the triggers is handled
  78554. */
  78555. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78556. /**
  78557. * Does this action manager handles actions of a given trigger
  78558. * @param trigger defines the trigger to be tested
  78559. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78560. * @return whether the trigger is handled
  78561. */
  78562. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78563. /**
  78564. * Does this action manager has pointer triggers
  78565. */
  78566. readonly hasPointerTriggers: boolean;
  78567. /**
  78568. * Does this action manager has pick triggers
  78569. */
  78570. readonly hasPickTriggers: boolean;
  78571. /**
  78572. * Registers an action to this action manager
  78573. * @param action defines the action to be registered
  78574. * @return the action amended (prepared) after registration
  78575. */
  78576. registerAction(action: IAction): Nullable<IAction>;
  78577. /**
  78578. * Unregisters an action to this action manager
  78579. * @param action defines the action to be unregistered
  78580. * @return a boolean indicating whether the action has been unregistered
  78581. */
  78582. unregisterAction(action: IAction): Boolean;
  78583. /**
  78584. * Process a specific trigger
  78585. * @param trigger defines the trigger to process
  78586. * @param evt defines the event details to be processed
  78587. */
  78588. processTrigger(trigger: number, evt?: IActionEvent): void;
  78589. /** @hidden */
  78590. _getEffectiveTarget(target: any, propertyPath: string): any;
  78591. /** @hidden */
  78592. _getProperty(propertyPath: string): string;
  78593. /**
  78594. * Serialize this manager to a JSON object
  78595. * @param name defines the property name to store this manager
  78596. * @returns a JSON representation of this manager
  78597. */
  78598. serialize(name: string): any;
  78599. /**
  78600. * Creates a new ActionManager from a JSON data
  78601. * @param parsedActions defines the JSON data to read from
  78602. * @param object defines the hosting mesh
  78603. * @param scene defines the hosting scene
  78604. */
  78605. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78606. /**
  78607. * Get a trigger name by index
  78608. * @param trigger defines the trigger index
  78609. * @returns a trigger name
  78610. */
  78611. static GetTriggerName(trigger: number): string;
  78612. }
  78613. }
  78614. declare module BABYLON {
  78615. /**
  78616. * Class representing a ray with position and direction
  78617. */
  78618. export class Ray {
  78619. /** origin point */
  78620. origin: Vector3;
  78621. /** direction */
  78622. direction: Vector3;
  78623. /** length of the ray */
  78624. length: number;
  78625. private static readonly TmpVector3;
  78626. private _tmpRay;
  78627. /**
  78628. * Creates a new ray
  78629. * @param origin origin point
  78630. * @param direction direction
  78631. * @param length length of the ray
  78632. */
  78633. constructor(
  78634. /** origin point */
  78635. origin: Vector3,
  78636. /** direction */
  78637. direction: Vector3,
  78638. /** length of the ray */
  78639. length?: number);
  78640. /**
  78641. * Checks if the ray intersects a box
  78642. * @param minimum bound of the box
  78643. * @param maximum bound of the box
  78644. * @param intersectionTreshold extra extend to be added to the box in all direction
  78645. * @returns if the box was hit
  78646. */
  78647. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78648. /**
  78649. * Checks if the ray intersects a box
  78650. * @param box the bounding box to check
  78651. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78652. * @returns if the box was hit
  78653. */
  78654. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78655. /**
  78656. * If the ray hits a sphere
  78657. * @param sphere the bounding sphere to check
  78658. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78659. * @returns true if it hits the sphere
  78660. */
  78661. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78662. /**
  78663. * If the ray hits a triange
  78664. * @param vertex0 triangle vertex
  78665. * @param vertex1 triangle vertex
  78666. * @param vertex2 triangle vertex
  78667. * @returns intersection information if hit
  78668. */
  78669. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78670. /**
  78671. * Checks if ray intersects a plane
  78672. * @param plane the plane to check
  78673. * @returns the distance away it was hit
  78674. */
  78675. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78676. /**
  78677. * Calculate the intercept of a ray on a given axis
  78678. * @param axis to check 'x' | 'y' | 'z'
  78679. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  78680. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  78681. */
  78682. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  78683. /**
  78684. * Checks if ray intersects a mesh
  78685. * @param mesh the mesh to check
  78686. * @param fastCheck if only the bounding box should checked
  78687. * @returns picking info of the intersecton
  78688. */
  78689. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78690. /**
  78691. * Checks if ray intersects a mesh
  78692. * @param meshes the meshes to check
  78693. * @param fastCheck if only the bounding box should checked
  78694. * @param results array to store result in
  78695. * @returns Array of picking infos
  78696. */
  78697. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78698. private _comparePickingInfo;
  78699. private static smallnum;
  78700. private static rayl;
  78701. /**
  78702. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78703. * @param sega the first point of the segment to test the intersection against
  78704. * @param segb the second point of the segment to test the intersection against
  78705. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78706. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78707. */
  78708. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78709. /**
  78710. * Update the ray from viewport position
  78711. * @param x position
  78712. * @param y y position
  78713. * @param viewportWidth viewport width
  78714. * @param viewportHeight viewport height
  78715. * @param world world matrix
  78716. * @param view view matrix
  78717. * @param projection projection matrix
  78718. * @returns this ray updated
  78719. */
  78720. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78721. /**
  78722. * Creates a ray with origin and direction of 0,0,0
  78723. * @returns the new ray
  78724. */
  78725. static Zero(): Ray;
  78726. /**
  78727. * Creates a new ray from screen space and viewport
  78728. * @param x position
  78729. * @param y y position
  78730. * @param viewportWidth viewport width
  78731. * @param viewportHeight viewport height
  78732. * @param world world matrix
  78733. * @param view view matrix
  78734. * @param projection projection matrix
  78735. * @returns new ray
  78736. */
  78737. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78738. /**
  78739. * 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
  78740. * transformed to the given world matrix.
  78741. * @param origin The origin point
  78742. * @param end The end point
  78743. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78744. * @returns the new ray
  78745. */
  78746. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78747. /**
  78748. * Transforms a ray by a matrix
  78749. * @param ray ray to transform
  78750. * @param matrix matrix to apply
  78751. * @returns the resulting new ray
  78752. */
  78753. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78754. /**
  78755. * Transforms a ray by a matrix
  78756. * @param ray ray to transform
  78757. * @param matrix matrix to apply
  78758. * @param result ray to store result in
  78759. */
  78760. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78761. /**
  78762. * Unproject a ray from screen space to object space
  78763. * @param sourceX defines the screen space x coordinate to use
  78764. * @param sourceY defines the screen space y coordinate to use
  78765. * @param viewportWidth defines the current width of the viewport
  78766. * @param viewportHeight defines the current height of the viewport
  78767. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78768. * @param view defines the view matrix to use
  78769. * @param projection defines the projection matrix to use
  78770. */
  78771. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78772. }
  78773. /**
  78774. * Type used to define predicate used to select faces when a mesh intersection is detected
  78775. */
  78776. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78777. interface Scene {
  78778. /** @hidden */
  78779. _tempPickingRay: Nullable<Ray>;
  78780. /** @hidden */
  78781. _cachedRayForTransform: Ray;
  78782. /** @hidden */
  78783. _pickWithRayInverseMatrix: Matrix;
  78784. /** @hidden */
  78785. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78786. /** @hidden */
  78787. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78788. }
  78789. }
  78790. declare module BABYLON {
  78791. interface Scene {
  78792. /** @hidden */
  78793. _pointerOverSprite: Nullable<Sprite>;
  78794. /** @hidden */
  78795. _pickedDownSprite: Nullable<Sprite>;
  78796. /** @hidden */
  78797. _tempSpritePickingRay: Nullable<Ray>;
  78798. /**
  78799. * All of the sprite managers added to this scene
  78800. * @see http://doc.babylonjs.com/babylon101/sprites
  78801. */
  78802. spriteManagers: Array<ISpriteManager>;
  78803. /**
  78804. * An event triggered when sprites rendering is about to start
  78805. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78806. */
  78807. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78808. /**
  78809. * An event triggered when sprites rendering is done
  78810. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78811. */
  78812. onAfterSpritesRenderingObservable: Observable<Scene>;
  78813. /** @hidden */
  78814. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78815. /** Launch a ray to try to pick a sprite in the scene
  78816. * @param x position on screen
  78817. * @param y position on screen
  78818. * @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
  78819. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78820. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78821. * @returns a PickingInfo
  78822. */
  78823. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78824. /** Use the given ray to pick a sprite in the scene
  78825. * @param ray The ray (in world space) to use to pick meshes
  78826. * @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
  78827. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78828. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78829. * @returns a PickingInfo
  78830. */
  78831. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78832. /**
  78833. * Force the sprite under the pointer
  78834. * @param sprite defines the sprite to use
  78835. */
  78836. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78837. /**
  78838. * Gets the sprite under the pointer
  78839. * @returns a Sprite or null if no sprite is under the pointer
  78840. */
  78841. getPointerOverSprite(): Nullable<Sprite>;
  78842. }
  78843. /**
  78844. * Defines the sprite scene component responsible to manage sprites
  78845. * in a given scene.
  78846. */
  78847. export class SpriteSceneComponent implements ISceneComponent {
  78848. /**
  78849. * The component name helpfull to identify the component in the list of scene components.
  78850. */
  78851. readonly name: string;
  78852. /**
  78853. * The scene the component belongs to.
  78854. */
  78855. scene: Scene;
  78856. /** @hidden */
  78857. private _spritePredicate;
  78858. /**
  78859. * Creates a new instance of the component for the given scene
  78860. * @param scene Defines the scene to register the component in
  78861. */
  78862. constructor(scene: Scene);
  78863. /**
  78864. * Registers the component in a given scene
  78865. */
  78866. register(): void;
  78867. /**
  78868. * Rebuilds the elements related to this component in case of
  78869. * context lost for instance.
  78870. */
  78871. rebuild(): void;
  78872. /**
  78873. * Disposes the component and the associated ressources.
  78874. */
  78875. dispose(): void;
  78876. private _pickSpriteButKeepRay;
  78877. private _pointerMove;
  78878. private _pointerDown;
  78879. private _pointerUp;
  78880. }
  78881. }
  78882. declare module BABYLON {
  78883. /** @hidden */
  78884. export var fogFragmentDeclaration: {
  78885. name: string;
  78886. shader: string;
  78887. };
  78888. }
  78889. declare module BABYLON {
  78890. /** @hidden */
  78891. export var fogFragment: {
  78892. name: string;
  78893. shader: string;
  78894. };
  78895. }
  78896. declare module BABYLON {
  78897. /** @hidden */
  78898. export var spritesPixelShader: {
  78899. name: string;
  78900. shader: string;
  78901. };
  78902. }
  78903. declare module BABYLON {
  78904. /** @hidden */
  78905. export var fogVertexDeclaration: {
  78906. name: string;
  78907. shader: string;
  78908. };
  78909. }
  78910. declare module BABYLON {
  78911. /** @hidden */
  78912. export var spritesVertexShader: {
  78913. name: string;
  78914. shader: string;
  78915. };
  78916. }
  78917. declare module BABYLON {
  78918. /**
  78919. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78920. */
  78921. export interface ISpriteManager extends IDisposable {
  78922. /**
  78923. * Restricts the camera to viewing objects with the same layerMask.
  78924. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78925. */
  78926. layerMask: number;
  78927. /**
  78928. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78929. */
  78930. isPickable: boolean;
  78931. /**
  78932. * Specifies the rendering group id for this mesh (0 by default)
  78933. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78934. */
  78935. renderingGroupId: number;
  78936. /**
  78937. * Defines the list of sprites managed by the manager.
  78938. */
  78939. sprites: Array<Sprite>;
  78940. /**
  78941. * Tests the intersection of a sprite with a specific ray.
  78942. * @param ray The ray we are sending to test the collision
  78943. * @param camera The camera space we are sending rays in
  78944. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78945. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78946. * @returns picking info or null.
  78947. */
  78948. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78949. /**
  78950. * Renders the list of sprites on screen.
  78951. */
  78952. render(): void;
  78953. }
  78954. /**
  78955. * Class used to manage multiple sprites on the same spritesheet
  78956. * @see http://doc.babylonjs.com/babylon101/sprites
  78957. */
  78958. export class SpriteManager implements ISpriteManager {
  78959. /** defines the manager's name */
  78960. name: string;
  78961. /** Gets the list of sprites */
  78962. sprites: Sprite[];
  78963. /** Gets or sets the rendering group id (0 by default) */
  78964. renderingGroupId: number;
  78965. /** Gets or sets camera layer mask */
  78966. layerMask: number;
  78967. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78968. fogEnabled: boolean;
  78969. /** Gets or sets a boolean indicating if the sprites are pickable */
  78970. isPickable: boolean;
  78971. /** Defines the default width of a cell in the spritesheet */
  78972. cellWidth: number;
  78973. /** Defines the default height of a cell in the spritesheet */
  78974. cellHeight: number;
  78975. /**
  78976. * An event triggered when the manager is disposed.
  78977. */
  78978. onDisposeObservable: Observable<SpriteManager>;
  78979. private _onDisposeObserver;
  78980. /**
  78981. * Callback called when the manager is disposed
  78982. */
  78983. onDispose: () => void;
  78984. private _capacity;
  78985. private _spriteTexture;
  78986. private _epsilon;
  78987. private _scene;
  78988. private _vertexData;
  78989. private _buffer;
  78990. private _vertexBuffers;
  78991. private _indexBuffer;
  78992. private _effectBase;
  78993. private _effectFog;
  78994. /**
  78995. * Gets or sets the spritesheet texture
  78996. */
  78997. texture: Texture;
  78998. /**
  78999. * Creates a new sprite manager
  79000. * @param name defines the manager's name
  79001. * @param imgUrl defines the sprite sheet url
  79002. * @param capacity defines the maximum allowed number of sprites
  79003. * @param cellSize defines the size of a sprite cell
  79004. * @param scene defines the hosting scene
  79005. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79006. * @param samplingMode defines the smapling mode to use with spritesheet
  79007. */
  79008. constructor(
  79009. /** defines the manager's name */
  79010. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  79011. private _appendSpriteVertex;
  79012. /**
  79013. * Intersects the sprites with a ray
  79014. * @param ray defines the ray to intersect with
  79015. * @param camera defines the current active camera
  79016. * @param predicate defines a predicate used to select candidate sprites
  79017. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79018. * @returns null if no hit or a PickingInfo
  79019. */
  79020. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79021. /**
  79022. * Render all child sprites
  79023. */
  79024. render(): void;
  79025. /**
  79026. * Release associated resources
  79027. */
  79028. dispose(): void;
  79029. }
  79030. }
  79031. declare module BABYLON {
  79032. /**
  79033. * Class used to represent a sprite
  79034. * @see http://doc.babylonjs.com/babylon101/sprites
  79035. */
  79036. export class Sprite {
  79037. /** defines the name */
  79038. name: string;
  79039. /** Gets or sets the current world position */
  79040. position: Vector3;
  79041. /** Gets or sets the main color */
  79042. color: Color4;
  79043. /** Gets or sets the width */
  79044. width: number;
  79045. /** Gets or sets the height */
  79046. height: number;
  79047. /** Gets or sets rotation angle */
  79048. angle: number;
  79049. /** Gets or sets the cell index in the sprite sheet */
  79050. cellIndex: number;
  79051. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79052. invertU: number;
  79053. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79054. invertV: number;
  79055. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79056. disposeWhenFinishedAnimating: boolean;
  79057. /** Gets the list of attached animations */
  79058. animations: Animation[];
  79059. /** Gets or sets a boolean indicating if the sprite can be picked */
  79060. isPickable: boolean;
  79061. /**
  79062. * Gets or sets the associated action manager
  79063. */
  79064. actionManager: Nullable<ActionManager>;
  79065. private _animationStarted;
  79066. private _loopAnimation;
  79067. private _fromIndex;
  79068. private _toIndex;
  79069. private _delay;
  79070. private _direction;
  79071. private _manager;
  79072. private _time;
  79073. private _onAnimationEnd;
  79074. /**
  79075. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79076. */
  79077. isVisible: boolean;
  79078. /**
  79079. * Gets or sets the sprite size
  79080. */
  79081. size: number;
  79082. /**
  79083. * Creates a new Sprite
  79084. * @param name defines the name
  79085. * @param manager defines the manager
  79086. */
  79087. constructor(
  79088. /** defines the name */
  79089. name: string, manager: ISpriteManager);
  79090. /**
  79091. * Starts an animation
  79092. * @param from defines the initial key
  79093. * @param to defines the end key
  79094. * @param loop defines if the animation must loop
  79095. * @param delay defines the start delay (in ms)
  79096. * @param onAnimationEnd defines a callback to call when animation ends
  79097. */
  79098. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79099. /** Stops current animation (if any) */
  79100. stopAnimation(): void;
  79101. /** @hidden */
  79102. _animate(deltaTime: number): void;
  79103. /** Release associated resources */
  79104. dispose(): void;
  79105. }
  79106. }
  79107. declare module BABYLON {
  79108. /**
  79109. * Information about the result of picking within a scene
  79110. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79111. */
  79112. export class PickingInfo {
  79113. /** @hidden */
  79114. _pickingUnavailable: boolean;
  79115. /**
  79116. * If the pick collided with an object
  79117. */
  79118. hit: boolean;
  79119. /**
  79120. * Distance away where the pick collided
  79121. */
  79122. distance: number;
  79123. /**
  79124. * The location of pick collision
  79125. */
  79126. pickedPoint: Nullable<Vector3>;
  79127. /**
  79128. * The mesh corresponding the the pick collision
  79129. */
  79130. pickedMesh: Nullable<AbstractMesh>;
  79131. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79132. bu: number;
  79133. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79134. bv: number;
  79135. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79136. faceId: number;
  79137. /** Id of the the submesh that was picked */
  79138. subMeshId: number;
  79139. /** If a sprite was picked, this will be the sprite the pick collided with */
  79140. pickedSprite: Nullable<Sprite>;
  79141. /**
  79142. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79143. */
  79144. originMesh: Nullable<AbstractMesh>;
  79145. /**
  79146. * The ray that was used to perform the picking.
  79147. */
  79148. ray: Nullable<Ray>;
  79149. /**
  79150. * Gets the normal correspodning to the face the pick collided with
  79151. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79152. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79153. * @returns The normal correspodning to the face the pick collided with
  79154. */
  79155. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79156. /**
  79157. * Gets the texture coordinates of where the pick occured
  79158. * @returns the vector containing the coordnates of the texture
  79159. */
  79160. getTextureCoordinates(): Nullable<Vector2>;
  79161. }
  79162. }
  79163. declare module BABYLON {
  79164. /**
  79165. * Gather the list of pointer event types as constants.
  79166. */
  79167. export class PointerEventTypes {
  79168. /**
  79169. * 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.
  79170. */
  79171. static readonly POINTERDOWN: number;
  79172. /**
  79173. * The pointerup event is fired when a pointer is no longer active.
  79174. */
  79175. static readonly POINTERUP: number;
  79176. /**
  79177. * The pointermove event is fired when a pointer changes coordinates.
  79178. */
  79179. static readonly POINTERMOVE: number;
  79180. /**
  79181. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79182. */
  79183. static readonly POINTERWHEEL: number;
  79184. /**
  79185. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79186. */
  79187. static readonly POINTERPICK: number;
  79188. /**
  79189. * The pointertap event is fired when a the object has been touched and released without drag.
  79190. */
  79191. static readonly POINTERTAP: number;
  79192. /**
  79193. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79194. */
  79195. static readonly POINTERDOUBLETAP: number;
  79196. }
  79197. /**
  79198. * Base class of pointer info types.
  79199. */
  79200. export class PointerInfoBase {
  79201. /**
  79202. * Defines the type of event (PointerEventTypes)
  79203. */
  79204. type: number;
  79205. /**
  79206. * Defines the related dom event
  79207. */
  79208. event: PointerEvent | MouseWheelEvent;
  79209. /**
  79210. * Instantiates the base class of pointers info.
  79211. * @param type Defines the type of event (PointerEventTypes)
  79212. * @param event Defines the related dom event
  79213. */
  79214. constructor(
  79215. /**
  79216. * Defines the type of event (PointerEventTypes)
  79217. */
  79218. type: number,
  79219. /**
  79220. * Defines the related dom event
  79221. */
  79222. event: PointerEvent | MouseWheelEvent);
  79223. }
  79224. /**
  79225. * This class is used to store pointer related info for the onPrePointerObservable event.
  79226. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79227. */
  79228. export class PointerInfoPre extends PointerInfoBase {
  79229. /**
  79230. * Ray from a pointer if availible (eg. 6dof controller)
  79231. */
  79232. ray: Nullable<Ray>;
  79233. /**
  79234. * Defines the local position of the pointer on the canvas.
  79235. */
  79236. localPosition: Vector2;
  79237. /**
  79238. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79239. */
  79240. skipOnPointerObservable: boolean;
  79241. /**
  79242. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79243. * @param type Defines the type of event (PointerEventTypes)
  79244. * @param event Defines the related dom event
  79245. * @param localX Defines the local x coordinates of the pointer when the event occured
  79246. * @param localY Defines the local y coordinates of the pointer when the event occured
  79247. */
  79248. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79249. }
  79250. /**
  79251. * This type contains all the data related to a pointer event in Babylon.js.
  79252. * 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.
  79253. */
  79254. export class PointerInfo extends PointerInfoBase {
  79255. /**
  79256. * Defines the picking info associated to the info (if any)\
  79257. */
  79258. pickInfo: Nullable<PickingInfo>;
  79259. /**
  79260. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79261. * @param type Defines the type of event (PointerEventTypes)
  79262. * @param event Defines the related dom event
  79263. * @param pickInfo Defines the picking info associated to the info (if any)\
  79264. */
  79265. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79266. /**
  79267. * Defines the picking info associated to the info (if any)\
  79268. */
  79269. pickInfo: Nullable<PickingInfo>);
  79270. }
  79271. /**
  79272. * Data relating to a touch event on the screen.
  79273. */
  79274. export interface PointerTouch {
  79275. /**
  79276. * X coordinate of touch.
  79277. */
  79278. x: number;
  79279. /**
  79280. * Y coordinate of touch.
  79281. */
  79282. y: number;
  79283. /**
  79284. * Id of touch. Unique for each finger.
  79285. */
  79286. pointerId: number;
  79287. /**
  79288. * Event type passed from DOM.
  79289. */
  79290. type: any;
  79291. }
  79292. }
  79293. declare module BABYLON {
  79294. /**
  79295. * Manage the mouse inputs to control the movement of a free camera.
  79296. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79297. */
  79298. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79299. /**
  79300. * Define if touch is enabled in the mouse input
  79301. */
  79302. touchEnabled: boolean;
  79303. /**
  79304. * Defines the camera the input is attached to.
  79305. */
  79306. camera: FreeCamera;
  79307. /**
  79308. * Defines the buttons associated with the input to handle camera move.
  79309. */
  79310. buttons: number[];
  79311. /**
  79312. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79313. */
  79314. angularSensibility: number;
  79315. private _pointerInput;
  79316. private _onMouseMove;
  79317. private _observer;
  79318. private previousPosition;
  79319. /**
  79320. * Observable for when a pointer move event occurs containing the move offset
  79321. */
  79322. onPointerMovedObservable: Observable<{
  79323. offsetX: number;
  79324. offsetY: number;
  79325. }>;
  79326. /**
  79327. * @hidden
  79328. * If the camera should be rotated automatically based on pointer movement
  79329. */
  79330. _allowCameraRotation: boolean;
  79331. /**
  79332. * Manage the mouse inputs to control the movement of a free camera.
  79333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79334. * @param touchEnabled Defines if touch is enabled or not
  79335. */
  79336. constructor(
  79337. /**
  79338. * Define if touch is enabled in the mouse input
  79339. */
  79340. touchEnabled?: boolean);
  79341. /**
  79342. * Attach the input controls to a specific dom element to get the input from.
  79343. * @param element Defines the element the controls should be listened from
  79344. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79345. */
  79346. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79347. /**
  79348. * Called on JS contextmenu event.
  79349. * Override this method to provide functionality.
  79350. */
  79351. protected onContextMenu(evt: PointerEvent): void;
  79352. /**
  79353. * Detach the current controls from the specified dom element.
  79354. * @param element Defines the element to stop listening the inputs from
  79355. */
  79356. detachControl(element: Nullable<HTMLElement>): void;
  79357. /**
  79358. * Gets the class name of the current intput.
  79359. * @returns the class name
  79360. */
  79361. getClassName(): string;
  79362. /**
  79363. * Get the friendly name associated with the input class.
  79364. * @returns the input friendly name
  79365. */
  79366. getSimpleName(): string;
  79367. }
  79368. }
  79369. declare module BABYLON {
  79370. /**
  79371. * Manage the touch inputs to control the movement of a free camera.
  79372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79373. */
  79374. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79375. /**
  79376. * Defines the camera the input is attached to.
  79377. */
  79378. camera: FreeCamera;
  79379. /**
  79380. * Defines the touch sensibility for rotation.
  79381. * The higher the faster.
  79382. */
  79383. touchAngularSensibility: number;
  79384. /**
  79385. * Defines the touch sensibility for move.
  79386. * The higher the faster.
  79387. */
  79388. touchMoveSensibility: number;
  79389. private _offsetX;
  79390. private _offsetY;
  79391. private _pointerPressed;
  79392. private _pointerInput;
  79393. private _observer;
  79394. private _onLostFocus;
  79395. /**
  79396. * Attach the input controls to a specific dom element to get the input from.
  79397. * @param element Defines the element the controls should be listened from
  79398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79399. */
  79400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79401. /**
  79402. * Detach the current controls from the specified dom element.
  79403. * @param element Defines the element to stop listening the inputs from
  79404. */
  79405. detachControl(element: Nullable<HTMLElement>): void;
  79406. /**
  79407. * Update the current camera state depending on the inputs that have been used this frame.
  79408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79409. */
  79410. checkInputs(): void;
  79411. /**
  79412. * Gets the class name of the current intput.
  79413. * @returns the class name
  79414. */
  79415. getClassName(): string;
  79416. /**
  79417. * Get the friendly name associated with the input class.
  79418. * @returns the input friendly name
  79419. */
  79420. getSimpleName(): string;
  79421. }
  79422. }
  79423. declare module BABYLON {
  79424. /**
  79425. * Default Inputs manager for the FreeCamera.
  79426. * It groups all the default supported inputs for ease of use.
  79427. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79428. */
  79429. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79430. /**
  79431. * @hidden
  79432. */
  79433. _mouseInput: Nullable<FreeCameraMouseInput>;
  79434. /**
  79435. * Instantiates a new FreeCameraInputsManager.
  79436. * @param camera Defines the camera the inputs belong to
  79437. */
  79438. constructor(camera: FreeCamera);
  79439. /**
  79440. * Add keyboard input support to the input manager.
  79441. * @returns the current input manager
  79442. */
  79443. addKeyboard(): FreeCameraInputsManager;
  79444. /**
  79445. * Add mouse input support to the input manager.
  79446. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79447. * @returns the current input manager
  79448. */
  79449. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79450. /**
  79451. * Removes the mouse input support from the manager
  79452. * @returns the current input manager
  79453. */
  79454. removeMouse(): FreeCameraInputsManager;
  79455. /**
  79456. * Add touch input support to the input manager.
  79457. * @returns the current input manager
  79458. */
  79459. addTouch(): FreeCameraInputsManager;
  79460. /**
  79461. * Remove all attached input methods from a camera
  79462. */
  79463. clear(): void;
  79464. }
  79465. }
  79466. declare module BABYLON {
  79467. /**
  79468. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79469. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79470. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79471. */
  79472. export class FreeCamera extends TargetCamera {
  79473. /**
  79474. * Define the collision ellipsoid of the camera.
  79475. * This is helpful to simulate a camera body like the player body around the camera
  79476. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79477. */
  79478. ellipsoid: Vector3;
  79479. /**
  79480. * Define an offset for the position of the ellipsoid around the camera.
  79481. * This can be helpful to determine the center of the body near the gravity center of the body
  79482. * instead of its head.
  79483. */
  79484. ellipsoidOffset: Vector3;
  79485. /**
  79486. * Enable or disable collisions of the camera with the rest of the scene objects.
  79487. */
  79488. checkCollisions: boolean;
  79489. /**
  79490. * Enable or disable gravity on the camera.
  79491. */
  79492. applyGravity: boolean;
  79493. /**
  79494. * Define the input manager associated to the camera.
  79495. */
  79496. inputs: FreeCameraInputsManager;
  79497. /**
  79498. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79499. * Higher values reduce sensitivity.
  79500. */
  79501. /**
  79502. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79503. * Higher values reduce sensitivity.
  79504. */
  79505. angularSensibility: number;
  79506. /**
  79507. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79508. */
  79509. keysUp: number[];
  79510. /**
  79511. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79512. */
  79513. keysDown: number[];
  79514. /**
  79515. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79516. */
  79517. keysLeft: number[];
  79518. /**
  79519. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79520. */
  79521. keysRight: number[];
  79522. /**
  79523. * Event raised when the camera collide with a mesh in the scene.
  79524. */
  79525. onCollide: (collidedMesh: AbstractMesh) => void;
  79526. private _collider;
  79527. private _needMoveForGravity;
  79528. private _oldPosition;
  79529. private _diffPosition;
  79530. private _newPosition;
  79531. /** @hidden */
  79532. _localDirection: Vector3;
  79533. /** @hidden */
  79534. _transformedDirection: Vector3;
  79535. /**
  79536. * Instantiates a Free Camera.
  79537. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79538. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79539. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79540. * @param name Define the name of the camera in the scene
  79541. * @param position Define the start position of the camera in the scene
  79542. * @param scene Define the scene the camera belongs to
  79543. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79544. */
  79545. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79546. /**
  79547. * Attached controls to the current camera.
  79548. * @param element Defines the element the controls should be listened from
  79549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79550. */
  79551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79552. /**
  79553. * Detach the current controls from the camera.
  79554. * The camera will stop reacting to inputs.
  79555. * @param element Defines the element to stop listening the inputs from
  79556. */
  79557. detachControl(element: HTMLElement): void;
  79558. private _collisionMask;
  79559. /**
  79560. * Define a collision mask to limit the list of object the camera can collide with
  79561. */
  79562. collisionMask: number;
  79563. /** @hidden */
  79564. _collideWithWorld(displacement: Vector3): void;
  79565. private _onCollisionPositionChange;
  79566. /** @hidden */
  79567. _checkInputs(): void;
  79568. /** @hidden */
  79569. _decideIfNeedsToMove(): boolean;
  79570. /** @hidden */
  79571. _updatePosition(): void;
  79572. /**
  79573. * Destroy the camera and release the current resources hold by it.
  79574. */
  79575. dispose(): void;
  79576. /**
  79577. * Gets the current object class name.
  79578. * @return the class name
  79579. */
  79580. getClassName(): string;
  79581. }
  79582. }
  79583. declare module BABYLON {
  79584. /**
  79585. * Represents a gamepad control stick position
  79586. */
  79587. export class StickValues {
  79588. /**
  79589. * The x component of the control stick
  79590. */
  79591. x: number;
  79592. /**
  79593. * The y component of the control stick
  79594. */
  79595. y: number;
  79596. /**
  79597. * Initializes the gamepad x and y control stick values
  79598. * @param x The x component of the gamepad control stick value
  79599. * @param y The y component of the gamepad control stick value
  79600. */
  79601. constructor(
  79602. /**
  79603. * The x component of the control stick
  79604. */
  79605. x: number,
  79606. /**
  79607. * The y component of the control stick
  79608. */
  79609. y: number);
  79610. }
  79611. /**
  79612. * An interface which manages callbacks for gamepad button changes
  79613. */
  79614. export interface GamepadButtonChanges {
  79615. /**
  79616. * Called when a gamepad has been changed
  79617. */
  79618. changed: boolean;
  79619. /**
  79620. * Called when a gamepad press event has been triggered
  79621. */
  79622. pressChanged: boolean;
  79623. /**
  79624. * Called when a touch event has been triggered
  79625. */
  79626. touchChanged: boolean;
  79627. /**
  79628. * Called when a value has changed
  79629. */
  79630. valueChanged: boolean;
  79631. }
  79632. /**
  79633. * Represents a gamepad
  79634. */
  79635. export class Gamepad {
  79636. /**
  79637. * The id of the gamepad
  79638. */
  79639. id: string;
  79640. /**
  79641. * The index of the gamepad
  79642. */
  79643. index: number;
  79644. /**
  79645. * The browser gamepad
  79646. */
  79647. browserGamepad: any;
  79648. /**
  79649. * Specifies what type of gamepad this represents
  79650. */
  79651. type: number;
  79652. private _leftStick;
  79653. private _rightStick;
  79654. /** @hidden */
  79655. _isConnected: boolean;
  79656. private _leftStickAxisX;
  79657. private _leftStickAxisY;
  79658. private _rightStickAxisX;
  79659. private _rightStickAxisY;
  79660. /**
  79661. * Triggered when the left control stick has been changed
  79662. */
  79663. private _onleftstickchanged;
  79664. /**
  79665. * Triggered when the right control stick has been changed
  79666. */
  79667. private _onrightstickchanged;
  79668. /**
  79669. * Represents a gamepad controller
  79670. */
  79671. static GAMEPAD: number;
  79672. /**
  79673. * Represents a generic controller
  79674. */
  79675. static GENERIC: number;
  79676. /**
  79677. * Represents an XBox controller
  79678. */
  79679. static XBOX: number;
  79680. /**
  79681. * Represents a pose-enabled controller
  79682. */
  79683. static POSE_ENABLED: number;
  79684. /**
  79685. * Specifies whether the left control stick should be Y-inverted
  79686. */
  79687. protected _invertLeftStickY: boolean;
  79688. /**
  79689. * Specifies if the gamepad has been connected
  79690. */
  79691. readonly isConnected: boolean;
  79692. /**
  79693. * Initializes the gamepad
  79694. * @param id The id of the gamepad
  79695. * @param index The index of the gamepad
  79696. * @param browserGamepad The browser gamepad
  79697. * @param leftStickX The x component of the left joystick
  79698. * @param leftStickY The y component of the left joystick
  79699. * @param rightStickX The x component of the right joystick
  79700. * @param rightStickY The y component of the right joystick
  79701. */
  79702. constructor(
  79703. /**
  79704. * The id of the gamepad
  79705. */
  79706. id: string,
  79707. /**
  79708. * The index of the gamepad
  79709. */
  79710. index: number,
  79711. /**
  79712. * The browser gamepad
  79713. */
  79714. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79715. /**
  79716. * Callback triggered when the left joystick has changed
  79717. * @param callback
  79718. */
  79719. onleftstickchanged(callback: (values: StickValues) => void): void;
  79720. /**
  79721. * Callback triggered when the right joystick has changed
  79722. * @param callback
  79723. */
  79724. onrightstickchanged(callback: (values: StickValues) => void): void;
  79725. /**
  79726. * Gets the left joystick
  79727. */
  79728. /**
  79729. * Sets the left joystick values
  79730. */
  79731. leftStick: StickValues;
  79732. /**
  79733. * Gets the right joystick
  79734. */
  79735. /**
  79736. * Sets the right joystick value
  79737. */
  79738. rightStick: StickValues;
  79739. /**
  79740. * Updates the gamepad joystick positions
  79741. */
  79742. update(): void;
  79743. /**
  79744. * Disposes the gamepad
  79745. */
  79746. dispose(): void;
  79747. }
  79748. /**
  79749. * Represents a generic gamepad
  79750. */
  79751. export class GenericPad extends Gamepad {
  79752. private _buttons;
  79753. private _onbuttondown;
  79754. private _onbuttonup;
  79755. /**
  79756. * Observable triggered when a button has been pressed
  79757. */
  79758. onButtonDownObservable: Observable<number>;
  79759. /**
  79760. * Observable triggered when a button has been released
  79761. */
  79762. onButtonUpObservable: Observable<number>;
  79763. /**
  79764. * Callback triggered when a button has been pressed
  79765. * @param callback Called when a button has been pressed
  79766. */
  79767. onbuttondown(callback: (buttonPressed: number) => void): void;
  79768. /**
  79769. * Callback triggered when a button has been released
  79770. * @param callback Called when a button has been released
  79771. */
  79772. onbuttonup(callback: (buttonReleased: number) => void): void;
  79773. /**
  79774. * Initializes the generic gamepad
  79775. * @param id The id of the generic gamepad
  79776. * @param index The index of the generic gamepad
  79777. * @param browserGamepad The browser gamepad
  79778. */
  79779. constructor(id: string, index: number, browserGamepad: any);
  79780. private _setButtonValue;
  79781. /**
  79782. * Updates the generic gamepad
  79783. */
  79784. update(): void;
  79785. /**
  79786. * Disposes the generic gamepad
  79787. */
  79788. dispose(): void;
  79789. }
  79790. }
  79791. declare module BABYLON {
  79792. /**
  79793. * Defines the types of pose enabled controllers that are supported
  79794. */
  79795. export enum PoseEnabledControllerType {
  79796. /**
  79797. * HTC Vive
  79798. */
  79799. VIVE = 0,
  79800. /**
  79801. * Oculus Rift
  79802. */
  79803. OCULUS = 1,
  79804. /**
  79805. * Windows mixed reality
  79806. */
  79807. WINDOWS = 2,
  79808. /**
  79809. * Samsung gear VR
  79810. */
  79811. GEAR_VR = 3,
  79812. /**
  79813. * Google Daydream
  79814. */
  79815. DAYDREAM = 4,
  79816. /**
  79817. * Generic
  79818. */
  79819. GENERIC = 5
  79820. }
  79821. /**
  79822. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79823. */
  79824. export interface MutableGamepadButton {
  79825. /**
  79826. * Value of the button/trigger
  79827. */
  79828. value: number;
  79829. /**
  79830. * If the button/trigger is currently touched
  79831. */
  79832. touched: boolean;
  79833. /**
  79834. * If the button/trigger is currently pressed
  79835. */
  79836. pressed: boolean;
  79837. }
  79838. /**
  79839. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79840. * @hidden
  79841. */
  79842. export interface ExtendedGamepadButton extends GamepadButton {
  79843. /**
  79844. * If the button/trigger is currently pressed
  79845. */
  79846. readonly pressed: boolean;
  79847. /**
  79848. * If the button/trigger is currently touched
  79849. */
  79850. readonly touched: boolean;
  79851. /**
  79852. * Value of the button/trigger
  79853. */
  79854. readonly value: number;
  79855. }
  79856. /** @hidden */
  79857. export interface _GamePadFactory {
  79858. /**
  79859. * Returns wether or not the current gamepad can be created for this type of controller.
  79860. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79861. * @returns true if it can be created, otherwise false
  79862. */
  79863. canCreate(gamepadInfo: any): boolean;
  79864. /**
  79865. * Creates a new instance of the Gamepad.
  79866. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79867. * @returns the new gamepad instance
  79868. */
  79869. create(gamepadInfo: any): Gamepad;
  79870. }
  79871. /**
  79872. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79873. */
  79874. export class PoseEnabledControllerHelper {
  79875. /** @hidden */
  79876. static _ControllerFactories: _GamePadFactory[];
  79877. /** @hidden */
  79878. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  79879. /**
  79880. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79881. * @param vrGamepad the gamepad to initialized
  79882. * @returns a vr controller of the type the gamepad identified as
  79883. */
  79884. static InitiateController(vrGamepad: any): Gamepad;
  79885. }
  79886. /**
  79887. * Defines the PoseEnabledController object that contains state of a vr capable controller
  79888. */
  79889. export class PoseEnabledController extends Gamepad implements PoseControlled {
  79890. private _deviceRoomPosition;
  79891. private _deviceRoomRotationQuaternion;
  79892. /**
  79893. * The device position in babylon space
  79894. */
  79895. devicePosition: Vector3;
  79896. /**
  79897. * The device rotation in babylon space
  79898. */
  79899. deviceRotationQuaternion: Quaternion;
  79900. /**
  79901. * The scale factor of the device in babylon space
  79902. */
  79903. deviceScaleFactor: number;
  79904. /**
  79905. * (Likely devicePosition should be used instead) The device position in its room space
  79906. */
  79907. position: Vector3;
  79908. /**
  79909. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  79910. */
  79911. rotationQuaternion: Quaternion;
  79912. /**
  79913. * The type of controller (Eg. Windows mixed reality)
  79914. */
  79915. controllerType: PoseEnabledControllerType;
  79916. protected _calculatedPosition: Vector3;
  79917. private _calculatedRotation;
  79918. /**
  79919. * The raw pose from the device
  79920. */
  79921. rawPose: DevicePose;
  79922. private _trackPosition;
  79923. private _maxRotationDistFromHeadset;
  79924. private _draggedRoomRotation;
  79925. /**
  79926. * @hidden
  79927. */
  79928. _disableTrackPosition(fixedPosition: Vector3): void;
  79929. /**
  79930. * Internal, the mesh attached to the controller
  79931. * @hidden
  79932. */
  79933. _mesh: Nullable<AbstractMesh>;
  79934. private _poseControlledCamera;
  79935. private _leftHandSystemQuaternion;
  79936. /**
  79937. * Internal, matrix used to convert room space to babylon space
  79938. * @hidden
  79939. */
  79940. _deviceToWorld: Matrix;
  79941. /**
  79942. * Node to be used when casting a ray from the controller
  79943. * @hidden
  79944. */
  79945. _pointingPoseNode: Nullable<TransformNode>;
  79946. /**
  79947. * Name of the child mesh that can be used to cast a ray from the controller
  79948. */
  79949. static readonly POINTING_POSE: string;
  79950. /**
  79951. * Creates a new PoseEnabledController from a gamepad
  79952. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  79953. */
  79954. constructor(browserGamepad: any);
  79955. private _workingMatrix;
  79956. /**
  79957. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  79958. */
  79959. update(): void;
  79960. /**
  79961. * Updates only the pose device and mesh without doing any button event checking
  79962. */
  79963. protected _updatePoseAndMesh(): void;
  79964. /**
  79965. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  79966. * @param poseData raw pose fromthe device
  79967. */
  79968. updateFromDevice(poseData: DevicePose): void;
  79969. /**
  79970. * @hidden
  79971. */
  79972. _meshAttachedObservable: Observable<AbstractMesh>;
  79973. /**
  79974. * Attaches a mesh to the controller
  79975. * @param mesh the mesh to be attached
  79976. */
  79977. attachToMesh(mesh: AbstractMesh): void;
  79978. /**
  79979. * Attaches the controllers mesh to a camera
  79980. * @param camera the camera the mesh should be attached to
  79981. */
  79982. attachToPoseControlledCamera(camera: TargetCamera): void;
  79983. /**
  79984. * Disposes of the controller
  79985. */
  79986. dispose(): void;
  79987. /**
  79988. * The mesh that is attached to the controller
  79989. */
  79990. readonly mesh: Nullable<AbstractMesh>;
  79991. /**
  79992. * Gets the ray of the controller in the direction the controller is pointing
  79993. * @param length the length the resulting ray should be
  79994. * @returns a ray in the direction the controller is pointing
  79995. */
  79996. getForwardRay(length?: number): Ray;
  79997. }
  79998. }
  79999. declare module BABYLON {
  80000. /**
  80001. * Defines the WebVRController object that represents controllers tracked in 3D space
  80002. */
  80003. export abstract class WebVRController extends PoseEnabledController {
  80004. /**
  80005. * Internal, the default controller model for the controller
  80006. */
  80007. protected _defaultModel: AbstractMesh;
  80008. /**
  80009. * Fired when the trigger state has changed
  80010. */
  80011. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80012. /**
  80013. * Fired when the main button state has changed
  80014. */
  80015. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80016. /**
  80017. * Fired when the secondary button state has changed
  80018. */
  80019. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80020. /**
  80021. * Fired when the pad state has changed
  80022. */
  80023. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80024. /**
  80025. * Fired when controllers stick values have changed
  80026. */
  80027. onPadValuesChangedObservable: Observable<StickValues>;
  80028. /**
  80029. * Array of button availible on the controller
  80030. */
  80031. protected _buttons: Array<MutableGamepadButton>;
  80032. private _onButtonStateChange;
  80033. /**
  80034. * Fired when a controller button's state has changed
  80035. * @param callback the callback containing the button that was modified
  80036. */
  80037. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80038. /**
  80039. * X and Y axis corresponding to the controllers joystick
  80040. */
  80041. pad: StickValues;
  80042. /**
  80043. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80044. */
  80045. hand: string;
  80046. /**
  80047. * The default controller model for the controller
  80048. */
  80049. readonly defaultModel: AbstractMesh;
  80050. /**
  80051. * Creates a new WebVRController from a gamepad
  80052. * @param vrGamepad the gamepad that the WebVRController should be created from
  80053. */
  80054. constructor(vrGamepad: any);
  80055. /**
  80056. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80057. */
  80058. update(): void;
  80059. /**
  80060. * Function to be called when a button is modified
  80061. */
  80062. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80063. /**
  80064. * Loads a mesh and attaches it to the controller
  80065. * @param scene the scene the mesh should be added to
  80066. * @param meshLoaded callback for when the mesh has been loaded
  80067. */
  80068. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80069. private _setButtonValue;
  80070. private _changes;
  80071. private _checkChanges;
  80072. /**
  80073. * Disposes of th webVRCOntroller
  80074. */
  80075. dispose(): void;
  80076. }
  80077. }
  80078. declare module BABYLON {
  80079. /**
  80080. * The HemisphericLight simulates the ambient environment light,
  80081. * so the passed direction is the light reflection direction, not the incoming direction.
  80082. */
  80083. export class HemisphericLight extends Light {
  80084. /**
  80085. * The groundColor is the light in the opposite direction to the one specified during creation.
  80086. * 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.
  80087. */
  80088. groundColor: Color3;
  80089. /**
  80090. * The light reflection direction, not the incoming direction.
  80091. */
  80092. direction: Vector3;
  80093. /**
  80094. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80095. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80096. * The HemisphericLight can't cast shadows.
  80097. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80098. * @param name The friendly name of the light
  80099. * @param direction The direction of the light reflection
  80100. * @param scene The scene the light belongs to
  80101. */
  80102. constructor(name: string, direction: Vector3, scene: Scene);
  80103. protected _buildUniformLayout(): void;
  80104. /**
  80105. * Returns the string "HemisphericLight".
  80106. * @return The class name
  80107. */
  80108. getClassName(): string;
  80109. /**
  80110. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80111. * Returns the updated direction.
  80112. * @param target The target the direction should point to
  80113. * @return The computed direction
  80114. */
  80115. setDirectionToTarget(target: Vector3): Vector3;
  80116. /**
  80117. * Returns the shadow generator associated to the light.
  80118. * @returns Always null for hemispheric lights because it does not support shadows.
  80119. */
  80120. getShadowGenerator(): Nullable<IShadowGenerator>;
  80121. /**
  80122. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80123. * @param effect The effect to update
  80124. * @param lightIndex The index of the light in the effect to update
  80125. * @returns The hemispheric light
  80126. */
  80127. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80128. /**
  80129. * Computes the world matrix of the node
  80130. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80131. * @param useWasUpdatedFlag defines a reserved property
  80132. * @returns the world matrix
  80133. */
  80134. computeWorldMatrix(): Matrix;
  80135. /**
  80136. * Returns the integer 3.
  80137. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80138. */
  80139. getTypeID(): number;
  80140. /**
  80141. * Prepares the list of defines specific to the light type.
  80142. * @param defines the list of defines
  80143. * @param lightIndex defines the index of the light for the effect
  80144. */
  80145. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80146. }
  80147. }
  80148. declare module BABYLON {
  80149. /** @hidden */
  80150. export var vrMultiviewToSingleviewPixelShader: {
  80151. name: string;
  80152. shader: string;
  80153. };
  80154. }
  80155. declare module BABYLON {
  80156. /**
  80157. * Renders to multiple views with a single draw call
  80158. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80159. */
  80160. export class MultiviewRenderTarget extends RenderTargetTexture {
  80161. /**
  80162. * Creates a multiview render target
  80163. * @param scene scene used with the render target
  80164. * @param size the size of the render target (used for each view)
  80165. */
  80166. constructor(scene: Scene, size?: number | {
  80167. width: number;
  80168. height: number;
  80169. } | {
  80170. ratio: number;
  80171. });
  80172. /**
  80173. * @hidden
  80174. * @param faceIndex the face index, if its a cube texture
  80175. */
  80176. _bindFrameBuffer(faceIndex?: number): void;
  80177. /**
  80178. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80179. * @returns the view count
  80180. */
  80181. getViewCount(): number;
  80182. }
  80183. }
  80184. declare module BABYLON {
  80185. interface Engine {
  80186. /**
  80187. * Creates a new multiview render target
  80188. * @param width defines the width of the texture
  80189. * @param height defines the height of the texture
  80190. * @returns the created multiview texture
  80191. */
  80192. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80193. /**
  80194. * Binds a multiview framebuffer to be drawn to
  80195. * @param multiviewTexture texture to bind
  80196. */
  80197. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80198. }
  80199. interface Camera {
  80200. /**
  80201. * @hidden
  80202. * 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)
  80203. */
  80204. _useMultiviewToSingleView: boolean;
  80205. /**
  80206. * @hidden
  80207. * 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)
  80208. */
  80209. _multiviewTexture: Nullable<RenderTargetTexture>;
  80210. /**
  80211. * @hidden
  80212. * ensures the multiview texture of the camera exists and has the specified width/height
  80213. * @param width height to set on the multiview texture
  80214. * @param height width to set on the multiview texture
  80215. */
  80216. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80217. }
  80218. interface Scene {
  80219. /** @hidden */
  80220. _transformMatrixR: Matrix;
  80221. /** @hidden */
  80222. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80223. /** @hidden */
  80224. _createMultiviewUbo(): void;
  80225. /** @hidden */
  80226. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80227. /** @hidden */
  80228. _renderMultiviewToSingleView(camera: Camera): void;
  80229. }
  80230. }
  80231. declare module BABYLON {
  80232. /**
  80233. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80234. * This will not be used for webXR as it supports displaying texture arrays directly
  80235. */
  80236. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80237. /**
  80238. * Initializes a VRMultiviewToSingleview
  80239. * @param name name of the post process
  80240. * @param camera camera to be applied to
  80241. * @param scaleFactor scaling factor to the size of the output texture
  80242. */
  80243. constructor(name: string, camera: Camera, scaleFactor: number);
  80244. }
  80245. }
  80246. declare module BABYLON {
  80247. interface Engine {
  80248. /** @hidden */
  80249. _vrDisplay: any;
  80250. /** @hidden */
  80251. _vrSupported: boolean;
  80252. /** @hidden */
  80253. _oldSize: Size;
  80254. /** @hidden */
  80255. _oldHardwareScaleFactor: number;
  80256. /** @hidden */
  80257. _vrExclusivePointerMode: boolean;
  80258. /** @hidden */
  80259. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80260. /** @hidden */
  80261. _onVRDisplayPointerRestricted: () => void;
  80262. /** @hidden */
  80263. _onVRDisplayPointerUnrestricted: () => void;
  80264. /** @hidden */
  80265. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80266. /** @hidden */
  80267. _onVrDisplayDisconnect: Nullable<() => void>;
  80268. /** @hidden */
  80269. _onVrDisplayPresentChange: Nullable<() => void>;
  80270. /**
  80271. * Observable signaled when VR display mode changes
  80272. */
  80273. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80274. /**
  80275. * Observable signaled when VR request present is complete
  80276. */
  80277. onVRRequestPresentComplete: Observable<boolean>;
  80278. /**
  80279. * Observable signaled when VR request present starts
  80280. */
  80281. onVRRequestPresentStart: Observable<Engine>;
  80282. /**
  80283. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80284. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80285. */
  80286. isInVRExclusivePointerMode: boolean;
  80287. /**
  80288. * Gets a boolean indicating if a webVR device was detected
  80289. * @returns true if a webVR device was detected
  80290. */
  80291. isVRDevicePresent(): boolean;
  80292. /**
  80293. * Gets the current webVR device
  80294. * @returns the current webVR device (or null)
  80295. */
  80296. getVRDevice(): any;
  80297. /**
  80298. * Initializes a webVR display and starts listening to display change events
  80299. * The onVRDisplayChangedObservable will be notified upon these changes
  80300. * @returns A promise containing a VRDisplay and if vr is supported
  80301. */
  80302. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80303. /** @hidden */
  80304. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80305. /**
  80306. * Call this function to switch to webVR mode
  80307. * Will do nothing if webVR is not supported or if there is no webVR device
  80308. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80309. */
  80310. enableVR(): void;
  80311. /** @hidden */
  80312. _onVRFullScreenTriggered(): void;
  80313. }
  80314. }
  80315. declare module BABYLON {
  80316. /**
  80317. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80318. * IMPORTANT!! The data is right-hand data.
  80319. * @export
  80320. * @interface DevicePose
  80321. */
  80322. export interface DevicePose {
  80323. /**
  80324. * The position of the device, values in array are [x,y,z].
  80325. */
  80326. readonly position: Nullable<Float32Array>;
  80327. /**
  80328. * The linearVelocity of the device, values in array are [x,y,z].
  80329. */
  80330. readonly linearVelocity: Nullable<Float32Array>;
  80331. /**
  80332. * The linearAcceleration of the device, values in array are [x,y,z].
  80333. */
  80334. readonly linearAcceleration: Nullable<Float32Array>;
  80335. /**
  80336. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80337. */
  80338. readonly orientation: Nullable<Float32Array>;
  80339. /**
  80340. * The angularVelocity of the device, values in array are [x,y,z].
  80341. */
  80342. readonly angularVelocity: Nullable<Float32Array>;
  80343. /**
  80344. * The angularAcceleration of the device, values in array are [x,y,z].
  80345. */
  80346. readonly angularAcceleration: Nullable<Float32Array>;
  80347. }
  80348. /**
  80349. * Interface representing a pose controlled object in Babylon.
  80350. * A pose controlled object has both regular pose values as well as pose values
  80351. * from an external device such as a VR head mounted display
  80352. */
  80353. export interface PoseControlled {
  80354. /**
  80355. * The position of the object in babylon space.
  80356. */
  80357. position: Vector3;
  80358. /**
  80359. * The rotation quaternion of the object in babylon space.
  80360. */
  80361. rotationQuaternion: Quaternion;
  80362. /**
  80363. * The position of the device in babylon space.
  80364. */
  80365. devicePosition?: Vector3;
  80366. /**
  80367. * The rotation quaternion of the device in babylon space.
  80368. */
  80369. deviceRotationQuaternion: Quaternion;
  80370. /**
  80371. * The raw pose coming from the device.
  80372. */
  80373. rawPose: Nullable<DevicePose>;
  80374. /**
  80375. * The scale of the device to be used when translating from device space to babylon space.
  80376. */
  80377. deviceScaleFactor: number;
  80378. /**
  80379. * Updates the poseControlled values based on the input device pose.
  80380. * @param poseData the pose data to update the object with
  80381. */
  80382. updateFromDevice(poseData: DevicePose): void;
  80383. }
  80384. /**
  80385. * Set of options to customize the webVRCamera
  80386. */
  80387. export interface WebVROptions {
  80388. /**
  80389. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80390. */
  80391. trackPosition?: boolean;
  80392. /**
  80393. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80394. */
  80395. positionScale?: number;
  80396. /**
  80397. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80398. */
  80399. displayName?: string;
  80400. /**
  80401. * Should the native controller meshes be initialized. (default: true)
  80402. */
  80403. controllerMeshes?: boolean;
  80404. /**
  80405. * Creating a default HemiLight only on controllers. (default: true)
  80406. */
  80407. defaultLightingOnControllers?: boolean;
  80408. /**
  80409. * If you don't want to use the default VR button of the helper. (default: false)
  80410. */
  80411. useCustomVRButton?: boolean;
  80412. /**
  80413. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80414. */
  80415. customVRButton?: HTMLButtonElement;
  80416. /**
  80417. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80418. */
  80419. rayLength?: number;
  80420. /**
  80421. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80422. */
  80423. defaultHeight?: number;
  80424. /**
  80425. * If multiview should be used if availible (default: false)
  80426. */
  80427. useMultiview?: boolean;
  80428. }
  80429. /**
  80430. * This represents a WebVR camera.
  80431. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80432. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80433. */
  80434. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80435. private webVROptions;
  80436. /**
  80437. * @hidden
  80438. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80439. */
  80440. _vrDevice: any;
  80441. /**
  80442. * The rawPose of the vrDevice.
  80443. */
  80444. rawPose: Nullable<DevicePose>;
  80445. private _onVREnabled;
  80446. private _specsVersion;
  80447. private _attached;
  80448. private _frameData;
  80449. protected _descendants: Array<Node>;
  80450. private _deviceRoomPosition;
  80451. /** @hidden */
  80452. _deviceRoomRotationQuaternion: Quaternion;
  80453. private _standingMatrix;
  80454. /**
  80455. * Represents device position in babylon space.
  80456. */
  80457. devicePosition: Vector3;
  80458. /**
  80459. * Represents device rotation in babylon space.
  80460. */
  80461. deviceRotationQuaternion: Quaternion;
  80462. /**
  80463. * The scale of the device to be used when translating from device space to babylon space.
  80464. */
  80465. deviceScaleFactor: number;
  80466. private _deviceToWorld;
  80467. private _worldToDevice;
  80468. /**
  80469. * References to the webVR controllers for the vrDevice.
  80470. */
  80471. controllers: Array<WebVRController>;
  80472. /**
  80473. * Emits an event when a controller is attached.
  80474. */
  80475. onControllersAttachedObservable: Observable<WebVRController[]>;
  80476. /**
  80477. * Emits an event when a controller's mesh has been loaded;
  80478. */
  80479. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80480. /**
  80481. * Emits an event when the HMD's pose has been updated.
  80482. */
  80483. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80484. private _poseSet;
  80485. /**
  80486. * If the rig cameras be used as parent instead of this camera.
  80487. */
  80488. rigParenting: boolean;
  80489. private _lightOnControllers;
  80490. private _defaultHeight?;
  80491. /**
  80492. * Instantiates a WebVRFreeCamera.
  80493. * @param name The name of the WebVRFreeCamera
  80494. * @param position The starting anchor position for the camera
  80495. * @param scene The scene the camera belongs to
  80496. * @param webVROptions a set of customizable options for the webVRCamera
  80497. */
  80498. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80499. /**
  80500. * Gets the device distance from the ground in meters.
  80501. * @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.
  80502. */
  80503. deviceDistanceToRoomGround(): number;
  80504. /**
  80505. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80506. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80507. */
  80508. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80509. /**
  80510. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80511. * @returns A promise with a boolean set to if the standing matrix is supported.
  80512. */
  80513. useStandingMatrixAsync(): Promise<boolean>;
  80514. /**
  80515. * Disposes the camera
  80516. */
  80517. dispose(): void;
  80518. /**
  80519. * Gets a vrController by name.
  80520. * @param name The name of the controller to retreive
  80521. * @returns the controller matching the name specified or null if not found
  80522. */
  80523. getControllerByName(name: string): Nullable<WebVRController>;
  80524. private _leftController;
  80525. /**
  80526. * The controller corresponding to the users left hand.
  80527. */
  80528. readonly leftController: Nullable<WebVRController>;
  80529. private _rightController;
  80530. /**
  80531. * The controller corresponding to the users right hand.
  80532. */
  80533. readonly rightController: Nullable<WebVRController>;
  80534. /**
  80535. * Casts a ray forward from the vrCamera's gaze.
  80536. * @param length Length of the ray (default: 100)
  80537. * @returns the ray corresponding to the gaze
  80538. */
  80539. getForwardRay(length?: number): Ray;
  80540. /**
  80541. * @hidden
  80542. * Updates the camera based on device's frame data
  80543. */
  80544. _checkInputs(): void;
  80545. /**
  80546. * Updates the poseControlled values based on the input device pose.
  80547. * @param poseData Pose coming from the device
  80548. */
  80549. updateFromDevice(poseData: DevicePose): void;
  80550. private _htmlElementAttached;
  80551. private _detachIfAttached;
  80552. /**
  80553. * WebVR's attach control will start broadcasting frames to the device.
  80554. * Note that in certain browsers (chrome for example) this function must be called
  80555. * within a user-interaction callback. Example:
  80556. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80557. *
  80558. * @param element html element to attach the vrDevice to
  80559. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80560. */
  80561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80562. /**
  80563. * Detaches the camera from the html element and disables VR
  80564. *
  80565. * @param element html element to detach from
  80566. */
  80567. detachControl(element: HTMLElement): void;
  80568. /**
  80569. * @returns the name of this class
  80570. */
  80571. getClassName(): string;
  80572. /**
  80573. * Calls resetPose on the vrDisplay
  80574. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80575. */
  80576. resetToCurrentRotation(): void;
  80577. /**
  80578. * @hidden
  80579. * Updates the rig cameras (left and right eye)
  80580. */
  80581. _updateRigCameras(): void;
  80582. private _workingVector;
  80583. private _oneVector;
  80584. private _workingMatrix;
  80585. private updateCacheCalled;
  80586. private _correctPositionIfNotTrackPosition;
  80587. /**
  80588. * @hidden
  80589. * Updates the cached values of the camera
  80590. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80591. */
  80592. _updateCache(ignoreParentClass?: boolean): void;
  80593. /**
  80594. * @hidden
  80595. * Get current device position in babylon world
  80596. */
  80597. _computeDevicePosition(): void;
  80598. /**
  80599. * Updates the current device position and rotation in the babylon world
  80600. */
  80601. update(): void;
  80602. /**
  80603. * @hidden
  80604. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80605. * @returns an identity matrix
  80606. */
  80607. _getViewMatrix(): Matrix;
  80608. private _tmpMatrix;
  80609. /**
  80610. * This function is called by the two RIG cameras.
  80611. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80612. * @hidden
  80613. */
  80614. _getWebVRViewMatrix(): Matrix;
  80615. /** @hidden */
  80616. _getWebVRProjectionMatrix(): Matrix;
  80617. private _onGamepadConnectedObserver;
  80618. private _onGamepadDisconnectedObserver;
  80619. private _updateCacheWhenTrackingDisabledObserver;
  80620. /**
  80621. * Initializes the controllers and their meshes
  80622. */
  80623. initControllers(): void;
  80624. }
  80625. }
  80626. declare module BABYLON {
  80627. /**
  80628. * Size options for a post process
  80629. */
  80630. export type PostProcessOptions = {
  80631. width: number;
  80632. height: number;
  80633. };
  80634. /**
  80635. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80636. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80637. */
  80638. export class PostProcess {
  80639. /** Name of the PostProcess. */
  80640. name: string;
  80641. /**
  80642. * Gets or sets the unique id of the post process
  80643. */
  80644. uniqueId: number;
  80645. /**
  80646. * Width of the texture to apply the post process on
  80647. */
  80648. width: number;
  80649. /**
  80650. * Height of the texture to apply the post process on
  80651. */
  80652. height: number;
  80653. /**
  80654. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80655. * @hidden
  80656. */
  80657. _outputTexture: Nullable<InternalTexture>;
  80658. /**
  80659. * Sampling mode used by the shader
  80660. * See https://doc.babylonjs.com/classes/3.1/texture
  80661. */
  80662. renderTargetSamplingMode: number;
  80663. /**
  80664. * Clear color to use when screen clearing
  80665. */
  80666. clearColor: Color4;
  80667. /**
  80668. * If the buffer needs to be cleared before applying the post process. (default: true)
  80669. * Should be set to false if shader will overwrite all previous pixels.
  80670. */
  80671. autoClear: boolean;
  80672. /**
  80673. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80674. */
  80675. alphaMode: number;
  80676. /**
  80677. * Sets the setAlphaBlendConstants of the babylon engine
  80678. */
  80679. alphaConstants: Color4;
  80680. /**
  80681. * Animations to be used for the post processing
  80682. */
  80683. animations: Animation[];
  80684. /**
  80685. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80686. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80687. */
  80688. enablePixelPerfectMode: boolean;
  80689. /**
  80690. * Force the postprocess to be applied without taking in account viewport
  80691. */
  80692. forceFullscreenViewport: boolean;
  80693. /**
  80694. * List of inspectable custom properties (used by the Inspector)
  80695. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80696. */
  80697. inspectableCustomProperties: IInspectable[];
  80698. /**
  80699. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80700. *
  80701. * | Value | Type | Description |
  80702. * | ----- | ----------------------------------- | ----------- |
  80703. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80704. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80705. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80706. *
  80707. */
  80708. scaleMode: number;
  80709. /**
  80710. * Force textures to be a power of two (default: false)
  80711. */
  80712. alwaysForcePOT: boolean;
  80713. private _samples;
  80714. /**
  80715. * Number of sample textures (default: 1)
  80716. */
  80717. samples: number;
  80718. /**
  80719. * Modify the scale of the post process to be the same as the viewport (default: false)
  80720. */
  80721. adaptScaleToCurrentViewport: boolean;
  80722. private _camera;
  80723. private _scene;
  80724. private _engine;
  80725. private _options;
  80726. private _reusable;
  80727. private _textureType;
  80728. /**
  80729. * Smart array of input and output textures for the post process.
  80730. * @hidden
  80731. */
  80732. _textures: SmartArray<InternalTexture>;
  80733. /**
  80734. * The index in _textures that corresponds to the output texture.
  80735. * @hidden
  80736. */
  80737. _currentRenderTextureInd: number;
  80738. private _effect;
  80739. private _samplers;
  80740. private _fragmentUrl;
  80741. private _vertexUrl;
  80742. private _parameters;
  80743. private _scaleRatio;
  80744. protected _indexParameters: any;
  80745. private _shareOutputWithPostProcess;
  80746. private _texelSize;
  80747. private _forcedOutputTexture;
  80748. /**
  80749. * Returns the fragment url or shader name used in the post process.
  80750. * @returns the fragment url or name in the shader store.
  80751. */
  80752. getEffectName(): string;
  80753. /**
  80754. * An event triggered when the postprocess is activated.
  80755. */
  80756. onActivateObservable: Observable<Camera>;
  80757. private _onActivateObserver;
  80758. /**
  80759. * A function that is added to the onActivateObservable
  80760. */
  80761. onActivate: Nullable<(camera: Camera) => void>;
  80762. /**
  80763. * An event triggered when the postprocess changes its size.
  80764. */
  80765. onSizeChangedObservable: Observable<PostProcess>;
  80766. private _onSizeChangedObserver;
  80767. /**
  80768. * A function that is added to the onSizeChangedObservable
  80769. */
  80770. onSizeChanged: (postProcess: PostProcess) => void;
  80771. /**
  80772. * An event triggered when the postprocess applies its effect.
  80773. */
  80774. onApplyObservable: Observable<Effect>;
  80775. private _onApplyObserver;
  80776. /**
  80777. * A function that is added to the onApplyObservable
  80778. */
  80779. onApply: (effect: Effect) => void;
  80780. /**
  80781. * An event triggered before rendering the postprocess
  80782. */
  80783. onBeforeRenderObservable: Observable<Effect>;
  80784. private _onBeforeRenderObserver;
  80785. /**
  80786. * A function that is added to the onBeforeRenderObservable
  80787. */
  80788. onBeforeRender: (effect: Effect) => void;
  80789. /**
  80790. * An event triggered after rendering the postprocess
  80791. */
  80792. onAfterRenderObservable: Observable<Effect>;
  80793. private _onAfterRenderObserver;
  80794. /**
  80795. * A function that is added to the onAfterRenderObservable
  80796. */
  80797. onAfterRender: (efect: Effect) => void;
  80798. /**
  80799. * 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
  80800. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80801. */
  80802. inputTexture: InternalTexture;
  80803. /**
  80804. * Gets the camera which post process is applied to.
  80805. * @returns The camera the post process is applied to.
  80806. */
  80807. getCamera(): Camera;
  80808. /**
  80809. * Gets the texel size of the postprocess.
  80810. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80811. */
  80812. readonly texelSize: Vector2;
  80813. /**
  80814. * Creates a new instance PostProcess
  80815. * @param name The name of the PostProcess.
  80816. * @param fragmentUrl The url of the fragment shader to be used.
  80817. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80818. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80819. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80820. * @param camera The camera to apply the render pass to.
  80821. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80822. * @param engine The engine which the post process will be applied. (default: current engine)
  80823. * @param reusable If the post process can be reused on the same frame. (default: false)
  80824. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80825. * @param textureType Type of textures used when performing the post process. (default: 0)
  80826. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80827. * @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
  80828. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80829. */
  80830. constructor(
  80831. /** Name of the PostProcess. */
  80832. 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);
  80833. /**
  80834. * Gets a string idenfifying the name of the class
  80835. * @returns "PostProcess" string
  80836. */
  80837. getClassName(): string;
  80838. /**
  80839. * Gets the engine which this post process belongs to.
  80840. * @returns The engine the post process was enabled with.
  80841. */
  80842. getEngine(): Engine;
  80843. /**
  80844. * The effect that is created when initializing the post process.
  80845. * @returns The created effect corresponding the the postprocess.
  80846. */
  80847. getEffect(): Effect;
  80848. /**
  80849. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  80850. * @param postProcess The post process to share the output with.
  80851. * @returns This post process.
  80852. */
  80853. shareOutputWith(postProcess: PostProcess): PostProcess;
  80854. /**
  80855. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  80856. * This should be called if the post process that shares output with this post process is disabled/disposed.
  80857. */
  80858. useOwnOutput(): void;
  80859. /**
  80860. * Updates the effect with the current post process compile time values and recompiles the shader.
  80861. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80862. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80863. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80864. * @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
  80865. * @param onCompiled Called when the shader has been compiled.
  80866. * @param onError Called if there is an error when compiling a shader.
  80867. */
  80868. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80869. /**
  80870. * The post process is reusable if it can be used multiple times within one frame.
  80871. * @returns If the post process is reusable
  80872. */
  80873. isReusable(): boolean;
  80874. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  80875. markTextureDirty(): void;
  80876. /**
  80877. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  80878. * 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.
  80879. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  80880. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  80881. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  80882. * @returns The target texture that was bound to be written to.
  80883. */
  80884. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  80885. /**
  80886. * If the post process is supported.
  80887. */
  80888. readonly isSupported: boolean;
  80889. /**
  80890. * The aspect ratio of the output texture.
  80891. */
  80892. readonly aspectRatio: number;
  80893. /**
  80894. * Get a value indicating if the post-process is ready to be used
  80895. * @returns true if the post-process is ready (shader is compiled)
  80896. */
  80897. isReady(): boolean;
  80898. /**
  80899. * Binds all textures and uniforms to the shader, this will be run on every pass.
  80900. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  80901. */
  80902. apply(): Nullable<Effect>;
  80903. private _disposeTextures;
  80904. /**
  80905. * Disposes the post process.
  80906. * @param camera The camera to dispose the post process on.
  80907. */
  80908. dispose(camera?: Camera): void;
  80909. }
  80910. }
  80911. declare module BABYLON {
  80912. /** @hidden */
  80913. export var kernelBlurVaryingDeclaration: {
  80914. name: string;
  80915. shader: string;
  80916. };
  80917. }
  80918. declare module BABYLON {
  80919. /** @hidden */
  80920. export var kernelBlurFragment: {
  80921. name: string;
  80922. shader: string;
  80923. };
  80924. }
  80925. declare module BABYLON {
  80926. /** @hidden */
  80927. export var kernelBlurFragment2: {
  80928. name: string;
  80929. shader: string;
  80930. };
  80931. }
  80932. declare module BABYLON {
  80933. /** @hidden */
  80934. export var kernelBlurPixelShader: {
  80935. name: string;
  80936. shader: string;
  80937. };
  80938. }
  80939. declare module BABYLON {
  80940. /** @hidden */
  80941. export var kernelBlurVertex: {
  80942. name: string;
  80943. shader: string;
  80944. };
  80945. }
  80946. declare module BABYLON {
  80947. /** @hidden */
  80948. export var kernelBlurVertexShader: {
  80949. name: string;
  80950. shader: string;
  80951. };
  80952. }
  80953. declare module BABYLON {
  80954. /**
  80955. * The Blur Post Process which blurs an image based on a kernel and direction.
  80956. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  80957. */
  80958. export class BlurPostProcess extends PostProcess {
  80959. /** The direction in which to blur the image. */
  80960. direction: Vector2;
  80961. private blockCompilation;
  80962. protected _kernel: number;
  80963. protected _idealKernel: number;
  80964. protected _packedFloat: boolean;
  80965. private _staticDefines;
  80966. /**
  80967. * Sets the length in pixels of the blur sample region
  80968. */
  80969. /**
  80970. * Gets the length in pixels of the blur sample region
  80971. */
  80972. kernel: number;
  80973. /**
  80974. * Sets wether or not the blur needs to unpack/repack floats
  80975. */
  80976. /**
  80977. * Gets wether or not the blur is unpacking/repacking floats
  80978. */
  80979. packedFloat: boolean;
  80980. /**
  80981. * Creates a new instance BlurPostProcess
  80982. * @param name The name of the effect.
  80983. * @param direction The direction in which to blur the image.
  80984. * @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.
  80985. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80986. * @param camera The camera to apply the render pass to.
  80987. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80988. * @param engine The engine which the post process will be applied. (default: current engine)
  80989. * @param reusable If the post process can be reused on the same frame. (default: false)
  80990. * @param textureType Type of textures used when performing the post process. (default: 0)
  80991. * @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)
  80992. */
  80993. constructor(name: string,
  80994. /** The direction in which to blur the image. */
  80995. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  80996. /**
  80997. * Updates the effect with the current post process compile time values and recompiles the shader.
  80998. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80999. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81000. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81001. * @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
  81002. * @param onCompiled Called when the shader has been compiled.
  81003. * @param onError Called if there is an error when compiling a shader.
  81004. */
  81005. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81006. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81007. /**
  81008. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81009. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81010. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81011. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81012. * The gaps between physical kernels are compensated for in the weighting of the samples
  81013. * @param idealKernel Ideal blur kernel.
  81014. * @return Nearest best kernel.
  81015. */
  81016. protected _nearestBestKernel(idealKernel: number): number;
  81017. /**
  81018. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81019. * @param x The point on the Gaussian distribution to sample.
  81020. * @return the value of the Gaussian function at x.
  81021. */
  81022. protected _gaussianWeight(x: number): number;
  81023. /**
  81024. * Generates a string that can be used as a floating point number in GLSL.
  81025. * @param x Value to print.
  81026. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81027. * @return GLSL float string.
  81028. */
  81029. protected _glslFloat(x: number, decimalFigures?: number): string;
  81030. }
  81031. }
  81032. declare module BABYLON {
  81033. /**
  81034. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81035. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81036. * You can then easily use it as a reflectionTexture on a flat surface.
  81037. * In case the surface is not a plane, please consider relying on reflection probes.
  81038. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81039. */
  81040. export class MirrorTexture extends RenderTargetTexture {
  81041. private scene;
  81042. /**
  81043. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81044. * 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.
  81045. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81046. */
  81047. mirrorPlane: Plane;
  81048. /**
  81049. * Define the blur ratio used to blur the reflection if needed.
  81050. */
  81051. blurRatio: number;
  81052. /**
  81053. * Define the adaptive blur kernel used to blur the reflection if needed.
  81054. * This will autocompute the closest best match for the `blurKernel`
  81055. */
  81056. adaptiveBlurKernel: number;
  81057. /**
  81058. * Define the blur kernel used to blur the reflection if needed.
  81059. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81060. */
  81061. blurKernel: number;
  81062. /**
  81063. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81064. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81065. */
  81066. blurKernelX: number;
  81067. /**
  81068. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81069. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81070. */
  81071. blurKernelY: number;
  81072. private _autoComputeBlurKernel;
  81073. protected _onRatioRescale(): void;
  81074. private _updateGammaSpace;
  81075. private _imageProcessingConfigChangeObserver;
  81076. private _transformMatrix;
  81077. private _mirrorMatrix;
  81078. private _savedViewMatrix;
  81079. private _blurX;
  81080. private _blurY;
  81081. private _adaptiveBlurKernel;
  81082. private _blurKernelX;
  81083. private _blurKernelY;
  81084. private _blurRatio;
  81085. /**
  81086. * Instantiates a Mirror Texture.
  81087. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81088. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81089. * You can then easily use it as a reflectionTexture on a flat surface.
  81090. * In case the surface is not a plane, please consider relying on reflection probes.
  81091. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81092. * @param name
  81093. * @param size
  81094. * @param scene
  81095. * @param generateMipMaps
  81096. * @param type
  81097. * @param samplingMode
  81098. * @param generateDepthBuffer
  81099. */
  81100. constructor(name: string, size: number | {
  81101. width: number;
  81102. height: number;
  81103. } | {
  81104. ratio: number;
  81105. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81106. private _preparePostProcesses;
  81107. /**
  81108. * Clone the mirror texture.
  81109. * @returns the cloned texture
  81110. */
  81111. clone(): MirrorTexture;
  81112. /**
  81113. * Serialize the texture to a JSON representation you could use in Parse later on
  81114. * @returns the serialized JSON representation
  81115. */
  81116. serialize(): any;
  81117. /**
  81118. * Dispose the texture and release its associated resources.
  81119. */
  81120. dispose(): void;
  81121. }
  81122. }
  81123. declare module BABYLON {
  81124. /**
  81125. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81126. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81127. */
  81128. export class Texture extends BaseTexture {
  81129. /** @hidden */
  81130. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81131. /** @hidden */
  81132. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81133. /** @hidden */
  81134. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81135. /** nearest is mag = nearest and min = nearest and mip = linear */
  81136. static readonly NEAREST_SAMPLINGMODE: number;
  81137. /** nearest is mag = nearest and min = nearest and mip = linear */
  81138. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81139. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81140. static readonly BILINEAR_SAMPLINGMODE: number;
  81141. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81142. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81143. /** Trilinear is mag = linear and min = linear and mip = linear */
  81144. static readonly TRILINEAR_SAMPLINGMODE: number;
  81145. /** Trilinear is mag = linear and min = linear and mip = linear */
  81146. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81147. /** mag = nearest and min = nearest and mip = nearest */
  81148. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81149. /** mag = nearest and min = linear and mip = nearest */
  81150. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81151. /** mag = nearest and min = linear and mip = linear */
  81152. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81153. /** mag = nearest and min = linear and mip = none */
  81154. static readonly NEAREST_LINEAR: number;
  81155. /** mag = nearest and min = nearest and mip = none */
  81156. static readonly NEAREST_NEAREST: number;
  81157. /** mag = linear and min = nearest and mip = nearest */
  81158. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81159. /** mag = linear and min = nearest and mip = linear */
  81160. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81161. /** mag = linear and min = linear and mip = none */
  81162. static readonly LINEAR_LINEAR: number;
  81163. /** mag = linear and min = nearest and mip = none */
  81164. static readonly LINEAR_NEAREST: number;
  81165. /** Explicit coordinates mode */
  81166. static readonly EXPLICIT_MODE: number;
  81167. /** Spherical coordinates mode */
  81168. static readonly SPHERICAL_MODE: number;
  81169. /** Planar coordinates mode */
  81170. static readonly PLANAR_MODE: number;
  81171. /** Cubic coordinates mode */
  81172. static readonly CUBIC_MODE: number;
  81173. /** Projection coordinates mode */
  81174. static readonly PROJECTION_MODE: number;
  81175. /** Inverse Cubic coordinates mode */
  81176. static readonly SKYBOX_MODE: number;
  81177. /** Inverse Cubic coordinates mode */
  81178. static readonly INVCUBIC_MODE: number;
  81179. /** Equirectangular coordinates mode */
  81180. static readonly EQUIRECTANGULAR_MODE: number;
  81181. /** Equirectangular Fixed coordinates mode */
  81182. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81183. /** Equirectangular Fixed Mirrored coordinates mode */
  81184. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81185. /** Texture is not repeating outside of 0..1 UVs */
  81186. static readonly CLAMP_ADDRESSMODE: number;
  81187. /** Texture is repeating outside of 0..1 UVs */
  81188. static readonly WRAP_ADDRESSMODE: number;
  81189. /** Texture is repeating and mirrored */
  81190. static readonly MIRROR_ADDRESSMODE: number;
  81191. /**
  81192. * 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
  81193. */
  81194. static UseSerializedUrlIfAny: boolean;
  81195. /**
  81196. * Define the url of the texture.
  81197. */
  81198. url: Nullable<string>;
  81199. /**
  81200. * Define an offset on the texture to offset the u coordinates of the UVs
  81201. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81202. */
  81203. uOffset: number;
  81204. /**
  81205. * Define an offset on the texture to offset the v coordinates of the UVs
  81206. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81207. */
  81208. vOffset: number;
  81209. /**
  81210. * Define an offset on the texture to scale the u coordinates of the UVs
  81211. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81212. */
  81213. uScale: number;
  81214. /**
  81215. * Define an offset on the texture to scale the v coordinates of the UVs
  81216. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81217. */
  81218. vScale: number;
  81219. /**
  81220. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81221. * @see http://doc.babylonjs.com/how_to/more_materials
  81222. */
  81223. uAng: number;
  81224. /**
  81225. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81226. * @see http://doc.babylonjs.com/how_to/more_materials
  81227. */
  81228. vAng: number;
  81229. /**
  81230. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81231. * @see http://doc.babylonjs.com/how_to/more_materials
  81232. */
  81233. wAng: number;
  81234. /**
  81235. * Defines the center of rotation (U)
  81236. */
  81237. uRotationCenter: number;
  81238. /**
  81239. * Defines the center of rotation (V)
  81240. */
  81241. vRotationCenter: number;
  81242. /**
  81243. * Defines the center of rotation (W)
  81244. */
  81245. wRotationCenter: number;
  81246. /**
  81247. * Are mip maps generated for this texture or not.
  81248. */
  81249. readonly noMipmap: boolean;
  81250. /**
  81251. * List of inspectable custom properties (used by the Inspector)
  81252. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81253. */
  81254. inspectableCustomProperties: Nullable<IInspectable[]>;
  81255. private _noMipmap;
  81256. /** @hidden */
  81257. _invertY: boolean;
  81258. private _rowGenerationMatrix;
  81259. private _cachedTextureMatrix;
  81260. private _projectionModeMatrix;
  81261. private _t0;
  81262. private _t1;
  81263. private _t2;
  81264. private _cachedUOffset;
  81265. private _cachedVOffset;
  81266. private _cachedUScale;
  81267. private _cachedVScale;
  81268. private _cachedUAng;
  81269. private _cachedVAng;
  81270. private _cachedWAng;
  81271. private _cachedProjectionMatrixId;
  81272. private _cachedCoordinatesMode;
  81273. /** @hidden */
  81274. protected _initialSamplingMode: number;
  81275. /** @hidden */
  81276. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  81277. private _deleteBuffer;
  81278. protected _format: Nullable<number>;
  81279. private _delayedOnLoad;
  81280. private _delayedOnError;
  81281. /**
  81282. * Observable triggered once the texture has been loaded.
  81283. */
  81284. onLoadObservable: Observable<Texture>;
  81285. protected _isBlocking: boolean;
  81286. /**
  81287. * Is the texture preventing material to render while loading.
  81288. * If false, a default texture will be used instead of the loading one during the preparation step.
  81289. */
  81290. isBlocking: boolean;
  81291. /**
  81292. * Get the current sampling mode associated with the texture.
  81293. */
  81294. readonly samplingMode: number;
  81295. /**
  81296. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81297. */
  81298. readonly invertY: boolean;
  81299. /**
  81300. * Instantiates a new texture.
  81301. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81302. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81303. * @param url define the url of the picture to load as a texture
  81304. * @param scene define the scene or engine the texture will belong to
  81305. * @param noMipmap define if the texture will require mip maps or not
  81306. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81307. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81308. * @param onLoad define a callback triggered when the texture has been loaded
  81309. * @param onError define a callback triggered when an error occurred during the loading session
  81310. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81311. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81312. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81313. */
  81314. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  81315. /**
  81316. * Update the url (and optional buffer) of this texture if url was null during construction.
  81317. * @param url the url of the texture
  81318. * @param buffer the buffer of the texture (defaults to null)
  81319. * @param onLoad callback called when the texture is loaded (defaults to null)
  81320. */
  81321. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81322. /**
  81323. * Finish the loading sequence of a texture flagged as delayed load.
  81324. * @hidden
  81325. */
  81326. delayLoad(): void;
  81327. private _prepareRowForTextureGeneration;
  81328. /**
  81329. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81330. * @returns the transform matrix of the texture.
  81331. */
  81332. getTextureMatrix(): Matrix;
  81333. /**
  81334. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81335. * @returns The reflection texture transform
  81336. */
  81337. getReflectionTextureMatrix(): Matrix;
  81338. /**
  81339. * Clones the texture.
  81340. * @returns the cloned texture
  81341. */
  81342. clone(): Texture;
  81343. /**
  81344. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81345. * @returns The JSON representation of the texture
  81346. */
  81347. serialize(): any;
  81348. /**
  81349. * Get the current class name of the texture useful for serialization or dynamic coding.
  81350. * @returns "Texture"
  81351. */
  81352. getClassName(): string;
  81353. /**
  81354. * Dispose the texture and release its associated resources.
  81355. */
  81356. dispose(): void;
  81357. /**
  81358. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81359. * @param parsedTexture Define the JSON representation of the texture
  81360. * @param scene Define the scene the parsed texture should be instantiated in
  81361. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81362. * @returns The parsed texture if successful
  81363. */
  81364. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81365. /**
  81366. * Creates a texture from its base 64 representation.
  81367. * @param data Define the base64 payload without the data: prefix
  81368. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81369. * @param scene Define the scene the texture should belong to
  81370. * @param noMipmap Forces the texture to not create mip map information if true
  81371. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81372. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81373. * @param onLoad define a callback triggered when the texture has been loaded
  81374. * @param onError define a callback triggered when an error occurred during the loading session
  81375. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81376. * @returns the created texture
  81377. */
  81378. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81379. /**
  81380. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81381. * @param data Define the base64 payload without the data: prefix
  81382. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81383. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81384. * @param scene Define the scene the texture should belong to
  81385. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81386. * @param noMipmap Forces the texture to not create mip map information if true
  81387. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81388. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81389. * @param onLoad define a callback triggered when the texture has been loaded
  81390. * @param onError define a callback triggered when an error occurred during the loading session
  81391. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81392. * @returns the created texture
  81393. */
  81394. 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;
  81395. }
  81396. }
  81397. declare module BABYLON {
  81398. /**
  81399. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81400. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81401. */
  81402. export class PostProcessManager {
  81403. private _scene;
  81404. private _indexBuffer;
  81405. private _vertexBuffers;
  81406. /**
  81407. * Creates a new instance PostProcess
  81408. * @param scene The scene that the post process is associated with.
  81409. */
  81410. constructor(scene: Scene);
  81411. private _prepareBuffers;
  81412. private _buildIndexBuffer;
  81413. /**
  81414. * Rebuilds the vertex buffers of the manager.
  81415. * @hidden
  81416. */
  81417. _rebuild(): void;
  81418. /**
  81419. * Prepares a frame to be run through a post process.
  81420. * @param sourceTexture The input texture to the post procesess. (default: null)
  81421. * @param postProcesses An array of post processes to be run. (default: null)
  81422. * @returns True if the post processes were able to be run.
  81423. * @hidden
  81424. */
  81425. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81426. /**
  81427. * Manually render a set of post processes to a texture.
  81428. * @param postProcesses An array of post processes to be run.
  81429. * @param targetTexture The target texture to render to.
  81430. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81431. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81432. * @param lodLevel defines which lod of the texture to render to
  81433. */
  81434. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81435. /**
  81436. * Finalize the result of the output of the postprocesses.
  81437. * @param doNotPresent If true the result will not be displayed to the screen.
  81438. * @param targetTexture The target texture to render to.
  81439. * @param faceIndex The index of the face to bind the target texture to.
  81440. * @param postProcesses The array of post processes to render.
  81441. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81442. * @hidden
  81443. */
  81444. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81445. /**
  81446. * Disposes of the post process manager.
  81447. */
  81448. dispose(): void;
  81449. }
  81450. }
  81451. declare module BABYLON {
  81452. interface AbstractScene {
  81453. /**
  81454. * The list of procedural textures added to the scene
  81455. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81456. */
  81457. proceduralTextures: Array<ProceduralTexture>;
  81458. }
  81459. /**
  81460. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81461. * in a given scene.
  81462. */
  81463. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81464. /**
  81465. * The component name helpfull to identify the component in the list of scene components.
  81466. */
  81467. readonly name: string;
  81468. /**
  81469. * The scene the component belongs to.
  81470. */
  81471. scene: Scene;
  81472. /**
  81473. * Creates a new instance of the component for the given scene
  81474. * @param scene Defines the scene to register the component in
  81475. */
  81476. constructor(scene: Scene);
  81477. /**
  81478. * Registers the component in a given scene
  81479. */
  81480. register(): void;
  81481. /**
  81482. * Rebuilds the elements related to this component in case of
  81483. * context lost for instance.
  81484. */
  81485. rebuild(): void;
  81486. /**
  81487. * Disposes the component and the associated ressources.
  81488. */
  81489. dispose(): void;
  81490. private _beforeClear;
  81491. }
  81492. }
  81493. declare module BABYLON {
  81494. interface Engine {
  81495. /**
  81496. * Creates a new render target cube texture
  81497. * @param size defines the size of the texture
  81498. * @param options defines the options used to create the texture
  81499. * @returns a new render target cube texture stored in an InternalTexture
  81500. */
  81501. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81502. }
  81503. }
  81504. declare module BABYLON {
  81505. /** @hidden */
  81506. export var proceduralVertexShader: {
  81507. name: string;
  81508. shader: string;
  81509. };
  81510. }
  81511. declare module BABYLON {
  81512. /**
  81513. * 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.
  81514. * This is the base class of any Procedural texture and contains most of the shareable code.
  81515. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81516. */
  81517. export class ProceduralTexture extends Texture {
  81518. isCube: boolean;
  81519. /**
  81520. * Define if the texture is enabled or not (disabled texture will not render)
  81521. */
  81522. isEnabled: boolean;
  81523. /**
  81524. * Define if the texture must be cleared before rendering (default is true)
  81525. */
  81526. autoClear: boolean;
  81527. /**
  81528. * Callback called when the texture is generated
  81529. */
  81530. onGenerated: () => void;
  81531. /**
  81532. * Event raised when the texture is generated
  81533. */
  81534. onGeneratedObservable: Observable<ProceduralTexture>;
  81535. /** @hidden */
  81536. _generateMipMaps: boolean;
  81537. /** @hidden **/
  81538. _effect: Effect;
  81539. /** @hidden */
  81540. _textures: {
  81541. [key: string]: Texture;
  81542. };
  81543. private _size;
  81544. private _currentRefreshId;
  81545. private _refreshRate;
  81546. private _vertexBuffers;
  81547. private _indexBuffer;
  81548. private _uniforms;
  81549. private _samplers;
  81550. private _fragment;
  81551. private _floats;
  81552. private _ints;
  81553. private _floatsArrays;
  81554. private _colors3;
  81555. private _colors4;
  81556. private _vectors2;
  81557. private _vectors3;
  81558. private _matrices;
  81559. private _fallbackTexture;
  81560. private _fallbackTextureUsed;
  81561. private _engine;
  81562. private _cachedDefines;
  81563. private _contentUpdateId;
  81564. private _contentData;
  81565. /**
  81566. * Instantiates a new procedural texture.
  81567. * 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.
  81568. * This is the base class of any Procedural texture and contains most of the shareable code.
  81569. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81570. * @param name Define the name of the texture
  81571. * @param size Define the size of the texture to create
  81572. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81573. * @param scene Define the scene the texture belongs to
  81574. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81575. * @param generateMipMaps Define if the texture should creates mip maps or not
  81576. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81577. */
  81578. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81579. /**
  81580. * The effect that is created when initializing the post process.
  81581. * @returns The created effect corresponding the the postprocess.
  81582. */
  81583. getEffect(): Effect;
  81584. /**
  81585. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81586. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81587. */
  81588. getContent(): Nullable<ArrayBufferView>;
  81589. private _createIndexBuffer;
  81590. /** @hidden */
  81591. _rebuild(): void;
  81592. /**
  81593. * Resets the texture in order to recreate its associated resources.
  81594. * This can be called in case of context loss
  81595. */
  81596. reset(): void;
  81597. protected _getDefines(): string;
  81598. /**
  81599. * Is the texture ready to be used ? (rendered at least once)
  81600. * @returns true if ready, otherwise, false.
  81601. */
  81602. isReady(): boolean;
  81603. /**
  81604. * Resets the refresh counter of the texture and start bak from scratch.
  81605. * Could be useful to regenerate the texture if it is setup to render only once.
  81606. */
  81607. resetRefreshCounter(): void;
  81608. /**
  81609. * Set the fragment shader to use in order to render the texture.
  81610. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81611. */
  81612. setFragment(fragment: any): void;
  81613. /**
  81614. * Define the refresh rate of the texture or the rendering frequency.
  81615. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81616. */
  81617. refreshRate: number;
  81618. /** @hidden */
  81619. _shouldRender(): boolean;
  81620. /**
  81621. * Get the size the texture is rendering at.
  81622. * @returns the size (texture is always squared)
  81623. */
  81624. getRenderSize(): number;
  81625. /**
  81626. * Resize the texture to new value.
  81627. * @param size Define the new size the texture should have
  81628. * @param generateMipMaps Define whether the new texture should create mip maps
  81629. */
  81630. resize(size: number, generateMipMaps: boolean): void;
  81631. private _checkUniform;
  81632. /**
  81633. * Set a texture in the shader program used to render.
  81634. * @param name Define the name of the uniform samplers as defined in the shader
  81635. * @param texture Define the texture to bind to this sampler
  81636. * @return the texture itself allowing "fluent" like uniform updates
  81637. */
  81638. setTexture(name: string, texture: Texture): ProceduralTexture;
  81639. /**
  81640. * Set a float in the shader.
  81641. * @param name Define the name of the uniform as defined in the shader
  81642. * @param value Define the value to give to the uniform
  81643. * @return the texture itself allowing "fluent" like uniform updates
  81644. */
  81645. setFloat(name: string, value: number): ProceduralTexture;
  81646. /**
  81647. * Set a int in the shader.
  81648. * @param name Define the name of the uniform as defined in the shader
  81649. * @param value Define the value to give to the uniform
  81650. * @return the texture itself allowing "fluent" like uniform updates
  81651. */
  81652. setInt(name: string, value: number): ProceduralTexture;
  81653. /**
  81654. * Set an array of floats in the shader.
  81655. * @param name Define the name of the uniform as defined in the shader
  81656. * @param value Define the value to give to the uniform
  81657. * @return the texture itself allowing "fluent" like uniform updates
  81658. */
  81659. setFloats(name: string, value: number[]): ProceduralTexture;
  81660. /**
  81661. * Set a vec3 in the shader from a Color3.
  81662. * @param name Define the name of the uniform as defined in the shader
  81663. * @param value Define the value to give to the uniform
  81664. * @return the texture itself allowing "fluent" like uniform updates
  81665. */
  81666. setColor3(name: string, value: Color3): ProceduralTexture;
  81667. /**
  81668. * Set a vec4 in the shader from a Color4.
  81669. * @param name Define the name of the uniform as defined in the shader
  81670. * @param value Define the value to give to the uniform
  81671. * @return the texture itself allowing "fluent" like uniform updates
  81672. */
  81673. setColor4(name: string, value: Color4): ProceduralTexture;
  81674. /**
  81675. * Set a vec2 in the shader from a Vector2.
  81676. * @param name Define the name of the uniform as defined in the shader
  81677. * @param value Define the value to give to the uniform
  81678. * @return the texture itself allowing "fluent" like uniform updates
  81679. */
  81680. setVector2(name: string, value: Vector2): ProceduralTexture;
  81681. /**
  81682. * Set a vec3 in the shader from a Vector3.
  81683. * @param name Define the name of the uniform as defined in the shader
  81684. * @param value Define the value to give to the uniform
  81685. * @return the texture itself allowing "fluent" like uniform updates
  81686. */
  81687. setVector3(name: string, value: Vector3): ProceduralTexture;
  81688. /**
  81689. * Set a mat4 in the shader from a MAtrix.
  81690. * @param name Define the name of the uniform as defined in the shader
  81691. * @param value Define the value to give to the uniform
  81692. * @return the texture itself allowing "fluent" like uniform updates
  81693. */
  81694. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81695. /**
  81696. * Render the texture to its associated render target.
  81697. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81698. */
  81699. render(useCameraPostProcess?: boolean): void;
  81700. /**
  81701. * Clone the texture.
  81702. * @returns the cloned texture
  81703. */
  81704. clone(): ProceduralTexture;
  81705. /**
  81706. * Dispose the texture and release its asoociated resources.
  81707. */
  81708. dispose(): void;
  81709. }
  81710. }
  81711. declare module BABYLON {
  81712. /**
  81713. * This represents the base class for particle system in Babylon.
  81714. * 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.
  81715. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81716. * @example https://doc.babylonjs.com/babylon101/particles
  81717. */
  81718. export class BaseParticleSystem {
  81719. /**
  81720. * Source color is added to the destination color without alpha affecting the result
  81721. */
  81722. static BLENDMODE_ONEONE: number;
  81723. /**
  81724. * Blend current color and particle color using particle’s alpha
  81725. */
  81726. static BLENDMODE_STANDARD: number;
  81727. /**
  81728. * Add current color and particle color multiplied by particle’s alpha
  81729. */
  81730. static BLENDMODE_ADD: number;
  81731. /**
  81732. * Multiply current color with particle color
  81733. */
  81734. static BLENDMODE_MULTIPLY: number;
  81735. /**
  81736. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81737. */
  81738. static BLENDMODE_MULTIPLYADD: number;
  81739. /**
  81740. * List of animations used by the particle system.
  81741. */
  81742. animations: Animation[];
  81743. /**
  81744. * The id of the Particle system.
  81745. */
  81746. id: string;
  81747. /**
  81748. * The friendly name of the Particle system.
  81749. */
  81750. name: string;
  81751. /**
  81752. * The rendering group used by the Particle system to chose when to render.
  81753. */
  81754. renderingGroupId: number;
  81755. /**
  81756. * The emitter represents the Mesh or position we are attaching the particle system to.
  81757. */
  81758. emitter: Nullable<AbstractMesh | Vector3>;
  81759. /**
  81760. * The maximum number of particles to emit per frame
  81761. */
  81762. emitRate: number;
  81763. /**
  81764. * If you want to launch only a few particles at once, that can be done, as well.
  81765. */
  81766. manualEmitCount: number;
  81767. /**
  81768. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81769. */
  81770. updateSpeed: number;
  81771. /**
  81772. * The amount of time the particle system is running (depends of the overall update speed).
  81773. */
  81774. targetStopDuration: number;
  81775. /**
  81776. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81777. */
  81778. disposeOnStop: boolean;
  81779. /**
  81780. * Minimum power of emitting particles.
  81781. */
  81782. minEmitPower: number;
  81783. /**
  81784. * Maximum power of emitting particles.
  81785. */
  81786. maxEmitPower: number;
  81787. /**
  81788. * Minimum life time of emitting particles.
  81789. */
  81790. minLifeTime: number;
  81791. /**
  81792. * Maximum life time of emitting particles.
  81793. */
  81794. maxLifeTime: number;
  81795. /**
  81796. * Minimum Size of emitting particles.
  81797. */
  81798. minSize: number;
  81799. /**
  81800. * Maximum Size of emitting particles.
  81801. */
  81802. maxSize: number;
  81803. /**
  81804. * Minimum scale of emitting particles on X axis.
  81805. */
  81806. minScaleX: number;
  81807. /**
  81808. * Maximum scale of emitting particles on X axis.
  81809. */
  81810. maxScaleX: number;
  81811. /**
  81812. * Minimum scale of emitting particles on Y axis.
  81813. */
  81814. minScaleY: number;
  81815. /**
  81816. * Maximum scale of emitting particles on Y axis.
  81817. */
  81818. maxScaleY: number;
  81819. /**
  81820. * Gets or sets the minimal initial rotation in radians.
  81821. */
  81822. minInitialRotation: number;
  81823. /**
  81824. * Gets or sets the maximal initial rotation in radians.
  81825. */
  81826. maxInitialRotation: number;
  81827. /**
  81828. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81829. */
  81830. minAngularSpeed: number;
  81831. /**
  81832. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81833. */
  81834. maxAngularSpeed: number;
  81835. /**
  81836. * The texture used to render each particle. (this can be a spritesheet)
  81837. */
  81838. particleTexture: Nullable<Texture>;
  81839. /**
  81840. * The layer mask we are rendering the particles through.
  81841. */
  81842. layerMask: number;
  81843. /**
  81844. * This can help using your own shader to render the particle system.
  81845. * The according effect will be created
  81846. */
  81847. customShader: any;
  81848. /**
  81849. * By default particle system starts as soon as they are created. This prevents the
  81850. * automatic start to happen and let you decide when to start emitting particles.
  81851. */
  81852. preventAutoStart: boolean;
  81853. private _noiseTexture;
  81854. /**
  81855. * Gets or sets a texture used to add random noise to particle positions
  81856. */
  81857. noiseTexture: Nullable<ProceduralTexture>;
  81858. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81859. noiseStrength: Vector3;
  81860. /**
  81861. * Callback triggered when the particle animation is ending.
  81862. */
  81863. onAnimationEnd: Nullable<() => void>;
  81864. /**
  81865. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  81866. */
  81867. blendMode: number;
  81868. /**
  81869. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  81870. * to override the particles.
  81871. */
  81872. forceDepthWrite: boolean;
  81873. /** 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 */
  81874. preWarmCycles: number;
  81875. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  81876. preWarmStepOffset: number;
  81877. /**
  81878. * 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)
  81879. */
  81880. spriteCellChangeSpeed: number;
  81881. /**
  81882. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81883. */
  81884. startSpriteCellID: number;
  81885. /**
  81886. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81887. */
  81888. endSpriteCellID: number;
  81889. /**
  81890. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81891. */
  81892. spriteCellWidth: number;
  81893. /**
  81894. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81895. */
  81896. spriteCellHeight: number;
  81897. /**
  81898. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81899. */
  81900. spriteRandomStartCell: boolean;
  81901. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81902. translationPivot: Vector2;
  81903. /** @hidden */
  81904. protected _isAnimationSheetEnabled: boolean;
  81905. /**
  81906. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81907. */
  81908. beginAnimationOnStart: boolean;
  81909. /**
  81910. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81911. */
  81912. beginAnimationFrom: number;
  81913. /**
  81914. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81915. */
  81916. beginAnimationTo: number;
  81917. /**
  81918. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81919. */
  81920. beginAnimationLoop: boolean;
  81921. /**
  81922. * Gets or sets a world offset applied to all particles
  81923. */
  81924. worldOffset: Vector3;
  81925. /**
  81926. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  81927. */
  81928. isAnimationSheetEnabled: boolean;
  81929. /**
  81930. * Get hosting scene
  81931. * @returns the scene
  81932. */
  81933. getScene(): Scene;
  81934. /**
  81935. * You can use gravity if you want to give an orientation to your particles.
  81936. */
  81937. gravity: Vector3;
  81938. protected _colorGradients: Nullable<Array<ColorGradient>>;
  81939. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  81940. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  81941. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  81942. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  81943. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  81944. protected _dragGradients: Nullable<Array<FactorGradient>>;
  81945. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  81946. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  81947. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  81948. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  81949. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  81950. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  81951. /**
  81952. * Defines the delay in milliseconds before starting the system (0 by default)
  81953. */
  81954. startDelay: number;
  81955. /**
  81956. * Gets the current list of drag gradients.
  81957. * You must use addDragGradient and removeDragGradient to udpate this list
  81958. * @returns the list of drag gradients
  81959. */
  81960. getDragGradients(): Nullable<Array<FactorGradient>>;
  81961. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81962. limitVelocityDamping: number;
  81963. /**
  81964. * Gets the current list of limit velocity gradients.
  81965. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81966. * @returns the list of limit velocity gradients
  81967. */
  81968. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81969. /**
  81970. * Gets the current list of color gradients.
  81971. * You must use addColorGradient and removeColorGradient to udpate this list
  81972. * @returns the list of color gradients
  81973. */
  81974. getColorGradients(): Nullable<Array<ColorGradient>>;
  81975. /**
  81976. * Gets the current list of size gradients.
  81977. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81978. * @returns the list of size gradients
  81979. */
  81980. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81981. /**
  81982. * Gets the current list of color remap gradients.
  81983. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  81984. * @returns the list of color remap gradients
  81985. */
  81986. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  81987. /**
  81988. * Gets the current list of alpha remap gradients.
  81989. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  81990. * @returns the list of alpha remap gradients
  81991. */
  81992. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  81993. /**
  81994. * Gets the current list of life time gradients.
  81995. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  81996. * @returns the list of life time gradients
  81997. */
  81998. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  81999. /**
  82000. * Gets the current list of angular speed gradients.
  82001. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82002. * @returns the list of angular speed gradients
  82003. */
  82004. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82005. /**
  82006. * Gets the current list of velocity gradients.
  82007. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82008. * @returns the list of velocity gradients
  82009. */
  82010. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82011. /**
  82012. * Gets the current list of start size gradients.
  82013. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82014. * @returns the list of start size gradients
  82015. */
  82016. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82017. /**
  82018. * Gets the current list of emit rate gradients.
  82019. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82020. * @returns the list of emit rate gradients
  82021. */
  82022. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82023. /**
  82024. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82025. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82026. */
  82027. direction1: Vector3;
  82028. /**
  82029. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82030. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82031. */
  82032. direction2: Vector3;
  82033. /**
  82034. * 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.
  82035. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82036. */
  82037. minEmitBox: Vector3;
  82038. /**
  82039. * 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.
  82040. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82041. */
  82042. maxEmitBox: Vector3;
  82043. /**
  82044. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82045. */
  82046. color1: Color4;
  82047. /**
  82048. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82049. */
  82050. color2: Color4;
  82051. /**
  82052. * Color the particle will have at the end of its lifetime
  82053. */
  82054. colorDead: Color4;
  82055. /**
  82056. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82057. */
  82058. textureMask: Color4;
  82059. /**
  82060. * The particle emitter type defines the emitter used by the particle system.
  82061. * It can be for example box, sphere, or cone...
  82062. */
  82063. particleEmitterType: IParticleEmitterType;
  82064. /** @hidden */
  82065. _isSubEmitter: boolean;
  82066. /**
  82067. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82068. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82069. */
  82070. billboardMode: number;
  82071. protected _isBillboardBased: boolean;
  82072. /**
  82073. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82074. */
  82075. isBillboardBased: boolean;
  82076. /**
  82077. * The scene the particle system belongs to.
  82078. */
  82079. protected _scene: Scene;
  82080. /**
  82081. * Local cache of defines for image processing.
  82082. */
  82083. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82084. /**
  82085. * Default configuration related to image processing available in the standard Material.
  82086. */
  82087. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82088. /**
  82089. * Gets the image processing configuration used either in this material.
  82090. */
  82091. /**
  82092. * Sets the Default image processing configuration used either in the this material.
  82093. *
  82094. * If sets to null, the scene one is in use.
  82095. */
  82096. imageProcessingConfiguration: ImageProcessingConfiguration;
  82097. /**
  82098. * Attaches a new image processing configuration to the Standard Material.
  82099. * @param configuration
  82100. */
  82101. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82102. /** @hidden */
  82103. protected _reset(): void;
  82104. /** @hidden */
  82105. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82106. /**
  82107. * Instantiates a particle system.
  82108. * 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.
  82109. * @param name The name of the particle system
  82110. */
  82111. constructor(name: string);
  82112. /**
  82113. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82114. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82115. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82116. * @returns the emitter
  82117. */
  82118. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82119. /**
  82120. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82121. * @param radius The radius of the hemisphere to emit from
  82122. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82123. * @returns the emitter
  82124. */
  82125. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82126. /**
  82127. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82128. * @param radius The radius of the sphere to emit from
  82129. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82130. * @returns the emitter
  82131. */
  82132. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82133. /**
  82134. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82135. * @param radius The radius of the sphere to emit from
  82136. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82137. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82138. * @returns the emitter
  82139. */
  82140. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82141. /**
  82142. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82143. * @param radius The radius of the emission cylinder
  82144. * @param height The height of the emission cylinder
  82145. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82146. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82147. * @returns the emitter
  82148. */
  82149. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82150. /**
  82151. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82152. * @param radius The radius of the cylinder to emit from
  82153. * @param height The height of the emission cylinder
  82154. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82155. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82156. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82157. * @returns the emitter
  82158. */
  82159. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82160. /**
  82161. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82162. * @param radius The radius of the cone to emit from
  82163. * @param angle The base angle of the cone
  82164. * @returns the emitter
  82165. */
  82166. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82167. /**
  82168. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82169. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82170. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82171. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82172. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82173. * @returns the emitter
  82174. */
  82175. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82176. }
  82177. }
  82178. declare module BABYLON {
  82179. /**
  82180. * Type of sub emitter
  82181. */
  82182. export enum SubEmitterType {
  82183. /**
  82184. * Attached to the particle over it's lifetime
  82185. */
  82186. ATTACHED = 0,
  82187. /**
  82188. * Created when the particle dies
  82189. */
  82190. END = 1
  82191. }
  82192. /**
  82193. * Sub emitter class used to emit particles from an existing particle
  82194. */
  82195. export class SubEmitter {
  82196. /**
  82197. * the particle system to be used by the sub emitter
  82198. */
  82199. particleSystem: ParticleSystem;
  82200. /**
  82201. * Type of the submitter (Default: END)
  82202. */
  82203. type: SubEmitterType;
  82204. /**
  82205. * 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)
  82206. * Note: This only is supported when using an emitter of type Mesh
  82207. */
  82208. inheritDirection: boolean;
  82209. /**
  82210. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82211. */
  82212. inheritedVelocityAmount: number;
  82213. /**
  82214. * Creates a sub emitter
  82215. * @param particleSystem the particle system to be used by the sub emitter
  82216. */
  82217. constructor(
  82218. /**
  82219. * the particle system to be used by the sub emitter
  82220. */
  82221. particleSystem: ParticleSystem);
  82222. /**
  82223. * Clones the sub emitter
  82224. * @returns the cloned sub emitter
  82225. */
  82226. clone(): SubEmitter;
  82227. /**
  82228. * Serialize current object to a JSON object
  82229. * @returns the serialized object
  82230. */
  82231. serialize(): any;
  82232. /** @hidden */
  82233. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82234. /**
  82235. * Creates a new SubEmitter from a serialized JSON version
  82236. * @param serializationObject defines the JSON object to read from
  82237. * @param scene defines the hosting scene
  82238. * @param rootUrl defines the rootUrl for data loading
  82239. * @returns a new SubEmitter
  82240. */
  82241. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82242. /** Release associated resources */
  82243. dispose(): void;
  82244. }
  82245. }
  82246. declare module BABYLON {
  82247. /** @hidden */
  82248. export var imageProcessingDeclaration: {
  82249. name: string;
  82250. shader: string;
  82251. };
  82252. }
  82253. declare module BABYLON {
  82254. /** @hidden */
  82255. export var imageProcessingFunctions: {
  82256. name: string;
  82257. shader: string;
  82258. };
  82259. }
  82260. declare module BABYLON {
  82261. /** @hidden */
  82262. export var particlesPixelShader: {
  82263. name: string;
  82264. shader: string;
  82265. };
  82266. }
  82267. declare module BABYLON {
  82268. /** @hidden */
  82269. export var particlesVertexShader: {
  82270. name: string;
  82271. shader: string;
  82272. };
  82273. }
  82274. declare module BABYLON {
  82275. /**
  82276. * This represents a particle system in Babylon.
  82277. * 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.
  82278. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82279. * @example https://doc.babylonjs.com/babylon101/particles
  82280. */
  82281. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82282. /**
  82283. * Billboard mode will only apply to Y axis
  82284. */
  82285. static readonly BILLBOARDMODE_Y: number;
  82286. /**
  82287. * Billboard mode will apply to all axes
  82288. */
  82289. static readonly BILLBOARDMODE_ALL: number;
  82290. /**
  82291. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82292. */
  82293. static readonly BILLBOARDMODE_STRETCHED: number;
  82294. /**
  82295. * This function can be defined to provide custom update for active particles.
  82296. * This function will be called instead of regular update (age, position, color, etc.).
  82297. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82298. */
  82299. updateFunction: (particles: Particle[]) => void;
  82300. private _emitterWorldMatrix;
  82301. /**
  82302. * This function can be defined to specify initial direction for every new particle.
  82303. * It by default use the emitterType defined function
  82304. */
  82305. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82306. /**
  82307. * This function can be defined to specify initial position for every new particle.
  82308. * It by default use the emitterType defined function
  82309. */
  82310. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82311. /**
  82312. * @hidden
  82313. */
  82314. _inheritedVelocityOffset: Vector3;
  82315. /**
  82316. * An event triggered when the system is disposed
  82317. */
  82318. onDisposeObservable: Observable<ParticleSystem>;
  82319. private _onDisposeObserver;
  82320. /**
  82321. * Sets a callback that will be triggered when the system is disposed
  82322. */
  82323. onDispose: () => void;
  82324. private _particles;
  82325. private _epsilon;
  82326. private _capacity;
  82327. private _stockParticles;
  82328. private _newPartsExcess;
  82329. private _vertexData;
  82330. private _vertexBuffer;
  82331. private _vertexBuffers;
  82332. private _spriteBuffer;
  82333. private _indexBuffer;
  82334. private _effect;
  82335. private _customEffect;
  82336. private _cachedDefines;
  82337. private _scaledColorStep;
  82338. private _colorDiff;
  82339. private _scaledDirection;
  82340. private _scaledGravity;
  82341. private _currentRenderId;
  82342. private _alive;
  82343. private _useInstancing;
  82344. private _started;
  82345. private _stopped;
  82346. private _actualFrame;
  82347. private _scaledUpdateSpeed;
  82348. private _vertexBufferSize;
  82349. /** @hidden */
  82350. _currentEmitRateGradient: Nullable<FactorGradient>;
  82351. /** @hidden */
  82352. _currentEmitRate1: number;
  82353. /** @hidden */
  82354. _currentEmitRate2: number;
  82355. /** @hidden */
  82356. _currentStartSizeGradient: Nullable<FactorGradient>;
  82357. /** @hidden */
  82358. _currentStartSize1: number;
  82359. /** @hidden */
  82360. _currentStartSize2: number;
  82361. private readonly _rawTextureWidth;
  82362. private _rampGradientsTexture;
  82363. private _useRampGradients;
  82364. /** Gets or sets a boolean indicating that ramp gradients must be used
  82365. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82366. */
  82367. useRampGradients: boolean;
  82368. /**
  82369. * 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.
  82370. * 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: [])
  82371. */
  82372. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82373. private _subEmitters;
  82374. /**
  82375. * @hidden
  82376. * If the particle systems emitter should be disposed when the particle system is disposed
  82377. */
  82378. _disposeEmitterOnDispose: boolean;
  82379. /**
  82380. * The current active Sub-systems, this property is used by the root particle system only.
  82381. */
  82382. activeSubSystems: Array<ParticleSystem>;
  82383. private _rootParticleSystem;
  82384. /**
  82385. * Gets the current list of active particles
  82386. */
  82387. readonly particles: Particle[];
  82388. /**
  82389. * Returns the string "ParticleSystem"
  82390. * @returns a string containing the class name
  82391. */
  82392. getClassName(): string;
  82393. /**
  82394. * Instantiates a particle system.
  82395. * 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.
  82396. * @param name The name of the particle system
  82397. * @param capacity The max number of particles alive at the same time
  82398. * @param scene The scene the particle system belongs to
  82399. * @param customEffect a custom effect used to change the way particles are rendered by default
  82400. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82401. * @param epsilon Offset used to render the particles
  82402. */
  82403. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82404. private _addFactorGradient;
  82405. private _removeFactorGradient;
  82406. /**
  82407. * Adds a new life time gradient
  82408. * @param gradient defines the gradient to use (between 0 and 1)
  82409. * @param factor defines the life time factor to affect to the specified gradient
  82410. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82411. * @returns the current particle system
  82412. */
  82413. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82414. /**
  82415. * Remove a specific life time gradient
  82416. * @param gradient defines the gradient to remove
  82417. * @returns the current particle system
  82418. */
  82419. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82420. /**
  82421. * Adds a new size gradient
  82422. * @param gradient defines the gradient to use (between 0 and 1)
  82423. * @param factor defines the size factor to affect to the specified gradient
  82424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82425. * @returns the current particle system
  82426. */
  82427. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82428. /**
  82429. * Remove a specific size gradient
  82430. * @param gradient defines the gradient to remove
  82431. * @returns the current particle system
  82432. */
  82433. removeSizeGradient(gradient: number): IParticleSystem;
  82434. /**
  82435. * Adds a new color remap gradient
  82436. * @param gradient defines the gradient to use (between 0 and 1)
  82437. * @param min defines the color remap minimal range
  82438. * @param max defines the color remap maximal range
  82439. * @returns the current particle system
  82440. */
  82441. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82442. /**
  82443. * Remove a specific color remap gradient
  82444. * @param gradient defines the gradient to remove
  82445. * @returns the current particle system
  82446. */
  82447. removeColorRemapGradient(gradient: number): IParticleSystem;
  82448. /**
  82449. * Adds a new alpha remap gradient
  82450. * @param gradient defines the gradient to use (between 0 and 1)
  82451. * @param min defines the alpha remap minimal range
  82452. * @param max defines the alpha remap maximal range
  82453. * @returns the current particle system
  82454. */
  82455. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82456. /**
  82457. * Remove a specific alpha remap gradient
  82458. * @param gradient defines the gradient to remove
  82459. * @returns the current particle system
  82460. */
  82461. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82462. /**
  82463. * Adds a new angular speed gradient
  82464. * @param gradient defines the gradient to use (between 0 and 1)
  82465. * @param factor defines the angular speed to affect to the specified gradient
  82466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82467. * @returns the current particle system
  82468. */
  82469. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82470. /**
  82471. * Remove a specific angular speed gradient
  82472. * @param gradient defines the gradient to remove
  82473. * @returns the current particle system
  82474. */
  82475. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82476. /**
  82477. * Adds a new velocity gradient
  82478. * @param gradient defines the gradient to use (between 0 and 1)
  82479. * @param factor defines the velocity to affect to the specified gradient
  82480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82481. * @returns the current particle system
  82482. */
  82483. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82484. /**
  82485. * Remove a specific velocity gradient
  82486. * @param gradient defines the gradient to remove
  82487. * @returns the current particle system
  82488. */
  82489. removeVelocityGradient(gradient: number): IParticleSystem;
  82490. /**
  82491. * Adds a new limit velocity gradient
  82492. * @param gradient defines the gradient to use (between 0 and 1)
  82493. * @param factor defines the limit velocity value to affect to the specified gradient
  82494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82495. * @returns the current particle system
  82496. */
  82497. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82498. /**
  82499. * Remove a specific limit velocity gradient
  82500. * @param gradient defines the gradient to remove
  82501. * @returns the current particle system
  82502. */
  82503. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82504. /**
  82505. * Adds a new drag gradient
  82506. * @param gradient defines the gradient to use (between 0 and 1)
  82507. * @param factor defines the drag value to affect to the specified gradient
  82508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82509. * @returns the current particle system
  82510. */
  82511. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82512. /**
  82513. * Remove a specific drag gradient
  82514. * @param gradient defines the gradient to remove
  82515. * @returns the current particle system
  82516. */
  82517. removeDragGradient(gradient: number): IParticleSystem;
  82518. /**
  82519. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82520. * @param gradient defines the gradient to use (between 0 and 1)
  82521. * @param factor defines the emit rate value to affect to the specified gradient
  82522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82523. * @returns the current particle system
  82524. */
  82525. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82526. /**
  82527. * Remove a specific emit rate gradient
  82528. * @param gradient defines the gradient to remove
  82529. * @returns the current particle system
  82530. */
  82531. removeEmitRateGradient(gradient: number): IParticleSystem;
  82532. /**
  82533. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82534. * @param gradient defines the gradient to use (between 0 and 1)
  82535. * @param factor defines the start size value to affect to the specified gradient
  82536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82537. * @returns the current particle system
  82538. */
  82539. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82540. /**
  82541. * Remove a specific start size gradient
  82542. * @param gradient defines the gradient to remove
  82543. * @returns the current particle system
  82544. */
  82545. removeStartSizeGradient(gradient: number): IParticleSystem;
  82546. private _createRampGradientTexture;
  82547. /**
  82548. * Gets the current list of ramp gradients.
  82549. * You must use addRampGradient and removeRampGradient to udpate this list
  82550. * @returns the list of ramp gradients
  82551. */
  82552. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82553. /**
  82554. * Adds a new ramp gradient used to remap particle colors
  82555. * @param gradient defines the gradient to use (between 0 and 1)
  82556. * @param color defines the color to affect to the specified gradient
  82557. * @returns the current particle system
  82558. */
  82559. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82560. /**
  82561. * Remove a specific ramp gradient
  82562. * @param gradient defines the gradient to remove
  82563. * @returns the current particle system
  82564. */
  82565. removeRampGradient(gradient: number): ParticleSystem;
  82566. /**
  82567. * Adds a new color gradient
  82568. * @param gradient defines the gradient to use (between 0 and 1)
  82569. * @param color1 defines the color to affect to the specified gradient
  82570. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82571. * @returns this particle system
  82572. */
  82573. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82574. /**
  82575. * Remove a specific color gradient
  82576. * @param gradient defines the gradient to remove
  82577. * @returns this particle system
  82578. */
  82579. removeColorGradient(gradient: number): IParticleSystem;
  82580. private _fetchR;
  82581. protected _reset(): void;
  82582. private _resetEffect;
  82583. private _createVertexBuffers;
  82584. private _createIndexBuffer;
  82585. /**
  82586. * Gets the maximum number of particles active at the same time.
  82587. * @returns The max number of active particles.
  82588. */
  82589. getCapacity(): number;
  82590. /**
  82591. * Gets whether there are still active particles in the system.
  82592. * @returns True if it is alive, otherwise false.
  82593. */
  82594. isAlive(): boolean;
  82595. /**
  82596. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82597. * @returns True if it has been started, otherwise false.
  82598. */
  82599. isStarted(): boolean;
  82600. private _prepareSubEmitterInternalArray;
  82601. /**
  82602. * Starts the particle system and begins to emit
  82603. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82604. */
  82605. start(delay?: number): void;
  82606. /**
  82607. * Stops the particle system.
  82608. * @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.
  82609. */
  82610. stop(stopSubEmitters?: boolean): void;
  82611. /**
  82612. * Remove all active particles
  82613. */
  82614. reset(): void;
  82615. /**
  82616. * @hidden (for internal use only)
  82617. */
  82618. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82619. /**
  82620. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82621. * Its lifetime will start back at 0.
  82622. */
  82623. recycleParticle: (particle: Particle) => void;
  82624. private _stopSubEmitters;
  82625. private _createParticle;
  82626. private _removeFromRoot;
  82627. private _emitFromParticle;
  82628. private _update;
  82629. /** @hidden */
  82630. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82631. /** @hidden */
  82632. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82633. /** @hidden */
  82634. private _getEffect;
  82635. /**
  82636. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82637. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82638. */
  82639. animate(preWarmOnly?: boolean): void;
  82640. private _appendParticleVertices;
  82641. /**
  82642. * Rebuilds the particle system.
  82643. */
  82644. rebuild(): void;
  82645. /**
  82646. * Is this system ready to be used/rendered
  82647. * @return true if the system is ready
  82648. */
  82649. isReady(): boolean;
  82650. private _render;
  82651. /**
  82652. * Renders the particle system in its current state.
  82653. * @returns the current number of particles
  82654. */
  82655. render(): number;
  82656. /**
  82657. * Disposes the particle system and free the associated resources
  82658. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82659. */
  82660. dispose(disposeTexture?: boolean): void;
  82661. /**
  82662. * Clones the particle system.
  82663. * @param name The name of the cloned object
  82664. * @param newEmitter The new emitter to use
  82665. * @returns the cloned particle system
  82666. */
  82667. clone(name: string, newEmitter: any): ParticleSystem;
  82668. /**
  82669. * Serializes the particle system to a JSON object.
  82670. * @returns the JSON object
  82671. */
  82672. serialize(): any;
  82673. /** @hidden */
  82674. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82675. /** @hidden */
  82676. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82677. /**
  82678. * Parses a JSON object to create a particle system.
  82679. * @param parsedParticleSystem The JSON object to parse
  82680. * @param scene The scene to create the particle system in
  82681. * @param rootUrl The root url to use to load external dependencies like texture
  82682. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82683. * @returns the Parsed particle system
  82684. */
  82685. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82686. }
  82687. }
  82688. declare module BABYLON {
  82689. /**
  82690. * A particle represents one of the element emitted by a particle system.
  82691. * This is mainly define by its coordinates, direction, velocity and age.
  82692. */
  82693. export class Particle {
  82694. /**
  82695. * The particle system the particle belongs to.
  82696. */
  82697. particleSystem: ParticleSystem;
  82698. private static _Count;
  82699. /**
  82700. * Unique ID of the particle
  82701. */
  82702. id: number;
  82703. /**
  82704. * The world position of the particle in the scene.
  82705. */
  82706. position: Vector3;
  82707. /**
  82708. * The world direction of the particle in the scene.
  82709. */
  82710. direction: Vector3;
  82711. /**
  82712. * The color of the particle.
  82713. */
  82714. color: Color4;
  82715. /**
  82716. * The color change of the particle per step.
  82717. */
  82718. colorStep: Color4;
  82719. /**
  82720. * Defines how long will the life of the particle be.
  82721. */
  82722. lifeTime: number;
  82723. /**
  82724. * The current age of the particle.
  82725. */
  82726. age: number;
  82727. /**
  82728. * The current size of the particle.
  82729. */
  82730. size: number;
  82731. /**
  82732. * The current scale of the particle.
  82733. */
  82734. scale: Vector2;
  82735. /**
  82736. * The current angle of the particle.
  82737. */
  82738. angle: number;
  82739. /**
  82740. * Defines how fast is the angle changing.
  82741. */
  82742. angularSpeed: number;
  82743. /**
  82744. * Defines the cell index used by the particle to be rendered from a sprite.
  82745. */
  82746. cellIndex: number;
  82747. /**
  82748. * The information required to support color remapping
  82749. */
  82750. remapData: Vector4;
  82751. /** @hidden */
  82752. _randomCellOffset?: number;
  82753. /** @hidden */
  82754. _initialDirection: Nullable<Vector3>;
  82755. /** @hidden */
  82756. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82757. /** @hidden */
  82758. _initialStartSpriteCellID: number;
  82759. /** @hidden */
  82760. _initialEndSpriteCellID: number;
  82761. /** @hidden */
  82762. _currentColorGradient: Nullable<ColorGradient>;
  82763. /** @hidden */
  82764. _currentColor1: Color4;
  82765. /** @hidden */
  82766. _currentColor2: Color4;
  82767. /** @hidden */
  82768. _currentSizeGradient: Nullable<FactorGradient>;
  82769. /** @hidden */
  82770. _currentSize1: number;
  82771. /** @hidden */
  82772. _currentSize2: number;
  82773. /** @hidden */
  82774. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82775. /** @hidden */
  82776. _currentAngularSpeed1: number;
  82777. /** @hidden */
  82778. _currentAngularSpeed2: number;
  82779. /** @hidden */
  82780. _currentVelocityGradient: Nullable<FactorGradient>;
  82781. /** @hidden */
  82782. _currentVelocity1: number;
  82783. /** @hidden */
  82784. _currentVelocity2: number;
  82785. /** @hidden */
  82786. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  82787. /** @hidden */
  82788. _currentLimitVelocity1: number;
  82789. /** @hidden */
  82790. _currentLimitVelocity2: number;
  82791. /** @hidden */
  82792. _currentDragGradient: Nullable<FactorGradient>;
  82793. /** @hidden */
  82794. _currentDrag1: number;
  82795. /** @hidden */
  82796. _currentDrag2: number;
  82797. /** @hidden */
  82798. _randomNoiseCoordinates1: Vector3;
  82799. /** @hidden */
  82800. _randomNoiseCoordinates2: Vector3;
  82801. /**
  82802. * Creates a new instance Particle
  82803. * @param particleSystem the particle system the particle belongs to
  82804. */
  82805. constructor(
  82806. /**
  82807. * The particle system the particle belongs to.
  82808. */
  82809. particleSystem: ParticleSystem);
  82810. private updateCellInfoFromSystem;
  82811. /**
  82812. * Defines how the sprite cell index is updated for the particle
  82813. */
  82814. updateCellIndex(): void;
  82815. /** @hidden */
  82816. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  82817. /** @hidden */
  82818. _inheritParticleInfoToSubEmitters(): void;
  82819. /** @hidden */
  82820. _reset(): void;
  82821. /**
  82822. * Copy the properties of particle to another one.
  82823. * @param other the particle to copy the information to.
  82824. */
  82825. copyTo(other: Particle): void;
  82826. }
  82827. }
  82828. declare module BABYLON {
  82829. /**
  82830. * Particle emitter represents a volume emitting particles.
  82831. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  82832. */
  82833. export interface IParticleEmitterType {
  82834. /**
  82835. * Called by the particle System when the direction is computed for the created particle.
  82836. * @param worldMatrix is the world matrix of the particle system
  82837. * @param directionToUpdate is the direction vector to update with the result
  82838. * @param particle is the particle we are computed the direction for
  82839. */
  82840. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82841. /**
  82842. * Called by the particle System when the position is computed for the created particle.
  82843. * @param worldMatrix is the world matrix of the particle system
  82844. * @param positionToUpdate is the position vector to update with the result
  82845. * @param particle is the particle we are computed the position for
  82846. */
  82847. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82848. /**
  82849. * Clones the current emitter and returns a copy of it
  82850. * @returns the new emitter
  82851. */
  82852. clone(): IParticleEmitterType;
  82853. /**
  82854. * Called by the GPUParticleSystem to setup the update shader
  82855. * @param effect defines the update shader
  82856. */
  82857. applyToShader(effect: Effect): void;
  82858. /**
  82859. * Returns a string to use to update the GPU particles update shader
  82860. * @returns the effect defines string
  82861. */
  82862. getEffectDefines(): string;
  82863. /**
  82864. * Returns a string representing the class name
  82865. * @returns a string containing the class name
  82866. */
  82867. getClassName(): string;
  82868. /**
  82869. * Serializes the particle system to a JSON object.
  82870. * @returns the JSON object
  82871. */
  82872. serialize(): any;
  82873. /**
  82874. * Parse properties from a JSON object
  82875. * @param serializationObject defines the JSON object
  82876. */
  82877. parse(serializationObject: any): void;
  82878. }
  82879. }
  82880. declare module BABYLON {
  82881. /**
  82882. * Particle emitter emitting particles from the inside of a box.
  82883. * It emits the particles randomly between 2 given directions.
  82884. */
  82885. export class BoxParticleEmitter implements IParticleEmitterType {
  82886. /**
  82887. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82888. */
  82889. direction1: Vector3;
  82890. /**
  82891. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82892. */
  82893. direction2: Vector3;
  82894. /**
  82895. * 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.
  82896. */
  82897. minEmitBox: Vector3;
  82898. /**
  82899. * 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.
  82900. */
  82901. maxEmitBox: Vector3;
  82902. /**
  82903. * Creates a new instance BoxParticleEmitter
  82904. */
  82905. constructor();
  82906. /**
  82907. * Called by the particle System when the direction is computed for the created particle.
  82908. * @param worldMatrix is the world matrix of the particle system
  82909. * @param directionToUpdate is the direction vector to update with the result
  82910. * @param particle is the particle we are computed the direction for
  82911. */
  82912. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82913. /**
  82914. * Called by the particle System when the position is computed for the created particle.
  82915. * @param worldMatrix is the world matrix of the particle system
  82916. * @param positionToUpdate is the position vector to update with the result
  82917. * @param particle is the particle we are computed the position for
  82918. */
  82919. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82920. /**
  82921. * Clones the current emitter and returns a copy of it
  82922. * @returns the new emitter
  82923. */
  82924. clone(): BoxParticleEmitter;
  82925. /**
  82926. * Called by the GPUParticleSystem to setup the update shader
  82927. * @param effect defines the update shader
  82928. */
  82929. applyToShader(effect: Effect): void;
  82930. /**
  82931. * Returns a string to use to update the GPU particles update shader
  82932. * @returns a string containng the defines string
  82933. */
  82934. getEffectDefines(): string;
  82935. /**
  82936. * Returns the string "BoxParticleEmitter"
  82937. * @returns a string containing the class name
  82938. */
  82939. getClassName(): string;
  82940. /**
  82941. * Serializes the particle system to a JSON object.
  82942. * @returns the JSON object
  82943. */
  82944. serialize(): any;
  82945. /**
  82946. * Parse properties from a JSON object
  82947. * @param serializationObject defines the JSON object
  82948. */
  82949. parse(serializationObject: any): void;
  82950. }
  82951. }
  82952. declare module BABYLON {
  82953. /**
  82954. * Particle emitter emitting particles from the inside of a cone.
  82955. * It emits the particles alongside the cone volume from the base to the particle.
  82956. * The emission direction might be randomized.
  82957. */
  82958. export class ConeParticleEmitter implements IParticleEmitterType {
  82959. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82960. directionRandomizer: number;
  82961. private _radius;
  82962. private _angle;
  82963. private _height;
  82964. /**
  82965. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  82966. */
  82967. radiusRange: number;
  82968. /**
  82969. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  82970. */
  82971. heightRange: number;
  82972. /**
  82973. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  82974. */
  82975. emitFromSpawnPointOnly: boolean;
  82976. /**
  82977. * Gets or sets the radius of the emission cone
  82978. */
  82979. radius: number;
  82980. /**
  82981. * Gets or sets the angle of the emission cone
  82982. */
  82983. angle: number;
  82984. private _buildHeight;
  82985. /**
  82986. * Creates a new instance ConeParticleEmitter
  82987. * @param radius the radius of the emission cone (1 by default)
  82988. * @param angle the cone base angle (PI by default)
  82989. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  82990. */
  82991. constructor(radius?: number, angle?: number,
  82992. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82993. directionRandomizer?: number);
  82994. /**
  82995. * Called by the particle System when the direction is computed for the created particle.
  82996. * @param worldMatrix is the world matrix of the particle system
  82997. * @param directionToUpdate is the direction vector to update with the result
  82998. * @param particle is the particle we are computed the direction for
  82999. */
  83000. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83001. /**
  83002. * Called by the particle System when the position is computed for the created particle.
  83003. * @param worldMatrix is the world matrix of the particle system
  83004. * @param positionToUpdate is the position vector to update with the result
  83005. * @param particle is the particle we are computed the position for
  83006. */
  83007. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83008. /**
  83009. * Clones the current emitter and returns a copy of it
  83010. * @returns the new emitter
  83011. */
  83012. clone(): ConeParticleEmitter;
  83013. /**
  83014. * Called by the GPUParticleSystem to setup the update shader
  83015. * @param effect defines the update shader
  83016. */
  83017. applyToShader(effect: Effect): void;
  83018. /**
  83019. * Returns a string to use to update the GPU particles update shader
  83020. * @returns a string containng the defines string
  83021. */
  83022. getEffectDefines(): string;
  83023. /**
  83024. * Returns the string "ConeParticleEmitter"
  83025. * @returns a string containing the class name
  83026. */
  83027. getClassName(): string;
  83028. /**
  83029. * Serializes the particle system to a JSON object.
  83030. * @returns the JSON object
  83031. */
  83032. serialize(): any;
  83033. /**
  83034. * Parse properties from a JSON object
  83035. * @param serializationObject defines the JSON object
  83036. */
  83037. parse(serializationObject: any): void;
  83038. }
  83039. }
  83040. declare module BABYLON {
  83041. /**
  83042. * Particle emitter emitting particles from the inside of a cylinder.
  83043. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83044. */
  83045. export class CylinderParticleEmitter implements IParticleEmitterType {
  83046. /**
  83047. * The radius of the emission cylinder.
  83048. */
  83049. radius: number;
  83050. /**
  83051. * The height of the emission cylinder.
  83052. */
  83053. height: number;
  83054. /**
  83055. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83056. */
  83057. radiusRange: number;
  83058. /**
  83059. * How much to randomize the particle direction [0-1].
  83060. */
  83061. directionRandomizer: number;
  83062. /**
  83063. * Creates a new instance CylinderParticleEmitter
  83064. * @param radius the radius of the emission cylinder (1 by default)
  83065. * @param height the height of the emission cylinder (1 by default)
  83066. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83067. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83068. */
  83069. constructor(
  83070. /**
  83071. * The radius of the emission cylinder.
  83072. */
  83073. radius?: number,
  83074. /**
  83075. * The height of the emission cylinder.
  83076. */
  83077. height?: number,
  83078. /**
  83079. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83080. */
  83081. radiusRange?: number,
  83082. /**
  83083. * How much to randomize the particle direction [0-1].
  83084. */
  83085. directionRandomizer?: number);
  83086. /**
  83087. * Called by the particle System when the direction is computed for the created particle.
  83088. * @param worldMatrix is the world matrix of the particle system
  83089. * @param directionToUpdate is the direction vector to update with the result
  83090. * @param particle is the particle we are computed the direction for
  83091. */
  83092. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83093. /**
  83094. * Called by the particle System when the position is computed for the created particle.
  83095. * @param worldMatrix is the world matrix of the particle system
  83096. * @param positionToUpdate is the position vector to update with the result
  83097. * @param particle is the particle we are computed the position for
  83098. */
  83099. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83100. /**
  83101. * Clones the current emitter and returns a copy of it
  83102. * @returns the new emitter
  83103. */
  83104. clone(): CylinderParticleEmitter;
  83105. /**
  83106. * Called by the GPUParticleSystem to setup the update shader
  83107. * @param effect defines the update shader
  83108. */
  83109. applyToShader(effect: Effect): void;
  83110. /**
  83111. * Returns a string to use to update the GPU particles update shader
  83112. * @returns a string containng the defines string
  83113. */
  83114. getEffectDefines(): string;
  83115. /**
  83116. * Returns the string "CylinderParticleEmitter"
  83117. * @returns a string containing the class name
  83118. */
  83119. getClassName(): string;
  83120. /**
  83121. * Serializes the particle system to a JSON object.
  83122. * @returns the JSON object
  83123. */
  83124. serialize(): any;
  83125. /**
  83126. * Parse properties from a JSON object
  83127. * @param serializationObject defines the JSON object
  83128. */
  83129. parse(serializationObject: any): void;
  83130. }
  83131. /**
  83132. * Particle emitter emitting particles from the inside of a cylinder.
  83133. * It emits the particles randomly between two vectors.
  83134. */
  83135. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83136. /**
  83137. * The min limit of the emission direction.
  83138. */
  83139. direction1: Vector3;
  83140. /**
  83141. * The max limit of the emission direction.
  83142. */
  83143. direction2: Vector3;
  83144. /**
  83145. * Creates a new instance CylinderDirectedParticleEmitter
  83146. * @param radius the radius of the emission cylinder (1 by default)
  83147. * @param height the height of the emission cylinder (1 by default)
  83148. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83149. * @param direction1 the min limit of the emission direction (up vector by default)
  83150. * @param direction2 the max limit of the emission direction (up vector by default)
  83151. */
  83152. constructor(radius?: number, height?: number, radiusRange?: number,
  83153. /**
  83154. * The min limit of the emission direction.
  83155. */
  83156. direction1?: Vector3,
  83157. /**
  83158. * The max limit of the emission direction.
  83159. */
  83160. direction2?: Vector3);
  83161. /**
  83162. * Called by the particle System when the direction is computed for the created particle.
  83163. * @param worldMatrix is the world matrix of the particle system
  83164. * @param directionToUpdate is the direction vector to update with the result
  83165. * @param particle is the particle we are computed the direction for
  83166. */
  83167. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83168. /**
  83169. * Clones the current emitter and returns a copy of it
  83170. * @returns the new emitter
  83171. */
  83172. clone(): CylinderDirectedParticleEmitter;
  83173. /**
  83174. * Called by the GPUParticleSystem to setup the update shader
  83175. * @param effect defines the update shader
  83176. */
  83177. applyToShader(effect: Effect): void;
  83178. /**
  83179. * Returns a string to use to update the GPU particles update shader
  83180. * @returns a string containng the defines string
  83181. */
  83182. getEffectDefines(): string;
  83183. /**
  83184. * Returns the string "CylinderDirectedParticleEmitter"
  83185. * @returns a string containing the class name
  83186. */
  83187. getClassName(): string;
  83188. /**
  83189. * Serializes the particle system to a JSON object.
  83190. * @returns the JSON object
  83191. */
  83192. serialize(): any;
  83193. /**
  83194. * Parse properties from a JSON object
  83195. * @param serializationObject defines the JSON object
  83196. */
  83197. parse(serializationObject: any): void;
  83198. }
  83199. }
  83200. declare module BABYLON {
  83201. /**
  83202. * Particle emitter emitting particles from the inside of a hemisphere.
  83203. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83204. */
  83205. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83206. /**
  83207. * The radius of the emission hemisphere.
  83208. */
  83209. radius: number;
  83210. /**
  83211. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83212. */
  83213. radiusRange: number;
  83214. /**
  83215. * How much to randomize the particle direction [0-1].
  83216. */
  83217. directionRandomizer: number;
  83218. /**
  83219. * Creates a new instance HemisphericParticleEmitter
  83220. * @param radius the radius of the emission hemisphere (1 by default)
  83221. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83222. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83223. */
  83224. constructor(
  83225. /**
  83226. * The radius of the emission hemisphere.
  83227. */
  83228. radius?: number,
  83229. /**
  83230. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83231. */
  83232. radiusRange?: number,
  83233. /**
  83234. * How much to randomize the particle direction [0-1].
  83235. */
  83236. directionRandomizer?: number);
  83237. /**
  83238. * Called by the particle System when the direction is computed for the created particle.
  83239. * @param worldMatrix is the world matrix of the particle system
  83240. * @param directionToUpdate is the direction vector to update with the result
  83241. * @param particle is the particle we are computed the direction for
  83242. */
  83243. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83244. /**
  83245. * Called by the particle System when the position is computed for the created particle.
  83246. * @param worldMatrix is the world matrix of the particle system
  83247. * @param positionToUpdate is the position vector to update with the result
  83248. * @param particle is the particle we are computed the position for
  83249. */
  83250. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83251. /**
  83252. * Clones the current emitter and returns a copy of it
  83253. * @returns the new emitter
  83254. */
  83255. clone(): HemisphericParticleEmitter;
  83256. /**
  83257. * Called by the GPUParticleSystem to setup the update shader
  83258. * @param effect defines the update shader
  83259. */
  83260. applyToShader(effect: Effect): void;
  83261. /**
  83262. * Returns a string to use to update the GPU particles update shader
  83263. * @returns a string containng the defines string
  83264. */
  83265. getEffectDefines(): string;
  83266. /**
  83267. * Returns the string "HemisphericParticleEmitter"
  83268. * @returns a string containing the class name
  83269. */
  83270. getClassName(): string;
  83271. /**
  83272. * Serializes the particle system to a JSON object.
  83273. * @returns the JSON object
  83274. */
  83275. serialize(): any;
  83276. /**
  83277. * Parse properties from a JSON object
  83278. * @param serializationObject defines the JSON object
  83279. */
  83280. parse(serializationObject: any): void;
  83281. }
  83282. }
  83283. declare module BABYLON {
  83284. /**
  83285. * Particle emitter emitting particles from a point.
  83286. * It emits the particles randomly between 2 given directions.
  83287. */
  83288. export class PointParticleEmitter implements IParticleEmitterType {
  83289. /**
  83290. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83291. */
  83292. direction1: Vector3;
  83293. /**
  83294. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83295. */
  83296. direction2: Vector3;
  83297. /**
  83298. * Creates a new instance PointParticleEmitter
  83299. */
  83300. constructor();
  83301. /**
  83302. * Called by the particle System when the direction is computed for the created particle.
  83303. * @param worldMatrix is the world matrix of the particle system
  83304. * @param directionToUpdate is the direction vector to update with the result
  83305. * @param particle is the particle we are computed the direction for
  83306. */
  83307. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83308. /**
  83309. * Called by the particle System when the position is computed for the created particle.
  83310. * @param worldMatrix is the world matrix of the particle system
  83311. * @param positionToUpdate is the position vector to update with the result
  83312. * @param particle is the particle we are computed the position for
  83313. */
  83314. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83315. /**
  83316. * Clones the current emitter and returns a copy of it
  83317. * @returns the new emitter
  83318. */
  83319. clone(): PointParticleEmitter;
  83320. /**
  83321. * Called by the GPUParticleSystem to setup the update shader
  83322. * @param effect defines the update shader
  83323. */
  83324. applyToShader(effect: Effect): void;
  83325. /**
  83326. * Returns a string to use to update the GPU particles update shader
  83327. * @returns a string containng the defines string
  83328. */
  83329. getEffectDefines(): string;
  83330. /**
  83331. * Returns the string "PointParticleEmitter"
  83332. * @returns a string containing the class name
  83333. */
  83334. getClassName(): string;
  83335. /**
  83336. * Serializes the particle system to a JSON object.
  83337. * @returns the JSON object
  83338. */
  83339. serialize(): any;
  83340. /**
  83341. * Parse properties from a JSON object
  83342. * @param serializationObject defines the JSON object
  83343. */
  83344. parse(serializationObject: any): void;
  83345. }
  83346. }
  83347. declare module BABYLON {
  83348. /**
  83349. * Particle emitter emitting particles from the inside of a sphere.
  83350. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83351. */
  83352. export class SphereParticleEmitter implements IParticleEmitterType {
  83353. /**
  83354. * The radius of the emission sphere.
  83355. */
  83356. radius: number;
  83357. /**
  83358. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83359. */
  83360. radiusRange: number;
  83361. /**
  83362. * How much to randomize the particle direction [0-1].
  83363. */
  83364. directionRandomizer: number;
  83365. /**
  83366. * Creates a new instance SphereParticleEmitter
  83367. * @param radius the radius of the emission sphere (1 by default)
  83368. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83369. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83370. */
  83371. constructor(
  83372. /**
  83373. * The radius of the emission sphere.
  83374. */
  83375. radius?: number,
  83376. /**
  83377. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83378. */
  83379. radiusRange?: number,
  83380. /**
  83381. * How much to randomize the particle direction [0-1].
  83382. */
  83383. directionRandomizer?: number);
  83384. /**
  83385. * Called by the particle System when the direction is computed for the created particle.
  83386. * @param worldMatrix is the world matrix of the particle system
  83387. * @param directionToUpdate is the direction vector to update with the result
  83388. * @param particle is the particle we are computed the direction for
  83389. */
  83390. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83391. /**
  83392. * Called by the particle System when the position is computed for the created particle.
  83393. * @param worldMatrix is the world matrix of the particle system
  83394. * @param positionToUpdate is the position vector to update with the result
  83395. * @param particle is the particle we are computed the position for
  83396. */
  83397. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83398. /**
  83399. * Clones the current emitter and returns a copy of it
  83400. * @returns the new emitter
  83401. */
  83402. clone(): SphereParticleEmitter;
  83403. /**
  83404. * Called by the GPUParticleSystem to setup the update shader
  83405. * @param effect defines the update shader
  83406. */
  83407. applyToShader(effect: Effect): void;
  83408. /**
  83409. * Returns a string to use to update the GPU particles update shader
  83410. * @returns a string containng the defines string
  83411. */
  83412. getEffectDefines(): string;
  83413. /**
  83414. * Returns the string "SphereParticleEmitter"
  83415. * @returns a string containing the class name
  83416. */
  83417. getClassName(): string;
  83418. /**
  83419. * Serializes the particle system to a JSON object.
  83420. * @returns the JSON object
  83421. */
  83422. serialize(): any;
  83423. /**
  83424. * Parse properties from a JSON object
  83425. * @param serializationObject defines the JSON object
  83426. */
  83427. parse(serializationObject: any): void;
  83428. }
  83429. /**
  83430. * Particle emitter emitting particles from the inside of a sphere.
  83431. * It emits the particles randomly between two vectors.
  83432. */
  83433. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83434. /**
  83435. * The min limit of the emission direction.
  83436. */
  83437. direction1: Vector3;
  83438. /**
  83439. * The max limit of the emission direction.
  83440. */
  83441. direction2: Vector3;
  83442. /**
  83443. * Creates a new instance SphereDirectedParticleEmitter
  83444. * @param radius the radius of the emission sphere (1 by default)
  83445. * @param direction1 the min limit of the emission direction (up vector by default)
  83446. * @param direction2 the max limit of the emission direction (up vector by default)
  83447. */
  83448. constructor(radius?: number,
  83449. /**
  83450. * The min limit of the emission direction.
  83451. */
  83452. direction1?: Vector3,
  83453. /**
  83454. * The max limit of the emission direction.
  83455. */
  83456. direction2?: Vector3);
  83457. /**
  83458. * Called by the particle System when the direction is computed for the created particle.
  83459. * @param worldMatrix is the world matrix of the particle system
  83460. * @param directionToUpdate is the direction vector to update with the result
  83461. * @param particle is the particle we are computed the direction for
  83462. */
  83463. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83464. /**
  83465. * Clones the current emitter and returns a copy of it
  83466. * @returns the new emitter
  83467. */
  83468. clone(): SphereDirectedParticleEmitter;
  83469. /**
  83470. * Called by the GPUParticleSystem to setup the update shader
  83471. * @param effect defines the update shader
  83472. */
  83473. applyToShader(effect: Effect): void;
  83474. /**
  83475. * Returns a string to use to update the GPU particles update shader
  83476. * @returns a string containng the defines string
  83477. */
  83478. getEffectDefines(): string;
  83479. /**
  83480. * Returns the string "SphereDirectedParticleEmitter"
  83481. * @returns a string containing the class name
  83482. */
  83483. getClassName(): string;
  83484. /**
  83485. * Serializes the particle system to a JSON object.
  83486. * @returns the JSON object
  83487. */
  83488. serialize(): any;
  83489. /**
  83490. * Parse properties from a JSON object
  83491. * @param serializationObject defines the JSON object
  83492. */
  83493. parse(serializationObject: any): void;
  83494. }
  83495. }
  83496. declare module BABYLON {
  83497. /**
  83498. * Interface representing a particle system in Babylon.js.
  83499. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83500. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83501. */
  83502. export interface IParticleSystem {
  83503. /**
  83504. * List of animations used by the particle system.
  83505. */
  83506. animations: Animation[];
  83507. /**
  83508. * The id of the Particle system.
  83509. */
  83510. id: string;
  83511. /**
  83512. * The name of the Particle system.
  83513. */
  83514. name: string;
  83515. /**
  83516. * The emitter represents the Mesh or position we are attaching the particle system to.
  83517. */
  83518. emitter: Nullable<AbstractMesh | Vector3>;
  83519. /**
  83520. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83521. */
  83522. isBillboardBased: boolean;
  83523. /**
  83524. * The rendering group used by the Particle system to chose when to render.
  83525. */
  83526. renderingGroupId: number;
  83527. /**
  83528. * The layer mask we are rendering the particles through.
  83529. */
  83530. layerMask: number;
  83531. /**
  83532. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83533. */
  83534. updateSpeed: number;
  83535. /**
  83536. * The amount of time the particle system is running (depends of the overall update speed).
  83537. */
  83538. targetStopDuration: number;
  83539. /**
  83540. * The texture used to render each particle. (this can be a spritesheet)
  83541. */
  83542. particleTexture: Nullable<Texture>;
  83543. /**
  83544. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83545. */
  83546. blendMode: number;
  83547. /**
  83548. * Minimum life time of emitting particles.
  83549. */
  83550. minLifeTime: number;
  83551. /**
  83552. * Maximum life time of emitting particles.
  83553. */
  83554. maxLifeTime: number;
  83555. /**
  83556. * Minimum Size of emitting particles.
  83557. */
  83558. minSize: number;
  83559. /**
  83560. * Maximum Size of emitting particles.
  83561. */
  83562. maxSize: number;
  83563. /**
  83564. * Minimum scale of emitting particles on X axis.
  83565. */
  83566. minScaleX: number;
  83567. /**
  83568. * Maximum scale of emitting particles on X axis.
  83569. */
  83570. maxScaleX: number;
  83571. /**
  83572. * Minimum scale of emitting particles on Y axis.
  83573. */
  83574. minScaleY: number;
  83575. /**
  83576. * Maximum scale of emitting particles on Y axis.
  83577. */
  83578. maxScaleY: number;
  83579. /**
  83580. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83581. */
  83582. color1: Color4;
  83583. /**
  83584. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83585. */
  83586. color2: Color4;
  83587. /**
  83588. * Color the particle will have at the end of its lifetime.
  83589. */
  83590. colorDead: Color4;
  83591. /**
  83592. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83593. */
  83594. emitRate: number;
  83595. /**
  83596. * You can use gravity if you want to give an orientation to your particles.
  83597. */
  83598. gravity: Vector3;
  83599. /**
  83600. * Minimum power of emitting particles.
  83601. */
  83602. minEmitPower: number;
  83603. /**
  83604. * Maximum power of emitting particles.
  83605. */
  83606. maxEmitPower: number;
  83607. /**
  83608. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83609. */
  83610. minAngularSpeed: number;
  83611. /**
  83612. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83613. */
  83614. maxAngularSpeed: number;
  83615. /**
  83616. * Gets or sets the minimal initial rotation in radians.
  83617. */
  83618. minInitialRotation: number;
  83619. /**
  83620. * Gets or sets the maximal initial rotation in radians.
  83621. */
  83622. maxInitialRotation: number;
  83623. /**
  83624. * The particle emitter type defines the emitter used by the particle system.
  83625. * It can be for example box, sphere, or cone...
  83626. */
  83627. particleEmitterType: Nullable<IParticleEmitterType>;
  83628. /**
  83629. * Defines the delay in milliseconds before starting the system (0 by default)
  83630. */
  83631. startDelay: number;
  83632. /**
  83633. * 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
  83634. */
  83635. preWarmCycles: number;
  83636. /**
  83637. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83638. */
  83639. preWarmStepOffset: number;
  83640. /**
  83641. * 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)
  83642. */
  83643. spriteCellChangeSpeed: number;
  83644. /**
  83645. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83646. */
  83647. startSpriteCellID: number;
  83648. /**
  83649. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83650. */
  83651. endSpriteCellID: number;
  83652. /**
  83653. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83654. */
  83655. spriteCellWidth: number;
  83656. /**
  83657. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83658. */
  83659. spriteCellHeight: number;
  83660. /**
  83661. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83662. */
  83663. spriteRandomStartCell: boolean;
  83664. /**
  83665. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83666. */
  83667. isAnimationSheetEnabled: boolean;
  83668. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83669. translationPivot: Vector2;
  83670. /**
  83671. * Gets or sets a texture used to add random noise to particle positions
  83672. */
  83673. noiseTexture: Nullable<BaseTexture>;
  83674. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83675. noiseStrength: Vector3;
  83676. /**
  83677. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83678. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83679. */
  83680. billboardMode: number;
  83681. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83682. limitVelocityDamping: number;
  83683. /**
  83684. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83685. */
  83686. beginAnimationOnStart: boolean;
  83687. /**
  83688. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83689. */
  83690. beginAnimationFrom: number;
  83691. /**
  83692. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83693. */
  83694. beginAnimationTo: number;
  83695. /**
  83696. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83697. */
  83698. beginAnimationLoop: boolean;
  83699. /**
  83700. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83701. */
  83702. disposeOnStop: boolean;
  83703. /**
  83704. * Gets the maximum number of particles active at the same time.
  83705. * @returns The max number of active particles.
  83706. */
  83707. getCapacity(): number;
  83708. /**
  83709. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83710. * @returns True if it has been started, otherwise false.
  83711. */
  83712. isStarted(): boolean;
  83713. /**
  83714. * Animates the particle system for this frame.
  83715. */
  83716. animate(): void;
  83717. /**
  83718. * Renders the particle system in its current state.
  83719. * @returns the current number of particles
  83720. */
  83721. render(): number;
  83722. /**
  83723. * Dispose the particle system and frees its associated resources.
  83724. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83725. */
  83726. dispose(disposeTexture?: boolean): void;
  83727. /**
  83728. * Clones the particle system.
  83729. * @param name The name of the cloned object
  83730. * @param newEmitter The new emitter to use
  83731. * @returns the cloned particle system
  83732. */
  83733. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83734. /**
  83735. * Serializes the particle system to a JSON object.
  83736. * @returns the JSON object
  83737. */
  83738. serialize(): any;
  83739. /**
  83740. * Rebuild the particle system
  83741. */
  83742. rebuild(): void;
  83743. /**
  83744. * Starts the particle system and begins to emit
  83745. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83746. */
  83747. start(delay?: number): void;
  83748. /**
  83749. * Stops the particle system.
  83750. */
  83751. stop(): void;
  83752. /**
  83753. * Remove all active particles
  83754. */
  83755. reset(): void;
  83756. /**
  83757. * Is this system ready to be used/rendered
  83758. * @return true if the system is ready
  83759. */
  83760. isReady(): boolean;
  83761. /**
  83762. * Adds a new color gradient
  83763. * @param gradient defines the gradient to use (between 0 and 1)
  83764. * @param color1 defines the color to affect to the specified gradient
  83765. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83766. * @returns the current particle system
  83767. */
  83768. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83769. /**
  83770. * Remove a specific color gradient
  83771. * @param gradient defines the gradient to remove
  83772. * @returns the current particle system
  83773. */
  83774. removeColorGradient(gradient: number): IParticleSystem;
  83775. /**
  83776. * Adds a new size gradient
  83777. * @param gradient defines the gradient to use (between 0 and 1)
  83778. * @param factor defines the size factor to affect to the specified gradient
  83779. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83780. * @returns the current particle system
  83781. */
  83782. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83783. /**
  83784. * Remove a specific size gradient
  83785. * @param gradient defines the gradient to remove
  83786. * @returns the current particle system
  83787. */
  83788. removeSizeGradient(gradient: number): IParticleSystem;
  83789. /**
  83790. * Gets the current list of color gradients.
  83791. * You must use addColorGradient and removeColorGradient to udpate this list
  83792. * @returns the list of color gradients
  83793. */
  83794. getColorGradients(): Nullable<Array<ColorGradient>>;
  83795. /**
  83796. * Gets the current list of size gradients.
  83797. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83798. * @returns the list of size gradients
  83799. */
  83800. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83801. /**
  83802. * Gets the current list of angular speed gradients.
  83803. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83804. * @returns the list of angular speed gradients
  83805. */
  83806. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83807. /**
  83808. * Adds a new angular speed gradient
  83809. * @param gradient defines the gradient to use (between 0 and 1)
  83810. * @param factor defines the angular speed to affect to the specified gradient
  83811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83812. * @returns the current particle system
  83813. */
  83814. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83815. /**
  83816. * Remove a specific angular speed gradient
  83817. * @param gradient defines the gradient to remove
  83818. * @returns the current particle system
  83819. */
  83820. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83821. /**
  83822. * Gets the current list of velocity gradients.
  83823. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83824. * @returns the list of velocity gradients
  83825. */
  83826. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83827. /**
  83828. * Adds a new velocity gradient
  83829. * @param gradient defines the gradient to use (between 0 and 1)
  83830. * @param factor defines the velocity to affect to the specified gradient
  83831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83832. * @returns the current particle system
  83833. */
  83834. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83835. /**
  83836. * Remove a specific velocity gradient
  83837. * @param gradient defines the gradient to remove
  83838. * @returns the current particle system
  83839. */
  83840. removeVelocityGradient(gradient: number): IParticleSystem;
  83841. /**
  83842. * Gets the current list of limit velocity gradients.
  83843. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83844. * @returns the list of limit velocity gradients
  83845. */
  83846. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83847. /**
  83848. * Adds a new limit velocity gradient
  83849. * @param gradient defines the gradient to use (between 0 and 1)
  83850. * @param factor defines the limit velocity to affect to the specified gradient
  83851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83852. * @returns the current particle system
  83853. */
  83854. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83855. /**
  83856. * Remove a specific limit velocity gradient
  83857. * @param gradient defines the gradient to remove
  83858. * @returns the current particle system
  83859. */
  83860. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83861. /**
  83862. * Adds a new drag gradient
  83863. * @param gradient defines the gradient to use (between 0 and 1)
  83864. * @param factor defines the drag to affect to the specified gradient
  83865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83866. * @returns the current particle system
  83867. */
  83868. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83869. /**
  83870. * Remove a specific drag gradient
  83871. * @param gradient defines the gradient to remove
  83872. * @returns the current particle system
  83873. */
  83874. removeDragGradient(gradient: number): IParticleSystem;
  83875. /**
  83876. * Gets the current list of drag gradients.
  83877. * You must use addDragGradient and removeDragGradient to udpate this list
  83878. * @returns the list of drag gradients
  83879. */
  83880. getDragGradients(): Nullable<Array<FactorGradient>>;
  83881. /**
  83882. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83883. * @param gradient defines the gradient to use (between 0 and 1)
  83884. * @param factor defines the emit rate to affect to the specified gradient
  83885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83886. * @returns the current particle system
  83887. */
  83888. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83889. /**
  83890. * Remove a specific emit rate gradient
  83891. * @param gradient defines the gradient to remove
  83892. * @returns the current particle system
  83893. */
  83894. removeEmitRateGradient(gradient: number): IParticleSystem;
  83895. /**
  83896. * Gets the current list of emit rate gradients.
  83897. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83898. * @returns the list of emit rate gradients
  83899. */
  83900. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83901. /**
  83902. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83903. * @param gradient defines the gradient to use (between 0 and 1)
  83904. * @param factor defines the start size to affect to the specified gradient
  83905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83906. * @returns the current particle system
  83907. */
  83908. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83909. /**
  83910. * Remove a specific start size gradient
  83911. * @param gradient defines the gradient to remove
  83912. * @returns the current particle system
  83913. */
  83914. removeStartSizeGradient(gradient: number): IParticleSystem;
  83915. /**
  83916. * Gets the current list of start size gradients.
  83917. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83918. * @returns the list of start size gradients
  83919. */
  83920. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83921. /**
  83922. * Adds a new life time gradient
  83923. * @param gradient defines the gradient to use (between 0 and 1)
  83924. * @param factor defines the life time factor to affect to the specified gradient
  83925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83926. * @returns the current particle system
  83927. */
  83928. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83929. /**
  83930. * Remove a specific life time gradient
  83931. * @param gradient defines the gradient to remove
  83932. * @returns the current particle system
  83933. */
  83934. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83935. /**
  83936. * Gets the current list of life time gradients.
  83937. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83938. * @returns the list of life time gradients
  83939. */
  83940. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83941. /**
  83942. * Gets the current list of color gradients.
  83943. * You must use addColorGradient and removeColorGradient to udpate this list
  83944. * @returns the list of color gradients
  83945. */
  83946. getColorGradients(): Nullable<Array<ColorGradient>>;
  83947. /**
  83948. * Adds a new ramp gradient used to remap particle colors
  83949. * @param gradient defines the gradient to use (between 0 and 1)
  83950. * @param color defines the color to affect to the specified gradient
  83951. * @returns the current particle system
  83952. */
  83953. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  83954. /**
  83955. * Gets the current list of ramp gradients.
  83956. * You must use addRampGradient and removeRampGradient to udpate this list
  83957. * @returns the list of ramp gradients
  83958. */
  83959. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83960. /** Gets or sets a boolean indicating that ramp gradients must be used
  83961. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83962. */
  83963. useRampGradients: boolean;
  83964. /**
  83965. * Adds a new color remap gradient
  83966. * @param gradient defines the gradient to use (between 0 and 1)
  83967. * @param min defines the color remap minimal range
  83968. * @param max defines the color remap maximal range
  83969. * @returns the current particle system
  83970. */
  83971. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83972. /**
  83973. * Gets the current list of color remap gradients.
  83974. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83975. * @returns the list of color remap gradients
  83976. */
  83977. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83978. /**
  83979. * Adds a new alpha remap gradient
  83980. * @param gradient defines the gradient to use (between 0 and 1)
  83981. * @param min defines the alpha remap minimal range
  83982. * @param max defines the alpha remap maximal range
  83983. * @returns the current particle system
  83984. */
  83985. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83986. /**
  83987. * Gets the current list of alpha remap gradients.
  83988. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83989. * @returns the list of alpha remap gradients
  83990. */
  83991. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83992. /**
  83993. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83994. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83995. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83996. * @returns the emitter
  83997. */
  83998. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83999. /**
  84000. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84001. * @param radius The radius of the hemisphere to emit from
  84002. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84003. * @returns the emitter
  84004. */
  84005. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84006. /**
  84007. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84008. * @param radius The radius of the sphere to emit from
  84009. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84010. * @returns the emitter
  84011. */
  84012. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84013. /**
  84014. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84015. * @param radius The radius of the sphere to emit from
  84016. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84017. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84018. * @returns the emitter
  84019. */
  84020. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84021. /**
  84022. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84023. * @param radius The radius of the emission cylinder
  84024. * @param height The height of the emission cylinder
  84025. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84026. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84027. * @returns the emitter
  84028. */
  84029. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84030. /**
  84031. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84032. * @param radius The radius of the cylinder to emit from
  84033. * @param height The height of the emission cylinder
  84034. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84035. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84036. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84037. * @returns the emitter
  84038. */
  84039. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84040. /**
  84041. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84042. * @param radius The radius of the cone to emit from
  84043. * @param angle The base angle of the cone
  84044. * @returns the emitter
  84045. */
  84046. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84047. /**
  84048. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84049. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84050. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84051. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84052. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84053. * @returns the emitter
  84054. */
  84055. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84056. /**
  84057. * Get hosting scene
  84058. * @returns the scene
  84059. */
  84060. getScene(): Scene;
  84061. }
  84062. }
  84063. declare module BABYLON {
  84064. /** @hidden */
  84065. export var linePixelShader: {
  84066. name: string;
  84067. shader: string;
  84068. };
  84069. }
  84070. declare module BABYLON {
  84071. /** @hidden */
  84072. export var lineVertexShader: {
  84073. name: string;
  84074. shader: string;
  84075. };
  84076. }
  84077. declare module BABYLON {
  84078. interface AbstractMesh {
  84079. /**
  84080. * Gets the edgesRenderer associated with the mesh
  84081. */
  84082. edgesRenderer: Nullable<EdgesRenderer>;
  84083. }
  84084. interface LinesMesh {
  84085. /**
  84086. * Enables the edge rendering mode on the mesh.
  84087. * This mode makes the mesh edges visible
  84088. * @param epsilon defines the maximal distance between two angles to detect a face
  84089. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84090. * @returns the currentAbstractMesh
  84091. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84092. */
  84093. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84094. }
  84095. interface InstancedLinesMesh {
  84096. /**
  84097. * Enables the edge rendering mode on the mesh.
  84098. * This mode makes the mesh edges visible
  84099. * @param epsilon defines the maximal distance between two angles to detect a face
  84100. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84101. * @returns the current InstancedLinesMesh
  84102. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84103. */
  84104. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84105. }
  84106. /**
  84107. * Defines the minimum contract an Edges renderer should follow.
  84108. */
  84109. export interface IEdgesRenderer extends IDisposable {
  84110. /**
  84111. * Gets or sets a boolean indicating if the edgesRenderer is active
  84112. */
  84113. isEnabled: boolean;
  84114. /**
  84115. * Renders the edges of the attached mesh,
  84116. */
  84117. render(): void;
  84118. /**
  84119. * Checks wether or not the edges renderer is ready to render.
  84120. * @return true if ready, otherwise false.
  84121. */
  84122. isReady(): boolean;
  84123. }
  84124. /**
  84125. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  84126. */
  84127. export class EdgesRenderer implements IEdgesRenderer {
  84128. /**
  84129. * Define the size of the edges with an orthographic camera
  84130. */
  84131. edgesWidthScalerForOrthographic: number;
  84132. /**
  84133. * Define the size of the edges with a perspective camera
  84134. */
  84135. edgesWidthScalerForPerspective: number;
  84136. protected _source: AbstractMesh;
  84137. protected _linesPositions: number[];
  84138. protected _linesNormals: number[];
  84139. protected _linesIndices: number[];
  84140. protected _epsilon: number;
  84141. protected _indicesCount: number;
  84142. protected _lineShader: ShaderMaterial;
  84143. protected _ib: DataBuffer;
  84144. protected _buffers: {
  84145. [key: string]: Nullable<VertexBuffer>;
  84146. };
  84147. protected _checkVerticesInsteadOfIndices: boolean;
  84148. private _meshRebuildObserver;
  84149. private _meshDisposeObserver;
  84150. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84151. isEnabled: boolean;
  84152. /**
  84153. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84154. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84155. * @param source Mesh used to create edges
  84156. * @param epsilon sum of angles in adjacency to check for edge
  84157. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84158. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84159. */
  84160. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84161. protected _prepareRessources(): void;
  84162. /** @hidden */
  84163. _rebuild(): void;
  84164. /**
  84165. * Releases the required resources for the edges renderer
  84166. */
  84167. dispose(): void;
  84168. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84169. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84170. /**
  84171. * Checks if the pair of p0 and p1 is en edge
  84172. * @param faceIndex
  84173. * @param edge
  84174. * @param faceNormals
  84175. * @param p0
  84176. * @param p1
  84177. * @private
  84178. */
  84179. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84180. /**
  84181. * push line into the position, normal and index buffer
  84182. * @protected
  84183. */
  84184. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84185. /**
  84186. * Generates lines edges from adjacencjes
  84187. * @private
  84188. */
  84189. _generateEdgesLines(): void;
  84190. /**
  84191. * Checks wether or not the edges renderer is ready to render.
  84192. * @return true if ready, otherwise false.
  84193. */
  84194. isReady(): boolean;
  84195. /**
  84196. * Renders the edges of the attached mesh,
  84197. */
  84198. render(): void;
  84199. }
  84200. /**
  84201. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84202. */
  84203. export class LineEdgesRenderer extends EdgesRenderer {
  84204. /**
  84205. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84206. * @param source LineMesh used to generate edges
  84207. * @param epsilon not important (specified angle for edge detection)
  84208. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84209. */
  84210. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84211. /**
  84212. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84213. */
  84214. _generateEdgesLines(): void;
  84215. }
  84216. }
  84217. declare module BABYLON {
  84218. /**
  84219. * This represents the object necessary to create a rendering group.
  84220. * This is exclusively used and created by the rendering manager.
  84221. * To modify the behavior, you use the available helpers in your scene or meshes.
  84222. * @hidden
  84223. */
  84224. export class RenderingGroup {
  84225. index: number;
  84226. private static _zeroVector;
  84227. private _scene;
  84228. private _opaqueSubMeshes;
  84229. private _transparentSubMeshes;
  84230. private _alphaTestSubMeshes;
  84231. private _depthOnlySubMeshes;
  84232. private _particleSystems;
  84233. private _spriteManagers;
  84234. private _opaqueSortCompareFn;
  84235. private _alphaTestSortCompareFn;
  84236. private _transparentSortCompareFn;
  84237. private _renderOpaque;
  84238. private _renderAlphaTest;
  84239. private _renderTransparent;
  84240. /** @hidden */
  84241. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84242. onBeforeTransparentRendering: () => void;
  84243. /**
  84244. * Set the opaque sort comparison function.
  84245. * If null the sub meshes will be render in the order they were created
  84246. */
  84247. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84248. /**
  84249. * Set the alpha test sort comparison function.
  84250. * If null the sub meshes will be render in the order they were created
  84251. */
  84252. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84253. /**
  84254. * Set the transparent sort comparison function.
  84255. * If null the sub meshes will be render in the order they were created
  84256. */
  84257. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84258. /**
  84259. * Creates a new rendering group.
  84260. * @param index The rendering group index
  84261. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84262. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84263. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84264. */
  84265. 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>);
  84266. /**
  84267. * Render all the sub meshes contained in the group.
  84268. * @param customRenderFunction Used to override the default render behaviour of the group.
  84269. * @returns true if rendered some submeshes.
  84270. */
  84271. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84272. /**
  84273. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84274. * @param subMeshes The submeshes to render
  84275. */
  84276. private renderOpaqueSorted;
  84277. /**
  84278. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84279. * @param subMeshes The submeshes to render
  84280. */
  84281. private renderAlphaTestSorted;
  84282. /**
  84283. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84284. * @param subMeshes The submeshes to render
  84285. */
  84286. private renderTransparentSorted;
  84287. /**
  84288. * Renders the submeshes in a specified order.
  84289. * @param subMeshes The submeshes to sort before render
  84290. * @param sortCompareFn The comparison function use to sort
  84291. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84292. * @param transparent Specifies to activate blending if true
  84293. */
  84294. private static renderSorted;
  84295. /**
  84296. * Renders the submeshes in the order they were dispatched (no sort applied).
  84297. * @param subMeshes The submeshes to render
  84298. */
  84299. private static renderUnsorted;
  84300. /**
  84301. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84302. * are rendered back to front if in the same alpha index.
  84303. *
  84304. * @param a The first submesh
  84305. * @param b The second submesh
  84306. * @returns The result of the comparison
  84307. */
  84308. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84309. /**
  84310. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84311. * are rendered back to front.
  84312. *
  84313. * @param a The first submesh
  84314. * @param b The second submesh
  84315. * @returns The result of the comparison
  84316. */
  84317. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84318. /**
  84319. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84320. * are rendered front to back (prevent overdraw).
  84321. *
  84322. * @param a The first submesh
  84323. * @param b The second submesh
  84324. * @returns The result of the comparison
  84325. */
  84326. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84327. /**
  84328. * Resets the different lists of submeshes to prepare a new frame.
  84329. */
  84330. prepare(): void;
  84331. dispose(): void;
  84332. /**
  84333. * Inserts the submesh in its correct queue depending on its material.
  84334. * @param subMesh The submesh to dispatch
  84335. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84336. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84337. */
  84338. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84339. dispatchSprites(spriteManager: ISpriteManager): void;
  84340. dispatchParticles(particleSystem: IParticleSystem): void;
  84341. private _renderParticles;
  84342. private _renderSprites;
  84343. }
  84344. }
  84345. declare module BABYLON {
  84346. /**
  84347. * Interface describing the different options available in the rendering manager
  84348. * regarding Auto Clear between groups.
  84349. */
  84350. export interface IRenderingManagerAutoClearSetup {
  84351. /**
  84352. * Defines whether or not autoclear is enable.
  84353. */
  84354. autoClear: boolean;
  84355. /**
  84356. * Defines whether or not to autoclear the depth buffer.
  84357. */
  84358. depth: boolean;
  84359. /**
  84360. * Defines whether or not to autoclear the stencil buffer.
  84361. */
  84362. stencil: boolean;
  84363. }
  84364. /**
  84365. * This class is used by the onRenderingGroupObservable
  84366. */
  84367. export class RenderingGroupInfo {
  84368. /**
  84369. * The Scene that being rendered
  84370. */
  84371. scene: Scene;
  84372. /**
  84373. * The camera currently used for the rendering pass
  84374. */
  84375. camera: Nullable<Camera>;
  84376. /**
  84377. * The ID of the renderingGroup being processed
  84378. */
  84379. renderingGroupId: number;
  84380. }
  84381. /**
  84382. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84383. * It is enable to manage the different groups as well as the different necessary sort functions.
  84384. * This should not be used directly aside of the few static configurations
  84385. */
  84386. export class RenderingManager {
  84387. /**
  84388. * The max id used for rendering groups (not included)
  84389. */
  84390. static MAX_RENDERINGGROUPS: number;
  84391. /**
  84392. * The min id used for rendering groups (included)
  84393. */
  84394. static MIN_RENDERINGGROUPS: number;
  84395. /**
  84396. * Used to globally prevent autoclearing scenes.
  84397. */
  84398. static AUTOCLEAR: boolean;
  84399. /**
  84400. * @hidden
  84401. */
  84402. _useSceneAutoClearSetup: boolean;
  84403. private _scene;
  84404. private _renderingGroups;
  84405. private _depthStencilBufferAlreadyCleaned;
  84406. private _autoClearDepthStencil;
  84407. private _customOpaqueSortCompareFn;
  84408. private _customAlphaTestSortCompareFn;
  84409. private _customTransparentSortCompareFn;
  84410. private _renderingGroupInfo;
  84411. /**
  84412. * Instantiates a new rendering group for a particular scene
  84413. * @param scene Defines the scene the groups belongs to
  84414. */
  84415. constructor(scene: Scene);
  84416. private _clearDepthStencilBuffer;
  84417. /**
  84418. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84419. * @hidden
  84420. */
  84421. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84422. /**
  84423. * Resets the different information of the group to prepare a new frame
  84424. * @hidden
  84425. */
  84426. reset(): void;
  84427. /**
  84428. * Dispose and release the group and its associated resources.
  84429. * @hidden
  84430. */
  84431. dispose(): void;
  84432. /**
  84433. * Clear the info related to rendering groups preventing retention points during dispose.
  84434. */
  84435. freeRenderingGroups(): void;
  84436. private _prepareRenderingGroup;
  84437. /**
  84438. * Add a sprite manager to the rendering manager in order to render it this frame.
  84439. * @param spriteManager Define the sprite manager to render
  84440. */
  84441. dispatchSprites(spriteManager: ISpriteManager): void;
  84442. /**
  84443. * Add a particle system to the rendering manager in order to render it this frame.
  84444. * @param particleSystem Define the particle system to render
  84445. */
  84446. dispatchParticles(particleSystem: IParticleSystem): void;
  84447. /**
  84448. * Add a submesh to the manager in order to render it this frame
  84449. * @param subMesh The submesh to dispatch
  84450. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84451. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84452. */
  84453. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84454. /**
  84455. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84456. * This allowed control for front to back rendering or reversly depending of the special needs.
  84457. *
  84458. * @param renderingGroupId The rendering group id corresponding to its index
  84459. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84460. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84461. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84462. */
  84463. 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;
  84464. /**
  84465. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84466. *
  84467. * @param renderingGroupId The rendering group id corresponding to its index
  84468. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84469. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84470. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84471. */
  84472. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84473. /**
  84474. * Gets the current auto clear configuration for one rendering group of the rendering
  84475. * manager.
  84476. * @param index the rendering group index to get the information for
  84477. * @returns The auto clear setup for the requested rendering group
  84478. */
  84479. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84480. }
  84481. }
  84482. declare module BABYLON {
  84483. /**
  84484. * This Helps creating a texture that will be created from a camera in your scene.
  84485. * It is basically a dynamic texture that could be used to create special effects for instance.
  84486. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84487. */
  84488. export class RenderTargetTexture extends Texture {
  84489. isCube: boolean;
  84490. /**
  84491. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84492. */
  84493. static readonly REFRESHRATE_RENDER_ONCE: number;
  84494. /**
  84495. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84496. */
  84497. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84498. /**
  84499. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84500. * the central point of your effect and can save a lot of performances.
  84501. */
  84502. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84503. /**
  84504. * Use this predicate to dynamically define the list of mesh you want to render.
  84505. * If set, the renderList property will be overwritten.
  84506. */
  84507. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84508. private _renderList;
  84509. /**
  84510. * Use this list to define the list of mesh you want to render.
  84511. */
  84512. renderList: Nullable<Array<AbstractMesh>>;
  84513. private _hookArray;
  84514. /**
  84515. * Define if particles should be rendered in your texture.
  84516. */
  84517. renderParticles: boolean;
  84518. /**
  84519. * Define if sprites should be rendered in your texture.
  84520. */
  84521. renderSprites: boolean;
  84522. /**
  84523. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84524. */
  84525. coordinatesMode: number;
  84526. /**
  84527. * Define the camera used to render the texture.
  84528. */
  84529. activeCamera: Nullable<Camera>;
  84530. /**
  84531. * Override the render function of the texture with your own one.
  84532. */
  84533. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84534. /**
  84535. * Define if camera post processes should be use while rendering the texture.
  84536. */
  84537. useCameraPostProcesses: boolean;
  84538. /**
  84539. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84540. */
  84541. ignoreCameraViewport: boolean;
  84542. private _postProcessManager;
  84543. private _postProcesses;
  84544. private _resizeObserver;
  84545. /**
  84546. * An event triggered when the texture is unbind.
  84547. */
  84548. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84549. /**
  84550. * An event triggered when the texture is unbind.
  84551. */
  84552. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84553. private _onAfterUnbindObserver;
  84554. /**
  84555. * Set a after unbind callback in the texture.
  84556. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84557. */
  84558. onAfterUnbind: () => void;
  84559. /**
  84560. * An event triggered before rendering the texture
  84561. */
  84562. onBeforeRenderObservable: Observable<number>;
  84563. private _onBeforeRenderObserver;
  84564. /**
  84565. * Set a before render callback in the texture.
  84566. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84567. */
  84568. onBeforeRender: (faceIndex: number) => void;
  84569. /**
  84570. * An event triggered after rendering the texture
  84571. */
  84572. onAfterRenderObservable: Observable<number>;
  84573. private _onAfterRenderObserver;
  84574. /**
  84575. * Set a after render callback in the texture.
  84576. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84577. */
  84578. onAfterRender: (faceIndex: number) => void;
  84579. /**
  84580. * An event triggered after the texture clear
  84581. */
  84582. onClearObservable: Observable<Engine>;
  84583. private _onClearObserver;
  84584. /**
  84585. * Set a clear callback in the texture.
  84586. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84587. */
  84588. onClear: (Engine: Engine) => void;
  84589. /**
  84590. * Define the clear color of the Render Target if it should be different from the scene.
  84591. */
  84592. clearColor: Color4;
  84593. protected _size: number | {
  84594. width: number;
  84595. height: number;
  84596. };
  84597. protected _initialSizeParameter: number | {
  84598. width: number;
  84599. height: number;
  84600. } | {
  84601. ratio: number;
  84602. };
  84603. protected _sizeRatio: Nullable<number>;
  84604. /** @hidden */
  84605. _generateMipMaps: boolean;
  84606. protected _renderingManager: RenderingManager;
  84607. /** @hidden */
  84608. _waitingRenderList: string[];
  84609. protected _doNotChangeAspectRatio: boolean;
  84610. protected _currentRefreshId: number;
  84611. protected _refreshRate: number;
  84612. protected _textureMatrix: Matrix;
  84613. protected _samples: number;
  84614. protected _renderTargetOptions: RenderTargetCreationOptions;
  84615. /**
  84616. * Gets render target creation options that were used.
  84617. */
  84618. readonly renderTargetOptions: RenderTargetCreationOptions;
  84619. protected _engine: Engine;
  84620. protected _onRatioRescale(): void;
  84621. /**
  84622. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84623. * It must define where the camera used to render the texture is set
  84624. */
  84625. boundingBoxPosition: Vector3;
  84626. private _boundingBoxSize;
  84627. /**
  84628. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84629. * When defined, the cubemap will switch to local mode
  84630. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84631. * @example https://www.babylonjs-playground.com/#RNASML
  84632. */
  84633. boundingBoxSize: Vector3;
  84634. /**
  84635. * In case the RTT has been created with a depth texture, get the associated
  84636. * depth texture.
  84637. * Otherwise, return null.
  84638. */
  84639. depthStencilTexture: Nullable<InternalTexture>;
  84640. /**
  84641. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84642. * or used a shadow, depth texture...
  84643. * @param name The friendly name of the texture
  84644. * @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)
  84645. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84646. * @param generateMipMaps True if mip maps need to be generated after render.
  84647. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84648. * @param type The type of the buffer in the RTT (int, half float, float...)
  84649. * @param isCube True if a cube texture needs to be created
  84650. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84651. * @param generateDepthBuffer True to generate a depth buffer
  84652. * @param generateStencilBuffer True to generate a stencil buffer
  84653. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84654. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84655. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84656. */
  84657. constructor(name: string, size: number | {
  84658. width: number;
  84659. height: number;
  84660. } | {
  84661. ratio: number;
  84662. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84663. /**
  84664. * Creates a depth stencil texture.
  84665. * This is only available in WebGL 2 or with the depth texture extension available.
  84666. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84667. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84668. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84669. */
  84670. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84671. private _processSizeParameter;
  84672. /**
  84673. * Define the number of samples to use in case of MSAA.
  84674. * It defaults to one meaning no MSAA has been enabled.
  84675. */
  84676. samples: number;
  84677. /**
  84678. * Resets the refresh counter of the texture and start bak from scratch.
  84679. * Could be useful to regenerate the texture if it is setup to render only once.
  84680. */
  84681. resetRefreshCounter(): void;
  84682. /**
  84683. * Define the refresh rate of the texture or the rendering frequency.
  84684. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84685. */
  84686. refreshRate: number;
  84687. /**
  84688. * Adds a post process to the render target rendering passes.
  84689. * @param postProcess define the post process to add
  84690. */
  84691. addPostProcess(postProcess: PostProcess): void;
  84692. /**
  84693. * Clear all the post processes attached to the render target
  84694. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84695. */
  84696. clearPostProcesses(dispose?: boolean): void;
  84697. /**
  84698. * Remove one of the post process from the list of attached post processes to the texture
  84699. * @param postProcess define the post process to remove from the list
  84700. */
  84701. removePostProcess(postProcess: PostProcess): void;
  84702. /** @hidden */
  84703. _shouldRender(): boolean;
  84704. /**
  84705. * Gets the actual render size of the texture.
  84706. * @returns the width of the render size
  84707. */
  84708. getRenderSize(): number;
  84709. /**
  84710. * Gets the actual render width of the texture.
  84711. * @returns the width of the render size
  84712. */
  84713. getRenderWidth(): number;
  84714. /**
  84715. * Gets the actual render height of the texture.
  84716. * @returns the height of the render size
  84717. */
  84718. getRenderHeight(): number;
  84719. /**
  84720. * Get if the texture can be rescaled or not.
  84721. */
  84722. readonly canRescale: boolean;
  84723. /**
  84724. * Resize the texture using a ratio.
  84725. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84726. */
  84727. scale(ratio: number): void;
  84728. /**
  84729. * Get the texture reflection matrix used to rotate/transform the reflection.
  84730. * @returns the reflection matrix
  84731. */
  84732. getReflectionTextureMatrix(): Matrix;
  84733. /**
  84734. * Resize the texture to a new desired size.
  84735. * Be carrefull as it will recreate all the data in the new texture.
  84736. * @param size Define the new size. It can be:
  84737. * - a number for squared texture,
  84738. * - an object containing { width: number, height: number }
  84739. * - or an object containing a ratio { ratio: number }
  84740. */
  84741. resize(size: number | {
  84742. width: number;
  84743. height: number;
  84744. } | {
  84745. ratio: number;
  84746. }): void;
  84747. /**
  84748. * Renders all the objects from the render list into the texture.
  84749. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84750. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84751. */
  84752. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84753. private _bestReflectionRenderTargetDimension;
  84754. /**
  84755. * @hidden
  84756. * @param faceIndex face index to bind to if this is a cubetexture
  84757. */
  84758. _bindFrameBuffer(faceIndex?: number): void;
  84759. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84760. private renderToTarget;
  84761. /**
  84762. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84763. * This allowed control for front to back rendering or reversly depending of the special needs.
  84764. *
  84765. * @param renderingGroupId The rendering group id corresponding to its index
  84766. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84767. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84768. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84769. */
  84770. 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;
  84771. /**
  84772. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84773. *
  84774. * @param renderingGroupId The rendering group id corresponding to its index
  84775. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84776. */
  84777. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84778. /**
  84779. * Clones the texture.
  84780. * @returns the cloned texture
  84781. */
  84782. clone(): RenderTargetTexture;
  84783. /**
  84784. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84785. * @returns The JSON representation of the texture
  84786. */
  84787. serialize(): any;
  84788. /**
  84789. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84790. */
  84791. disposeFramebufferObjects(): void;
  84792. /**
  84793. * Dispose the texture and release its associated resources.
  84794. */
  84795. dispose(): void;
  84796. /** @hidden */
  84797. _rebuild(): void;
  84798. /**
  84799. * Clear the info related to rendering groups preventing retention point in material dispose.
  84800. */
  84801. freeRenderingGroups(): void;
  84802. /**
  84803. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84804. * @returns the view count
  84805. */
  84806. getViewCount(): number;
  84807. }
  84808. }
  84809. declare module BABYLON {
  84810. /**
  84811. * Base class for the main features of a material in Babylon.js
  84812. */
  84813. export class Material implements IAnimatable {
  84814. /**
  84815. * Returns the triangle fill mode
  84816. */
  84817. static readonly TriangleFillMode: number;
  84818. /**
  84819. * Returns the wireframe mode
  84820. */
  84821. static readonly WireFrameFillMode: number;
  84822. /**
  84823. * Returns the point fill mode
  84824. */
  84825. static readonly PointFillMode: number;
  84826. /**
  84827. * Returns the point list draw mode
  84828. */
  84829. static readonly PointListDrawMode: number;
  84830. /**
  84831. * Returns the line list draw mode
  84832. */
  84833. static readonly LineListDrawMode: number;
  84834. /**
  84835. * Returns the line loop draw mode
  84836. */
  84837. static readonly LineLoopDrawMode: number;
  84838. /**
  84839. * Returns the line strip draw mode
  84840. */
  84841. static readonly LineStripDrawMode: number;
  84842. /**
  84843. * Returns the triangle strip draw mode
  84844. */
  84845. static readonly TriangleStripDrawMode: number;
  84846. /**
  84847. * Returns the triangle fan draw mode
  84848. */
  84849. static readonly TriangleFanDrawMode: number;
  84850. /**
  84851. * Stores the clock-wise side orientation
  84852. */
  84853. static readonly ClockWiseSideOrientation: number;
  84854. /**
  84855. * Stores the counter clock-wise side orientation
  84856. */
  84857. static readonly CounterClockWiseSideOrientation: number;
  84858. /**
  84859. * The dirty texture flag value
  84860. */
  84861. static readonly TextureDirtyFlag: number;
  84862. /**
  84863. * The dirty light flag value
  84864. */
  84865. static readonly LightDirtyFlag: number;
  84866. /**
  84867. * The dirty fresnel flag value
  84868. */
  84869. static readonly FresnelDirtyFlag: number;
  84870. /**
  84871. * The dirty attribute flag value
  84872. */
  84873. static readonly AttributesDirtyFlag: number;
  84874. /**
  84875. * The dirty misc flag value
  84876. */
  84877. static readonly MiscDirtyFlag: number;
  84878. /**
  84879. * The all dirty flag value
  84880. */
  84881. static readonly AllDirtyFlag: number;
  84882. /**
  84883. * The ID of the material
  84884. */
  84885. id: string;
  84886. /**
  84887. * Gets or sets the unique id of the material
  84888. */
  84889. uniqueId: number;
  84890. /**
  84891. * The name of the material
  84892. */
  84893. name: string;
  84894. /**
  84895. * Gets or sets user defined metadata
  84896. */
  84897. metadata: any;
  84898. /**
  84899. * For internal use only. Please do not use.
  84900. */
  84901. reservedDataStore: any;
  84902. /**
  84903. * Specifies if the ready state should be checked on each call
  84904. */
  84905. checkReadyOnEveryCall: boolean;
  84906. /**
  84907. * Specifies if the ready state should be checked once
  84908. */
  84909. checkReadyOnlyOnce: boolean;
  84910. /**
  84911. * The state of the material
  84912. */
  84913. state: string;
  84914. /**
  84915. * The alpha value of the material
  84916. */
  84917. protected _alpha: number;
  84918. /**
  84919. * List of inspectable custom properties (used by the Inspector)
  84920. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84921. */
  84922. inspectableCustomProperties: IInspectable[];
  84923. /**
  84924. * Sets the alpha value of the material
  84925. */
  84926. /**
  84927. * Gets the alpha value of the material
  84928. */
  84929. alpha: number;
  84930. /**
  84931. * Specifies if back face culling is enabled
  84932. */
  84933. protected _backFaceCulling: boolean;
  84934. /**
  84935. * Sets the back-face culling state
  84936. */
  84937. /**
  84938. * Gets the back-face culling state
  84939. */
  84940. backFaceCulling: boolean;
  84941. /**
  84942. * Stores the value for side orientation
  84943. */
  84944. sideOrientation: number;
  84945. /**
  84946. * Callback triggered when the material is compiled
  84947. */
  84948. onCompiled: Nullable<(effect: Effect) => void>;
  84949. /**
  84950. * Callback triggered when an error occurs
  84951. */
  84952. onError: Nullable<(effect: Effect, errors: string) => void>;
  84953. /**
  84954. * Callback triggered to get the render target textures
  84955. */
  84956. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84957. /**
  84958. * Gets a boolean indicating that current material needs to register RTT
  84959. */
  84960. readonly hasRenderTargetTextures: boolean;
  84961. /**
  84962. * Specifies if the material should be serialized
  84963. */
  84964. doNotSerialize: boolean;
  84965. /**
  84966. * @hidden
  84967. */
  84968. _storeEffectOnSubMeshes: boolean;
  84969. /**
  84970. * Stores the animations for the material
  84971. */
  84972. animations: Nullable<Array<Animation>>;
  84973. /**
  84974. * An event triggered when the material is disposed
  84975. */
  84976. onDisposeObservable: Observable<Material>;
  84977. /**
  84978. * An observer which watches for dispose events
  84979. */
  84980. private _onDisposeObserver;
  84981. private _onUnBindObservable;
  84982. /**
  84983. * Called during a dispose event
  84984. */
  84985. onDispose: () => void;
  84986. private _onBindObservable;
  84987. /**
  84988. * An event triggered when the material is bound
  84989. */
  84990. readonly onBindObservable: Observable<AbstractMesh>;
  84991. /**
  84992. * An observer which watches for bind events
  84993. */
  84994. private _onBindObserver;
  84995. /**
  84996. * Called during a bind event
  84997. */
  84998. onBind: (Mesh: AbstractMesh) => void;
  84999. /**
  85000. * An event triggered when the material is unbound
  85001. */
  85002. readonly onUnBindObservable: Observable<Material>;
  85003. /**
  85004. * Stores the value of the alpha mode
  85005. */
  85006. private _alphaMode;
  85007. /**
  85008. * Sets the value of the alpha mode.
  85009. *
  85010. * | Value | Type | Description |
  85011. * | --- | --- | --- |
  85012. * | 0 | ALPHA_DISABLE | |
  85013. * | 1 | ALPHA_ADD | |
  85014. * | 2 | ALPHA_COMBINE | |
  85015. * | 3 | ALPHA_SUBTRACT | |
  85016. * | 4 | ALPHA_MULTIPLY | |
  85017. * | 5 | ALPHA_MAXIMIZED | |
  85018. * | 6 | ALPHA_ONEONE | |
  85019. * | 7 | ALPHA_PREMULTIPLIED | |
  85020. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  85021. * | 9 | ALPHA_INTERPOLATE | |
  85022. * | 10 | ALPHA_SCREENMODE | |
  85023. *
  85024. */
  85025. /**
  85026. * Gets the value of the alpha mode
  85027. */
  85028. alphaMode: number;
  85029. /**
  85030. * Stores the state of the need depth pre-pass value
  85031. */
  85032. private _needDepthPrePass;
  85033. /**
  85034. * Sets the need depth pre-pass value
  85035. */
  85036. /**
  85037. * Gets the depth pre-pass value
  85038. */
  85039. needDepthPrePass: boolean;
  85040. /**
  85041. * Specifies if depth writing should be disabled
  85042. */
  85043. disableDepthWrite: boolean;
  85044. /**
  85045. * Specifies if depth writing should be forced
  85046. */
  85047. forceDepthWrite: boolean;
  85048. /**
  85049. * Specifies if there should be a separate pass for culling
  85050. */
  85051. separateCullingPass: boolean;
  85052. /**
  85053. * Stores the state specifing if fog should be enabled
  85054. */
  85055. private _fogEnabled;
  85056. /**
  85057. * Sets the state for enabling fog
  85058. */
  85059. /**
  85060. * Gets the value of the fog enabled state
  85061. */
  85062. fogEnabled: boolean;
  85063. /**
  85064. * Stores the size of points
  85065. */
  85066. pointSize: number;
  85067. /**
  85068. * Stores the z offset value
  85069. */
  85070. zOffset: number;
  85071. /**
  85072. * Gets a value specifying if wireframe mode is enabled
  85073. */
  85074. /**
  85075. * Sets the state of wireframe mode
  85076. */
  85077. wireframe: boolean;
  85078. /**
  85079. * Gets the value specifying if point clouds are enabled
  85080. */
  85081. /**
  85082. * Sets the state of point cloud mode
  85083. */
  85084. pointsCloud: boolean;
  85085. /**
  85086. * Gets the material fill mode
  85087. */
  85088. /**
  85089. * Sets the material fill mode
  85090. */
  85091. fillMode: number;
  85092. /**
  85093. * @hidden
  85094. * Stores the effects for the material
  85095. */
  85096. _effect: Nullable<Effect>;
  85097. /**
  85098. * @hidden
  85099. * Specifies if the material was previously ready
  85100. */
  85101. _wasPreviouslyReady: boolean;
  85102. /**
  85103. * Specifies if uniform buffers should be used
  85104. */
  85105. private _useUBO;
  85106. /**
  85107. * Stores a reference to the scene
  85108. */
  85109. private _scene;
  85110. /**
  85111. * Stores the fill mode state
  85112. */
  85113. private _fillMode;
  85114. /**
  85115. * Specifies if the depth write state should be cached
  85116. */
  85117. private _cachedDepthWriteState;
  85118. /**
  85119. * Stores the uniform buffer
  85120. */
  85121. protected _uniformBuffer: UniformBuffer;
  85122. /** @hidden */
  85123. _indexInSceneMaterialArray: number;
  85124. /** @hidden */
  85125. meshMap: Nullable<{
  85126. [id: string]: AbstractMesh | undefined;
  85127. }>;
  85128. /**
  85129. * Creates a material instance
  85130. * @param name defines the name of the material
  85131. * @param scene defines the scene to reference
  85132. * @param doNotAdd specifies if the material should be added to the scene
  85133. */
  85134. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  85135. /**
  85136. * Returns a string representation of the current material
  85137. * @param fullDetails defines a boolean indicating which levels of logging is desired
  85138. * @returns a string with material information
  85139. */
  85140. toString(fullDetails?: boolean): string;
  85141. /**
  85142. * Gets the class name of the material
  85143. * @returns a string with the class name of the material
  85144. */
  85145. getClassName(): string;
  85146. /**
  85147. * Specifies if updates for the material been locked
  85148. */
  85149. readonly isFrozen: boolean;
  85150. /**
  85151. * Locks updates for the material
  85152. */
  85153. freeze(): void;
  85154. /**
  85155. * Unlocks updates for the material
  85156. */
  85157. unfreeze(): void;
  85158. /**
  85159. * Specifies if the material is ready to be used
  85160. * @param mesh defines the mesh to check
  85161. * @param useInstances specifies if instances should be used
  85162. * @returns a boolean indicating if the material is ready to be used
  85163. */
  85164. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85165. /**
  85166. * Specifies that the submesh is ready to be used
  85167. * @param mesh defines the mesh to check
  85168. * @param subMesh defines which submesh to check
  85169. * @param useInstances specifies that instances should be used
  85170. * @returns a boolean indicating that the submesh is ready or not
  85171. */
  85172. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85173. /**
  85174. * Returns the material effect
  85175. * @returns the effect associated with the material
  85176. */
  85177. getEffect(): Nullable<Effect>;
  85178. /**
  85179. * Returns the current scene
  85180. * @returns a Scene
  85181. */
  85182. getScene(): Scene;
  85183. /**
  85184. * Specifies if the material will require alpha blending
  85185. * @returns a boolean specifying if alpha blending is needed
  85186. */
  85187. needAlphaBlending(): boolean;
  85188. /**
  85189. * Specifies if the mesh will require alpha blending
  85190. * @param mesh defines the mesh to check
  85191. * @returns a boolean specifying if alpha blending is needed for the mesh
  85192. */
  85193. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85194. /**
  85195. * Specifies if this material should be rendered in alpha test mode
  85196. * @returns a boolean specifying if an alpha test is needed.
  85197. */
  85198. needAlphaTesting(): boolean;
  85199. /**
  85200. * Gets the texture used for the alpha test
  85201. * @returns the texture to use for alpha testing
  85202. */
  85203. getAlphaTestTexture(): Nullable<BaseTexture>;
  85204. /**
  85205. * Marks the material to indicate that it needs to be re-calculated
  85206. */
  85207. markDirty(): void;
  85208. /** @hidden */
  85209. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85210. /**
  85211. * Binds the material to the mesh
  85212. * @param world defines the world transformation matrix
  85213. * @param mesh defines the mesh to bind the material to
  85214. */
  85215. bind(world: Matrix, mesh?: Mesh): void;
  85216. /**
  85217. * Binds the submesh to the material
  85218. * @param world defines the world transformation matrix
  85219. * @param mesh defines the mesh containing the submesh
  85220. * @param subMesh defines the submesh to bind the material to
  85221. */
  85222. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85223. /**
  85224. * Binds the world matrix to the material
  85225. * @param world defines the world transformation matrix
  85226. */
  85227. bindOnlyWorldMatrix(world: Matrix): void;
  85228. /**
  85229. * Binds the scene's uniform buffer to the effect.
  85230. * @param effect defines the effect to bind to the scene uniform buffer
  85231. * @param sceneUbo defines the uniform buffer storing scene data
  85232. */
  85233. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85234. /**
  85235. * Binds the view matrix to the effect
  85236. * @param effect defines the effect to bind the view matrix to
  85237. */
  85238. bindView(effect: Effect): void;
  85239. /**
  85240. * Binds the view projection matrix to the effect
  85241. * @param effect defines the effect to bind the view projection matrix to
  85242. */
  85243. bindViewProjection(effect: Effect): void;
  85244. /**
  85245. * Specifies if material alpha testing should be turned on for the mesh
  85246. * @param mesh defines the mesh to check
  85247. */
  85248. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85249. /**
  85250. * Processes to execute after binding the material to a mesh
  85251. * @param mesh defines the rendered mesh
  85252. */
  85253. protected _afterBind(mesh?: Mesh): void;
  85254. /**
  85255. * Unbinds the material from the mesh
  85256. */
  85257. unbind(): void;
  85258. /**
  85259. * Gets the active textures from the material
  85260. * @returns an array of textures
  85261. */
  85262. getActiveTextures(): BaseTexture[];
  85263. /**
  85264. * Specifies if the material uses a texture
  85265. * @param texture defines the texture to check against the material
  85266. * @returns a boolean specifying if the material uses the texture
  85267. */
  85268. hasTexture(texture: BaseTexture): boolean;
  85269. /**
  85270. * Makes a duplicate of the material, and gives it a new name
  85271. * @param name defines the new name for the duplicated material
  85272. * @returns the cloned material
  85273. */
  85274. clone(name: string): Nullable<Material>;
  85275. /**
  85276. * Gets the meshes bound to the material
  85277. * @returns an array of meshes bound to the material
  85278. */
  85279. getBindedMeshes(): AbstractMesh[];
  85280. /**
  85281. * Force shader compilation
  85282. * @param mesh defines the mesh associated with this material
  85283. * @param onCompiled defines a function to execute once the material is compiled
  85284. * @param options defines the options to configure the compilation
  85285. */
  85286. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85287. clipPlane: boolean;
  85288. }>): void;
  85289. /**
  85290. * Force shader compilation
  85291. * @param mesh defines the mesh that will use this material
  85292. * @param options defines additional options for compiling the shaders
  85293. * @returns a promise that resolves when the compilation completes
  85294. */
  85295. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85296. clipPlane: boolean;
  85297. }>): Promise<void>;
  85298. private static readonly _AllDirtyCallBack;
  85299. private static readonly _ImageProcessingDirtyCallBack;
  85300. private static readonly _TextureDirtyCallBack;
  85301. private static readonly _FresnelDirtyCallBack;
  85302. private static readonly _MiscDirtyCallBack;
  85303. private static readonly _LightsDirtyCallBack;
  85304. private static readonly _AttributeDirtyCallBack;
  85305. private static _FresnelAndMiscDirtyCallBack;
  85306. private static _TextureAndMiscDirtyCallBack;
  85307. private static readonly _DirtyCallbackArray;
  85308. private static readonly _RunDirtyCallBacks;
  85309. /**
  85310. * Marks a define in the material to indicate that it needs to be re-computed
  85311. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85312. */
  85313. markAsDirty(flag: number): void;
  85314. /**
  85315. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85316. * @param func defines a function which checks material defines against the submeshes
  85317. */
  85318. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85319. /**
  85320. * Indicates that we need to re-calculated for all submeshes
  85321. */
  85322. protected _markAllSubMeshesAsAllDirty(): void;
  85323. /**
  85324. * Indicates that image processing needs to be re-calculated for all submeshes
  85325. */
  85326. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85327. /**
  85328. * Indicates that textures need to be re-calculated for all submeshes
  85329. */
  85330. protected _markAllSubMeshesAsTexturesDirty(): void;
  85331. /**
  85332. * Indicates that fresnel needs to be re-calculated for all submeshes
  85333. */
  85334. protected _markAllSubMeshesAsFresnelDirty(): void;
  85335. /**
  85336. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85337. */
  85338. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85339. /**
  85340. * Indicates that lights need to be re-calculated for all submeshes
  85341. */
  85342. protected _markAllSubMeshesAsLightsDirty(): void;
  85343. /**
  85344. * Indicates that attributes need to be re-calculated for all submeshes
  85345. */
  85346. protected _markAllSubMeshesAsAttributesDirty(): void;
  85347. /**
  85348. * Indicates that misc needs to be re-calculated for all submeshes
  85349. */
  85350. protected _markAllSubMeshesAsMiscDirty(): void;
  85351. /**
  85352. * Indicates that textures and misc need to be re-calculated for all submeshes
  85353. */
  85354. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85355. /**
  85356. * Disposes the material
  85357. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85358. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85359. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85360. */
  85361. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85362. /** @hidden */
  85363. private releaseVertexArrayObject;
  85364. /**
  85365. * Serializes this material
  85366. * @returns the serialized material object
  85367. */
  85368. serialize(): any;
  85369. /**
  85370. * Creates a material from parsed material data
  85371. * @param parsedMaterial defines parsed material data
  85372. * @param scene defines the hosting scene
  85373. * @param rootUrl defines the root URL to use to load textures
  85374. * @returns a new material
  85375. */
  85376. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85377. }
  85378. }
  85379. declare module BABYLON {
  85380. /**
  85381. * Base class for submeshes
  85382. */
  85383. export class BaseSubMesh {
  85384. /** @hidden */
  85385. _materialDefines: Nullable<MaterialDefines>;
  85386. /** @hidden */
  85387. _materialEffect: Nullable<Effect>;
  85388. /**
  85389. * Gets associated effect
  85390. */
  85391. readonly effect: Nullable<Effect>;
  85392. /**
  85393. * Sets associated effect (effect used to render this submesh)
  85394. * @param effect defines the effect to associate with
  85395. * @param defines defines the set of defines used to compile this effect
  85396. */
  85397. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85398. }
  85399. /**
  85400. * Defines a subdivision inside a mesh
  85401. */
  85402. export class SubMesh extends BaseSubMesh implements ICullable {
  85403. /** the material index to use */
  85404. materialIndex: number;
  85405. /** vertex index start */
  85406. verticesStart: number;
  85407. /** vertices count */
  85408. verticesCount: number;
  85409. /** index start */
  85410. indexStart: number;
  85411. /** indices count */
  85412. indexCount: number;
  85413. /** @hidden */
  85414. _linesIndexCount: number;
  85415. private _mesh;
  85416. private _renderingMesh;
  85417. private _boundingInfo;
  85418. private _linesIndexBuffer;
  85419. /** @hidden */
  85420. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85421. /** @hidden */
  85422. _trianglePlanes: Plane[];
  85423. /** @hidden */
  85424. _lastColliderTransformMatrix: Nullable<Matrix>;
  85425. /** @hidden */
  85426. _renderId: number;
  85427. /** @hidden */
  85428. _alphaIndex: number;
  85429. /** @hidden */
  85430. _distanceToCamera: number;
  85431. /** @hidden */
  85432. _id: number;
  85433. private _currentMaterial;
  85434. /**
  85435. * Add a new submesh to a mesh
  85436. * @param materialIndex defines the material index to use
  85437. * @param verticesStart defines vertex index start
  85438. * @param verticesCount defines vertices count
  85439. * @param indexStart defines index start
  85440. * @param indexCount defines indices count
  85441. * @param mesh defines the parent mesh
  85442. * @param renderingMesh defines an optional rendering mesh
  85443. * @param createBoundingBox defines if bounding box should be created for this submesh
  85444. * @returns the new submesh
  85445. */
  85446. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85447. /**
  85448. * Creates a new submesh
  85449. * @param materialIndex defines the material index to use
  85450. * @param verticesStart defines vertex index start
  85451. * @param verticesCount defines vertices count
  85452. * @param indexStart defines index start
  85453. * @param indexCount defines indices count
  85454. * @param mesh defines the parent mesh
  85455. * @param renderingMesh defines an optional rendering mesh
  85456. * @param createBoundingBox defines if bounding box should be created for this submesh
  85457. */
  85458. constructor(
  85459. /** the material index to use */
  85460. materialIndex: number,
  85461. /** vertex index start */
  85462. verticesStart: number,
  85463. /** vertices count */
  85464. verticesCount: number,
  85465. /** index start */
  85466. indexStart: number,
  85467. /** indices count */
  85468. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85469. /**
  85470. * Returns true if this submesh covers the entire parent mesh
  85471. * @ignorenaming
  85472. */
  85473. readonly IsGlobal: boolean;
  85474. /**
  85475. * Returns the submesh BoudingInfo object
  85476. * @returns current bounding info (or mesh's one if the submesh is global)
  85477. */
  85478. getBoundingInfo(): BoundingInfo;
  85479. /**
  85480. * Sets the submesh BoundingInfo
  85481. * @param boundingInfo defines the new bounding info to use
  85482. * @returns the SubMesh
  85483. */
  85484. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85485. /**
  85486. * Returns the mesh of the current submesh
  85487. * @return the parent mesh
  85488. */
  85489. getMesh(): AbstractMesh;
  85490. /**
  85491. * Returns the rendering mesh of the submesh
  85492. * @returns the rendering mesh (could be different from parent mesh)
  85493. */
  85494. getRenderingMesh(): Mesh;
  85495. /**
  85496. * Returns the submesh material
  85497. * @returns null or the current material
  85498. */
  85499. getMaterial(): Nullable<Material>;
  85500. /**
  85501. * Sets a new updated BoundingInfo object to the submesh
  85502. * @param data defines an optional position array to use to determine the bounding info
  85503. * @returns the SubMesh
  85504. */
  85505. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85506. /** @hidden */
  85507. _checkCollision(collider: Collider): boolean;
  85508. /**
  85509. * Updates the submesh BoundingInfo
  85510. * @param world defines the world matrix to use to update the bounding info
  85511. * @returns the submesh
  85512. */
  85513. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85514. /**
  85515. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85516. * @param frustumPlanes defines the frustum planes
  85517. * @returns true if the submesh is intersecting with the frustum
  85518. */
  85519. isInFrustum(frustumPlanes: Plane[]): boolean;
  85520. /**
  85521. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85522. * @param frustumPlanes defines the frustum planes
  85523. * @returns true if the submesh is inside the frustum
  85524. */
  85525. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85526. /**
  85527. * Renders the submesh
  85528. * @param enableAlphaMode defines if alpha needs to be used
  85529. * @returns the submesh
  85530. */
  85531. render(enableAlphaMode: boolean): SubMesh;
  85532. /**
  85533. * @hidden
  85534. */
  85535. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85536. /**
  85537. * Checks if the submesh intersects with a ray
  85538. * @param ray defines the ray to test
  85539. * @returns true is the passed ray intersects the submesh bounding box
  85540. */
  85541. canIntersects(ray: Ray): boolean;
  85542. /**
  85543. * Intersects current submesh with a ray
  85544. * @param ray defines the ray to test
  85545. * @param positions defines mesh's positions array
  85546. * @param indices defines mesh's indices array
  85547. * @param fastCheck defines if only bounding info should be used
  85548. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85549. * @returns intersection info or null if no intersection
  85550. */
  85551. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85552. /** @hidden */
  85553. private _intersectLines;
  85554. /** @hidden */
  85555. private _intersectUnIndexedLines;
  85556. /** @hidden */
  85557. private _intersectTriangles;
  85558. /** @hidden */
  85559. private _intersectUnIndexedTriangles;
  85560. /** @hidden */
  85561. _rebuild(): void;
  85562. /**
  85563. * Creates a new submesh from the passed mesh
  85564. * @param newMesh defines the new hosting mesh
  85565. * @param newRenderingMesh defines an optional rendering mesh
  85566. * @returns the new submesh
  85567. */
  85568. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85569. /**
  85570. * Release associated resources
  85571. */
  85572. dispose(): void;
  85573. /**
  85574. * Gets the class name
  85575. * @returns the string "SubMesh".
  85576. */
  85577. getClassName(): string;
  85578. /**
  85579. * Creates a new submesh from indices data
  85580. * @param materialIndex the index of the main mesh material
  85581. * @param startIndex the index where to start the copy in the mesh indices array
  85582. * @param indexCount the number of indices to copy then from the startIndex
  85583. * @param mesh the main mesh to create the submesh from
  85584. * @param renderingMesh the optional rendering mesh
  85585. * @returns a new submesh
  85586. */
  85587. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85588. }
  85589. }
  85590. declare module BABYLON {
  85591. /**
  85592. * Class used to store geometry data (vertex buffers + index buffer)
  85593. */
  85594. export class Geometry implements IGetSetVerticesData {
  85595. /**
  85596. * Gets or sets the ID of the geometry
  85597. */
  85598. id: string;
  85599. /**
  85600. * Gets or sets the unique ID of the geometry
  85601. */
  85602. uniqueId: number;
  85603. /**
  85604. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85605. */
  85606. delayLoadState: number;
  85607. /**
  85608. * Gets the file containing the data to load when running in delay load state
  85609. */
  85610. delayLoadingFile: Nullable<string>;
  85611. /**
  85612. * Callback called when the geometry is updated
  85613. */
  85614. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85615. private _scene;
  85616. private _engine;
  85617. private _meshes;
  85618. private _totalVertices;
  85619. /** @hidden */
  85620. _indices: IndicesArray;
  85621. /** @hidden */
  85622. _vertexBuffers: {
  85623. [key: string]: VertexBuffer;
  85624. };
  85625. private _isDisposed;
  85626. private _extend;
  85627. private _boundingBias;
  85628. /** @hidden */
  85629. _delayInfo: Array<string>;
  85630. private _indexBuffer;
  85631. private _indexBufferIsUpdatable;
  85632. /** @hidden */
  85633. _boundingInfo: Nullable<BoundingInfo>;
  85634. /** @hidden */
  85635. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85636. /** @hidden */
  85637. _softwareSkinningFrameId: number;
  85638. private _vertexArrayObjects;
  85639. private _updatable;
  85640. /** @hidden */
  85641. _positions: Nullable<Vector3[]>;
  85642. /**
  85643. * 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
  85644. */
  85645. /**
  85646. * 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
  85647. */
  85648. boundingBias: Vector2;
  85649. /**
  85650. * Static function used to attach a new empty geometry to a mesh
  85651. * @param mesh defines the mesh to attach the geometry to
  85652. * @returns the new Geometry
  85653. */
  85654. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85655. /**
  85656. * Creates a new geometry
  85657. * @param id defines the unique ID
  85658. * @param scene defines the hosting scene
  85659. * @param vertexData defines the VertexData used to get geometry data
  85660. * @param updatable defines if geometry must be updatable (false by default)
  85661. * @param mesh defines the mesh that will be associated with the geometry
  85662. */
  85663. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85664. /**
  85665. * Gets the current extend of the geometry
  85666. */
  85667. readonly extend: {
  85668. minimum: Vector3;
  85669. maximum: Vector3;
  85670. };
  85671. /**
  85672. * Gets the hosting scene
  85673. * @returns the hosting Scene
  85674. */
  85675. getScene(): Scene;
  85676. /**
  85677. * Gets the hosting engine
  85678. * @returns the hosting Engine
  85679. */
  85680. getEngine(): Engine;
  85681. /**
  85682. * Defines if the geometry is ready to use
  85683. * @returns true if the geometry is ready to be used
  85684. */
  85685. isReady(): boolean;
  85686. /**
  85687. * Gets a value indicating that the geometry should not be serialized
  85688. */
  85689. readonly doNotSerialize: boolean;
  85690. /** @hidden */
  85691. _rebuild(): void;
  85692. /**
  85693. * Affects all geometry data in one call
  85694. * @param vertexData defines the geometry data
  85695. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85696. */
  85697. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85698. /**
  85699. * Set specific vertex data
  85700. * @param kind defines the data kind (Position, normal, etc...)
  85701. * @param data defines the vertex data to use
  85702. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85703. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85704. */
  85705. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85706. /**
  85707. * Removes a specific vertex data
  85708. * @param kind defines the data kind (Position, normal, etc...)
  85709. */
  85710. removeVerticesData(kind: string): void;
  85711. /**
  85712. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85713. * @param buffer defines the vertex buffer to use
  85714. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85715. */
  85716. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85717. /**
  85718. * Update a specific vertex buffer
  85719. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85720. * It will do nothing if the buffer is not updatable
  85721. * @param kind defines the data kind (Position, normal, etc...)
  85722. * @param data defines the data to use
  85723. * @param offset defines the offset in the target buffer where to store the data
  85724. * @param useBytes set to true if the offset is in bytes
  85725. */
  85726. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85727. /**
  85728. * Update a specific vertex buffer
  85729. * This function will create a new buffer if the current one is not updatable
  85730. * @param kind defines the data kind (Position, normal, etc...)
  85731. * @param data defines the data to use
  85732. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85733. */
  85734. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85735. private _updateBoundingInfo;
  85736. /** @hidden */
  85737. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85738. /**
  85739. * Gets total number of vertices
  85740. * @returns the total number of vertices
  85741. */
  85742. getTotalVertices(): number;
  85743. /**
  85744. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85745. * @param kind defines the data kind (Position, normal, etc...)
  85746. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85747. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85748. * @returns a float array containing vertex data
  85749. */
  85750. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85751. /**
  85752. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85753. * @param kind defines the data kind (Position, normal, etc...)
  85754. * @returns true if the vertex buffer with the specified kind is updatable
  85755. */
  85756. isVertexBufferUpdatable(kind: string): boolean;
  85757. /**
  85758. * Gets a specific vertex buffer
  85759. * @param kind defines the data kind (Position, normal, etc...)
  85760. * @returns a VertexBuffer
  85761. */
  85762. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85763. /**
  85764. * Returns all vertex buffers
  85765. * @return an object holding all vertex buffers indexed by kind
  85766. */
  85767. getVertexBuffers(): Nullable<{
  85768. [key: string]: VertexBuffer;
  85769. }>;
  85770. /**
  85771. * Gets a boolean indicating if specific vertex buffer is present
  85772. * @param kind defines the data kind (Position, normal, etc...)
  85773. * @returns true if data is present
  85774. */
  85775. isVerticesDataPresent(kind: string): boolean;
  85776. /**
  85777. * Gets a list of all attached data kinds (Position, normal, etc...)
  85778. * @returns a list of string containing all kinds
  85779. */
  85780. getVerticesDataKinds(): string[];
  85781. /**
  85782. * Update index buffer
  85783. * @param indices defines the indices to store in the index buffer
  85784. * @param offset defines the offset in the target buffer where to store the data
  85785. * @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)
  85786. */
  85787. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85788. /**
  85789. * Creates a new index buffer
  85790. * @param indices defines the indices to store in the index buffer
  85791. * @param totalVertices defines the total number of vertices (could be null)
  85792. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85793. */
  85794. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85795. /**
  85796. * Return the total number of indices
  85797. * @returns the total number of indices
  85798. */
  85799. getTotalIndices(): number;
  85800. /**
  85801. * Gets the index buffer array
  85802. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85803. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85804. * @returns the index buffer array
  85805. */
  85806. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85807. /**
  85808. * Gets the index buffer
  85809. * @return the index buffer
  85810. */
  85811. getIndexBuffer(): Nullable<DataBuffer>;
  85812. /** @hidden */
  85813. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85814. /**
  85815. * Release the associated resources for a specific mesh
  85816. * @param mesh defines the source mesh
  85817. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85818. */
  85819. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85820. /**
  85821. * Apply current geometry to a given mesh
  85822. * @param mesh defines the mesh to apply geometry to
  85823. */
  85824. applyToMesh(mesh: Mesh): void;
  85825. private _updateExtend;
  85826. private _applyToMesh;
  85827. private notifyUpdate;
  85828. /**
  85829. * Load the geometry if it was flagged as delay loaded
  85830. * @param scene defines the hosting scene
  85831. * @param onLoaded defines a callback called when the geometry is loaded
  85832. */
  85833. load(scene: Scene, onLoaded?: () => void): void;
  85834. private _queueLoad;
  85835. /**
  85836. * Invert the geometry to move from a right handed system to a left handed one.
  85837. */
  85838. toLeftHanded(): void;
  85839. /** @hidden */
  85840. _resetPointsArrayCache(): void;
  85841. /** @hidden */
  85842. _generatePointsArray(): boolean;
  85843. /**
  85844. * Gets a value indicating if the geometry is disposed
  85845. * @returns true if the geometry was disposed
  85846. */
  85847. isDisposed(): boolean;
  85848. private _disposeVertexArrayObjects;
  85849. /**
  85850. * Free all associated resources
  85851. */
  85852. dispose(): void;
  85853. /**
  85854. * Clone the current geometry into a new geometry
  85855. * @param id defines the unique ID of the new geometry
  85856. * @returns a new geometry object
  85857. */
  85858. copy(id: string): Geometry;
  85859. /**
  85860. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85861. * @return a JSON representation of the current geometry data (without the vertices data)
  85862. */
  85863. serialize(): any;
  85864. private toNumberArray;
  85865. /**
  85866. * Serialize all vertices data into a JSON oject
  85867. * @returns a JSON representation of the current geometry data
  85868. */
  85869. serializeVerticeData(): any;
  85870. /**
  85871. * Extracts a clone of a mesh geometry
  85872. * @param mesh defines the source mesh
  85873. * @param id defines the unique ID of the new geometry object
  85874. * @returns the new geometry object
  85875. */
  85876. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85877. /**
  85878. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85879. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85880. * Be aware Math.random() could cause collisions, but:
  85881. * "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"
  85882. * @returns a string containing a new GUID
  85883. */
  85884. static RandomId(): string;
  85885. /** @hidden */
  85886. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85887. private static _CleanMatricesWeights;
  85888. /**
  85889. * Create a new geometry from persisted data (Using .babylon file format)
  85890. * @param parsedVertexData defines the persisted data
  85891. * @param scene defines the hosting scene
  85892. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85893. * @returns the new geometry object
  85894. */
  85895. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85896. }
  85897. }
  85898. declare module BABYLON {
  85899. /**
  85900. * Define an interface for all classes that will get and set the data on vertices
  85901. */
  85902. export interface IGetSetVerticesData {
  85903. /**
  85904. * Gets a boolean indicating if specific vertex data is present
  85905. * @param kind defines the vertex data kind to use
  85906. * @returns true is data kind is present
  85907. */
  85908. isVerticesDataPresent(kind: string): boolean;
  85909. /**
  85910. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85911. * @param kind defines the data kind (Position, normal, etc...)
  85912. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85913. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85914. * @returns a float array containing vertex data
  85915. */
  85916. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85917. /**
  85918. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85919. * @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.
  85920. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85921. * @returns the indices array or an empty array if the mesh has no geometry
  85922. */
  85923. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85924. /**
  85925. * Set specific vertex data
  85926. * @param kind defines the data kind (Position, normal, etc...)
  85927. * @param data defines the vertex data to use
  85928. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85929. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85930. */
  85931. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85932. /**
  85933. * Update a specific associated vertex buffer
  85934. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85935. * - VertexBuffer.PositionKind
  85936. * - VertexBuffer.UVKind
  85937. * - VertexBuffer.UV2Kind
  85938. * - VertexBuffer.UV3Kind
  85939. * - VertexBuffer.UV4Kind
  85940. * - VertexBuffer.UV5Kind
  85941. * - VertexBuffer.UV6Kind
  85942. * - VertexBuffer.ColorKind
  85943. * - VertexBuffer.MatricesIndicesKind
  85944. * - VertexBuffer.MatricesIndicesExtraKind
  85945. * - VertexBuffer.MatricesWeightsKind
  85946. * - VertexBuffer.MatricesWeightsExtraKind
  85947. * @param data defines the data source
  85948. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85949. * @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)
  85950. */
  85951. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85952. /**
  85953. * Creates a new index buffer
  85954. * @param indices defines the indices to store in the index buffer
  85955. * @param totalVertices defines the total number of vertices (could be null)
  85956. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85957. */
  85958. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85959. }
  85960. /**
  85961. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85962. */
  85963. export class VertexData {
  85964. /**
  85965. * Mesh side orientation : usually the external or front surface
  85966. */
  85967. static readonly FRONTSIDE: number;
  85968. /**
  85969. * Mesh side orientation : usually the internal or back surface
  85970. */
  85971. static readonly BACKSIDE: number;
  85972. /**
  85973. * Mesh side orientation : both internal and external or front and back surfaces
  85974. */
  85975. static readonly DOUBLESIDE: number;
  85976. /**
  85977. * Mesh side orientation : by default, `FRONTSIDE`
  85978. */
  85979. static readonly DEFAULTSIDE: number;
  85980. /**
  85981. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85982. */
  85983. positions: Nullable<FloatArray>;
  85984. /**
  85985. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85986. */
  85987. normals: Nullable<FloatArray>;
  85988. /**
  85989. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85990. */
  85991. tangents: Nullable<FloatArray>;
  85992. /**
  85993. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85994. */
  85995. uvs: Nullable<FloatArray>;
  85996. /**
  85997. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85998. */
  85999. uvs2: Nullable<FloatArray>;
  86000. /**
  86001. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86002. */
  86003. uvs3: Nullable<FloatArray>;
  86004. /**
  86005. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86006. */
  86007. uvs4: Nullable<FloatArray>;
  86008. /**
  86009. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86010. */
  86011. uvs5: Nullable<FloatArray>;
  86012. /**
  86013. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86014. */
  86015. uvs6: Nullable<FloatArray>;
  86016. /**
  86017. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  86018. */
  86019. colors: Nullable<FloatArray>;
  86020. /**
  86021. * 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).
  86022. */
  86023. matricesIndices: Nullable<FloatArray>;
  86024. /**
  86025. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  86026. */
  86027. matricesWeights: Nullable<FloatArray>;
  86028. /**
  86029. * An array extending the number of possible indices
  86030. */
  86031. matricesIndicesExtra: Nullable<FloatArray>;
  86032. /**
  86033. * An array extending the number of possible weights when the number of indices is extended
  86034. */
  86035. matricesWeightsExtra: Nullable<FloatArray>;
  86036. /**
  86037. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  86038. */
  86039. indices: Nullable<IndicesArray>;
  86040. /**
  86041. * Uses the passed data array to set the set the values for the specified kind of data
  86042. * @param data a linear array of floating numbers
  86043. * @param kind the type of data that is being set, eg positions, colors etc
  86044. */
  86045. set(data: FloatArray, kind: string): void;
  86046. /**
  86047. * Associates the vertexData to the passed Mesh.
  86048. * Sets it as updatable or not (default `false`)
  86049. * @param mesh the mesh the vertexData is applied to
  86050. * @param updatable when used and having the value true allows new data to update the vertexData
  86051. * @returns the VertexData
  86052. */
  86053. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  86054. /**
  86055. * Associates the vertexData to the passed Geometry.
  86056. * Sets it as updatable or not (default `false`)
  86057. * @param geometry the geometry the vertexData is applied to
  86058. * @param updatable when used and having the value true allows new data to update the vertexData
  86059. * @returns VertexData
  86060. */
  86061. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  86062. /**
  86063. * Updates the associated mesh
  86064. * @param mesh the mesh to be updated
  86065. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86066. * @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
  86067. * @returns VertexData
  86068. */
  86069. updateMesh(mesh: Mesh): VertexData;
  86070. /**
  86071. * Updates the associated geometry
  86072. * @param geometry the geometry to be updated
  86073. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86074. * @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
  86075. * @returns VertexData.
  86076. */
  86077. updateGeometry(geometry: Geometry): VertexData;
  86078. private _applyTo;
  86079. private _update;
  86080. /**
  86081. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86082. * @param matrix the transforming matrix
  86083. * @returns the VertexData
  86084. */
  86085. transform(matrix: Matrix): VertexData;
  86086. /**
  86087. * Merges the passed VertexData into the current one
  86088. * @param other the VertexData to be merged into the current one
  86089. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  86090. * @returns the modified VertexData
  86091. */
  86092. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  86093. private _mergeElement;
  86094. private _validate;
  86095. /**
  86096. * Serializes the VertexData
  86097. * @returns a serialized object
  86098. */
  86099. serialize(): any;
  86100. /**
  86101. * Extracts the vertexData from a mesh
  86102. * @param mesh the mesh from which to extract the VertexData
  86103. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  86104. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86105. * @returns the object VertexData associated to the passed mesh
  86106. */
  86107. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86108. /**
  86109. * Extracts the vertexData from the geometry
  86110. * @param geometry the geometry from which to extract the VertexData
  86111. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  86112. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86113. * @returns the object VertexData associated to the passed mesh
  86114. */
  86115. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86116. private static _ExtractFrom;
  86117. /**
  86118. * Creates the VertexData for a Ribbon
  86119. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  86120. * * pathArray array of paths, each of which an array of successive Vector3
  86121. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  86122. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  86123. * * 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
  86124. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86125. * * 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)
  86126. * * 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)
  86127. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  86128. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  86129. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  86130. * @returns the VertexData of the ribbon
  86131. */
  86132. static CreateRibbon(options: {
  86133. pathArray: Vector3[][];
  86134. closeArray?: boolean;
  86135. closePath?: boolean;
  86136. offset?: number;
  86137. sideOrientation?: number;
  86138. frontUVs?: Vector4;
  86139. backUVs?: Vector4;
  86140. invertUV?: boolean;
  86141. uvs?: Vector2[];
  86142. colors?: Color4[];
  86143. }): VertexData;
  86144. /**
  86145. * Creates the VertexData for a box
  86146. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86147. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86148. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86149. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86150. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86151. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86152. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86153. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86154. * * 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)
  86155. * * 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)
  86156. * @returns the VertexData of the box
  86157. */
  86158. static CreateBox(options: {
  86159. size?: number;
  86160. width?: number;
  86161. height?: number;
  86162. depth?: number;
  86163. faceUV?: Vector4[];
  86164. faceColors?: Color4[];
  86165. sideOrientation?: number;
  86166. frontUVs?: Vector4;
  86167. backUVs?: Vector4;
  86168. }): VertexData;
  86169. /**
  86170. * Creates the VertexData for a tiled box
  86171. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86172. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86173. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86174. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86176. * @returns the VertexData of the box
  86177. */
  86178. static CreateTiledBox(options: {
  86179. pattern?: number;
  86180. width?: number;
  86181. height?: number;
  86182. depth?: number;
  86183. tileSize?: number;
  86184. tileWidth?: number;
  86185. tileHeight?: number;
  86186. alignHorizontal?: number;
  86187. alignVertical?: number;
  86188. faceUV?: Vector4[];
  86189. faceColors?: Color4[];
  86190. sideOrientation?: number;
  86191. }): VertexData;
  86192. /**
  86193. * Creates the VertexData for a tiled plane
  86194. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86195. * * pattern a limited pattern arrangement depending on the number
  86196. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86197. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86198. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86199. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86200. * * 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)
  86201. * * 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)
  86202. * @returns the VertexData of the tiled plane
  86203. */
  86204. static CreateTiledPlane(options: {
  86205. pattern?: number;
  86206. tileSize?: number;
  86207. tileWidth?: number;
  86208. tileHeight?: number;
  86209. size?: number;
  86210. width?: number;
  86211. height?: number;
  86212. alignHorizontal?: number;
  86213. alignVertical?: number;
  86214. sideOrientation?: number;
  86215. frontUVs?: Vector4;
  86216. backUVs?: Vector4;
  86217. }): VertexData;
  86218. /**
  86219. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86220. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86221. * * segments sets the number of horizontal strips optional, default 32
  86222. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86223. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86224. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86225. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86226. * * 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
  86227. * * 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
  86228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86229. * * 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)
  86230. * * 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)
  86231. * @returns the VertexData of the ellipsoid
  86232. */
  86233. static CreateSphere(options: {
  86234. segments?: number;
  86235. diameter?: number;
  86236. diameterX?: number;
  86237. diameterY?: number;
  86238. diameterZ?: number;
  86239. arc?: number;
  86240. slice?: number;
  86241. sideOrientation?: number;
  86242. frontUVs?: Vector4;
  86243. backUVs?: Vector4;
  86244. }): VertexData;
  86245. /**
  86246. * Creates the VertexData for a cylinder, cone or prism
  86247. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86248. * * height sets the height (y direction) of the cylinder, optional, default 2
  86249. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86250. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86251. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86252. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86253. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86254. * * 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
  86255. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86256. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86257. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86258. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86260. * * 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)
  86261. * * 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)
  86262. * @returns the VertexData of the cylinder, cone or prism
  86263. */
  86264. static CreateCylinder(options: {
  86265. height?: number;
  86266. diameterTop?: number;
  86267. diameterBottom?: number;
  86268. diameter?: number;
  86269. tessellation?: number;
  86270. subdivisions?: number;
  86271. arc?: number;
  86272. faceColors?: Color4[];
  86273. faceUV?: Vector4[];
  86274. hasRings?: boolean;
  86275. enclose?: boolean;
  86276. sideOrientation?: number;
  86277. frontUVs?: Vector4;
  86278. backUVs?: Vector4;
  86279. }): VertexData;
  86280. /**
  86281. * Creates the VertexData for a torus
  86282. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86283. * * diameter the diameter of the torus, optional default 1
  86284. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86285. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86286. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86287. * * 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)
  86288. * * 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)
  86289. * @returns the VertexData of the torus
  86290. */
  86291. static CreateTorus(options: {
  86292. diameter?: number;
  86293. thickness?: number;
  86294. tessellation?: number;
  86295. sideOrientation?: number;
  86296. frontUVs?: Vector4;
  86297. backUVs?: Vector4;
  86298. }): VertexData;
  86299. /**
  86300. * Creates the VertexData of the LineSystem
  86301. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86302. * - lines an array of lines, each line being an array of successive Vector3
  86303. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86304. * @returns the VertexData of the LineSystem
  86305. */
  86306. static CreateLineSystem(options: {
  86307. lines: Vector3[][];
  86308. colors?: Nullable<Color4[][]>;
  86309. }): VertexData;
  86310. /**
  86311. * Create the VertexData for a DashedLines
  86312. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86313. * - points an array successive Vector3
  86314. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86315. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86316. * - dashNb the intended total number of dashes, optional, default 200
  86317. * @returns the VertexData for the DashedLines
  86318. */
  86319. static CreateDashedLines(options: {
  86320. points: Vector3[];
  86321. dashSize?: number;
  86322. gapSize?: number;
  86323. dashNb?: number;
  86324. }): VertexData;
  86325. /**
  86326. * Creates the VertexData for a Ground
  86327. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86328. * - width the width (x direction) of the ground, optional, default 1
  86329. * - height the height (z direction) of the ground, optional, default 1
  86330. * - subdivisions the number of subdivisions per side, optional, default 1
  86331. * @returns the VertexData of the Ground
  86332. */
  86333. static CreateGround(options: {
  86334. width?: number;
  86335. height?: number;
  86336. subdivisions?: number;
  86337. subdivisionsX?: number;
  86338. subdivisionsY?: number;
  86339. }): VertexData;
  86340. /**
  86341. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86342. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86343. * * xmin the ground minimum X coordinate, optional, default -1
  86344. * * zmin the ground minimum Z coordinate, optional, default -1
  86345. * * xmax the ground maximum X coordinate, optional, default 1
  86346. * * zmax the ground maximum Z coordinate, optional, default 1
  86347. * * 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}
  86348. * * 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}
  86349. * @returns the VertexData of the TiledGround
  86350. */
  86351. static CreateTiledGround(options: {
  86352. xmin: number;
  86353. zmin: number;
  86354. xmax: number;
  86355. zmax: number;
  86356. subdivisions?: {
  86357. w: number;
  86358. h: number;
  86359. };
  86360. precision?: {
  86361. w: number;
  86362. h: number;
  86363. };
  86364. }): VertexData;
  86365. /**
  86366. * Creates the VertexData of the Ground designed from a heightmap
  86367. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86368. * * width the width (x direction) of the ground
  86369. * * height the height (z direction) of the ground
  86370. * * subdivisions the number of subdivisions per side
  86371. * * minHeight the minimum altitude on the ground, optional, default 0
  86372. * * maxHeight the maximum altitude on the ground, optional default 1
  86373. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86374. * * buffer the array holding the image color data
  86375. * * bufferWidth the width of image
  86376. * * bufferHeight the height of image
  86377. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86378. * @returns the VertexData of the Ground designed from a heightmap
  86379. */
  86380. static CreateGroundFromHeightMap(options: {
  86381. width: number;
  86382. height: number;
  86383. subdivisions: number;
  86384. minHeight: number;
  86385. maxHeight: number;
  86386. colorFilter: Color3;
  86387. buffer: Uint8Array;
  86388. bufferWidth: number;
  86389. bufferHeight: number;
  86390. alphaFilter: number;
  86391. }): VertexData;
  86392. /**
  86393. * Creates the VertexData for a Plane
  86394. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86395. * * size sets the width and height of the plane to the value of size, optional default 1
  86396. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86397. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86399. * * 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)
  86400. * * 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)
  86401. * @returns the VertexData of the box
  86402. */
  86403. static CreatePlane(options: {
  86404. size?: number;
  86405. width?: number;
  86406. height?: number;
  86407. sideOrientation?: number;
  86408. frontUVs?: Vector4;
  86409. backUVs?: Vector4;
  86410. }): VertexData;
  86411. /**
  86412. * Creates the VertexData of the Disc or regular Polygon
  86413. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86414. * * radius the radius of the disc, optional default 0.5
  86415. * * tessellation the number of polygon sides, optional, default 64
  86416. * * 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
  86417. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86418. * * 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)
  86419. * * 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)
  86420. * @returns the VertexData of the box
  86421. */
  86422. static CreateDisc(options: {
  86423. radius?: number;
  86424. tessellation?: number;
  86425. arc?: number;
  86426. sideOrientation?: number;
  86427. frontUVs?: Vector4;
  86428. backUVs?: Vector4;
  86429. }): VertexData;
  86430. /**
  86431. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86432. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86433. * @param polygon a mesh built from polygonTriangulation.build()
  86434. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86435. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86436. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86437. * @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)
  86438. * @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)
  86439. * @returns the VertexData of the Polygon
  86440. */
  86441. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86442. /**
  86443. * Creates the VertexData of the IcoSphere
  86444. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86445. * * radius the radius of the IcoSphere, optional default 1
  86446. * * radiusX allows stretching in the x direction, optional, default radius
  86447. * * radiusY allows stretching in the y direction, optional, default radius
  86448. * * radiusZ allows stretching in the z direction, optional, default radius
  86449. * * flat when true creates a flat shaded mesh, optional, default true
  86450. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86451. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86452. * * 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)
  86453. * * 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)
  86454. * @returns the VertexData of the IcoSphere
  86455. */
  86456. static CreateIcoSphere(options: {
  86457. radius?: number;
  86458. radiusX?: number;
  86459. radiusY?: number;
  86460. radiusZ?: number;
  86461. flat?: boolean;
  86462. subdivisions?: number;
  86463. sideOrientation?: number;
  86464. frontUVs?: Vector4;
  86465. backUVs?: Vector4;
  86466. }): VertexData;
  86467. /**
  86468. * Creates the VertexData for a Polyhedron
  86469. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86470. * * type provided types are:
  86471. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86472. * * 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)
  86473. * * size the size of the IcoSphere, optional default 1
  86474. * * sizeX allows stretching in the x direction, optional, default size
  86475. * * sizeY allows stretching in the y direction, optional, default size
  86476. * * sizeZ allows stretching in the z direction, optional, default size
  86477. * * 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
  86478. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86479. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86480. * * flat when true creates a flat shaded mesh, optional, default true
  86481. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86483. * * 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)
  86484. * * 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)
  86485. * @returns the VertexData of the Polyhedron
  86486. */
  86487. static CreatePolyhedron(options: {
  86488. type?: number;
  86489. size?: number;
  86490. sizeX?: number;
  86491. sizeY?: number;
  86492. sizeZ?: number;
  86493. custom?: any;
  86494. faceUV?: Vector4[];
  86495. faceColors?: Color4[];
  86496. flat?: boolean;
  86497. sideOrientation?: number;
  86498. frontUVs?: Vector4;
  86499. backUVs?: Vector4;
  86500. }): VertexData;
  86501. /**
  86502. * Creates the VertexData for a TorusKnot
  86503. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86504. * * radius the radius of the torus knot, optional, default 2
  86505. * * tube the thickness of the tube, optional, default 0.5
  86506. * * radialSegments the number of sides on each tube segments, optional, default 32
  86507. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86508. * * p the number of windings around the z axis, optional, default 2
  86509. * * q the number of windings around the x axis, optional, default 3
  86510. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86511. * * 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)
  86512. * * 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)
  86513. * @returns the VertexData of the Torus Knot
  86514. */
  86515. static CreateTorusKnot(options: {
  86516. radius?: number;
  86517. tube?: number;
  86518. radialSegments?: number;
  86519. tubularSegments?: number;
  86520. p?: number;
  86521. q?: number;
  86522. sideOrientation?: number;
  86523. frontUVs?: Vector4;
  86524. backUVs?: Vector4;
  86525. }): VertexData;
  86526. /**
  86527. * Compute normals for given positions and indices
  86528. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86529. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86530. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86531. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86532. * * facetNormals : optional array of facet normals (vector3)
  86533. * * facetPositions : optional array of facet positions (vector3)
  86534. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86535. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86536. * * bInfo : optional bounding info, required for facetPartitioning computation
  86537. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86538. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86539. * * useRightHandedSystem: optional boolean to for right handed system computation
  86540. * * depthSort : optional boolean to enable the facet depth sort computation
  86541. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86542. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86543. */
  86544. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86545. facetNormals?: any;
  86546. facetPositions?: any;
  86547. facetPartitioning?: any;
  86548. ratio?: number;
  86549. bInfo?: any;
  86550. bbSize?: Vector3;
  86551. subDiv?: any;
  86552. useRightHandedSystem?: boolean;
  86553. depthSort?: boolean;
  86554. distanceTo?: Vector3;
  86555. depthSortedFacets?: any;
  86556. }): void;
  86557. /** @hidden */
  86558. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86559. /**
  86560. * Applies VertexData created from the imported parameters to the geometry
  86561. * @param parsedVertexData the parsed data from an imported file
  86562. * @param geometry the geometry to apply the VertexData to
  86563. */
  86564. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86565. }
  86566. }
  86567. declare module BABYLON {
  86568. /**
  86569. * Class containing static functions to help procedurally build meshes
  86570. */
  86571. export class DiscBuilder {
  86572. /**
  86573. * Creates a plane polygonal mesh. By default, this is a disc
  86574. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86575. * * 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
  86576. * * 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
  86577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  86579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86580. * @param name defines the name of the mesh
  86581. * @param options defines the options used to create the mesh
  86582. * @param scene defines the hosting scene
  86583. * @returns the plane polygonal mesh
  86584. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86585. */
  86586. static CreateDisc(name: string, options: {
  86587. radius?: number;
  86588. tessellation?: number;
  86589. arc?: number;
  86590. updatable?: boolean;
  86591. sideOrientation?: number;
  86592. frontUVs?: Vector4;
  86593. backUVs?: Vector4;
  86594. }, scene?: Nullable<Scene>): Mesh;
  86595. }
  86596. }
  86597. declare module BABYLON {
  86598. /**
  86599. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86600. *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.
  86601. * The SPS is also a particle system. It provides some methods to manage the particles.
  86602. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86603. *
  86604. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86605. */
  86606. export class SolidParticleSystem implements IDisposable {
  86607. /**
  86608. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86609. * Example : var p = SPS.particles[i];
  86610. */
  86611. particles: SolidParticle[];
  86612. /**
  86613. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86614. */
  86615. nbParticles: number;
  86616. /**
  86617. * If the particles must ever face the camera (default false). Useful for planar particles.
  86618. */
  86619. billboard: boolean;
  86620. /**
  86621. * Recompute normals when adding a shape
  86622. */
  86623. recomputeNormals: boolean;
  86624. /**
  86625. * This a counter ofr your own usage. It's not set by any SPS functions.
  86626. */
  86627. counter: number;
  86628. /**
  86629. * The SPS name. This name is also given to the underlying mesh.
  86630. */
  86631. name: string;
  86632. /**
  86633. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86634. */
  86635. mesh: Mesh;
  86636. /**
  86637. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86638. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86639. */
  86640. vars: any;
  86641. /**
  86642. * This array is populated when the SPS is set as 'pickable'.
  86643. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86644. * Each element of this array is an object `{idx: int, faceId: int}`.
  86645. * `idx` is the picked particle index in the `SPS.particles` array
  86646. * `faceId` is the picked face index counted within this particle.
  86647. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86648. */
  86649. pickedParticles: {
  86650. idx: number;
  86651. faceId: number;
  86652. }[];
  86653. /**
  86654. * This array is populated when `enableDepthSort` is set to true.
  86655. * Each element of this array is an instance of the class DepthSortedParticle.
  86656. */
  86657. depthSortedParticles: DepthSortedParticle[];
  86658. /**
  86659. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86660. * @hidden
  86661. */
  86662. _bSphereOnly: boolean;
  86663. /**
  86664. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86665. * @hidden
  86666. */
  86667. _bSphereRadiusFactor: number;
  86668. private _scene;
  86669. private _positions;
  86670. private _indices;
  86671. private _normals;
  86672. private _colors;
  86673. private _uvs;
  86674. private _indices32;
  86675. private _positions32;
  86676. private _normals32;
  86677. private _fixedNormal32;
  86678. private _colors32;
  86679. private _uvs32;
  86680. private _index;
  86681. private _updatable;
  86682. private _pickable;
  86683. private _isVisibilityBoxLocked;
  86684. private _alwaysVisible;
  86685. private _depthSort;
  86686. private _shapeCounter;
  86687. private _copy;
  86688. private _color;
  86689. private _computeParticleColor;
  86690. private _computeParticleTexture;
  86691. private _computeParticleRotation;
  86692. private _computeParticleVertex;
  86693. private _computeBoundingBox;
  86694. private _depthSortParticles;
  86695. private _camera;
  86696. private _mustUnrotateFixedNormals;
  86697. private _particlesIntersect;
  86698. private _needs32Bits;
  86699. /**
  86700. * Creates a SPS (Solid Particle System) object.
  86701. * @param name (String) is the SPS name, this will be the underlying mesh name.
  86702. * @param scene (Scene) is the scene in which the SPS is added.
  86703. * @param options defines the options of the sps e.g.
  86704. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  86705. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  86706. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  86707. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  86708. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  86709. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  86710. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  86711. */
  86712. constructor(name: string, scene: Scene, options?: {
  86713. updatable?: boolean;
  86714. isPickable?: boolean;
  86715. enableDepthSort?: boolean;
  86716. particleIntersection?: boolean;
  86717. boundingSphereOnly?: boolean;
  86718. bSphereRadiusFactor?: number;
  86719. });
  86720. /**
  86721. * Builds the SPS underlying mesh. Returns a standard Mesh.
  86722. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  86723. * @returns the created mesh
  86724. */
  86725. buildMesh(): Mesh;
  86726. /**
  86727. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  86728. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  86729. * Thus the particles generated from `digest()` have their property `position` set yet.
  86730. * @param mesh ( Mesh ) is the mesh to be digested
  86731. * @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
  86732. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  86733. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  86734. * @returns the current SPS
  86735. */
  86736. digest(mesh: Mesh, options?: {
  86737. facetNb?: number;
  86738. number?: number;
  86739. delta?: number;
  86740. }): SolidParticleSystem;
  86741. private _unrotateFixedNormals;
  86742. private _resetCopy;
  86743. private _meshBuilder;
  86744. private _posToShape;
  86745. private _uvsToShapeUV;
  86746. private _addParticle;
  86747. /**
  86748. * Adds some particles to the SPS from the model shape. Returns the shape id.
  86749. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  86750. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  86751. * @param nb (positive integer) the number of particles to be created from this model
  86752. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  86753. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  86754. * @returns the number of shapes in the system
  86755. */
  86756. addShape(mesh: Mesh, nb: number, options?: {
  86757. positionFunction?: any;
  86758. vertexFunction?: any;
  86759. }): number;
  86760. private _rebuildParticle;
  86761. /**
  86762. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  86763. * @returns the SPS.
  86764. */
  86765. rebuildMesh(): SolidParticleSystem;
  86766. /**
  86767. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  86768. * This method calls `updateParticle()` for each particle of the SPS.
  86769. * For an animated SPS, it is usually called within the render loop.
  86770. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  86771. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  86772. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  86773. * @returns the SPS.
  86774. */
  86775. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  86776. /**
  86777. * Disposes the SPS.
  86778. */
  86779. dispose(): void;
  86780. /**
  86781. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  86782. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86783. * @returns the SPS.
  86784. */
  86785. refreshVisibleSize(): SolidParticleSystem;
  86786. /**
  86787. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  86788. * @param size the size (float) of the visibility box
  86789. * note : this doesn't lock the SPS mesh bounding box.
  86790. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86791. */
  86792. setVisibilityBox(size: number): void;
  86793. /**
  86794. * Gets whether the SPS as always visible or not
  86795. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86796. */
  86797. /**
  86798. * Sets the SPS as always visible or not
  86799. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86800. */
  86801. isAlwaysVisible: boolean;
  86802. /**
  86803. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86804. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86805. */
  86806. /**
  86807. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86808. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86809. */
  86810. isVisibilityBoxLocked: boolean;
  86811. /**
  86812. * Tells to `setParticles()` to compute the particle rotations or not.
  86813. * Default value : true. The SPS is faster when it's set to false.
  86814. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86815. */
  86816. /**
  86817. * Gets if `setParticles()` computes the particle rotations or not.
  86818. * Default value : true. The SPS is faster when it's set to false.
  86819. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86820. */
  86821. computeParticleRotation: boolean;
  86822. /**
  86823. * Tells to `setParticles()` to compute the particle colors or not.
  86824. * Default value : true. The SPS is faster when it's set to false.
  86825. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86826. */
  86827. /**
  86828. * Gets if `setParticles()` computes the particle colors or not.
  86829. * Default value : true. The SPS is faster when it's set to false.
  86830. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86831. */
  86832. computeParticleColor: boolean;
  86833. /**
  86834. * Gets if `setParticles()` computes the particle textures or not.
  86835. * Default value : true. The SPS is faster when it's set to false.
  86836. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  86837. */
  86838. computeParticleTexture: boolean;
  86839. /**
  86840. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  86841. * Default value : false. The SPS is faster when it's set to false.
  86842. * Note : the particle custom vertex positions aren't stored values.
  86843. */
  86844. /**
  86845. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  86846. * Default value : false. The SPS is faster when it's set to false.
  86847. * Note : the particle custom vertex positions aren't stored values.
  86848. */
  86849. computeParticleVertex: boolean;
  86850. /**
  86851. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  86852. */
  86853. /**
  86854. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  86855. */
  86856. computeBoundingBox: boolean;
  86857. /**
  86858. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  86859. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86860. * Default : `true`
  86861. */
  86862. /**
  86863. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  86864. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86865. * Default : `true`
  86866. */
  86867. depthSortParticles: boolean;
  86868. /**
  86869. * This function does nothing. It may be overwritten to set all the particle first values.
  86870. * The SPS doesn't call this function, you may have to call it by your own.
  86871. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86872. */
  86873. initParticles(): void;
  86874. /**
  86875. * This function does nothing. It may be overwritten to recycle a particle.
  86876. * The SPS doesn't call this function, you may have to call it by your own.
  86877. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86878. * @param particle The particle to recycle
  86879. * @returns the recycled particle
  86880. */
  86881. recycleParticle(particle: SolidParticle): SolidParticle;
  86882. /**
  86883. * Updates a particle : this function should be overwritten by the user.
  86884. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  86885. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86886. * @example : just set a particle position or velocity and recycle conditions
  86887. * @param particle The particle to update
  86888. * @returns the updated particle
  86889. */
  86890. updateParticle(particle: SolidParticle): SolidParticle;
  86891. /**
  86892. * Updates a vertex of a particle : it can be overwritten by the user.
  86893. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  86894. * @param particle the current particle
  86895. * @param vertex the current index of the current particle
  86896. * @param pt the index of the current vertex in the particle shape
  86897. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  86898. * @example : just set a vertex particle position
  86899. * @returns the updated vertex
  86900. */
  86901. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  86902. /**
  86903. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  86904. * This does nothing and may be overwritten by the user.
  86905. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86906. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86907. * @param update the boolean update value actually passed to setParticles()
  86908. */
  86909. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86910. /**
  86911. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  86912. * This will be passed three parameters.
  86913. * This does nothing and may be overwritten by the user.
  86914. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86915. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86916. * @param update the boolean update value actually passed to setParticles()
  86917. */
  86918. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86919. }
  86920. }
  86921. declare module BABYLON {
  86922. /**
  86923. * Represents one particle of a solid particle system.
  86924. */
  86925. export class SolidParticle {
  86926. /**
  86927. * particle global index
  86928. */
  86929. idx: number;
  86930. /**
  86931. * The color of the particle
  86932. */
  86933. color: Nullable<Color4>;
  86934. /**
  86935. * The world space position of the particle.
  86936. */
  86937. position: Vector3;
  86938. /**
  86939. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  86940. */
  86941. rotation: Vector3;
  86942. /**
  86943. * The world space rotation quaternion of the particle.
  86944. */
  86945. rotationQuaternion: Nullable<Quaternion>;
  86946. /**
  86947. * The scaling of the particle.
  86948. */
  86949. scaling: Vector3;
  86950. /**
  86951. * The uvs of the particle.
  86952. */
  86953. uvs: Vector4;
  86954. /**
  86955. * The current speed of the particle.
  86956. */
  86957. velocity: Vector3;
  86958. /**
  86959. * The pivot point in the particle local space.
  86960. */
  86961. pivot: Vector3;
  86962. /**
  86963. * Must the particle be translated from its pivot point in its local space ?
  86964. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  86965. * Default : false
  86966. */
  86967. translateFromPivot: boolean;
  86968. /**
  86969. * Is the particle active or not ?
  86970. */
  86971. alive: boolean;
  86972. /**
  86973. * Is the particle visible or not ?
  86974. */
  86975. isVisible: boolean;
  86976. /**
  86977. * Index of this particle in the global "positions" array (Internal use)
  86978. * @hidden
  86979. */
  86980. _pos: number;
  86981. /**
  86982. * @hidden Index of this particle in the global "indices" array (Internal use)
  86983. */
  86984. _ind: number;
  86985. /**
  86986. * @hidden ModelShape of this particle (Internal use)
  86987. */
  86988. _model: ModelShape;
  86989. /**
  86990. * ModelShape id of this particle
  86991. */
  86992. shapeId: number;
  86993. /**
  86994. * Index of the particle in its shape id (Internal use)
  86995. */
  86996. idxInShape: number;
  86997. /**
  86998. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  86999. */
  87000. _modelBoundingInfo: BoundingInfo;
  87001. /**
  87002. * @hidden Particle BoundingInfo object (Internal use)
  87003. */
  87004. _boundingInfo: BoundingInfo;
  87005. /**
  87006. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  87007. */
  87008. _sps: SolidParticleSystem;
  87009. /**
  87010. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  87011. */
  87012. _stillInvisible: boolean;
  87013. /**
  87014. * @hidden Last computed particle rotation matrix
  87015. */
  87016. _rotationMatrix: number[];
  87017. /**
  87018. * Parent particle Id, if any.
  87019. * Default null.
  87020. */
  87021. parentId: Nullable<number>;
  87022. /**
  87023. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  87024. * The possible values are :
  87025. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87026. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87027. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87028. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87029. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87030. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  87031. * */
  87032. cullingStrategy: number;
  87033. /**
  87034. * @hidden Internal global position in the SPS.
  87035. */
  87036. _globalPosition: Vector3;
  87037. /**
  87038. * Creates a Solid Particle object.
  87039. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  87040. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  87041. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  87042. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  87043. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  87044. * @param shapeId (integer) is the model shape identifier in the SPS.
  87045. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  87046. * @param sps defines the sps it is associated to
  87047. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  87048. */
  87049. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  87050. /**
  87051. * Legacy support, changed scale to scaling
  87052. */
  87053. /**
  87054. * Legacy support, changed scale to scaling
  87055. */
  87056. scale: Vector3;
  87057. /**
  87058. * Legacy support, changed quaternion to rotationQuaternion
  87059. */
  87060. /**
  87061. * Legacy support, changed quaternion to rotationQuaternion
  87062. */
  87063. quaternion: Nullable<Quaternion>;
  87064. /**
  87065. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  87066. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  87067. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  87068. * @returns true if it intersects
  87069. */
  87070. intersectsMesh(target: Mesh | SolidParticle): boolean;
  87071. /**
  87072. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  87073. * A particle is in the frustum if its bounding box intersects the frustum
  87074. * @param frustumPlanes defines the frustum to test
  87075. * @returns true if the particle is in the frustum planes
  87076. */
  87077. isInFrustum(frustumPlanes: Plane[]): boolean;
  87078. /**
  87079. * get the rotation matrix of the particle
  87080. * @hidden
  87081. */
  87082. getRotationMatrix(m: Matrix): void;
  87083. }
  87084. /**
  87085. * Represents the shape of the model used by one particle of a solid particle system.
  87086. * SPS internal tool, don't use it manually.
  87087. */
  87088. export class ModelShape {
  87089. /**
  87090. * The shape id
  87091. * @hidden
  87092. */
  87093. shapeID: number;
  87094. /**
  87095. * flat array of model positions (internal use)
  87096. * @hidden
  87097. */
  87098. _shape: Vector3[];
  87099. /**
  87100. * flat array of model UVs (internal use)
  87101. * @hidden
  87102. */
  87103. _shapeUV: number[];
  87104. /**
  87105. * length of the shape in the model indices array (internal use)
  87106. * @hidden
  87107. */
  87108. _indicesLength: number;
  87109. /**
  87110. * Custom position function (internal use)
  87111. * @hidden
  87112. */
  87113. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  87114. /**
  87115. * Custom vertex function (internal use)
  87116. * @hidden
  87117. */
  87118. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  87119. /**
  87120. * 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.
  87121. * SPS internal tool, don't use it manually.
  87122. * @hidden
  87123. */
  87124. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  87125. }
  87126. /**
  87127. * Represents a Depth Sorted Particle in the solid particle system.
  87128. */
  87129. export class DepthSortedParticle {
  87130. /**
  87131. * Index of the particle in the "indices" array
  87132. */
  87133. ind: number;
  87134. /**
  87135. * Length of the particle shape in the "indices" array
  87136. */
  87137. indicesLength: number;
  87138. /**
  87139. * Squared distance from the particle to the camera
  87140. */
  87141. sqDistance: number;
  87142. }
  87143. }
  87144. declare module BABYLON {
  87145. /**
  87146. * @hidden
  87147. */
  87148. export class _MeshCollisionData {
  87149. _checkCollisions: boolean;
  87150. _collisionMask: number;
  87151. _collisionGroup: number;
  87152. _collider: Nullable<Collider>;
  87153. _oldPositionForCollisions: Vector3;
  87154. _diffPositionForCollisions: Vector3;
  87155. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  87156. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  87157. }
  87158. }
  87159. declare module BABYLON {
  87160. /** @hidden */
  87161. class _FacetDataStorage {
  87162. facetPositions: Vector3[];
  87163. facetNormals: Vector3[];
  87164. facetPartitioning: number[][];
  87165. facetNb: number;
  87166. partitioningSubdivisions: number;
  87167. partitioningBBoxRatio: number;
  87168. facetDataEnabled: boolean;
  87169. facetParameters: any;
  87170. bbSize: Vector3;
  87171. subDiv: {
  87172. max: number;
  87173. X: number;
  87174. Y: number;
  87175. Z: number;
  87176. };
  87177. facetDepthSort: boolean;
  87178. facetDepthSortEnabled: boolean;
  87179. depthSortedIndices: IndicesArray;
  87180. depthSortedFacets: {
  87181. ind: number;
  87182. sqDistance: number;
  87183. }[];
  87184. facetDepthSortFunction: (f1: {
  87185. ind: number;
  87186. sqDistance: number;
  87187. }, f2: {
  87188. ind: number;
  87189. sqDistance: number;
  87190. }) => number;
  87191. facetDepthSortFrom: Vector3;
  87192. facetDepthSortOrigin: Vector3;
  87193. invertedMatrix: Matrix;
  87194. }
  87195. /**
  87196. * @hidden
  87197. **/
  87198. class _InternalAbstractMeshDataInfo {
  87199. _hasVertexAlpha: boolean;
  87200. _useVertexColors: boolean;
  87201. _numBoneInfluencers: number;
  87202. _applyFog: boolean;
  87203. _receiveShadows: boolean;
  87204. _facetData: _FacetDataStorage;
  87205. _visibility: number;
  87206. _skeleton: Nullable<Skeleton>;
  87207. _layerMask: number;
  87208. _computeBonesUsingShaders: boolean;
  87209. _isActive: boolean;
  87210. _onlyForInstances: boolean;
  87211. _isActiveIntermediate: boolean;
  87212. _onlyForInstancesIntermediate: boolean;
  87213. }
  87214. /**
  87215. * Class used to store all common mesh properties
  87216. */
  87217. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  87218. /** No occlusion */
  87219. static OCCLUSION_TYPE_NONE: number;
  87220. /** Occlusion set to optimisitic */
  87221. static OCCLUSION_TYPE_OPTIMISTIC: number;
  87222. /** Occlusion set to strict */
  87223. static OCCLUSION_TYPE_STRICT: number;
  87224. /** Use an accurante occlusion algorithm */
  87225. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  87226. /** Use a conservative occlusion algorithm */
  87227. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  87228. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  87229. * Test order :
  87230. * Is the bounding sphere outside the frustum ?
  87231. * If not, are the bounding box vertices outside the frustum ?
  87232. * It not, then the cullable object is in the frustum.
  87233. */
  87234. static readonly CULLINGSTRATEGY_STANDARD: number;
  87235. /** Culling strategy : Bounding Sphere Only.
  87236. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  87237. * It's also less accurate than the standard because some not visible objects can still be selected.
  87238. * Test : is the bounding sphere outside the frustum ?
  87239. * If not, then the cullable object is in the frustum.
  87240. */
  87241. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  87242. /** Culling strategy : Optimistic Inclusion.
  87243. * This in an inclusion test first, then the standard exclusion test.
  87244. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  87245. * 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.
  87246. * Anyway, it's as accurate as the standard strategy.
  87247. * Test :
  87248. * Is the cullable object bounding sphere center in the frustum ?
  87249. * If not, apply the default culling strategy.
  87250. */
  87251. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  87252. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  87253. * This in an inclusion test first, then the bounding sphere only exclusion test.
  87254. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  87255. * 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.
  87256. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  87257. * Test :
  87258. * Is the cullable object bounding sphere center in the frustum ?
  87259. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  87260. */
  87261. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  87262. /**
  87263. * No billboard
  87264. */
  87265. static readonly BILLBOARDMODE_NONE: number;
  87266. /** Billboard on X axis */
  87267. static readonly BILLBOARDMODE_X: number;
  87268. /** Billboard on Y axis */
  87269. static readonly BILLBOARDMODE_Y: number;
  87270. /** Billboard on Z axis */
  87271. static readonly BILLBOARDMODE_Z: number;
  87272. /** Billboard on all axes */
  87273. static readonly BILLBOARDMODE_ALL: number;
  87274. /** @hidden */
  87275. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  87276. /**
  87277. * The culling strategy to use to check whether the mesh must be rendered or not.
  87278. * This value can be changed at any time and will be used on the next render mesh selection.
  87279. * The possible values are :
  87280. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87281. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87282. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87283. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87284. * Please read each static variable documentation to get details about the culling process.
  87285. * */
  87286. cullingStrategy: number;
  87287. /**
  87288. * Gets the number of facets in the mesh
  87289. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87290. */
  87291. readonly facetNb: number;
  87292. /**
  87293. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  87294. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87295. */
  87296. partitioningSubdivisions: number;
  87297. /**
  87298. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  87299. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  87300. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87301. */
  87302. partitioningBBoxRatio: number;
  87303. /**
  87304. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  87305. * Works only for updatable meshes.
  87306. * Doesn't work with multi-materials
  87307. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87308. */
  87309. mustDepthSortFacets: boolean;
  87310. /**
  87311. * The location (Vector3) where the facet depth sort must be computed from.
  87312. * By default, the active camera position.
  87313. * Used only when facet depth sort is enabled
  87314. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87315. */
  87316. facetDepthSortFrom: Vector3;
  87317. /**
  87318. * gets a boolean indicating if facetData is enabled
  87319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87320. */
  87321. readonly isFacetDataEnabled: boolean;
  87322. /** @hidden */
  87323. _updateNonUniformScalingState(value: boolean): boolean;
  87324. /**
  87325. * An event triggered when this mesh collides with another one
  87326. */
  87327. onCollideObservable: Observable<AbstractMesh>;
  87328. /** Set a function to call when this mesh collides with another one */
  87329. onCollide: () => void;
  87330. /**
  87331. * An event triggered when the collision's position changes
  87332. */
  87333. onCollisionPositionChangeObservable: Observable<Vector3>;
  87334. /** Set a function to call when the collision's position changes */
  87335. onCollisionPositionChange: () => void;
  87336. /**
  87337. * An event triggered when material is changed
  87338. */
  87339. onMaterialChangedObservable: Observable<AbstractMesh>;
  87340. /**
  87341. * Gets or sets the orientation for POV movement & rotation
  87342. */
  87343. definedFacingForward: boolean;
  87344. /** @hidden */
  87345. _occlusionQuery: Nullable<WebGLQuery>;
  87346. /** @hidden */
  87347. _renderingGroup: Nullable<RenderingGroup>;
  87348. /**
  87349. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87350. */
  87351. /**
  87352. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87353. */
  87354. visibility: number;
  87355. /** Gets or sets the alpha index used to sort transparent meshes
  87356. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  87357. */
  87358. alphaIndex: number;
  87359. /**
  87360. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  87361. */
  87362. isVisible: boolean;
  87363. /**
  87364. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  87365. */
  87366. isPickable: boolean;
  87367. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  87368. showSubMeshesBoundingBox: boolean;
  87369. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  87370. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  87371. */
  87372. isBlocker: boolean;
  87373. /**
  87374. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  87375. */
  87376. enablePointerMoveEvents: boolean;
  87377. /**
  87378. * Specifies the rendering group id for this mesh (0 by default)
  87379. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  87380. */
  87381. renderingGroupId: number;
  87382. private _material;
  87383. /** Gets or sets current material */
  87384. material: Nullable<Material>;
  87385. /**
  87386. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  87387. * @see http://doc.babylonjs.com/babylon101/shadows
  87388. */
  87389. receiveShadows: boolean;
  87390. /** Defines color to use when rendering outline */
  87391. outlineColor: Color3;
  87392. /** Define width to use when rendering outline */
  87393. outlineWidth: number;
  87394. /** Defines color to use when rendering overlay */
  87395. overlayColor: Color3;
  87396. /** Defines alpha to use when rendering overlay */
  87397. overlayAlpha: number;
  87398. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  87399. hasVertexAlpha: boolean;
  87400. /** 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) */
  87401. useVertexColors: boolean;
  87402. /**
  87403. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  87404. */
  87405. computeBonesUsingShaders: boolean;
  87406. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  87407. numBoneInfluencers: number;
  87408. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  87409. applyFog: boolean;
  87410. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  87411. useOctreeForRenderingSelection: boolean;
  87412. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  87413. useOctreeForPicking: boolean;
  87414. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  87415. useOctreeForCollisions: boolean;
  87416. /**
  87417. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  87418. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  87419. */
  87420. layerMask: number;
  87421. /**
  87422. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  87423. */
  87424. alwaysSelectAsActiveMesh: boolean;
  87425. /**
  87426. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  87427. */
  87428. doNotSyncBoundingInfo: boolean;
  87429. /**
  87430. * Gets or sets the current action manager
  87431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87432. */
  87433. actionManager: Nullable<AbstractActionManager>;
  87434. private _meshCollisionData;
  87435. /**
  87436. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  87437. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87438. */
  87439. ellipsoid: Vector3;
  87440. /**
  87441. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  87442. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87443. */
  87444. ellipsoidOffset: Vector3;
  87445. /**
  87446. * Gets or sets a collision mask used to mask collisions (default is -1).
  87447. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87448. */
  87449. collisionMask: number;
  87450. /**
  87451. * Gets or sets the current collision group mask (-1 by default).
  87452. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87453. */
  87454. collisionGroup: number;
  87455. /**
  87456. * Defines edge width used when edgesRenderer is enabled
  87457. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87458. */
  87459. edgesWidth: number;
  87460. /**
  87461. * Defines edge color used when edgesRenderer is enabled
  87462. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87463. */
  87464. edgesColor: Color4;
  87465. /** @hidden */
  87466. _edgesRenderer: Nullable<IEdgesRenderer>;
  87467. /** @hidden */
  87468. _masterMesh: Nullable<AbstractMesh>;
  87469. /** @hidden */
  87470. _boundingInfo: Nullable<BoundingInfo>;
  87471. /** @hidden */
  87472. _renderId: number;
  87473. /**
  87474. * Gets or sets the list of subMeshes
  87475. * @see http://doc.babylonjs.com/how_to/multi_materials
  87476. */
  87477. subMeshes: SubMesh[];
  87478. /** @hidden */
  87479. _intersectionsInProgress: AbstractMesh[];
  87480. /** @hidden */
  87481. _unIndexed: boolean;
  87482. /** @hidden */
  87483. _lightSources: Light[];
  87484. /** Gets the list of lights affecting that mesh */
  87485. readonly lightSources: Light[];
  87486. /** @hidden */
  87487. readonly _positions: Nullable<Vector3[]>;
  87488. /** @hidden */
  87489. _waitingData: {
  87490. lods: Nullable<any>;
  87491. actions: Nullable<any>;
  87492. freezeWorldMatrix: Nullable<boolean>;
  87493. };
  87494. /** @hidden */
  87495. _bonesTransformMatrices: Nullable<Float32Array>;
  87496. /** @hidden */
  87497. _transformMatrixTexture: Nullable<RawTexture>;
  87498. /**
  87499. * Gets or sets a skeleton to apply skining transformations
  87500. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87501. */
  87502. skeleton: Nullable<Skeleton>;
  87503. /**
  87504. * An event triggered when the mesh is rebuilt.
  87505. */
  87506. onRebuildObservable: Observable<AbstractMesh>;
  87507. /**
  87508. * Creates a new AbstractMesh
  87509. * @param name defines the name of the mesh
  87510. * @param scene defines the hosting scene
  87511. */
  87512. constructor(name: string, scene?: Nullable<Scene>);
  87513. /**
  87514. * Returns the string "AbstractMesh"
  87515. * @returns "AbstractMesh"
  87516. */
  87517. getClassName(): string;
  87518. /**
  87519. * Gets a string representation of the current mesh
  87520. * @param fullDetails defines a boolean indicating if full details must be included
  87521. * @returns a string representation of the current mesh
  87522. */
  87523. toString(fullDetails?: boolean): string;
  87524. /**
  87525. * @hidden
  87526. */
  87527. protected _getEffectiveParent(): Nullable<Node>;
  87528. /** @hidden */
  87529. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87530. /** @hidden */
  87531. _rebuild(): void;
  87532. /** @hidden */
  87533. _resyncLightSources(): void;
  87534. /** @hidden */
  87535. _resyncLighSource(light: Light): void;
  87536. /** @hidden */
  87537. _unBindEffect(): void;
  87538. /** @hidden */
  87539. _removeLightSource(light: Light): void;
  87540. private _markSubMeshesAsDirty;
  87541. /** @hidden */
  87542. _markSubMeshesAsLightDirty(): void;
  87543. /** @hidden */
  87544. _markSubMeshesAsAttributesDirty(): void;
  87545. /** @hidden */
  87546. _markSubMeshesAsMiscDirty(): void;
  87547. /**
  87548. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87549. */
  87550. scaling: Vector3;
  87551. /**
  87552. * Returns true if the mesh is blocked. Implemented by child classes
  87553. */
  87554. readonly isBlocked: boolean;
  87555. /**
  87556. * Returns the mesh itself by default. Implemented by child classes
  87557. * @param camera defines the camera to use to pick the right LOD level
  87558. * @returns the currentAbstractMesh
  87559. */
  87560. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87561. /**
  87562. * Returns 0 by default. Implemented by child classes
  87563. * @returns an integer
  87564. */
  87565. getTotalVertices(): number;
  87566. /**
  87567. * Returns a positive integer : the total number of indices in this mesh geometry.
  87568. * @returns the numner of indices or zero if the mesh has no geometry.
  87569. */
  87570. getTotalIndices(): number;
  87571. /**
  87572. * Returns null by default. Implemented by child classes
  87573. * @returns null
  87574. */
  87575. getIndices(): Nullable<IndicesArray>;
  87576. /**
  87577. * Returns the array of the requested vertex data kind. Implemented by child classes
  87578. * @param kind defines the vertex data kind to use
  87579. * @returns null
  87580. */
  87581. getVerticesData(kind: string): Nullable<FloatArray>;
  87582. /**
  87583. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87584. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87585. * Note that a new underlying VertexBuffer object is created each call.
  87586. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87587. * @param kind defines vertex data kind:
  87588. * * VertexBuffer.PositionKind
  87589. * * VertexBuffer.UVKind
  87590. * * VertexBuffer.UV2Kind
  87591. * * VertexBuffer.UV3Kind
  87592. * * VertexBuffer.UV4Kind
  87593. * * VertexBuffer.UV5Kind
  87594. * * VertexBuffer.UV6Kind
  87595. * * VertexBuffer.ColorKind
  87596. * * VertexBuffer.MatricesIndicesKind
  87597. * * VertexBuffer.MatricesIndicesExtraKind
  87598. * * VertexBuffer.MatricesWeightsKind
  87599. * * VertexBuffer.MatricesWeightsExtraKind
  87600. * @param data defines the data source
  87601. * @param updatable defines if the data must be flagged as updatable (or static)
  87602. * @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
  87603. * @returns the current mesh
  87604. */
  87605. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87606. /**
  87607. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87608. * If the mesh has no geometry, it is simply returned as it is.
  87609. * @param kind defines vertex data kind:
  87610. * * VertexBuffer.PositionKind
  87611. * * VertexBuffer.UVKind
  87612. * * VertexBuffer.UV2Kind
  87613. * * VertexBuffer.UV3Kind
  87614. * * VertexBuffer.UV4Kind
  87615. * * VertexBuffer.UV5Kind
  87616. * * VertexBuffer.UV6Kind
  87617. * * VertexBuffer.ColorKind
  87618. * * VertexBuffer.MatricesIndicesKind
  87619. * * VertexBuffer.MatricesIndicesExtraKind
  87620. * * VertexBuffer.MatricesWeightsKind
  87621. * * VertexBuffer.MatricesWeightsExtraKind
  87622. * @param data defines the data source
  87623. * @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
  87624. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87625. * @returns the current mesh
  87626. */
  87627. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87628. /**
  87629. * Sets the mesh indices,
  87630. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87631. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87632. * @param totalVertices Defines the total number of vertices
  87633. * @returns the current mesh
  87634. */
  87635. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87636. /**
  87637. * Gets a boolean indicating if specific vertex data is present
  87638. * @param kind defines the vertex data kind to use
  87639. * @returns true is data kind is present
  87640. */
  87641. isVerticesDataPresent(kind: string): boolean;
  87642. /**
  87643. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  87644. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  87645. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  87646. * @returns a BoundingInfo
  87647. */
  87648. getBoundingInfo(): BoundingInfo;
  87649. /**
  87650. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87651. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87652. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87653. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87654. * @returns the current mesh
  87655. */
  87656. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  87657. /**
  87658. * Overwrite the current bounding info
  87659. * @param boundingInfo defines the new bounding info
  87660. * @returns the current mesh
  87661. */
  87662. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87663. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87664. readonly useBones: boolean;
  87665. /** @hidden */
  87666. _preActivate(): void;
  87667. /** @hidden */
  87668. _preActivateForIntermediateRendering(renderId: number): void;
  87669. /** @hidden */
  87670. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87671. /** @hidden */
  87672. _postActivate(): void;
  87673. /** @hidden */
  87674. _freeze(): void;
  87675. /** @hidden */
  87676. _unFreeze(): void;
  87677. /**
  87678. * Gets the current world matrix
  87679. * @returns a Matrix
  87680. */
  87681. getWorldMatrix(): Matrix;
  87682. /** @hidden */
  87683. _getWorldMatrixDeterminant(): number;
  87684. /**
  87685. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87686. */
  87687. readonly isAnInstance: boolean;
  87688. /**
  87689. * Perform relative position change from the point of view of behind the front of the mesh.
  87690. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87691. * Supports definition of mesh facing forward or backward
  87692. * @param amountRight defines the distance on the right axis
  87693. * @param amountUp defines the distance on the up axis
  87694. * @param amountForward defines the distance on the forward axis
  87695. * @returns the current mesh
  87696. */
  87697. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87698. /**
  87699. * Calculate relative position change from the point of view of behind the front of the mesh.
  87700. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87701. * Supports definition of mesh facing forward or backward
  87702. * @param amountRight defines the distance on the right axis
  87703. * @param amountUp defines the distance on the up axis
  87704. * @param amountForward defines the distance on the forward axis
  87705. * @returns the new displacement vector
  87706. */
  87707. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  87708. /**
  87709. * Perform relative rotation change from the point of view of behind the front of the mesh.
  87710. * Supports definition of mesh facing forward or backward
  87711. * @param flipBack defines the flip
  87712. * @param twirlClockwise defines the twirl
  87713. * @param tiltRight defines the tilt
  87714. * @returns the current mesh
  87715. */
  87716. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  87717. /**
  87718. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  87719. * Supports definition of mesh facing forward or backward.
  87720. * @param flipBack defines the flip
  87721. * @param twirlClockwise defines the twirl
  87722. * @param tiltRight defines the tilt
  87723. * @returns the new rotation vector
  87724. */
  87725. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  87726. /**
  87727. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87728. * This means the mesh underlying bounding box and sphere are recomputed.
  87729. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87730. * @returns the current mesh
  87731. */
  87732. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  87733. /** @hidden */
  87734. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  87735. /** @hidden */
  87736. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  87737. /** @hidden */
  87738. _updateBoundingInfo(): AbstractMesh;
  87739. /** @hidden */
  87740. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  87741. /** @hidden */
  87742. protected _afterComputeWorldMatrix(): void;
  87743. /** @hidden */
  87744. readonly _effectiveMesh: AbstractMesh;
  87745. /**
  87746. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87747. * A mesh is in the frustum if its bounding box intersects the frustum
  87748. * @param frustumPlanes defines the frustum to test
  87749. * @returns true if the mesh is in the frustum planes
  87750. */
  87751. isInFrustum(frustumPlanes: Plane[]): boolean;
  87752. /**
  87753. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  87754. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  87755. * @param frustumPlanes defines the frustum to test
  87756. * @returns true if the mesh is completely in the frustum planes
  87757. */
  87758. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87759. /**
  87760. * True if the mesh intersects another mesh or a SolidParticle object
  87761. * @param mesh defines a target mesh or SolidParticle to test
  87762. * @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)
  87763. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  87764. * @returns true if there is an intersection
  87765. */
  87766. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  87767. /**
  87768. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  87769. * @param point defines the point to test
  87770. * @returns true if there is an intersection
  87771. */
  87772. intersectsPoint(point: Vector3): boolean;
  87773. /**
  87774. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  87775. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87776. */
  87777. checkCollisions: boolean;
  87778. /**
  87779. * Gets Collider object used to compute collisions (not physics)
  87780. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87781. */
  87782. readonly collider: Nullable<Collider>;
  87783. /**
  87784. * Move the mesh using collision engine
  87785. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87786. * @param displacement defines the requested displacement vector
  87787. * @returns the current mesh
  87788. */
  87789. moveWithCollisions(displacement: Vector3): AbstractMesh;
  87790. private _onCollisionPositionChange;
  87791. /** @hidden */
  87792. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  87793. /** @hidden */
  87794. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  87795. /** @hidden */
  87796. _checkCollision(collider: Collider): AbstractMesh;
  87797. /** @hidden */
  87798. _generatePointsArray(): boolean;
  87799. /**
  87800. * Checks if the passed Ray intersects with the mesh
  87801. * @param ray defines the ray to use
  87802. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  87803. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87804. * @returns the picking info
  87805. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87806. */
  87807. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  87808. /**
  87809. * Clones the current mesh
  87810. * @param name defines the mesh name
  87811. * @param newParent defines the new mesh parent
  87812. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  87813. * @returns the new mesh
  87814. */
  87815. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87816. /**
  87817. * Disposes all the submeshes of the current meshnp
  87818. * @returns the current mesh
  87819. */
  87820. releaseSubMeshes(): AbstractMesh;
  87821. /**
  87822. * Releases resources associated with this abstract mesh.
  87823. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87824. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87825. */
  87826. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87827. /**
  87828. * Adds the passed mesh as a child to the current mesh
  87829. * @param mesh defines the child mesh
  87830. * @returns the current mesh
  87831. */
  87832. addChild(mesh: AbstractMesh): AbstractMesh;
  87833. /**
  87834. * Removes the passed mesh from the current mesh children list
  87835. * @param mesh defines the child mesh
  87836. * @returns the current mesh
  87837. */
  87838. removeChild(mesh: AbstractMesh): AbstractMesh;
  87839. /** @hidden */
  87840. private _initFacetData;
  87841. /**
  87842. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  87843. * This method can be called within the render loop.
  87844. * 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
  87845. * @returns the current mesh
  87846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87847. */
  87848. updateFacetData(): AbstractMesh;
  87849. /**
  87850. * Returns the facetLocalNormals array.
  87851. * The normals are expressed in the mesh local spac
  87852. * @returns an array of Vector3
  87853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87854. */
  87855. getFacetLocalNormals(): Vector3[];
  87856. /**
  87857. * Returns the facetLocalPositions array.
  87858. * The facet positions are expressed in the mesh local space
  87859. * @returns an array of Vector3
  87860. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87861. */
  87862. getFacetLocalPositions(): Vector3[];
  87863. /**
  87864. * Returns the facetLocalPartioning array
  87865. * @returns an array of array of numbers
  87866. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87867. */
  87868. getFacetLocalPartitioning(): number[][];
  87869. /**
  87870. * Returns the i-th facet position in the world system.
  87871. * This method allocates a new Vector3 per call
  87872. * @param i defines the facet index
  87873. * @returns a new Vector3
  87874. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87875. */
  87876. getFacetPosition(i: number): Vector3;
  87877. /**
  87878. * Sets the reference Vector3 with the i-th facet position in the world system
  87879. * @param i defines the facet index
  87880. * @param ref defines the target vector
  87881. * @returns the current mesh
  87882. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87883. */
  87884. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  87885. /**
  87886. * Returns the i-th facet normal in the world system.
  87887. * This method allocates a new Vector3 per call
  87888. * @param i defines the facet index
  87889. * @returns a new Vector3
  87890. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87891. */
  87892. getFacetNormal(i: number): Vector3;
  87893. /**
  87894. * Sets the reference Vector3 with the i-th facet normal in the world system
  87895. * @param i defines the facet index
  87896. * @param ref defines the target vector
  87897. * @returns the current mesh
  87898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87899. */
  87900. getFacetNormalToRef(i: number, ref: Vector3): this;
  87901. /**
  87902. * 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)
  87903. * @param x defines x coordinate
  87904. * @param y defines y coordinate
  87905. * @param z defines z coordinate
  87906. * @returns the array of facet indexes
  87907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87908. */
  87909. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  87910. /**
  87911. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  87912. * @param projected sets as the (x,y,z) world projection on the facet
  87913. * @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
  87914. * @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
  87915. * @param x defines x coordinate
  87916. * @param y defines y coordinate
  87917. * @param z defines z coordinate
  87918. * @returns the face index if found (or null instead)
  87919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87920. */
  87921. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87922. /**
  87923. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  87924. * @param projected sets as the (x,y,z) local projection on the facet
  87925. * @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
  87926. * @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
  87927. * @param x defines x coordinate
  87928. * @param y defines y coordinate
  87929. * @param z defines z coordinate
  87930. * @returns the face index if found (or null instead)
  87931. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87932. */
  87933. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87934. /**
  87935. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  87936. * @returns the parameters
  87937. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87938. */
  87939. getFacetDataParameters(): any;
  87940. /**
  87941. * Disables the feature FacetData and frees the related memory
  87942. * @returns the current mesh
  87943. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87944. */
  87945. disableFacetData(): AbstractMesh;
  87946. /**
  87947. * Updates the AbstractMesh indices array
  87948. * @param indices defines the data source
  87949. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87950. * @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)
  87951. * @returns the current mesh
  87952. */
  87953. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  87954. /**
  87955. * Creates new normals data for the mesh
  87956. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  87957. * @returns the current mesh
  87958. */
  87959. createNormals(updatable: boolean): AbstractMesh;
  87960. /**
  87961. * Align the mesh with a normal
  87962. * @param normal defines the normal to use
  87963. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  87964. * @returns the current mesh
  87965. */
  87966. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  87967. /** @hidden */
  87968. _checkOcclusionQuery(): boolean;
  87969. /**
  87970. * Disables the mesh edge rendering mode
  87971. * @returns the currentAbstractMesh
  87972. */
  87973. disableEdgesRendering(): AbstractMesh;
  87974. /**
  87975. * Enables the edge rendering mode on the mesh.
  87976. * This mode makes the mesh edges visible
  87977. * @param epsilon defines the maximal distance between two angles to detect a face
  87978. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87979. * @returns the currentAbstractMesh
  87980. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87981. */
  87982. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87983. }
  87984. }
  87985. declare module BABYLON {
  87986. /**
  87987. * Interface used to define ActionEvent
  87988. */
  87989. export interface IActionEvent {
  87990. /** The mesh or sprite that triggered the action */
  87991. source: any;
  87992. /** The X mouse cursor position at the time of the event */
  87993. pointerX: number;
  87994. /** The Y mouse cursor position at the time of the event */
  87995. pointerY: number;
  87996. /** The mesh that is currently pointed at (can be null) */
  87997. meshUnderPointer: Nullable<AbstractMesh>;
  87998. /** the original (browser) event that triggered the ActionEvent */
  87999. sourceEvent?: any;
  88000. /** additional data for the event */
  88001. additionalData?: any;
  88002. }
  88003. /**
  88004. * ActionEvent is the event being sent when an action is triggered.
  88005. */
  88006. export class ActionEvent implements IActionEvent {
  88007. /** The mesh or sprite that triggered the action */
  88008. source: any;
  88009. /** The X mouse cursor position at the time of the event */
  88010. pointerX: number;
  88011. /** The Y mouse cursor position at the time of the event */
  88012. pointerY: number;
  88013. /** The mesh that is currently pointed at (can be null) */
  88014. meshUnderPointer: Nullable<AbstractMesh>;
  88015. /** the original (browser) event that triggered the ActionEvent */
  88016. sourceEvent?: any;
  88017. /** additional data for the event */
  88018. additionalData?: any;
  88019. /**
  88020. * Creates a new ActionEvent
  88021. * @param source The mesh or sprite that triggered the action
  88022. * @param pointerX The X mouse cursor position at the time of the event
  88023. * @param pointerY The Y mouse cursor position at the time of the event
  88024. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  88025. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  88026. * @param additionalData additional data for the event
  88027. */
  88028. constructor(
  88029. /** The mesh or sprite that triggered the action */
  88030. source: any,
  88031. /** The X mouse cursor position at the time of the event */
  88032. pointerX: number,
  88033. /** The Y mouse cursor position at the time of the event */
  88034. pointerY: number,
  88035. /** The mesh that is currently pointed at (can be null) */
  88036. meshUnderPointer: Nullable<AbstractMesh>,
  88037. /** the original (browser) event that triggered the ActionEvent */
  88038. sourceEvent?: any,
  88039. /** additional data for the event */
  88040. additionalData?: any);
  88041. /**
  88042. * Helper function to auto-create an ActionEvent from a source mesh.
  88043. * @param source The source mesh that triggered the event
  88044. * @param evt The original (browser) event
  88045. * @param additionalData additional data for the event
  88046. * @returns the new ActionEvent
  88047. */
  88048. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  88049. /**
  88050. * Helper function to auto-create an ActionEvent from a source sprite
  88051. * @param source The source sprite that triggered the event
  88052. * @param scene Scene associated with the sprite
  88053. * @param evt The original (browser) event
  88054. * @param additionalData additional data for the event
  88055. * @returns the new ActionEvent
  88056. */
  88057. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  88058. /**
  88059. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  88060. * @param scene the scene where the event occurred
  88061. * @param evt The original (browser) event
  88062. * @returns the new ActionEvent
  88063. */
  88064. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  88065. /**
  88066. * Helper function to auto-create an ActionEvent from a primitive
  88067. * @param prim defines the target primitive
  88068. * @param pointerPos defines the pointer position
  88069. * @param evt The original (browser) event
  88070. * @param additionalData additional data for the event
  88071. * @returns the new ActionEvent
  88072. */
  88073. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  88074. }
  88075. }
  88076. declare module BABYLON {
  88077. /**
  88078. * Abstract class used to decouple action Manager from scene and meshes.
  88079. * Do not instantiate.
  88080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  88081. */
  88082. export abstract class AbstractActionManager implements IDisposable {
  88083. /** Gets the list of active triggers */
  88084. static Triggers: {
  88085. [key: string]: number;
  88086. };
  88087. /** Gets the cursor to use when hovering items */
  88088. hoverCursor: string;
  88089. /** Gets the list of actions */
  88090. actions: IAction[];
  88091. /**
  88092. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  88093. */
  88094. isRecursive: boolean;
  88095. /**
  88096. * Releases all associated resources
  88097. */
  88098. abstract dispose(): void;
  88099. /**
  88100. * Does this action manager has pointer triggers
  88101. */
  88102. abstract readonly hasPointerTriggers: boolean;
  88103. /**
  88104. * Does this action manager has pick triggers
  88105. */
  88106. abstract readonly hasPickTriggers: boolean;
  88107. /**
  88108. * Process a specific trigger
  88109. * @param trigger defines the trigger to process
  88110. * @param evt defines the event details to be processed
  88111. */
  88112. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  88113. /**
  88114. * Does this action manager handles actions of any of the given triggers
  88115. * @param triggers defines the triggers to be tested
  88116. * @return a boolean indicating whether one (or more) of the triggers is handled
  88117. */
  88118. abstract hasSpecificTriggers(triggers: number[]): boolean;
  88119. /**
  88120. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88121. * speed.
  88122. * @param triggerA defines the trigger to be tested
  88123. * @param triggerB defines the trigger to be tested
  88124. * @return a boolean indicating whether one (or more) of the triggers is handled
  88125. */
  88126. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88127. /**
  88128. * Does this action manager handles actions of a given trigger
  88129. * @param trigger defines the trigger to be tested
  88130. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88131. * @return whether the trigger is handled
  88132. */
  88133. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88134. /**
  88135. * Serialize this manager to a JSON object
  88136. * @param name defines the property name to store this manager
  88137. * @returns a JSON representation of this manager
  88138. */
  88139. abstract serialize(name: string): any;
  88140. /**
  88141. * Registers an action to this action manager
  88142. * @param action defines the action to be registered
  88143. * @return the action amended (prepared) after registration
  88144. */
  88145. abstract registerAction(action: IAction): Nullable<IAction>;
  88146. /**
  88147. * Unregisters an action to this action manager
  88148. * @param action defines the action to be unregistered
  88149. * @return a boolean indicating whether the action has been unregistered
  88150. */
  88151. abstract unregisterAction(action: IAction): Boolean;
  88152. /**
  88153. * Does exist one action manager with at least one trigger
  88154. **/
  88155. static readonly HasTriggers: boolean;
  88156. /**
  88157. * Does exist one action manager with at least one pick trigger
  88158. **/
  88159. static readonly HasPickTriggers: boolean;
  88160. /**
  88161. * Does exist one action manager that handles actions of a given trigger
  88162. * @param trigger defines the trigger to be tested
  88163. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  88164. **/
  88165. static HasSpecificTrigger(trigger: number): boolean;
  88166. }
  88167. }
  88168. declare module BABYLON {
  88169. /**
  88170. * Defines how a node can be built from a string name.
  88171. */
  88172. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  88173. /**
  88174. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  88175. */
  88176. export class Node implements IBehaviorAware<Node> {
  88177. /** @hidden */
  88178. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  88179. private static _NodeConstructors;
  88180. /**
  88181. * Add a new node constructor
  88182. * @param type defines the type name of the node to construct
  88183. * @param constructorFunc defines the constructor function
  88184. */
  88185. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  88186. /**
  88187. * Returns a node constructor based on type name
  88188. * @param type defines the type name
  88189. * @param name defines the new node name
  88190. * @param scene defines the hosting scene
  88191. * @param options defines optional options to transmit to constructors
  88192. * @returns the new constructor or null
  88193. */
  88194. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  88195. /**
  88196. * Gets or sets the name of the node
  88197. */
  88198. name: string;
  88199. /**
  88200. * Gets or sets the id of the node
  88201. */
  88202. id: string;
  88203. /**
  88204. * Gets or sets the unique id of the node
  88205. */
  88206. uniqueId: number;
  88207. /**
  88208. * Gets or sets a string used to store user defined state for the node
  88209. */
  88210. state: string;
  88211. /**
  88212. * Gets or sets an object used to store user defined information for the node
  88213. */
  88214. metadata: any;
  88215. /**
  88216. * For internal use only. Please do not use.
  88217. */
  88218. reservedDataStore: any;
  88219. /**
  88220. * List of inspectable custom properties (used by the Inspector)
  88221. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88222. */
  88223. inspectableCustomProperties: IInspectable[];
  88224. /**
  88225. * Gets or sets a boolean used to define if the node must be serialized
  88226. */
  88227. doNotSerialize: boolean;
  88228. /** @hidden */
  88229. _isDisposed: boolean;
  88230. /**
  88231. * Gets a list of Animations associated with the node
  88232. */
  88233. animations: Animation[];
  88234. protected _ranges: {
  88235. [name: string]: Nullable<AnimationRange>;
  88236. };
  88237. /**
  88238. * Callback raised when the node is ready to be used
  88239. */
  88240. onReady: Nullable<(node: Node) => void>;
  88241. private _isEnabled;
  88242. private _isParentEnabled;
  88243. private _isReady;
  88244. /** @hidden */
  88245. _currentRenderId: number;
  88246. private _parentUpdateId;
  88247. /** @hidden */
  88248. _childUpdateId: number;
  88249. /** @hidden */
  88250. _waitingParentId: Nullable<string>;
  88251. /** @hidden */
  88252. _scene: Scene;
  88253. /** @hidden */
  88254. _cache: any;
  88255. private _parentNode;
  88256. private _children;
  88257. /** @hidden */
  88258. _worldMatrix: Matrix;
  88259. /** @hidden */
  88260. _worldMatrixDeterminant: number;
  88261. /** @hidden */
  88262. _worldMatrixDeterminantIsDirty: boolean;
  88263. /** @hidden */
  88264. private _sceneRootNodesIndex;
  88265. /**
  88266. * Gets a boolean indicating if the node has been disposed
  88267. * @returns true if the node was disposed
  88268. */
  88269. isDisposed(): boolean;
  88270. /**
  88271. * Gets or sets the parent of the node (without keeping the current position in the scene)
  88272. * @see https://doc.babylonjs.com/how_to/parenting
  88273. */
  88274. parent: Nullable<Node>;
  88275. private addToSceneRootNodes;
  88276. private removeFromSceneRootNodes;
  88277. private _animationPropertiesOverride;
  88278. /**
  88279. * Gets or sets the animation properties override
  88280. */
  88281. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88282. /**
  88283. * Gets a string idenfifying the name of the class
  88284. * @returns "Node" string
  88285. */
  88286. getClassName(): string;
  88287. /** @hidden */
  88288. readonly _isNode: boolean;
  88289. /**
  88290. * An event triggered when the mesh is disposed
  88291. */
  88292. onDisposeObservable: Observable<Node>;
  88293. private _onDisposeObserver;
  88294. /**
  88295. * Sets a callback that will be raised when the node will be disposed
  88296. */
  88297. onDispose: () => void;
  88298. /**
  88299. * Creates a new Node
  88300. * @param name the name and id to be given to this node
  88301. * @param scene the scene this node will be added to
  88302. * @param addToRootNodes the node will be added to scene.rootNodes
  88303. */
  88304. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  88305. /**
  88306. * Gets the scene of the node
  88307. * @returns a scene
  88308. */
  88309. getScene(): Scene;
  88310. /**
  88311. * Gets the engine of the node
  88312. * @returns a Engine
  88313. */
  88314. getEngine(): Engine;
  88315. private _behaviors;
  88316. /**
  88317. * Attach a behavior to the node
  88318. * @see http://doc.babylonjs.com/features/behaviour
  88319. * @param behavior defines the behavior to attach
  88320. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  88321. * @returns the current Node
  88322. */
  88323. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  88324. /**
  88325. * Remove an attached behavior
  88326. * @see http://doc.babylonjs.com/features/behaviour
  88327. * @param behavior defines the behavior to attach
  88328. * @returns the current Node
  88329. */
  88330. removeBehavior(behavior: Behavior<Node>): Node;
  88331. /**
  88332. * Gets the list of attached behaviors
  88333. * @see http://doc.babylonjs.com/features/behaviour
  88334. */
  88335. readonly behaviors: Behavior<Node>[];
  88336. /**
  88337. * Gets an attached behavior by name
  88338. * @param name defines the name of the behavior to look for
  88339. * @see http://doc.babylonjs.com/features/behaviour
  88340. * @returns null if behavior was not found else the requested behavior
  88341. */
  88342. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  88343. /**
  88344. * Returns the latest update of the World matrix
  88345. * @returns a Matrix
  88346. */
  88347. getWorldMatrix(): Matrix;
  88348. /** @hidden */
  88349. _getWorldMatrixDeterminant(): number;
  88350. /**
  88351. * Returns directly the latest state of the mesh World matrix.
  88352. * A Matrix is returned.
  88353. */
  88354. readonly worldMatrixFromCache: Matrix;
  88355. /** @hidden */
  88356. _initCache(): void;
  88357. /** @hidden */
  88358. updateCache(force?: boolean): void;
  88359. /** @hidden */
  88360. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  88361. /** @hidden */
  88362. _updateCache(ignoreParentClass?: boolean): void;
  88363. /** @hidden */
  88364. _isSynchronized(): boolean;
  88365. /** @hidden */
  88366. _markSyncedWithParent(): void;
  88367. /** @hidden */
  88368. isSynchronizedWithParent(): boolean;
  88369. /** @hidden */
  88370. isSynchronized(): boolean;
  88371. /**
  88372. * Is this node ready to be used/rendered
  88373. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88374. * @return true if the node is ready
  88375. */
  88376. isReady(completeCheck?: boolean): boolean;
  88377. /**
  88378. * Is this node enabled?
  88379. * 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
  88380. * @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
  88381. * @return whether this node (and its parent) is enabled
  88382. */
  88383. isEnabled(checkAncestors?: boolean): boolean;
  88384. /** @hidden */
  88385. protected _syncParentEnabledState(): void;
  88386. /**
  88387. * Set the enabled state of this node
  88388. * @param value defines the new enabled state
  88389. */
  88390. setEnabled(value: boolean): void;
  88391. /**
  88392. * Is this node a descendant of the given node?
  88393. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  88394. * @param ancestor defines the parent node to inspect
  88395. * @returns a boolean indicating if this node is a descendant of the given node
  88396. */
  88397. isDescendantOf(ancestor: Node): boolean;
  88398. /** @hidden */
  88399. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  88400. /**
  88401. * Will return all nodes that have this node as ascendant
  88402. * @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
  88403. * @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
  88404. * @return all children nodes of all types
  88405. */
  88406. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  88407. /**
  88408. * Get all child-meshes of this node
  88409. * @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)
  88410. * @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
  88411. * @returns an array of AbstractMesh
  88412. */
  88413. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  88414. /**
  88415. * Get all direct children of this node
  88416. * @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
  88417. * @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)
  88418. * @returns an array of Node
  88419. */
  88420. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  88421. /** @hidden */
  88422. _setReady(state: boolean): void;
  88423. /**
  88424. * Get an animation by name
  88425. * @param name defines the name of the animation to look for
  88426. * @returns null if not found else the requested animation
  88427. */
  88428. getAnimationByName(name: string): Nullable<Animation>;
  88429. /**
  88430. * Creates an animation range for this node
  88431. * @param name defines the name of the range
  88432. * @param from defines the starting key
  88433. * @param to defines the end key
  88434. */
  88435. createAnimationRange(name: string, from: number, to: number): void;
  88436. /**
  88437. * Delete a specific animation range
  88438. * @param name defines the name of the range to delete
  88439. * @param deleteFrames defines if animation frames from the range must be deleted as well
  88440. */
  88441. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88442. /**
  88443. * Get an animation range by name
  88444. * @param name defines the name of the animation range to look for
  88445. * @returns null if not found else the requested animation range
  88446. */
  88447. getAnimationRange(name: string): Nullable<AnimationRange>;
  88448. /**
  88449. * Gets the list of all animation ranges defined on this node
  88450. * @returns an array
  88451. */
  88452. getAnimationRanges(): Nullable<AnimationRange>[];
  88453. /**
  88454. * Will start the animation sequence
  88455. * @param name defines the range frames for animation sequence
  88456. * @param loop defines if the animation should loop (false by default)
  88457. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  88458. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  88459. * @returns the object created for this animation. If range does not exist, it will return null
  88460. */
  88461. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88462. /**
  88463. * Serialize animation ranges into a JSON compatible object
  88464. * @returns serialization object
  88465. */
  88466. serializeAnimationRanges(): any;
  88467. /**
  88468. * Computes the world matrix of the node
  88469. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88470. * @returns the world matrix
  88471. */
  88472. computeWorldMatrix(force?: boolean): Matrix;
  88473. /**
  88474. * Releases resources associated with this node.
  88475. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88476. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88477. */
  88478. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88479. /**
  88480. * Parse animation range data from a serialization object and store them into a given node
  88481. * @param node defines where to store the animation ranges
  88482. * @param parsedNode defines the serialization object to read data from
  88483. * @param scene defines the hosting scene
  88484. */
  88485. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88486. /**
  88487. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88488. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88489. * @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
  88490. * @returns the new bounding vectors
  88491. */
  88492. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88493. min: Vector3;
  88494. max: Vector3;
  88495. };
  88496. }
  88497. }
  88498. declare module BABYLON {
  88499. /**
  88500. * @hidden
  88501. */
  88502. export class _IAnimationState {
  88503. key: number;
  88504. repeatCount: number;
  88505. workValue?: any;
  88506. loopMode?: number;
  88507. offsetValue?: any;
  88508. highLimitValue?: any;
  88509. }
  88510. /**
  88511. * Class used to store any kind of animation
  88512. */
  88513. export class Animation {
  88514. /**Name of the animation */
  88515. name: string;
  88516. /**Property to animate */
  88517. targetProperty: string;
  88518. /**The frames per second of the animation */
  88519. framePerSecond: number;
  88520. /**The data type of the animation */
  88521. dataType: number;
  88522. /**The loop mode of the animation */
  88523. loopMode?: number | undefined;
  88524. /**Specifies if blending should be enabled */
  88525. enableBlending?: boolean | undefined;
  88526. /**
  88527. * Use matrix interpolation instead of using direct key value when animating matrices
  88528. */
  88529. static AllowMatricesInterpolation: boolean;
  88530. /**
  88531. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88532. */
  88533. static AllowMatrixDecomposeForInterpolation: boolean;
  88534. /**
  88535. * Stores the key frames of the animation
  88536. */
  88537. private _keys;
  88538. /**
  88539. * Stores the easing function of the animation
  88540. */
  88541. private _easingFunction;
  88542. /**
  88543. * @hidden Internal use only
  88544. */
  88545. _runtimeAnimations: RuntimeAnimation[];
  88546. /**
  88547. * The set of event that will be linked to this animation
  88548. */
  88549. private _events;
  88550. /**
  88551. * Stores an array of target property paths
  88552. */
  88553. targetPropertyPath: string[];
  88554. /**
  88555. * Stores the blending speed of the animation
  88556. */
  88557. blendingSpeed: number;
  88558. /**
  88559. * Stores the animation ranges for the animation
  88560. */
  88561. private _ranges;
  88562. /**
  88563. * @hidden Internal use
  88564. */
  88565. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88566. /**
  88567. * Sets up an animation
  88568. * @param property The property to animate
  88569. * @param animationType The animation type to apply
  88570. * @param framePerSecond The frames per second of the animation
  88571. * @param easingFunction The easing function used in the animation
  88572. * @returns The created animation
  88573. */
  88574. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88575. /**
  88576. * Create and start an animation on a node
  88577. * @param name defines the name of the global animation that will be run on all nodes
  88578. * @param node defines the root node where the animation will take place
  88579. * @param targetProperty defines property to animate
  88580. * @param framePerSecond defines the number of frame per second yo use
  88581. * @param totalFrame defines the number of frames in total
  88582. * @param from defines the initial value
  88583. * @param to defines the final value
  88584. * @param loopMode defines which loop mode you want to use (off by default)
  88585. * @param easingFunction defines the easing function to use (linear by default)
  88586. * @param onAnimationEnd defines the callback to call when animation end
  88587. * @returns the animatable created for this animation
  88588. */
  88589. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88590. /**
  88591. * Create and start an animation on a node and its descendants
  88592. * @param name defines the name of the global animation that will be run on all nodes
  88593. * @param node defines the root node where the animation will take place
  88594. * @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
  88595. * @param targetProperty defines property to animate
  88596. * @param framePerSecond defines the number of frame per second to use
  88597. * @param totalFrame defines the number of frames in total
  88598. * @param from defines the initial value
  88599. * @param to defines the final value
  88600. * @param loopMode defines which loop mode you want to use (off by default)
  88601. * @param easingFunction defines the easing function to use (linear by default)
  88602. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88603. * @returns the list of animatables created for all nodes
  88604. * @example https://www.babylonjs-playground.com/#MH0VLI
  88605. */
  88606. 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[]>;
  88607. /**
  88608. * Creates a new animation, merges it with the existing animations and starts it
  88609. * @param name Name of the animation
  88610. * @param node Node which contains the scene that begins the animations
  88611. * @param targetProperty Specifies which property to animate
  88612. * @param framePerSecond The frames per second of the animation
  88613. * @param totalFrame The total number of frames
  88614. * @param from The frame at the beginning of the animation
  88615. * @param to The frame at the end of the animation
  88616. * @param loopMode Specifies the loop mode of the animation
  88617. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88618. * @param onAnimationEnd Callback to run once the animation is complete
  88619. * @returns Nullable animation
  88620. */
  88621. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88622. /**
  88623. * Transition property of an host to the target Value
  88624. * @param property The property to transition
  88625. * @param targetValue The target Value of the property
  88626. * @param host The object where the property to animate belongs
  88627. * @param scene Scene used to run the animation
  88628. * @param frameRate Framerate (in frame/s) to use
  88629. * @param transition The transition type we want to use
  88630. * @param duration The duration of the animation, in milliseconds
  88631. * @param onAnimationEnd Callback trigger at the end of the animation
  88632. * @returns Nullable animation
  88633. */
  88634. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88635. /**
  88636. * Return the array of runtime animations currently using this animation
  88637. */
  88638. readonly runtimeAnimations: RuntimeAnimation[];
  88639. /**
  88640. * Specifies if any of the runtime animations are currently running
  88641. */
  88642. readonly hasRunningRuntimeAnimations: boolean;
  88643. /**
  88644. * Initializes the animation
  88645. * @param name Name of the animation
  88646. * @param targetProperty Property to animate
  88647. * @param framePerSecond The frames per second of the animation
  88648. * @param dataType The data type of the animation
  88649. * @param loopMode The loop mode of the animation
  88650. * @param enableBlending Specifies if blending should be enabled
  88651. */
  88652. constructor(
  88653. /**Name of the animation */
  88654. name: string,
  88655. /**Property to animate */
  88656. targetProperty: string,
  88657. /**The frames per second of the animation */
  88658. framePerSecond: number,
  88659. /**The data type of the animation */
  88660. dataType: number,
  88661. /**The loop mode of the animation */
  88662. loopMode?: number | undefined,
  88663. /**Specifies if blending should be enabled */
  88664. enableBlending?: boolean | undefined);
  88665. /**
  88666. * Converts the animation to a string
  88667. * @param fullDetails support for multiple levels of logging within scene loading
  88668. * @returns String form of the animation
  88669. */
  88670. toString(fullDetails?: boolean): string;
  88671. /**
  88672. * Add an event to this animation
  88673. * @param event Event to add
  88674. */
  88675. addEvent(event: AnimationEvent): void;
  88676. /**
  88677. * Remove all events found at the given frame
  88678. * @param frame The frame to remove events from
  88679. */
  88680. removeEvents(frame: number): void;
  88681. /**
  88682. * Retrieves all the events from the animation
  88683. * @returns Events from the animation
  88684. */
  88685. getEvents(): AnimationEvent[];
  88686. /**
  88687. * Creates an animation range
  88688. * @param name Name of the animation range
  88689. * @param from Starting frame of the animation range
  88690. * @param to Ending frame of the animation
  88691. */
  88692. createRange(name: string, from: number, to: number): void;
  88693. /**
  88694. * Deletes an animation range by name
  88695. * @param name Name of the animation range to delete
  88696. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88697. */
  88698. deleteRange(name: string, deleteFrames?: boolean): void;
  88699. /**
  88700. * Gets the animation range by name, or null if not defined
  88701. * @param name Name of the animation range
  88702. * @returns Nullable animation range
  88703. */
  88704. getRange(name: string): Nullable<AnimationRange>;
  88705. /**
  88706. * Gets the key frames from the animation
  88707. * @returns The key frames of the animation
  88708. */
  88709. getKeys(): Array<IAnimationKey>;
  88710. /**
  88711. * Gets the highest frame rate of the animation
  88712. * @returns Highest frame rate of the animation
  88713. */
  88714. getHighestFrame(): number;
  88715. /**
  88716. * Gets the easing function of the animation
  88717. * @returns Easing function of the animation
  88718. */
  88719. getEasingFunction(): IEasingFunction;
  88720. /**
  88721. * Sets the easing function of the animation
  88722. * @param easingFunction A custom mathematical formula for animation
  88723. */
  88724. setEasingFunction(easingFunction: EasingFunction): void;
  88725. /**
  88726. * Interpolates a scalar linearly
  88727. * @param startValue Start value of the animation curve
  88728. * @param endValue End value of the animation curve
  88729. * @param gradient Scalar amount to interpolate
  88730. * @returns Interpolated scalar value
  88731. */
  88732. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  88733. /**
  88734. * Interpolates a scalar cubically
  88735. * @param startValue Start value of the animation curve
  88736. * @param outTangent End tangent of the animation
  88737. * @param endValue End value of the animation curve
  88738. * @param inTangent Start tangent of the animation curve
  88739. * @param gradient Scalar amount to interpolate
  88740. * @returns Interpolated scalar value
  88741. */
  88742. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  88743. /**
  88744. * Interpolates a quaternion using a spherical linear interpolation
  88745. * @param startValue Start value of the animation curve
  88746. * @param endValue End value of the animation curve
  88747. * @param gradient Scalar amount to interpolate
  88748. * @returns Interpolated quaternion value
  88749. */
  88750. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  88751. /**
  88752. * Interpolates a quaternion cubically
  88753. * @param startValue Start value of the animation curve
  88754. * @param outTangent End tangent of the animation curve
  88755. * @param endValue End value of the animation curve
  88756. * @param inTangent Start tangent of the animation curve
  88757. * @param gradient Scalar amount to interpolate
  88758. * @returns Interpolated quaternion value
  88759. */
  88760. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  88761. /**
  88762. * Interpolates a Vector3 linearl
  88763. * @param startValue Start value of the animation curve
  88764. * @param endValue End value of the animation curve
  88765. * @param gradient Scalar amount to interpolate
  88766. * @returns Interpolated scalar value
  88767. */
  88768. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  88769. /**
  88770. * Interpolates a Vector3 cubically
  88771. * @param startValue Start value of the animation curve
  88772. * @param outTangent End tangent of the animation
  88773. * @param endValue End value of the animation curve
  88774. * @param inTangent Start tangent of the animation curve
  88775. * @param gradient Scalar amount to interpolate
  88776. * @returns InterpolatedVector3 value
  88777. */
  88778. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  88779. /**
  88780. * Interpolates a Vector2 linearly
  88781. * @param startValue Start value of the animation curve
  88782. * @param endValue End value of the animation curve
  88783. * @param gradient Scalar amount to interpolate
  88784. * @returns Interpolated Vector2 value
  88785. */
  88786. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  88787. /**
  88788. * Interpolates a Vector2 cubically
  88789. * @param startValue Start value of the animation curve
  88790. * @param outTangent End tangent of the animation
  88791. * @param endValue End value of the animation curve
  88792. * @param inTangent Start tangent of the animation curve
  88793. * @param gradient Scalar amount to interpolate
  88794. * @returns Interpolated Vector2 value
  88795. */
  88796. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  88797. /**
  88798. * Interpolates a size linearly
  88799. * @param startValue Start value of the animation curve
  88800. * @param endValue End value of the animation curve
  88801. * @param gradient Scalar amount to interpolate
  88802. * @returns Interpolated Size value
  88803. */
  88804. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  88805. /**
  88806. * Interpolates a Color3 linearly
  88807. * @param startValue Start value of the animation curve
  88808. * @param endValue End value of the animation curve
  88809. * @param gradient Scalar amount to interpolate
  88810. * @returns Interpolated Color3 value
  88811. */
  88812. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  88813. /**
  88814. * @hidden Internal use only
  88815. */
  88816. _getKeyValue(value: any): any;
  88817. /**
  88818. * @hidden Internal use only
  88819. */
  88820. _interpolate(currentFrame: number, state: _IAnimationState): any;
  88821. /**
  88822. * Defines the function to use to interpolate matrices
  88823. * @param startValue defines the start matrix
  88824. * @param endValue defines the end matrix
  88825. * @param gradient defines the gradient between both matrices
  88826. * @param result defines an optional target matrix where to store the interpolation
  88827. * @returns the interpolated matrix
  88828. */
  88829. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  88830. /**
  88831. * Makes a copy of the animation
  88832. * @returns Cloned animation
  88833. */
  88834. clone(): Animation;
  88835. /**
  88836. * Sets the key frames of the animation
  88837. * @param values The animation key frames to set
  88838. */
  88839. setKeys(values: Array<IAnimationKey>): void;
  88840. /**
  88841. * Serializes the animation to an object
  88842. * @returns Serialized object
  88843. */
  88844. serialize(): any;
  88845. /**
  88846. * Float animation type
  88847. */
  88848. private static _ANIMATIONTYPE_FLOAT;
  88849. /**
  88850. * Vector3 animation type
  88851. */
  88852. private static _ANIMATIONTYPE_VECTOR3;
  88853. /**
  88854. * Quaternion animation type
  88855. */
  88856. private static _ANIMATIONTYPE_QUATERNION;
  88857. /**
  88858. * Matrix animation type
  88859. */
  88860. private static _ANIMATIONTYPE_MATRIX;
  88861. /**
  88862. * Color3 animation type
  88863. */
  88864. private static _ANIMATIONTYPE_COLOR3;
  88865. /**
  88866. * Vector2 animation type
  88867. */
  88868. private static _ANIMATIONTYPE_VECTOR2;
  88869. /**
  88870. * Size animation type
  88871. */
  88872. private static _ANIMATIONTYPE_SIZE;
  88873. /**
  88874. * Relative Loop Mode
  88875. */
  88876. private static _ANIMATIONLOOPMODE_RELATIVE;
  88877. /**
  88878. * Cycle Loop Mode
  88879. */
  88880. private static _ANIMATIONLOOPMODE_CYCLE;
  88881. /**
  88882. * Constant Loop Mode
  88883. */
  88884. private static _ANIMATIONLOOPMODE_CONSTANT;
  88885. /**
  88886. * Get the float animation type
  88887. */
  88888. static readonly ANIMATIONTYPE_FLOAT: number;
  88889. /**
  88890. * Get the Vector3 animation type
  88891. */
  88892. static readonly ANIMATIONTYPE_VECTOR3: number;
  88893. /**
  88894. * Get the Vector2 animation type
  88895. */
  88896. static readonly ANIMATIONTYPE_VECTOR2: number;
  88897. /**
  88898. * Get the Size animation type
  88899. */
  88900. static readonly ANIMATIONTYPE_SIZE: number;
  88901. /**
  88902. * Get the Quaternion animation type
  88903. */
  88904. static readonly ANIMATIONTYPE_QUATERNION: number;
  88905. /**
  88906. * Get the Matrix animation type
  88907. */
  88908. static readonly ANIMATIONTYPE_MATRIX: number;
  88909. /**
  88910. * Get the Color3 animation type
  88911. */
  88912. static readonly ANIMATIONTYPE_COLOR3: number;
  88913. /**
  88914. * Get the Relative Loop Mode
  88915. */
  88916. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  88917. /**
  88918. * Get the Cycle Loop Mode
  88919. */
  88920. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  88921. /**
  88922. * Get the Constant Loop Mode
  88923. */
  88924. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  88925. /** @hidden */
  88926. static _UniversalLerp(left: any, right: any, amount: number): any;
  88927. /**
  88928. * Parses an animation object and creates an animation
  88929. * @param parsedAnimation Parsed animation object
  88930. * @returns Animation object
  88931. */
  88932. static Parse(parsedAnimation: any): Animation;
  88933. /**
  88934. * Appends the serialized animations from the source animations
  88935. * @param source Source containing the animations
  88936. * @param destination Target to store the animations
  88937. */
  88938. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88939. }
  88940. }
  88941. declare module BABYLON {
  88942. /**
  88943. * Base class of all the textures in babylon.
  88944. * It groups all the common properties the materials, post process, lights... might need
  88945. * in order to make a correct use of the texture.
  88946. */
  88947. export class BaseTexture implements IAnimatable {
  88948. /**
  88949. * Default anisotropic filtering level for the application.
  88950. * It is set to 4 as a good tradeoff between perf and quality.
  88951. */
  88952. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  88953. /**
  88954. * Gets or sets the unique id of the texture
  88955. */
  88956. uniqueId: number;
  88957. /**
  88958. * Define the name of the texture.
  88959. */
  88960. name: string;
  88961. /**
  88962. * Gets or sets an object used to store user defined information.
  88963. */
  88964. metadata: any;
  88965. /**
  88966. * For internal use only. Please do not use.
  88967. */
  88968. reservedDataStore: any;
  88969. private _hasAlpha;
  88970. /**
  88971. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  88972. */
  88973. hasAlpha: boolean;
  88974. /**
  88975. * Defines if the alpha value should be determined via the rgb values.
  88976. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  88977. */
  88978. getAlphaFromRGB: boolean;
  88979. /**
  88980. * Intensity or strength of the texture.
  88981. * It is commonly used by materials to fine tune the intensity of the texture
  88982. */
  88983. level: number;
  88984. /**
  88985. * Define the UV chanel to use starting from 0 and defaulting to 0.
  88986. * This is part of the texture as textures usually maps to one uv set.
  88987. */
  88988. coordinatesIndex: number;
  88989. private _coordinatesMode;
  88990. /**
  88991. * How a texture is mapped.
  88992. *
  88993. * | Value | Type | Description |
  88994. * | ----- | ----------------------------------- | ----------- |
  88995. * | 0 | EXPLICIT_MODE | |
  88996. * | 1 | SPHERICAL_MODE | |
  88997. * | 2 | PLANAR_MODE | |
  88998. * | 3 | CUBIC_MODE | |
  88999. * | 4 | PROJECTION_MODE | |
  89000. * | 5 | SKYBOX_MODE | |
  89001. * | 6 | INVCUBIC_MODE | |
  89002. * | 7 | EQUIRECTANGULAR_MODE | |
  89003. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  89004. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  89005. */
  89006. coordinatesMode: number;
  89007. /**
  89008. * | Value | Type | Description |
  89009. * | ----- | ------------------ | ----------- |
  89010. * | 0 | CLAMP_ADDRESSMODE | |
  89011. * | 1 | WRAP_ADDRESSMODE | |
  89012. * | 2 | MIRROR_ADDRESSMODE | |
  89013. */
  89014. wrapU: number;
  89015. /**
  89016. * | Value | Type | Description |
  89017. * | ----- | ------------------ | ----------- |
  89018. * | 0 | CLAMP_ADDRESSMODE | |
  89019. * | 1 | WRAP_ADDRESSMODE | |
  89020. * | 2 | MIRROR_ADDRESSMODE | |
  89021. */
  89022. wrapV: number;
  89023. /**
  89024. * | Value | Type | Description |
  89025. * | ----- | ------------------ | ----------- |
  89026. * | 0 | CLAMP_ADDRESSMODE | |
  89027. * | 1 | WRAP_ADDRESSMODE | |
  89028. * | 2 | MIRROR_ADDRESSMODE | |
  89029. */
  89030. wrapR: number;
  89031. /**
  89032. * With compliant hardware and browser (supporting anisotropic filtering)
  89033. * this defines the level of anisotropic filtering in the texture.
  89034. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  89035. */
  89036. anisotropicFilteringLevel: number;
  89037. /**
  89038. * Define if the texture is a cube texture or if false a 2d texture.
  89039. */
  89040. isCube: boolean;
  89041. /**
  89042. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  89043. */
  89044. is3D: boolean;
  89045. /**
  89046. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  89047. * HDR texture are usually stored in linear space.
  89048. * This only impacts the PBR and Background materials
  89049. */
  89050. gammaSpace: boolean;
  89051. /**
  89052. * Gets whether or not the texture contains RGBD data.
  89053. */
  89054. readonly isRGBD: boolean;
  89055. /**
  89056. * Is Z inverted in the texture (useful in a cube texture).
  89057. */
  89058. invertZ: boolean;
  89059. /**
  89060. * Are mip maps generated for this texture or not.
  89061. */
  89062. readonly noMipmap: boolean;
  89063. /**
  89064. * @hidden
  89065. */
  89066. lodLevelInAlpha: boolean;
  89067. /**
  89068. * With prefiltered texture, defined the offset used during the prefiltering steps.
  89069. */
  89070. lodGenerationOffset: number;
  89071. /**
  89072. * With prefiltered texture, defined the scale used during the prefiltering steps.
  89073. */
  89074. lodGenerationScale: number;
  89075. /**
  89076. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  89077. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  89078. * average roughness values.
  89079. */
  89080. linearSpecularLOD: boolean;
  89081. /**
  89082. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  89083. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  89084. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  89085. */
  89086. irradianceTexture: Nullable<BaseTexture>;
  89087. /**
  89088. * Define if the texture is a render target.
  89089. */
  89090. isRenderTarget: boolean;
  89091. /**
  89092. * Define the unique id of the texture in the scene.
  89093. */
  89094. readonly uid: string;
  89095. /**
  89096. * Return a string representation of the texture.
  89097. * @returns the texture as a string
  89098. */
  89099. toString(): string;
  89100. /**
  89101. * Get the class name of the texture.
  89102. * @returns "BaseTexture"
  89103. */
  89104. getClassName(): string;
  89105. /**
  89106. * Define the list of animation attached to the texture.
  89107. */
  89108. animations: Animation[];
  89109. /**
  89110. * An event triggered when the texture is disposed.
  89111. */
  89112. onDisposeObservable: Observable<BaseTexture>;
  89113. private _onDisposeObserver;
  89114. /**
  89115. * Callback triggered when the texture has been disposed.
  89116. * Kept for back compatibility, you can use the onDisposeObservable instead.
  89117. */
  89118. onDispose: () => void;
  89119. /**
  89120. * Define the current state of the loading sequence when in delayed load mode.
  89121. */
  89122. delayLoadState: number;
  89123. private _scene;
  89124. /** @hidden */
  89125. _texture: Nullable<InternalTexture>;
  89126. private _uid;
  89127. /**
  89128. * Define if the texture is preventinga material to render or not.
  89129. * If not and the texture is not ready, the engine will use a default black texture instead.
  89130. */
  89131. readonly isBlocking: boolean;
  89132. /**
  89133. * Instantiates a new BaseTexture.
  89134. * Base class of all the textures in babylon.
  89135. * It groups all the common properties the materials, post process, lights... might need
  89136. * in order to make a correct use of the texture.
  89137. * @param scene Define the scene the texture blongs to
  89138. */
  89139. constructor(scene: Nullable<Scene>);
  89140. /**
  89141. * Get the scene the texture belongs to.
  89142. * @returns the scene or null if undefined
  89143. */
  89144. getScene(): Nullable<Scene>;
  89145. /**
  89146. * Get the texture transform matrix used to offset tile the texture for istance.
  89147. * @returns the transformation matrix
  89148. */
  89149. getTextureMatrix(): Matrix;
  89150. /**
  89151. * Get the texture reflection matrix used to rotate/transform the reflection.
  89152. * @returns the reflection matrix
  89153. */
  89154. getReflectionTextureMatrix(): Matrix;
  89155. /**
  89156. * Get the underlying lower level texture from Babylon.
  89157. * @returns the insternal texture
  89158. */
  89159. getInternalTexture(): Nullable<InternalTexture>;
  89160. /**
  89161. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  89162. * @returns true if ready or not blocking
  89163. */
  89164. isReadyOrNotBlocking(): boolean;
  89165. /**
  89166. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  89167. * @returns true if fully ready
  89168. */
  89169. isReady(): boolean;
  89170. private _cachedSize;
  89171. /**
  89172. * Get the size of the texture.
  89173. * @returns the texture size.
  89174. */
  89175. getSize(): ISize;
  89176. /**
  89177. * Get the base size of the texture.
  89178. * It can be different from the size if the texture has been resized for POT for instance
  89179. * @returns the base size
  89180. */
  89181. getBaseSize(): ISize;
  89182. /**
  89183. * Update the sampling mode of the texture.
  89184. * Default is Trilinear mode.
  89185. *
  89186. * | Value | Type | Description |
  89187. * | ----- | ------------------ | ----------- |
  89188. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  89189. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  89190. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  89191. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  89192. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  89193. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  89194. * | 7 | NEAREST_LINEAR | |
  89195. * | 8 | NEAREST_NEAREST | |
  89196. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  89197. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  89198. * | 11 | LINEAR_LINEAR | |
  89199. * | 12 | LINEAR_NEAREST | |
  89200. *
  89201. * > _mag_: magnification filter (close to the viewer)
  89202. * > _min_: minification filter (far from the viewer)
  89203. * > _mip_: filter used between mip map levels
  89204. *@param samplingMode Define the new sampling mode of the texture
  89205. */
  89206. updateSamplingMode(samplingMode: number): void;
  89207. /**
  89208. * Scales the texture if is `canRescale()`
  89209. * @param ratio the resize factor we want to use to rescale
  89210. */
  89211. scale(ratio: number): void;
  89212. /**
  89213. * Get if the texture can rescale.
  89214. */
  89215. readonly canRescale: boolean;
  89216. /** @hidden */
  89217. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89218. /** @hidden */
  89219. _rebuild(): void;
  89220. /**
  89221. * Triggers the load sequence in delayed load mode.
  89222. */
  89223. delayLoad(): void;
  89224. /**
  89225. * Clones the texture.
  89226. * @returns the cloned texture
  89227. */
  89228. clone(): Nullable<BaseTexture>;
  89229. /**
  89230. * Get the texture underlying type (INT, FLOAT...)
  89231. */
  89232. readonly textureType: number;
  89233. /**
  89234. * Get the texture underlying format (RGB, RGBA...)
  89235. */
  89236. readonly textureFormat: number;
  89237. /**
  89238. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89239. * This will returns an RGBA array buffer containing either in values (0-255) or
  89240. * float values (0-1) depending of the underlying buffer type.
  89241. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89242. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89243. * @param buffer defines a user defined buffer to fill with data (can be null)
  89244. * @returns The Array buffer containing the pixels data.
  89245. */
  89246. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89247. /**
  89248. * Release and destroy the underlying lower level texture aka internalTexture.
  89249. */
  89250. releaseInternalTexture(): void;
  89251. /**
  89252. * Get the polynomial representation of the texture data.
  89253. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  89254. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  89255. */
  89256. sphericalPolynomial: Nullable<SphericalPolynomial>;
  89257. /** @hidden */
  89258. readonly _lodTextureHigh: Nullable<BaseTexture>;
  89259. /** @hidden */
  89260. readonly _lodTextureMid: Nullable<BaseTexture>;
  89261. /** @hidden */
  89262. readonly _lodTextureLow: Nullable<BaseTexture>;
  89263. /**
  89264. * Dispose the texture and release its associated resources.
  89265. */
  89266. dispose(): void;
  89267. /**
  89268. * Serialize the texture into a JSON representation that can be parsed later on.
  89269. * @returns the JSON representation of the texture
  89270. */
  89271. serialize(): any;
  89272. /**
  89273. * Helper function to be called back once a list of texture contains only ready textures.
  89274. * @param textures Define the list of textures to wait for
  89275. * @param callback Define the callback triggered once the entire list will be ready
  89276. */
  89277. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89278. }
  89279. }
  89280. declare module BABYLON {
  89281. /**
  89282. * Uniform buffer objects.
  89283. *
  89284. * Handles blocks of uniform on the GPU.
  89285. *
  89286. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89287. *
  89288. * For more information, please refer to :
  89289. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89290. */
  89291. export class UniformBuffer {
  89292. private _engine;
  89293. private _buffer;
  89294. private _data;
  89295. private _bufferData;
  89296. private _dynamic?;
  89297. private _uniformLocations;
  89298. private _uniformSizes;
  89299. private _uniformLocationPointer;
  89300. private _needSync;
  89301. private _noUBO;
  89302. private _currentEffect;
  89303. private static _MAX_UNIFORM_SIZE;
  89304. private static _tempBuffer;
  89305. /**
  89306. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89307. * This is dynamic to allow compat with webgl 1 and 2.
  89308. * You will need to pass the name of the uniform as well as the value.
  89309. */
  89310. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89311. /**
  89312. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89313. * This is dynamic to allow compat with webgl 1 and 2.
  89314. * You will need to pass the name of the uniform as well as the value.
  89315. */
  89316. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89317. /**
  89318. * Lambda to Update a single float in a uniform buffer.
  89319. * This is dynamic to allow compat with webgl 1 and 2.
  89320. * You will need to pass the name of the uniform as well as the value.
  89321. */
  89322. updateFloat: (name: string, x: number) => void;
  89323. /**
  89324. * Lambda to Update a vec2 of float in a uniform buffer.
  89325. * This is dynamic to allow compat with webgl 1 and 2.
  89326. * You will need to pass the name of the uniform as well as the value.
  89327. */
  89328. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89329. /**
  89330. * Lambda to Update a vec3 of float in a uniform buffer.
  89331. * This is dynamic to allow compat with webgl 1 and 2.
  89332. * You will need to pass the name of the uniform as well as the value.
  89333. */
  89334. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89335. /**
  89336. * Lambda to Update a vec4 of float in a uniform buffer.
  89337. * This is dynamic to allow compat with webgl 1 and 2.
  89338. * You will need to pass the name of the uniform as well as the value.
  89339. */
  89340. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89341. /**
  89342. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89343. * This is dynamic to allow compat with webgl 1 and 2.
  89344. * You will need to pass the name of the uniform as well as the value.
  89345. */
  89346. updateMatrix: (name: string, mat: Matrix) => void;
  89347. /**
  89348. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89349. * This is dynamic to allow compat with webgl 1 and 2.
  89350. * You will need to pass the name of the uniform as well as the value.
  89351. */
  89352. updateVector3: (name: string, vector: Vector3) => void;
  89353. /**
  89354. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89355. * This is dynamic to allow compat with webgl 1 and 2.
  89356. * You will need to pass the name of the uniform as well as the value.
  89357. */
  89358. updateVector4: (name: string, vector: Vector4) => void;
  89359. /**
  89360. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89361. * This is dynamic to allow compat with webgl 1 and 2.
  89362. * You will need to pass the name of the uniform as well as the value.
  89363. */
  89364. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89365. /**
  89366. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89367. * This is dynamic to allow compat with webgl 1 and 2.
  89368. * You will need to pass the name of the uniform as well as the value.
  89369. */
  89370. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89371. /**
  89372. * Instantiates a new Uniform buffer objects.
  89373. *
  89374. * Handles blocks of uniform on the GPU.
  89375. *
  89376. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89377. *
  89378. * For more information, please refer to :
  89379. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89380. * @param engine Define the engine the buffer is associated with
  89381. * @param data Define the data contained in the buffer
  89382. * @param dynamic Define if the buffer is updatable
  89383. */
  89384. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89385. /**
  89386. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89387. * or just falling back on setUniformXXX calls.
  89388. */
  89389. readonly useUbo: boolean;
  89390. /**
  89391. * Indicates if the WebGL underlying uniform buffer is in sync
  89392. * with the javascript cache data.
  89393. */
  89394. readonly isSync: boolean;
  89395. /**
  89396. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89397. * Also, a dynamic UniformBuffer will disable cache verification and always
  89398. * update the underlying WebGL uniform buffer to the GPU.
  89399. * @returns if Dynamic, otherwise false
  89400. */
  89401. isDynamic(): boolean;
  89402. /**
  89403. * The data cache on JS side.
  89404. * @returns the underlying data as a float array
  89405. */
  89406. getData(): Float32Array;
  89407. /**
  89408. * The underlying WebGL Uniform buffer.
  89409. * @returns the webgl buffer
  89410. */
  89411. getBuffer(): Nullable<DataBuffer>;
  89412. /**
  89413. * std140 layout specifies how to align data within an UBO structure.
  89414. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89415. * for specs.
  89416. */
  89417. private _fillAlignment;
  89418. /**
  89419. * Adds an uniform in the buffer.
  89420. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89421. * for the layout to be correct !
  89422. * @param name Name of the uniform, as used in the uniform block in the shader.
  89423. * @param size Data size, or data directly.
  89424. */
  89425. addUniform(name: string, size: number | number[]): void;
  89426. /**
  89427. * Adds a Matrix 4x4 to the uniform buffer.
  89428. * @param name Name of the uniform, as used in the uniform block in the shader.
  89429. * @param mat A 4x4 matrix.
  89430. */
  89431. addMatrix(name: string, mat: Matrix): void;
  89432. /**
  89433. * Adds a vec2 to the uniform buffer.
  89434. * @param name Name of the uniform, as used in the uniform block in the shader.
  89435. * @param x Define the x component value of the vec2
  89436. * @param y Define the y component value of the vec2
  89437. */
  89438. addFloat2(name: string, x: number, y: number): void;
  89439. /**
  89440. * Adds a vec3 to the uniform buffer.
  89441. * @param name Name of the uniform, as used in the uniform block in the shader.
  89442. * @param x Define the x component value of the vec3
  89443. * @param y Define the y component value of the vec3
  89444. * @param z Define the z component value of the vec3
  89445. */
  89446. addFloat3(name: string, x: number, y: number, z: number): void;
  89447. /**
  89448. * Adds a vec3 to the uniform buffer.
  89449. * @param name Name of the uniform, as used in the uniform block in the shader.
  89450. * @param color Define the vec3 from a Color
  89451. */
  89452. addColor3(name: string, color: Color3): void;
  89453. /**
  89454. * Adds a vec4 to the uniform buffer.
  89455. * @param name Name of the uniform, as used in the uniform block in the shader.
  89456. * @param color Define the rgb components from a Color
  89457. * @param alpha Define the a component of the vec4
  89458. */
  89459. addColor4(name: string, color: Color3, alpha: number): void;
  89460. /**
  89461. * Adds a vec3 to the uniform buffer.
  89462. * @param name Name of the uniform, as used in the uniform block in the shader.
  89463. * @param vector Define the vec3 components from a Vector
  89464. */
  89465. addVector3(name: string, vector: Vector3): void;
  89466. /**
  89467. * Adds a Matrix 3x3 to the uniform buffer.
  89468. * @param name Name of the uniform, as used in the uniform block in the shader.
  89469. */
  89470. addMatrix3x3(name: string): void;
  89471. /**
  89472. * Adds a Matrix 2x2 to the uniform buffer.
  89473. * @param name Name of the uniform, as used in the uniform block in the shader.
  89474. */
  89475. addMatrix2x2(name: string): void;
  89476. /**
  89477. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89478. */
  89479. create(): void;
  89480. /** @hidden */
  89481. _rebuild(): void;
  89482. /**
  89483. * Updates the WebGL Uniform Buffer on the GPU.
  89484. * If the `dynamic` flag is set to true, no cache comparison is done.
  89485. * Otherwise, the buffer will be updated only if the cache differs.
  89486. */
  89487. update(): void;
  89488. /**
  89489. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89490. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89491. * @param data Define the flattened data
  89492. * @param size Define the size of the data.
  89493. */
  89494. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89495. private _updateMatrix3x3ForUniform;
  89496. private _updateMatrix3x3ForEffect;
  89497. private _updateMatrix2x2ForEffect;
  89498. private _updateMatrix2x2ForUniform;
  89499. private _updateFloatForEffect;
  89500. private _updateFloatForUniform;
  89501. private _updateFloat2ForEffect;
  89502. private _updateFloat2ForUniform;
  89503. private _updateFloat3ForEffect;
  89504. private _updateFloat3ForUniform;
  89505. private _updateFloat4ForEffect;
  89506. private _updateFloat4ForUniform;
  89507. private _updateMatrixForEffect;
  89508. private _updateMatrixForUniform;
  89509. private _updateVector3ForEffect;
  89510. private _updateVector3ForUniform;
  89511. private _updateVector4ForEffect;
  89512. private _updateVector4ForUniform;
  89513. private _updateColor3ForEffect;
  89514. private _updateColor3ForUniform;
  89515. private _updateColor4ForEffect;
  89516. private _updateColor4ForUniform;
  89517. /**
  89518. * Sets a sampler uniform on the effect.
  89519. * @param name Define the name of the sampler.
  89520. * @param texture Define the texture to set in the sampler
  89521. */
  89522. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89523. /**
  89524. * Directly updates the value of the uniform in the cache AND on the GPU.
  89525. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89526. * @param data Define the flattened data
  89527. */
  89528. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89529. /**
  89530. * Binds this uniform buffer to an effect.
  89531. * @param effect Define the effect to bind the buffer to
  89532. * @param name Name of the uniform block in the shader.
  89533. */
  89534. bindToEffect(effect: Effect, name: string): void;
  89535. /**
  89536. * Disposes the uniform buffer.
  89537. */
  89538. dispose(): void;
  89539. }
  89540. }
  89541. declare module BABYLON {
  89542. /**
  89543. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89545. */
  89546. export class Analyser {
  89547. /**
  89548. * Gets or sets the smoothing
  89549. * @ignorenaming
  89550. */
  89551. SMOOTHING: number;
  89552. /**
  89553. * Gets or sets the FFT table size
  89554. * @ignorenaming
  89555. */
  89556. FFT_SIZE: number;
  89557. /**
  89558. * Gets or sets the bar graph amplitude
  89559. * @ignorenaming
  89560. */
  89561. BARGRAPHAMPLITUDE: number;
  89562. /**
  89563. * Gets or sets the position of the debug canvas
  89564. * @ignorenaming
  89565. */
  89566. DEBUGCANVASPOS: {
  89567. x: number;
  89568. y: number;
  89569. };
  89570. /**
  89571. * Gets or sets the debug canvas size
  89572. * @ignorenaming
  89573. */
  89574. DEBUGCANVASSIZE: {
  89575. width: number;
  89576. height: number;
  89577. };
  89578. private _byteFreqs;
  89579. private _byteTime;
  89580. private _floatFreqs;
  89581. private _webAudioAnalyser;
  89582. private _debugCanvas;
  89583. private _debugCanvasContext;
  89584. private _scene;
  89585. private _registerFunc;
  89586. private _audioEngine;
  89587. /**
  89588. * Creates a new analyser
  89589. * @param scene defines hosting scene
  89590. */
  89591. constructor(scene: Scene);
  89592. /**
  89593. * Get the number of data values you will have to play with for the visualization
  89594. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89595. * @returns a number
  89596. */
  89597. getFrequencyBinCount(): number;
  89598. /**
  89599. * Gets the current frequency data as a byte array
  89600. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89601. * @returns a Uint8Array
  89602. */
  89603. getByteFrequencyData(): Uint8Array;
  89604. /**
  89605. * Gets the current waveform as a byte array
  89606. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89607. * @returns a Uint8Array
  89608. */
  89609. getByteTimeDomainData(): Uint8Array;
  89610. /**
  89611. * Gets the current frequency data as a float array
  89612. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89613. * @returns a Float32Array
  89614. */
  89615. getFloatFrequencyData(): Float32Array;
  89616. /**
  89617. * Renders the debug canvas
  89618. */
  89619. drawDebugCanvas(): void;
  89620. /**
  89621. * Stops rendering the debug canvas and removes it
  89622. */
  89623. stopDebugCanvas(): void;
  89624. /**
  89625. * Connects two audio nodes
  89626. * @param inputAudioNode defines first node to connect
  89627. * @param outputAudioNode defines second node to connect
  89628. */
  89629. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89630. /**
  89631. * Releases all associated resources
  89632. */
  89633. dispose(): void;
  89634. }
  89635. }
  89636. declare module BABYLON {
  89637. /**
  89638. * This represents an audio engine and it is responsible
  89639. * to play, synchronize and analyse sounds throughout the application.
  89640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89641. */
  89642. export interface IAudioEngine extends IDisposable {
  89643. /**
  89644. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89645. */
  89646. readonly canUseWebAudio: boolean;
  89647. /**
  89648. * Gets the current AudioContext if available.
  89649. */
  89650. readonly audioContext: Nullable<AudioContext>;
  89651. /**
  89652. * The master gain node defines the global audio volume of your audio engine.
  89653. */
  89654. readonly masterGain: GainNode;
  89655. /**
  89656. * Gets whether or not mp3 are supported by your browser.
  89657. */
  89658. readonly isMP3supported: boolean;
  89659. /**
  89660. * Gets whether or not ogg are supported by your browser.
  89661. */
  89662. readonly isOGGsupported: boolean;
  89663. /**
  89664. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89665. * @ignoreNaming
  89666. */
  89667. WarnedWebAudioUnsupported: boolean;
  89668. /**
  89669. * Defines if the audio engine relies on a custom unlocked button.
  89670. * In this case, the embedded button will not be displayed.
  89671. */
  89672. useCustomUnlockedButton: boolean;
  89673. /**
  89674. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89675. */
  89676. readonly unlocked: boolean;
  89677. /**
  89678. * Event raised when audio has been unlocked on the browser.
  89679. */
  89680. onAudioUnlockedObservable: Observable<AudioEngine>;
  89681. /**
  89682. * Event raised when audio has been locked on the browser.
  89683. */
  89684. onAudioLockedObservable: Observable<AudioEngine>;
  89685. /**
  89686. * Flags the audio engine in Locked state.
  89687. * This happens due to new browser policies preventing audio to autoplay.
  89688. */
  89689. lock(): void;
  89690. /**
  89691. * Unlocks the audio engine once a user action has been done on the dom.
  89692. * This is helpful to resume play once browser policies have been satisfied.
  89693. */
  89694. unlock(): void;
  89695. }
  89696. /**
  89697. * This represents the default audio engine used in babylon.
  89698. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89700. */
  89701. export class AudioEngine implements IAudioEngine {
  89702. private _audioContext;
  89703. private _audioContextInitialized;
  89704. private _muteButton;
  89705. private _hostElement;
  89706. /**
  89707. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89708. */
  89709. canUseWebAudio: boolean;
  89710. /**
  89711. * The master gain node defines the global audio volume of your audio engine.
  89712. */
  89713. masterGain: GainNode;
  89714. /**
  89715. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89716. * @ignoreNaming
  89717. */
  89718. WarnedWebAudioUnsupported: boolean;
  89719. /**
  89720. * Gets whether or not mp3 are supported by your browser.
  89721. */
  89722. isMP3supported: boolean;
  89723. /**
  89724. * Gets whether or not ogg are supported by your browser.
  89725. */
  89726. isOGGsupported: boolean;
  89727. /**
  89728. * Gets whether audio has been unlocked on the device.
  89729. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  89730. * a user interaction has happened.
  89731. */
  89732. unlocked: boolean;
  89733. /**
  89734. * Defines if the audio engine relies on a custom unlocked button.
  89735. * In this case, the embedded button will not be displayed.
  89736. */
  89737. useCustomUnlockedButton: boolean;
  89738. /**
  89739. * Event raised when audio has been unlocked on the browser.
  89740. */
  89741. onAudioUnlockedObservable: Observable<AudioEngine>;
  89742. /**
  89743. * Event raised when audio has been locked on the browser.
  89744. */
  89745. onAudioLockedObservable: Observable<AudioEngine>;
  89746. /**
  89747. * Gets the current AudioContext if available.
  89748. */
  89749. readonly audioContext: Nullable<AudioContext>;
  89750. private _connectedAnalyser;
  89751. /**
  89752. * Instantiates a new audio engine.
  89753. *
  89754. * There should be only one per page as some browsers restrict the number
  89755. * of audio contexts you can create.
  89756. * @param hostElement defines the host element where to display the mute icon if necessary
  89757. */
  89758. constructor(hostElement?: Nullable<HTMLElement>);
  89759. /**
  89760. * Flags the audio engine in Locked state.
  89761. * This happens due to new browser policies preventing audio to autoplay.
  89762. */
  89763. lock(): void;
  89764. /**
  89765. * Unlocks the audio engine once a user action has been done on the dom.
  89766. * This is helpful to resume play once browser policies have been satisfied.
  89767. */
  89768. unlock(): void;
  89769. private _resumeAudioContext;
  89770. private _initializeAudioContext;
  89771. private _tryToRun;
  89772. private _triggerRunningState;
  89773. private _triggerSuspendedState;
  89774. private _displayMuteButton;
  89775. private _moveButtonToTopLeft;
  89776. private _onResize;
  89777. private _hideMuteButton;
  89778. /**
  89779. * Destroy and release the resources associated with the audio ccontext.
  89780. */
  89781. dispose(): void;
  89782. /**
  89783. * Gets the global volume sets on the master gain.
  89784. * @returns the global volume if set or -1 otherwise
  89785. */
  89786. getGlobalVolume(): number;
  89787. /**
  89788. * Sets the global volume of your experience (sets on the master gain).
  89789. * @param newVolume Defines the new global volume of the application
  89790. */
  89791. setGlobalVolume(newVolume: number): void;
  89792. /**
  89793. * Connect the audio engine to an audio analyser allowing some amazing
  89794. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89796. * @param analyser The analyser to connect to the engine
  89797. */
  89798. connectToAnalyser(analyser: Analyser): void;
  89799. }
  89800. }
  89801. declare module BABYLON {
  89802. /**
  89803. * Interface used to present a loading screen while loading a scene
  89804. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89805. */
  89806. export interface ILoadingScreen {
  89807. /**
  89808. * Function called to display the loading screen
  89809. */
  89810. displayLoadingUI: () => void;
  89811. /**
  89812. * Function called to hide the loading screen
  89813. */
  89814. hideLoadingUI: () => void;
  89815. /**
  89816. * Gets or sets the color to use for the background
  89817. */
  89818. loadingUIBackgroundColor: string;
  89819. /**
  89820. * Gets or sets the text to display while loading
  89821. */
  89822. loadingUIText: string;
  89823. }
  89824. /**
  89825. * Class used for the default loading screen
  89826. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89827. */
  89828. export class DefaultLoadingScreen implements ILoadingScreen {
  89829. private _renderingCanvas;
  89830. private _loadingText;
  89831. private _loadingDivBackgroundColor;
  89832. private _loadingDiv;
  89833. private _loadingTextDiv;
  89834. /** Gets or sets the logo url to use for the default loading screen */
  89835. static DefaultLogoUrl: string;
  89836. /** Gets or sets the spinner url to use for the default loading screen */
  89837. static DefaultSpinnerUrl: string;
  89838. /**
  89839. * Creates a new default loading screen
  89840. * @param _renderingCanvas defines the canvas used to render the scene
  89841. * @param _loadingText defines the default text to display
  89842. * @param _loadingDivBackgroundColor defines the default background color
  89843. */
  89844. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  89845. /**
  89846. * Function called to display the loading screen
  89847. */
  89848. displayLoadingUI(): void;
  89849. /**
  89850. * Function called to hide the loading screen
  89851. */
  89852. hideLoadingUI(): void;
  89853. /**
  89854. * Gets or sets the text to display while loading
  89855. */
  89856. loadingUIText: string;
  89857. /**
  89858. * Gets or sets the color to use for the background
  89859. */
  89860. loadingUIBackgroundColor: string;
  89861. private _resizeLoadingUI;
  89862. }
  89863. }
  89864. declare module BABYLON {
  89865. /** @hidden */
  89866. export class WebGLPipelineContext implements IPipelineContext {
  89867. engine: Engine;
  89868. program: Nullable<WebGLProgram>;
  89869. context?: WebGLRenderingContext;
  89870. vertexShader?: WebGLShader;
  89871. fragmentShader?: WebGLShader;
  89872. isParallelCompiled: boolean;
  89873. onCompiled?: () => void;
  89874. transformFeedback?: WebGLTransformFeedback | null;
  89875. readonly isAsync: boolean;
  89876. readonly isReady: boolean;
  89877. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89878. }
  89879. }
  89880. declare module BABYLON {
  89881. /** @hidden */
  89882. export class WebGLDataBuffer extends DataBuffer {
  89883. private _buffer;
  89884. constructor(resource: WebGLBuffer);
  89885. readonly underlyingResource: any;
  89886. }
  89887. }
  89888. declare module BABYLON {
  89889. /** @hidden */
  89890. export class WebGL2ShaderProcessor implements IShaderProcessor {
  89891. attributeProcessor(attribute: string): string;
  89892. varyingProcessor(varying: string, isFragment: boolean): string;
  89893. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  89894. }
  89895. }
  89896. declare module BABYLON {
  89897. /**
  89898. * Settings for finer control over video usage
  89899. */
  89900. export interface VideoTextureSettings {
  89901. /**
  89902. * Applies `autoplay` to video, if specified
  89903. */
  89904. autoPlay?: boolean;
  89905. /**
  89906. * Applies `loop` to video, if specified
  89907. */
  89908. loop?: boolean;
  89909. /**
  89910. * Automatically updates internal texture from video at every frame in the render loop
  89911. */
  89912. autoUpdateTexture: boolean;
  89913. /**
  89914. * Image src displayed during the video loading or until the user interacts with the video.
  89915. */
  89916. poster?: string;
  89917. }
  89918. /**
  89919. * If you want to display a video in your scene, this is the special texture for that.
  89920. * This special texture works similar to other textures, with the exception of a few parameters.
  89921. * @see https://doc.babylonjs.com/how_to/video_texture
  89922. */
  89923. export class VideoTexture extends Texture {
  89924. /**
  89925. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  89926. */
  89927. readonly autoUpdateTexture: boolean;
  89928. /**
  89929. * The video instance used by the texture internally
  89930. */
  89931. readonly video: HTMLVideoElement;
  89932. private _onUserActionRequestedObservable;
  89933. /**
  89934. * Event triggerd when a dom action is required by the user to play the video.
  89935. * This happens due to recent changes in browser policies preventing video to auto start.
  89936. */
  89937. readonly onUserActionRequestedObservable: Observable<Texture>;
  89938. private _generateMipMaps;
  89939. private _engine;
  89940. private _stillImageCaptured;
  89941. private _displayingPosterTexture;
  89942. private _settings;
  89943. private _createInternalTextureOnEvent;
  89944. /**
  89945. * Creates a video texture.
  89946. * If you want to display a video in your scene, this is the special texture for that.
  89947. * This special texture works similar to other textures, with the exception of a few parameters.
  89948. * @see https://doc.babylonjs.com/how_to/video_texture
  89949. * @param name optional name, will detect from video source, if not defined
  89950. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  89951. * @param scene is obviously the current scene.
  89952. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  89953. * @param invertY is false by default but can be used to invert video on Y axis
  89954. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  89955. * @param settings allows finer control over video usage
  89956. */
  89957. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  89958. private _getName;
  89959. private _getVideo;
  89960. private _createInternalTexture;
  89961. private reset;
  89962. /**
  89963. * @hidden Internal method to initiate `update`.
  89964. */
  89965. _rebuild(): void;
  89966. /**
  89967. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  89968. */
  89969. update(): void;
  89970. /**
  89971. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  89972. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  89973. */
  89974. updateTexture(isVisible: boolean): void;
  89975. protected _updateInternalTexture: () => void;
  89976. /**
  89977. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  89978. * @param url New url.
  89979. */
  89980. updateURL(url: string): void;
  89981. /**
  89982. * Dispose the texture and release its associated resources.
  89983. */
  89984. dispose(): void;
  89985. /**
  89986. * Creates a video texture straight from a stream.
  89987. * @param scene Define the scene the texture should be created in
  89988. * @param stream Define the stream the texture should be created from
  89989. * @returns The created video texture as a promise
  89990. */
  89991. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  89992. /**
  89993. * Creates a video texture straight from your WebCam video feed.
  89994. * @param scene Define the scene the texture should be created in
  89995. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89996. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89997. * @returns The created video texture as a promise
  89998. */
  89999. static CreateFromWebCamAsync(scene: Scene, constraints: {
  90000. minWidth: number;
  90001. maxWidth: number;
  90002. minHeight: number;
  90003. maxHeight: number;
  90004. deviceId: string;
  90005. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  90006. /**
  90007. * Creates a video texture straight from your WebCam video feed.
  90008. * @param scene Define the scene the texture should be created in
  90009. * @param onReady Define a callback to triggered once the texture will be ready
  90010. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  90011. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  90012. */
  90013. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  90014. minWidth: number;
  90015. maxWidth: number;
  90016. minHeight: number;
  90017. maxHeight: number;
  90018. deviceId: string;
  90019. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  90020. }
  90021. }
  90022. declare module BABYLON {
  90023. /**
  90024. * Interface for attribute information associated with buffer instanciation
  90025. */
  90026. export class InstancingAttributeInfo {
  90027. /**
  90028. * Index/offset of the attribute in the vertex shader
  90029. */
  90030. index: number;
  90031. /**
  90032. * size of the attribute, 1, 2, 3 or 4
  90033. */
  90034. attributeSize: number;
  90035. /**
  90036. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  90037. * default is FLOAT
  90038. */
  90039. attribyteType: number;
  90040. /**
  90041. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  90042. */
  90043. normalized: boolean;
  90044. /**
  90045. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  90046. */
  90047. offset: number;
  90048. /**
  90049. * Name of the GLSL attribute, for debugging purpose only
  90050. */
  90051. attributeName: string;
  90052. }
  90053. /**
  90054. * Define options used to create a depth texture
  90055. */
  90056. export class DepthTextureCreationOptions {
  90057. /** Specifies whether or not a stencil should be allocated in the texture */
  90058. generateStencil?: boolean;
  90059. /** Specifies whether or not bilinear filtering is enable on the texture */
  90060. bilinearFiltering?: boolean;
  90061. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  90062. comparisonFunction?: number;
  90063. /** Specifies if the created texture is a cube texture */
  90064. isCube?: boolean;
  90065. }
  90066. /**
  90067. * Class used to describe the capabilities of the engine relatively to the current browser
  90068. */
  90069. export class EngineCapabilities {
  90070. /** Maximum textures units per fragment shader */
  90071. maxTexturesImageUnits: number;
  90072. /** Maximum texture units per vertex shader */
  90073. maxVertexTextureImageUnits: number;
  90074. /** Maximum textures units in the entire pipeline */
  90075. maxCombinedTexturesImageUnits: number;
  90076. /** Maximum texture size */
  90077. maxTextureSize: number;
  90078. /** Maximum cube texture size */
  90079. maxCubemapTextureSize: number;
  90080. /** Maximum render texture size */
  90081. maxRenderTextureSize: number;
  90082. /** Maximum number of vertex attributes */
  90083. maxVertexAttribs: number;
  90084. /** Maximum number of varyings */
  90085. maxVaryingVectors: number;
  90086. /** Maximum number of uniforms per vertex shader */
  90087. maxVertexUniformVectors: number;
  90088. /** Maximum number of uniforms per fragment shader */
  90089. maxFragmentUniformVectors: number;
  90090. /** Defines if standard derivates (dx/dy) are supported */
  90091. standardDerivatives: boolean;
  90092. /** Defines if s3tc texture compression is supported */
  90093. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  90094. /** Defines if pvrtc texture compression is supported */
  90095. pvrtc: any;
  90096. /** Defines if etc1 texture compression is supported */
  90097. etc1: any;
  90098. /** Defines if etc2 texture compression is supported */
  90099. etc2: any;
  90100. /** Defines if astc texture compression is supported */
  90101. astc: any;
  90102. /** Defines if float textures are supported */
  90103. textureFloat: boolean;
  90104. /** Defines if vertex array objects are supported */
  90105. vertexArrayObject: boolean;
  90106. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  90107. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  90108. /** Gets the maximum level of anisotropy supported */
  90109. maxAnisotropy: number;
  90110. /** Defines if instancing is supported */
  90111. instancedArrays: boolean;
  90112. /** Defines if 32 bits indices are supported */
  90113. uintIndices: boolean;
  90114. /** Defines if high precision shaders are supported */
  90115. highPrecisionShaderSupported: boolean;
  90116. /** Defines if depth reading in the fragment shader is supported */
  90117. fragmentDepthSupported: boolean;
  90118. /** Defines if float texture linear filtering is supported*/
  90119. textureFloatLinearFiltering: boolean;
  90120. /** Defines if rendering to float textures is supported */
  90121. textureFloatRender: boolean;
  90122. /** Defines if half float textures are supported*/
  90123. textureHalfFloat: boolean;
  90124. /** Defines if half float texture linear filtering is supported*/
  90125. textureHalfFloatLinearFiltering: boolean;
  90126. /** Defines if rendering to half float textures is supported */
  90127. textureHalfFloatRender: boolean;
  90128. /** Defines if textureLOD shader command is supported */
  90129. textureLOD: boolean;
  90130. /** Defines if draw buffers extension is supported */
  90131. drawBuffersExtension: boolean;
  90132. /** Defines if depth textures are supported */
  90133. depthTextureExtension: boolean;
  90134. /** Defines if float color buffer are supported */
  90135. colorBufferFloat: boolean;
  90136. /** Gets disjoint timer query extension (null if not supported) */
  90137. timerQuery: EXT_disjoint_timer_query;
  90138. /** Defines if timestamp can be used with timer query */
  90139. canUseTimestampForTimerQuery: boolean;
  90140. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  90141. multiview: any;
  90142. /** Function used to let the system compiles shaders in background */
  90143. parallelShaderCompile: {
  90144. COMPLETION_STATUS_KHR: number;
  90145. };
  90146. }
  90147. /** Interface defining initialization parameters for Engine class */
  90148. export interface EngineOptions extends WebGLContextAttributes {
  90149. /**
  90150. * Defines if the engine should no exceed a specified device ratio
  90151. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  90152. */
  90153. limitDeviceRatio?: number;
  90154. /**
  90155. * Defines if webvr should be enabled automatically
  90156. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90157. */
  90158. autoEnableWebVR?: boolean;
  90159. /**
  90160. * Defines if webgl2 should be turned off even if supported
  90161. * @see http://doc.babylonjs.com/features/webgl2
  90162. */
  90163. disableWebGL2Support?: boolean;
  90164. /**
  90165. * Defines if webaudio should be initialized as well
  90166. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90167. */
  90168. audioEngine?: boolean;
  90169. /**
  90170. * Defines if animations should run using a deterministic lock step
  90171. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90172. */
  90173. deterministicLockstep?: boolean;
  90174. /** Defines the maximum steps to use with deterministic lock step mode */
  90175. lockstepMaxSteps?: number;
  90176. /**
  90177. * Defines that engine should ignore context lost events
  90178. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  90179. */
  90180. doNotHandleContextLost?: boolean;
  90181. /**
  90182. * Defines that engine should ignore modifying touch action attribute and style
  90183. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  90184. */
  90185. doNotHandleTouchAction?: boolean;
  90186. /**
  90187. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  90188. */
  90189. useHighPrecisionFloats?: boolean;
  90190. }
  90191. /**
  90192. * Defines the interface used by display changed events
  90193. */
  90194. export interface IDisplayChangedEventArgs {
  90195. /** Gets the vrDisplay object (if any) */
  90196. vrDisplay: Nullable<any>;
  90197. /** Gets a boolean indicating if webVR is supported */
  90198. vrSupported: boolean;
  90199. }
  90200. /**
  90201. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  90202. */
  90203. export class Engine {
  90204. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  90205. static ExceptionList: ({
  90206. key: string;
  90207. capture: string;
  90208. captureConstraint: number;
  90209. targets: string[];
  90210. } | {
  90211. key: string;
  90212. capture: null;
  90213. captureConstraint: null;
  90214. targets: string[];
  90215. })[];
  90216. /** Gets the list of created engines */
  90217. static readonly Instances: Engine[];
  90218. /**
  90219. * Gets the latest created engine
  90220. */
  90221. static readonly LastCreatedEngine: Nullable<Engine>;
  90222. /**
  90223. * Gets the latest created scene
  90224. */
  90225. static readonly LastCreatedScene: Nullable<Scene>;
  90226. /**
  90227. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  90228. * @param flag defines which part of the materials must be marked as dirty
  90229. * @param predicate defines a predicate used to filter which materials should be affected
  90230. */
  90231. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90232. /** @hidden */
  90233. static _TextureLoaders: IInternalTextureLoader[];
  90234. /** Defines that alpha blending is disabled */
  90235. static readonly ALPHA_DISABLE: number;
  90236. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  90237. static readonly ALPHA_ADD: number;
  90238. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  90239. static readonly ALPHA_COMBINE: number;
  90240. /** Defines that alpha blending to DEST - SRC * DEST */
  90241. static readonly ALPHA_SUBTRACT: number;
  90242. /** Defines that alpha blending to SRC * DEST */
  90243. static readonly ALPHA_MULTIPLY: number;
  90244. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  90245. static readonly ALPHA_MAXIMIZED: number;
  90246. /** Defines that alpha blending to SRC + DEST */
  90247. static readonly ALPHA_ONEONE: number;
  90248. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  90249. static readonly ALPHA_PREMULTIPLIED: number;
  90250. /**
  90251. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  90252. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  90253. */
  90254. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  90255. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  90256. static readonly ALPHA_INTERPOLATE: number;
  90257. /**
  90258. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  90259. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  90260. */
  90261. static readonly ALPHA_SCREENMODE: number;
  90262. /** Defines that the ressource is not delayed*/
  90263. static readonly DELAYLOADSTATE_NONE: number;
  90264. /** Defines that the ressource was successfully delay loaded */
  90265. static readonly DELAYLOADSTATE_LOADED: number;
  90266. /** Defines that the ressource is currently delay loading */
  90267. static readonly DELAYLOADSTATE_LOADING: number;
  90268. /** Defines that the ressource is delayed and has not started loading */
  90269. static readonly DELAYLOADSTATE_NOTLOADED: number;
  90270. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  90271. static readonly NEVER: number;
  90272. /** 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 */
  90273. static readonly ALWAYS: number;
  90274. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  90275. static readonly LESS: number;
  90276. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  90277. static readonly EQUAL: number;
  90278. /** 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 */
  90279. static readonly LEQUAL: number;
  90280. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  90281. static readonly GREATER: number;
  90282. /** 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 */
  90283. static readonly GEQUAL: number;
  90284. /** 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 */
  90285. static readonly NOTEQUAL: number;
  90286. /** Passed to stencilOperation to specify that stencil value must be kept */
  90287. static readonly KEEP: number;
  90288. /** Passed to stencilOperation to specify that stencil value must be replaced */
  90289. static readonly REPLACE: number;
  90290. /** Passed to stencilOperation to specify that stencil value must be incremented */
  90291. static readonly INCR: number;
  90292. /** Passed to stencilOperation to specify that stencil value must be decremented */
  90293. static readonly DECR: number;
  90294. /** Passed to stencilOperation to specify that stencil value must be inverted */
  90295. static readonly INVERT: number;
  90296. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  90297. static readonly INCR_WRAP: number;
  90298. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  90299. static readonly DECR_WRAP: number;
  90300. /** Texture is not repeating outside of 0..1 UVs */
  90301. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  90302. /** Texture is repeating outside of 0..1 UVs */
  90303. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  90304. /** Texture is repeating and mirrored */
  90305. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  90306. /** ALPHA */
  90307. static readonly TEXTUREFORMAT_ALPHA: number;
  90308. /** LUMINANCE */
  90309. static readonly TEXTUREFORMAT_LUMINANCE: number;
  90310. /** LUMINANCE_ALPHA */
  90311. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  90312. /** RGB */
  90313. static readonly TEXTUREFORMAT_RGB: number;
  90314. /** RGBA */
  90315. static readonly TEXTUREFORMAT_RGBA: number;
  90316. /** RED */
  90317. static readonly TEXTUREFORMAT_RED: number;
  90318. /** RED (2nd reference) */
  90319. static readonly TEXTUREFORMAT_R: number;
  90320. /** RG */
  90321. static readonly TEXTUREFORMAT_RG: number;
  90322. /** RED_INTEGER */
  90323. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  90324. /** RED_INTEGER (2nd reference) */
  90325. static readonly TEXTUREFORMAT_R_INTEGER: number;
  90326. /** RG_INTEGER */
  90327. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  90328. /** RGB_INTEGER */
  90329. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  90330. /** RGBA_INTEGER */
  90331. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  90332. /** UNSIGNED_BYTE */
  90333. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  90334. /** UNSIGNED_BYTE (2nd reference) */
  90335. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  90336. /** FLOAT */
  90337. static readonly TEXTURETYPE_FLOAT: number;
  90338. /** HALF_FLOAT */
  90339. static readonly TEXTURETYPE_HALF_FLOAT: number;
  90340. /** BYTE */
  90341. static readonly TEXTURETYPE_BYTE: number;
  90342. /** SHORT */
  90343. static readonly TEXTURETYPE_SHORT: number;
  90344. /** UNSIGNED_SHORT */
  90345. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  90346. /** INT */
  90347. static readonly TEXTURETYPE_INT: number;
  90348. /** UNSIGNED_INT */
  90349. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  90350. /** UNSIGNED_SHORT_4_4_4_4 */
  90351. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  90352. /** UNSIGNED_SHORT_5_5_5_1 */
  90353. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  90354. /** UNSIGNED_SHORT_5_6_5 */
  90355. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  90356. /** UNSIGNED_INT_2_10_10_10_REV */
  90357. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  90358. /** UNSIGNED_INT_24_8 */
  90359. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  90360. /** UNSIGNED_INT_10F_11F_11F_REV */
  90361. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  90362. /** UNSIGNED_INT_5_9_9_9_REV */
  90363. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  90364. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  90365. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  90366. /** nearest is mag = nearest and min = nearest and mip = linear */
  90367. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  90368. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90369. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  90370. /** Trilinear is mag = linear and min = linear and mip = linear */
  90371. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  90372. /** nearest is mag = nearest and min = nearest and mip = linear */
  90373. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  90374. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90375. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  90376. /** Trilinear is mag = linear and min = linear and mip = linear */
  90377. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  90378. /** mag = nearest and min = nearest and mip = nearest */
  90379. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  90380. /** mag = nearest and min = linear and mip = nearest */
  90381. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  90382. /** mag = nearest and min = linear and mip = linear */
  90383. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  90384. /** mag = nearest and min = linear and mip = none */
  90385. static readonly TEXTURE_NEAREST_LINEAR: number;
  90386. /** mag = nearest and min = nearest and mip = none */
  90387. static readonly TEXTURE_NEAREST_NEAREST: number;
  90388. /** mag = linear and min = nearest and mip = nearest */
  90389. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  90390. /** mag = linear and min = nearest and mip = linear */
  90391. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  90392. /** mag = linear and min = linear and mip = none */
  90393. static readonly TEXTURE_LINEAR_LINEAR: number;
  90394. /** mag = linear and min = nearest and mip = none */
  90395. static readonly TEXTURE_LINEAR_NEAREST: number;
  90396. /** Explicit coordinates mode */
  90397. static readonly TEXTURE_EXPLICIT_MODE: number;
  90398. /** Spherical coordinates mode */
  90399. static readonly TEXTURE_SPHERICAL_MODE: number;
  90400. /** Planar coordinates mode */
  90401. static readonly TEXTURE_PLANAR_MODE: number;
  90402. /** Cubic coordinates mode */
  90403. static readonly TEXTURE_CUBIC_MODE: number;
  90404. /** Projection coordinates mode */
  90405. static readonly TEXTURE_PROJECTION_MODE: number;
  90406. /** Skybox coordinates mode */
  90407. static readonly TEXTURE_SKYBOX_MODE: number;
  90408. /** Inverse Cubic coordinates mode */
  90409. static readonly TEXTURE_INVCUBIC_MODE: number;
  90410. /** Equirectangular coordinates mode */
  90411. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  90412. /** Equirectangular Fixed coordinates mode */
  90413. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  90414. /** Equirectangular Fixed Mirrored coordinates mode */
  90415. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  90416. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  90417. static readonly SCALEMODE_FLOOR: number;
  90418. /** Defines that texture rescaling will look for the nearest power of 2 size */
  90419. static readonly SCALEMODE_NEAREST: number;
  90420. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  90421. static readonly SCALEMODE_CEILING: number;
  90422. /**
  90423. * Returns the current npm package of the sdk
  90424. */
  90425. static readonly NpmPackage: string;
  90426. /**
  90427. * Returns the current version of the framework
  90428. */
  90429. static readonly Version: string;
  90430. /**
  90431. * Returns a string describing the current engine
  90432. */
  90433. readonly description: string;
  90434. /**
  90435. * Gets or sets the epsilon value used by collision engine
  90436. */
  90437. static CollisionsEpsilon: number;
  90438. /**
  90439. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  90440. */
  90441. static ShadersRepository: string;
  90442. /**
  90443. * Method called to create the default loading screen.
  90444. * This can be overriden in your own app.
  90445. * @param canvas The rendering canvas element
  90446. * @returns The loading screen
  90447. */
  90448. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  90449. /**
  90450. * Method called to create the default rescale post process on each engine.
  90451. */
  90452. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  90453. /** @hidden */
  90454. _shaderProcessor: IShaderProcessor;
  90455. /**
  90456. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  90457. */
  90458. forcePOTTextures: boolean;
  90459. /**
  90460. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  90461. */
  90462. isFullscreen: boolean;
  90463. /**
  90464. * Gets a boolean indicating if the pointer is currently locked
  90465. */
  90466. isPointerLock: boolean;
  90467. /**
  90468. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  90469. */
  90470. cullBackFaces: boolean;
  90471. /**
  90472. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  90473. */
  90474. renderEvenInBackground: boolean;
  90475. /**
  90476. * Gets or sets a boolean indicating that cache can be kept between frames
  90477. */
  90478. preventCacheWipeBetweenFrames: boolean;
  90479. /**
  90480. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90481. **/
  90482. enableOfflineSupport: boolean;
  90483. /**
  90484. * 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)
  90485. **/
  90486. disableManifestCheck: boolean;
  90487. /**
  90488. * Gets the list of created scenes
  90489. */
  90490. scenes: Scene[];
  90491. /**
  90492. * Event raised when a new scene is created
  90493. */
  90494. onNewSceneAddedObservable: Observable<Scene>;
  90495. /**
  90496. * Gets the list of created postprocesses
  90497. */
  90498. postProcesses: PostProcess[];
  90499. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90500. validateShaderPrograms: boolean;
  90501. /**
  90502. * Observable event triggered each time the rendering canvas is resized
  90503. */
  90504. onResizeObservable: Observable<Engine>;
  90505. /**
  90506. * Observable event triggered each time the canvas loses focus
  90507. */
  90508. onCanvasBlurObservable: Observable<Engine>;
  90509. /**
  90510. * Observable event triggered each time the canvas gains focus
  90511. */
  90512. onCanvasFocusObservable: Observable<Engine>;
  90513. /**
  90514. * Observable event triggered each time the canvas receives pointerout event
  90515. */
  90516. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90517. /**
  90518. * Observable event triggered before each texture is initialized
  90519. */
  90520. onBeforeTextureInitObservable: Observable<Texture>;
  90521. /**
  90522. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90523. */
  90524. disableUniformBuffers: boolean;
  90525. /** @hidden */
  90526. _uniformBuffers: UniformBuffer[];
  90527. /**
  90528. * Gets a boolean indicating that the engine supports uniform buffers
  90529. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90530. */
  90531. readonly supportsUniformBuffers: boolean;
  90532. /**
  90533. * Observable raised when the engine begins a new frame
  90534. */
  90535. onBeginFrameObservable: Observable<Engine>;
  90536. /**
  90537. * If set, will be used to request the next animation frame for the render loop
  90538. */
  90539. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90540. /**
  90541. * Observable raised when the engine ends the current frame
  90542. */
  90543. onEndFrameObservable: Observable<Engine>;
  90544. /**
  90545. * Observable raised when the engine is about to compile a shader
  90546. */
  90547. onBeforeShaderCompilationObservable: Observable<Engine>;
  90548. /**
  90549. * Observable raised when the engine has jsut compiled a shader
  90550. */
  90551. onAfterShaderCompilationObservable: Observable<Engine>;
  90552. /** @hidden */
  90553. _gl: WebGLRenderingContext;
  90554. private _renderingCanvas;
  90555. private _windowIsBackground;
  90556. private _webGLVersion;
  90557. protected _highPrecisionShadersAllowed: boolean;
  90558. /** @hidden */
  90559. readonly _shouldUseHighPrecisionShader: boolean;
  90560. /**
  90561. * Gets a boolean indicating that only power of 2 textures are supported
  90562. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90563. */
  90564. readonly needPOTTextures: boolean;
  90565. /** @hidden */
  90566. _badOS: boolean;
  90567. /** @hidden */
  90568. _badDesktopOS: boolean;
  90569. /**
  90570. * Gets the audio engine
  90571. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90572. * @ignorenaming
  90573. */
  90574. static audioEngine: IAudioEngine;
  90575. /**
  90576. * Default AudioEngine factory responsible of creating the Audio Engine.
  90577. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90578. */
  90579. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90580. /**
  90581. * Default offline support factory responsible of creating a tool used to store data locally.
  90582. * By default, this will create a Database object if the workload has been embedded.
  90583. */
  90584. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90585. private _onFocus;
  90586. private _onBlur;
  90587. private _onCanvasPointerOut;
  90588. private _onCanvasBlur;
  90589. private _onCanvasFocus;
  90590. private _onFullscreenChange;
  90591. private _onPointerLockChange;
  90592. private _hardwareScalingLevel;
  90593. /** @hidden */
  90594. _caps: EngineCapabilities;
  90595. private _pointerLockRequested;
  90596. private _isStencilEnable;
  90597. private _colorWrite;
  90598. private _loadingScreen;
  90599. /** @hidden */
  90600. _drawCalls: PerfCounter;
  90601. private _glVersion;
  90602. private _glRenderer;
  90603. private _glVendor;
  90604. private _videoTextureSupported;
  90605. private _renderingQueueLaunched;
  90606. private _activeRenderLoops;
  90607. private _deterministicLockstep;
  90608. private _lockstepMaxSteps;
  90609. /**
  90610. * Observable signaled when a context lost event is raised
  90611. */
  90612. onContextLostObservable: Observable<Engine>;
  90613. /**
  90614. * Observable signaled when a context restored event is raised
  90615. */
  90616. onContextRestoredObservable: Observable<Engine>;
  90617. private _onContextLost;
  90618. private _onContextRestored;
  90619. private _contextWasLost;
  90620. /** @hidden */
  90621. _doNotHandleContextLost: boolean;
  90622. /**
  90623. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90624. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90625. */
  90626. doNotHandleContextLost: boolean;
  90627. private _performanceMonitor;
  90628. private _fps;
  90629. private _deltaTime;
  90630. /**
  90631. * Turn this value on if you want to pause FPS computation when in background
  90632. */
  90633. disablePerformanceMonitorInBackground: boolean;
  90634. /**
  90635. * Gets the performance monitor attached to this engine
  90636. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90637. */
  90638. readonly performanceMonitor: PerformanceMonitor;
  90639. /**
  90640. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90641. */
  90642. disableVertexArrayObjects: boolean;
  90643. /** @hidden */
  90644. protected _depthCullingState: _DepthCullingState;
  90645. /** @hidden */
  90646. protected _stencilState: _StencilState;
  90647. /** @hidden */
  90648. protected _alphaState: _AlphaState;
  90649. /** @hidden */
  90650. protected _alphaMode: number;
  90651. /** @hidden */
  90652. _internalTexturesCache: InternalTexture[];
  90653. /** @hidden */
  90654. protected _activeChannel: number;
  90655. private _currentTextureChannel;
  90656. /** @hidden */
  90657. protected _boundTexturesCache: {
  90658. [key: string]: Nullable<InternalTexture>;
  90659. };
  90660. /** @hidden */
  90661. protected _currentEffect: Nullable<Effect>;
  90662. /** @hidden */
  90663. protected _currentProgram: Nullable<WebGLProgram>;
  90664. private _compiledEffects;
  90665. private _vertexAttribArraysEnabled;
  90666. /** @hidden */
  90667. protected _cachedViewport: Nullable<Viewport>;
  90668. private _cachedVertexArrayObject;
  90669. /** @hidden */
  90670. protected _cachedVertexBuffers: any;
  90671. /** @hidden */
  90672. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90673. /** @hidden */
  90674. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90675. /** @hidden */
  90676. _currentRenderTarget: Nullable<InternalTexture>;
  90677. private _uintIndicesCurrentlySet;
  90678. private _currentBoundBuffer;
  90679. /** @hidden */
  90680. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90681. private _currentBufferPointers;
  90682. private _currentInstanceLocations;
  90683. private _currentInstanceBuffers;
  90684. private _textureUnits;
  90685. /** @hidden */
  90686. _workingCanvas: Nullable<HTMLCanvasElement>;
  90687. /** @hidden */
  90688. _workingContext: Nullable<CanvasRenderingContext2D>;
  90689. private _rescalePostProcess;
  90690. private _dummyFramebuffer;
  90691. private _externalData;
  90692. /** @hidden */
  90693. _bindedRenderFunction: any;
  90694. private _vaoRecordInProgress;
  90695. private _mustWipeVertexAttributes;
  90696. private _emptyTexture;
  90697. private _emptyCubeTexture;
  90698. private _emptyTexture3D;
  90699. /** @hidden */
  90700. _frameHandler: number;
  90701. private _nextFreeTextureSlots;
  90702. private _maxSimultaneousTextures;
  90703. private _activeRequests;
  90704. private _texturesSupported;
  90705. /** @hidden */
  90706. _textureFormatInUse: Nullable<string>;
  90707. /**
  90708. * Gets the list of texture formats supported
  90709. */
  90710. readonly texturesSupported: Array<string>;
  90711. /**
  90712. * Gets the list of texture formats in use
  90713. */
  90714. readonly textureFormatInUse: Nullable<string>;
  90715. /**
  90716. * Gets the current viewport
  90717. */
  90718. readonly currentViewport: Nullable<Viewport>;
  90719. /**
  90720. * Gets the default empty texture
  90721. */
  90722. readonly emptyTexture: InternalTexture;
  90723. /**
  90724. * Gets the default empty 3D texture
  90725. */
  90726. readonly emptyTexture3D: InternalTexture;
  90727. /**
  90728. * Gets the default empty cube texture
  90729. */
  90730. readonly emptyCubeTexture: InternalTexture;
  90731. /**
  90732. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  90733. */
  90734. readonly premultipliedAlpha: boolean;
  90735. /**
  90736. * Creates a new engine
  90737. * @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
  90738. * @param antialias defines enable antialiasing (default: false)
  90739. * @param options defines further options to be sent to the getContext() function
  90740. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  90741. */
  90742. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  90743. /**
  90744. * Initializes a webVR display and starts listening to display change events
  90745. * The onVRDisplayChangedObservable will be notified upon these changes
  90746. * @returns The onVRDisplayChangedObservable
  90747. */
  90748. initWebVR(): Observable<IDisplayChangedEventArgs>;
  90749. /** @hidden */
  90750. _prepareVRComponent(): void;
  90751. /** @hidden */
  90752. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  90753. /** @hidden */
  90754. _submitVRFrame(): void;
  90755. /**
  90756. * Call this function to leave webVR mode
  90757. * Will do nothing if webVR is not supported or if there is no webVR device
  90758. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90759. */
  90760. disableVR(): void;
  90761. /**
  90762. * Gets a boolean indicating that the system is in VR mode and is presenting
  90763. * @returns true if VR mode is engaged
  90764. */
  90765. isVRPresenting(): boolean;
  90766. /** @hidden */
  90767. _requestVRFrame(): void;
  90768. private _disableTouchAction;
  90769. private _rebuildInternalTextures;
  90770. private _rebuildEffects;
  90771. /**
  90772. * Gets a boolean indicating if all created effects are ready
  90773. * @returns true if all effects are ready
  90774. */
  90775. areAllEffectsReady(): boolean;
  90776. private _rebuildBuffers;
  90777. private _initGLContext;
  90778. /**
  90779. * Gets version of the current webGL context
  90780. */
  90781. readonly webGLVersion: number;
  90782. /**
  90783. * Gets a string idenfifying the name of the class
  90784. * @returns "Engine" string
  90785. */
  90786. getClassName(): string;
  90787. /**
  90788. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  90789. */
  90790. readonly isStencilEnable: boolean;
  90791. /** @hidden */
  90792. _prepareWorkingCanvas(): void;
  90793. /**
  90794. * Reset the texture cache to empty state
  90795. */
  90796. resetTextureCache(): void;
  90797. /**
  90798. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  90799. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90800. * @returns true if engine is in deterministic lock step mode
  90801. */
  90802. isDeterministicLockStep(): boolean;
  90803. /**
  90804. * Gets the max steps when engine is running in deterministic lock step
  90805. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90806. * @returns the max steps
  90807. */
  90808. getLockstepMaxSteps(): number;
  90809. /**
  90810. * Gets an object containing information about the current webGL context
  90811. * @returns an object containing the vender, the renderer and the version of the current webGL context
  90812. */
  90813. getGlInfo(): {
  90814. vendor: string;
  90815. renderer: string;
  90816. version: string;
  90817. };
  90818. /**
  90819. * Gets current aspect ratio
  90820. * @param camera defines the camera to use to get the aspect ratio
  90821. * @param useScreen defines if screen size must be used (or the current render target if any)
  90822. * @returns a number defining the aspect ratio
  90823. */
  90824. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  90825. /**
  90826. * Gets current screen aspect ratio
  90827. * @returns a number defining the aspect ratio
  90828. */
  90829. getScreenAspectRatio(): number;
  90830. /**
  90831. * Gets the current render width
  90832. * @param useScreen defines if screen size must be used (or the current render target if any)
  90833. * @returns a number defining the current render width
  90834. */
  90835. getRenderWidth(useScreen?: boolean): number;
  90836. /**
  90837. * Gets the current render height
  90838. * @param useScreen defines if screen size must be used (or the current render target if any)
  90839. * @returns a number defining the current render height
  90840. */
  90841. getRenderHeight(useScreen?: boolean): number;
  90842. /**
  90843. * Gets the HTML canvas attached with the current webGL context
  90844. * @returns a HTML canvas
  90845. */
  90846. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  90847. /**
  90848. * Gets the client rect of the HTML canvas attached with the current webGL context
  90849. * @returns a client rectanglee
  90850. */
  90851. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  90852. /**
  90853. * Defines the hardware scaling level.
  90854. * By default the hardware scaling level is computed from the window device ratio.
  90855. * 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.
  90856. * @param level defines the level to use
  90857. */
  90858. setHardwareScalingLevel(level: number): void;
  90859. /**
  90860. * Gets the current hardware scaling level.
  90861. * By default the hardware scaling level is computed from the window device ratio.
  90862. * 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.
  90863. * @returns a number indicating the current hardware scaling level
  90864. */
  90865. getHardwareScalingLevel(): number;
  90866. /**
  90867. * Gets the list of loaded textures
  90868. * @returns an array containing all loaded textures
  90869. */
  90870. getLoadedTexturesCache(): InternalTexture[];
  90871. /**
  90872. * Gets the object containing all engine capabilities
  90873. * @returns the EngineCapabilities object
  90874. */
  90875. getCaps(): EngineCapabilities;
  90876. /**
  90877. * Gets the current depth function
  90878. * @returns a number defining the depth function
  90879. */
  90880. getDepthFunction(): Nullable<number>;
  90881. /**
  90882. * Sets the current depth function
  90883. * @param depthFunc defines the function to use
  90884. */
  90885. setDepthFunction(depthFunc: number): void;
  90886. /**
  90887. * Sets the current depth function to GREATER
  90888. */
  90889. setDepthFunctionToGreater(): void;
  90890. /**
  90891. * Sets the current depth function to GEQUAL
  90892. */
  90893. setDepthFunctionToGreaterOrEqual(): void;
  90894. /**
  90895. * Sets the current depth function to LESS
  90896. */
  90897. setDepthFunctionToLess(): void;
  90898. private _cachedStencilBuffer;
  90899. private _cachedStencilFunction;
  90900. private _cachedStencilMask;
  90901. private _cachedStencilOperationPass;
  90902. private _cachedStencilOperationFail;
  90903. private _cachedStencilOperationDepthFail;
  90904. private _cachedStencilReference;
  90905. /**
  90906. * Caches the the state of the stencil buffer
  90907. */
  90908. cacheStencilState(): void;
  90909. /**
  90910. * Restores the state of the stencil buffer
  90911. */
  90912. restoreStencilState(): void;
  90913. /**
  90914. * Sets the current depth function to LEQUAL
  90915. */
  90916. setDepthFunctionToLessOrEqual(): void;
  90917. /**
  90918. * Gets a boolean indicating if stencil buffer is enabled
  90919. * @returns the current stencil buffer state
  90920. */
  90921. getStencilBuffer(): boolean;
  90922. /**
  90923. * Enable or disable the stencil buffer
  90924. * @param enable defines if the stencil buffer must be enabled or disabled
  90925. */
  90926. setStencilBuffer(enable: boolean): void;
  90927. /**
  90928. * Gets the current stencil mask
  90929. * @returns a number defining the new stencil mask to use
  90930. */
  90931. getStencilMask(): number;
  90932. /**
  90933. * Sets the current stencil mask
  90934. * @param mask defines the new stencil mask to use
  90935. */
  90936. setStencilMask(mask: number): void;
  90937. /**
  90938. * Gets the current stencil function
  90939. * @returns a number defining the stencil function to use
  90940. */
  90941. getStencilFunction(): number;
  90942. /**
  90943. * Gets the current stencil reference value
  90944. * @returns a number defining the stencil reference value to use
  90945. */
  90946. getStencilFunctionReference(): number;
  90947. /**
  90948. * Gets the current stencil mask
  90949. * @returns a number defining the stencil mask to use
  90950. */
  90951. getStencilFunctionMask(): number;
  90952. /**
  90953. * Sets the current stencil function
  90954. * @param stencilFunc defines the new stencil function to use
  90955. */
  90956. setStencilFunction(stencilFunc: number): void;
  90957. /**
  90958. * Sets the current stencil reference
  90959. * @param reference defines the new stencil reference to use
  90960. */
  90961. setStencilFunctionReference(reference: number): void;
  90962. /**
  90963. * Sets the current stencil mask
  90964. * @param mask defines the new stencil mask to use
  90965. */
  90966. setStencilFunctionMask(mask: number): void;
  90967. /**
  90968. * Gets the current stencil operation when stencil fails
  90969. * @returns a number defining stencil operation to use when stencil fails
  90970. */
  90971. getStencilOperationFail(): number;
  90972. /**
  90973. * Gets the current stencil operation when depth fails
  90974. * @returns a number defining stencil operation to use when depth fails
  90975. */
  90976. getStencilOperationDepthFail(): number;
  90977. /**
  90978. * Gets the current stencil operation when stencil passes
  90979. * @returns a number defining stencil operation to use when stencil passes
  90980. */
  90981. getStencilOperationPass(): number;
  90982. /**
  90983. * Sets the stencil operation to use when stencil fails
  90984. * @param operation defines the stencil operation to use when stencil fails
  90985. */
  90986. setStencilOperationFail(operation: number): void;
  90987. /**
  90988. * Sets the stencil operation to use when depth fails
  90989. * @param operation defines the stencil operation to use when depth fails
  90990. */
  90991. setStencilOperationDepthFail(operation: number): void;
  90992. /**
  90993. * Sets the stencil operation to use when stencil passes
  90994. * @param operation defines the stencil operation to use when stencil passes
  90995. */
  90996. setStencilOperationPass(operation: number): void;
  90997. /**
  90998. * Sets a boolean indicating if the dithering state is enabled or disabled
  90999. * @param value defines the dithering state
  91000. */
  91001. setDitheringState(value: boolean): void;
  91002. /**
  91003. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  91004. * @param value defines the rasterizer state
  91005. */
  91006. setRasterizerState(value: boolean): void;
  91007. /**
  91008. * stop executing a render loop function and remove it from the execution array
  91009. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  91010. */
  91011. stopRenderLoop(renderFunction?: () => void): void;
  91012. /** @hidden */
  91013. _renderLoop(): void;
  91014. /**
  91015. * Register and execute a render loop. The engine can have more than one render function
  91016. * @param renderFunction defines the function to continuously execute
  91017. */
  91018. runRenderLoop(renderFunction: () => void): void;
  91019. /**
  91020. * Toggle full screen mode
  91021. * @param requestPointerLock defines if a pointer lock should be requested from the user
  91022. */
  91023. switchFullscreen(requestPointerLock: boolean): void;
  91024. /**
  91025. * Enters full screen mode
  91026. * @param requestPointerLock defines if a pointer lock should be requested from the user
  91027. */
  91028. enterFullscreen(requestPointerLock: boolean): void;
  91029. /**
  91030. * Exits full screen mode
  91031. */
  91032. exitFullscreen(): void;
  91033. /**
  91034. * Enters Pointerlock mode
  91035. */
  91036. enterPointerlock(): void;
  91037. /**
  91038. * Exits Pointerlock mode
  91039. */
  91040. exitPointerlock(): void;
  91041. /**
  91042. * Clear the current render buffer or the current render target (if any is set up)
  91043. * @param color defines the color to use
  91044. * @param backBuffer defines if the back buffer must be cleared
  91045. * @param depth defines if the depth buffer must be cleared
  91046. * @param stencil defines if the stencil buffer must be cleared
  91047. */
  91048. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  91049. /**
  91050. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  91051. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  91052. * @param y defines the y-coordinate of the corner of the clear rectangle
  91053. * @param width defines the width of the clear rectangle
  91054. * @param height defines the height of the clear rectangle
  91055. * @param clearColor defines the clear color
  91056. */
  91057. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  91058. /**
  91059. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  91060. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  91061. * @param y defines the y-coordinate of the corner of the clear rectangle
  91062. * @param width defines the width of the clear rectangle
  91063. * @param height defines the height of the clear rectangle
  91064. */
  91065. enableScissor(x: number, y: number, width: number, height: number): void;
  91066. /**
  91067. * Disable previously set scissor test rectangle
  91068. */
  91069. disableScissor(): void;
  91070. private _viewportCached;
  91071. /** @hidden */
  91072. _viewport(x: number, y: number, width: number, height: number): void;
  91073. /**
  91074. * Set the WebGL's viewport
  91075. * @param viewport defines the viewport element to be used
  91076. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  91077. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  91078. */
  91079. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  91080. /**
  91081. * Directly set the WebGL Viewport
  91082. * @param x defines the x coordinate of the viewport (in screen space)
  91083. * @param y defines the y coordinate of the viewport (in screen space)
  91084. * @param width defines the width of the viewport (in screen space)
  91085. * @param height defines the height of the viewport (in screen space)
  91086. * @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
  91087. */
  91088. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  91089. /**
  91090. * Begin a new frame
  91091. */
  91092. beginFrame(): void;
  91093. /**
  91094. * Enf the current frame
  91095. */
  91096. endFrame(): void;
  91097. /**
  91098. * Resize the view according to the canvas' size
  91099. */
  91100. resize(): void;
  91101. /**
  91102. * Force a specific size of the canvas
  91103. * @param width defines the new canvas' width
  91104. * @param height defines the new canvas' height
  91105. */
  91106. setSize(width: number, height: number): void;
  91107. /**
  91108. * Binds the frame buffer to the specified texture.
  91109. * @param texture The texture to render to or null for the default canvas
  91110. * @param faceIndex The face of the texture to render to in case of cube texture
  91111. * @param requiredWidth The width of the target to render to
  91112. * @param requiredHeight The height of the target to render to
  91113. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  91114. * @param depthStencilTexture The depth stencil texture to use to render
  91115. * @param lodLevel defines le lod level to bind to the frame buffer
  91116. */
  91117. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  91118. /** @hidden */
  91119. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  91120. /**
  91121. * Unbind the current render target texture from the webGL context
  91122. * @param texture defines the render target texture to unbind
  91123. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  91124. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  91125. */
  91126. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  91127. /**
  91128. * Force the mipmap generation for the given render target texture
  91129. * @param texture defines the render target texture to use
  91130. */
  91131. generateMipMapsForCubemap(texture: InternalTexture): void;
  91132. /**
  91133. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  91134. */
  91135. flushFramebuffer(): void;
  91136. /**
  91137. * Unbind the current render target and bind the default framebuffer
  91138. */
  91139. restoreDefaultFramebuffer(): void;
  91140. /**
  91141. * Create an uniform buffer
  91142. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91143. * @param elements defines the content of the uniform buffer
  91144. * @returns the webGL uniform buffer
  91145. */
  91146. createUniformBuffer(elements: FloatArray): DataBuffer;
  91147. /**
  91148. * Create a dynamic uniform buffer
  91149. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91150. * @param elements defines the content of the uniform buffer
  91151. * @returns the webGL uniform buffer
  91152. */
  91153. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  91154. /**
  91155. * Update an existing uniform buffer
  91156. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91157. * @param uniformBuffer defines the target uniform buffer
  91158. * @param elements defines the content to update
  91159. * @param offset defines the offset in the uniform buffer where update should start
  91160. * @param count defines the size of the data to update
  91161. */
  91162. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  91163. private _resetVertexBufferBinding;
  91164. /**
  91165. * Creates a vertex buffer
  91166. * @param data the data for the vertex buffer
  91167. * @returns the new WebGL static buffer
  91168. */
  91169. createVertexBuffer(data: DataArray): DataBuffer;
  91170. /**
  91171. * Creates a dynamic vertex buffer
  91172. * @param data the data for the dynamic vertex buffer
  91173. * @returns the new WebGL dynamic buffer
  91174. */
  91175. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  91176. /**
  91177. * Update a dynamic index buffer
  91178. * @param indexBuffer defines the target index buffer
  91179. * @param indices defines the data to update
  91180. * @param offset defines the offset in the target index buffer where update should start
  91181. */
  91182. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91183. /**
  91184. * Updates a dynamic vertex buffer.
  91185. * @param vertexBuffer the vertex buffer to update
  91186. * @param data the data used to update the vertex buffer
  91187. * @param byteOffset the byte offset of the data
  91188. * @param byteLength the byte length of the data
  91189. */
  91190. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91191. private _resetIndexBufferBinding;
  91192. /**
  91193. * Creates a new index buffer
  91194. * @param indices defines the content of the index buffer
  91195. * @param updatable defines if the index buffer must be updatable
  91196. * @returns a new webGL buffer
  91197. */
  91198. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  91199. /**
  91200. * Bind a webGL buffer to the webGL context
  91201. * @param buffer defines the buffer to bind
  91202. */
  91203. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  91204. /**
  91205. * Bind an uniform buffer to the current webGL context
  91206. * @param buffer defines the buffer to bind
  91207. */
  91208. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  91209. /**
  91210. * Bind a buffer to the current webGL context at a given location
  91211. * @param buffer defines the buffer to bind
  91212. * @param location defines the index where to bind the buffer
  91213. */
  91214. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  91215. /**
  91216. * Bind a specific block at a given index in a specific shader program
  91217. * @param pipelineContext defines the pipeline context to use
  91218. * @param blockName defines the block name
  91219. * @param index defines the index where to bind the block
  91220. */
  91221. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  91222. private bindIndexBuffer;
  91223. private bindBuffer;
  91224. /**
  91225. * update the bound buffer with the given data
  91226. * @param data defines the data to update
  91227. */
  91228. updateArrayBuffer(data: Float32Array): void;
  91229. private _vertexAttribPointer;
  91230. private _bindIndexBufferWithCache;
  91231. private _bindVertexBuffersAttributes;
  91232. /**
  91233. * Records a vertex array object
  91234. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91235. * @param vertexBuffers defines the list of vertex buffers to store
  91236. * @param indexBuffer defines the index buffer to store
  91237. * @param effect defines the effect to store
  91238. * @returns the new vertex array object
  91239. */
  91240. recordVertexArrayObject(vertexBuffers: {
  91241. [key: string]: VertexBuffer;
  91242. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  91243. /**
  91244. * Bind a specific vertex array object
  91245. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91246. * @param vertexArrayObject defines the vertex array object to bind
  91247. * @param indexBuffer defines the index buffer to bind
  91248. */
  91249. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  91250. /**
  91251. * Bind webGl buffers directly to the webGL context
  91252. * @param vertexBuffer defines the vertex buffer to bind
  91253. * @param indexBuffer defines the index buffer to bind
  91254. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  91255. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  91256. * @param effect defines the effect associated with the vertex buffer
  91257. */
  91258. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  91259. private _unbindVertexArrayObject;
  91260. /**
  91261. * Bind a list of vertex buffers to the webGL context
  91262. * @param vertexBuffers defines the list of vertex buffers to bind
  91263. * @param indexBuffer defines the index buffer to bind
  91264. * @param effect defines the effect associated with the vertex buffers
  91265. */
  91266. bindBuffers(vertexBuffers: {
  91267. [key: string]: Nullable<VertexBuffer>;
  91268. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  91269. /**
  91270. * Unbind all instance attributes
  91271. */
  91272. unbindInstanceAttributes(): void;
  91273. /**
  91274. * Release and free the memory of a vertex array object
  91275. * @param vao defines the vertex array object to delete
  91276. */
  91277. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  91278. /** @hidden */
  91279. _releaseBuffer(buffer: DataBuffer): boolean;
  91280. /**
  91281. * Creates a webGL buffer to use with instanciation
  91282. * @param capacity defines the size of the buffer
  91283. * @returns the webGL buffer
  91284. */
  91285. createInstancesBuffer(capacity: number): DataBuffer;
  91286. /**
  91287. * Delete a webGL buffer used with instanciation
  91288. * @param buffer defines the webGL buffer to delete
  91289. */
  91290. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  91291. /**
  91292. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  91293. * @param instancesBuffer defines the webGL buffer to update and bind
  91294. * @param data defines the data to store in the buffer
  91295. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  91296. */
  91297. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  91298. /**
  91299. * Apply all cached states (depth, culling, stencil and alpha)
  91300. */
  91301. applyStates(): void;
  91302. /**
  91303. * Send a draw order
  91304. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91305. * @param indexStart defines the starting index
  91306. * @param indexCount defines the number of index to draw
  91307. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91308. */
  91309. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  91310. /**
  91311. * Draw a list of points
  91312. * @param verticesStart defines the index of first vertex to draw
  91313. * @param verticesCount defines the count of vertices to draw
  91314. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91315. */
  91316. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91317. /**
  91318. * Draw a list of unindexed primitives
  91319. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91320. * @param verticesStart defines the index of first vertex to draw
  91321. * @param verticesCount defines the count of vertices to draw
  91322. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91323. */
  91324. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91325. /**
  91326. * Draw a list of indexed primitives
  91327. * @param fillMode defines the primitive to use
  91328. * @param indexStart defines the starting index
  91329. * @param indexCount defines the number of index to draw
  91330. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91331. */
  91332. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  91333. /**
  91334. * Draw a list of unindexed primitives
  91335. * @param fillMode defines the primitive to use
  91336. * @param verticesStart defines the index of first vertex to draw
  91337. * @param verticesCount defines the count of vertices to draw
  91338. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91339. */
  91340. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91341. private _drawMode;
  91342. /** @hidden */
  91343. _releaseEffect(effect: Effect): void;
  91344. /** @hidden */
  91345. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  91346. /**
  91347. * Create a new effect (used to store vertex/fragment shaders)
  91348. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  91349. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  91350. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  91351. * @param samplers defines an array of string used to represent textures
  91352. * @param defines defines the string containing the defines to use to compile the shaders
  91353. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  91354. * @param onCompiled defines a function to call when the effect creation is successful
  91355. * @param onError defines a function to call when the effect creation has failed
  91356. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  91357. * @returns the new Effect
  91358. */
  91359. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  91360. private _compileShader;
  91361. private _compileRawShader;
  91362. /**
  91363. * Directly creates a webGL program
  91364. * @param pipelineContext defines the pipeline context to attach to
  91365. * @param vertexCode defines the vertex shader code to use
  91366. * @param fragmentCode defines the fragment shader code to use
  91367. * @param context defines the webGL context to use (if not set, the current one will be used)
  91368. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91369. * @returns the new webGL program
  91370. */
  91371. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91372. /**
  91373. * Creates a webGL program
  91374. * @param pipelineContext defines the pipeline context to attach to
  91375. * @param vertexCode defines the vertex shader code to use
  91376. * @param fragmentCode defines the fragment shader code to use
  91377. * @param defines defines the string containing the defines to use to compile the shaders
  91378. * @param context defines the webGL context to use (if not set, the current one will be used)
  91379. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91380. * @returns the new webGL program
  91381. */
  91382. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91383. /**
  91384. * Creates a new pipeline context
  91385. * @returns the new pipeline
  91386. */
  91387. createPipelineContext(): WebGLPipelineContext;
  91388. private _createShaderProgram;
  91389. private _finalizePipelineContext;
  91390. /** @hidden */
  91391. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  91392. /** @hidden */
  91393. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  91394. /** @hidden */
  91395. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  91396. /**
  91397. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  91398. * @param pipelineContext defines the pipeline context to use
  91399. * @param uniformsNames defines the list of uniform names
  91400. * @returns an array of webGL uniform locations
  91401. */
  91402. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  91403. /**
  91404. * Gets the lsit of active attributes for a given webGL program
  91405. * @param pipelineContext defines the pipeline context to use
  91406. * @param attributesNames defines the list of attribute names to get
  91407. * @returns an array of indices indicating the offset of each attribute
  91408. */
  91409. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  91410. /**
  91411. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  91412. * @param effect defines the effect to activate
  91413. */
  91414. enableEffect(effect: Nullable<Effect>): void;
  91415. /**
  91416. * Set the value of an uniform to an array of int32
  91417. * @param uniform defines the webGL uniform location where to store the value
  91418. * @param array defines the array of int32 to store
  91419. */
  91420. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91421. /**
  91422. * Set the value of an uniform to an array of int32 (stored as vec2)
  91423. * @param uniform defines the webGL uniform location where to store the value
  91424. * @param array defines the array of int32 to store
  91425. */
  91426. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91427. /**
  91428. * Set the value of an uniform to an array of int32 (stored as vec3)
  91429. * @param uniform defines the webGL uniform location where to store the value
  91430. * @param array defines the array of int32 to store
  91431. */
  91432. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91433. /**
  91434. * Set the value of an uniform to an array of int32 (stored as vec4)
  91435. * @param uniform defines the webGL uniform location where to store the value
  91436. * @param array defines the array of int32 to store
  91437. */
  91438. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91439. /**
  91440. * Set the value of an uniform to an array of float32
  91441. * @param uniform defines the webGL uniform location where to store the value
  91442. * @param array defines the array of float32 to store
  91443. */
  91444. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91445. /**
  91446. * Set the value of an uniform to an array of float32 (stored as vec2)
  91447. * @param uniform defines the webGL uniform location where to store the value
  91448. * @param array defines the array of float32 to store
  91449. */
  91450. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91451. /**
  91452. * Set the value of an uniform to an array of float32 (stored as vec3)
  91453. * @param uniform defines the webGL uniform location where to store the value
  91454. * @param array defines the array of float32 to store
  91455. */
  91456. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91457. /**
  91458. * Set the value of an uniform to an array of float32 (stored as vec4)
  91459. * @param uniform defines the webGL uniform location where to store the value
  91460. * @param array defines the array of float32 to store
  91461. */
  91462. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91463. /**
  91464. * Set the value of an uniform to an array of number
  91465. * @param uniform defines the webGL uniform location where to store the value
  91466. * @param array defines the array of number to store
  91467. */
  91468. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91469. /**
  91470. * Set the value of an uniform to an array of number (stored as vec2)
  91471. * @param uniform defines the webGL uniform location where to store the value
  91472. * @param array defines the array of number to store
  91473. */
  91474. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91475. /**
  91476. * Set the value of an uniform to an array of number (stored as vec3)
  91477. * @param uniform defines the webGL uniform location where to store the value
  91478. * @param array defines the array of number to store
  91479. */
  91480. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91481. /**
  91482. * Set the value of an uniform to an array of number (stored as vec4)
  91483. * @param uniform defines the webGL uniform location where to store the value
  91484. * @param array defines the array of number to store
  91485. */
  91486. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91487. /**
  91488. * Set the value of an uniform to an array of float32 (stored as matrices)
  91489. * @param uniform defines the webGL uniform location where to store the value
  91490. * @param matrices defines the array of float32 to store
  91491. */
  91492. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91493. /**
  91494. * Set the value of an uniform to a matrix
  91495. * @param uniform defines the webGL uniform location where to store the value
  91496. * @param matrix defines the matrix to store
  91497. */
  91498. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91499. /**
  91500. * Set the value of an uniform to a matrix (3x3)
  91501. * @param uniform defines the webGL uniform location where to store the value
  91502. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91503. */
  91504. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91505. /**
  91506. * Set the value of an uniform to a matrix (2x2)
  91507. * @param uniform defines the webGL uniform location where to store the value
  91508. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91509. */
  91510. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91511. /**
  91512. * Set the value of an uniform to a number (int)
  91513. * @param uniform defines the webGL uniform location where to store the value
  91514. * @param value defines the int number to store
  91515. */
  91516. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91517. /**
  91518. * Set the value of an uniform to a number (float)
  91519. * @param uniform defines the webGL uniform location where to store the value
  91520. * @param value defines the float number to store
  91521. */
  91522. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91523. /**
  91524. * Set the value of an uniform to a vec2
  91525. * @param uniform defines the webGL uniform location where to store the value
  91526. * @param x defines the 1st component of the value
  91527. * @param y defines the 2nd component of the value
  91528. */
  91529. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91530. /**
  91531. * Set the value of an uniform to a vec3
  91532. * @param uniform defines the webGL uniform location where to store the value
  91533. * @param x defines the 1st component of the value
  91534. * @param y defines the 2nd component of the value
  91535. * @param z defines the 3rd component of the value
  91536. */
  91537. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91538. /**
  91539. * Set the value of an uniform to a boolean
  91540. * @param uniform defines the webGL uniform location where to store the value
  91541. * @param bool defines the boolean to store
  91542. */
  91543. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91544. /**
  91545. * Set the value of an uniform to a vec4
  91546. * @param uniform defines the webGL uniform location where to store the value
  91547. * @param x defines the 1st component of the value
  91548. * @param y defines the 2nd component of the value
  91549. * @param z defines the 3rd component of the value
  91550. * @param w defines the 4th component of the value
  91551. */
  91552. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91553. /**
  91554. * Set the value of an uniform to a Color3
  91555. * @param uniform defines the webGL uniform location where to store the value
  91556. * @param color3 defines the color to store
  91557. */
  91558. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91559. /**
  91560. * Set the value of an uniform to a Color3 and an alpha value
  91561. * @param uniform defines the webGL uniform location where to store the value
  91562. * @param color3 defines the color to store
  91563. * @param alpha defines the alpha component to store
  91564. */
  91565. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91566. /**
  91567. * Sets a Color4 on a uniform variable
  91568. * @param uniform defines the uniform location
  91569. * @param color4 defines the value to be set
  91570. */
  91571. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91572. /**
  91573. * Set various states to the webGL context
  91574. * @param culling defines backface culling state
  91575. * @param zOffset defines the value to apply to zOffset (0 by default)
  91576. * @param force defines if states must be applied even if cache is up to date
  91577. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91578. */
  91579. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91580. /**
  91581. * Set the z offset to apply to current rendering
  91582. * @param value defines the offset to apply
  91583. */
  91584. setZOffset(value: number): void;
  91585. /**
  91586. * Gets the current value of the zOffset
  91587. * @returns the current zOffset state
  91588. */
  91589. getZOffset(): number;
  91590. /**
  91591. * Enable or disable depth buffering
  91592. * @param enable defines the state to set
  91593. */
  91594. setDepthBuffer(enable: boolean): void;
  91595. /**
  91596. * Gets a boolean indicating if depth writing is enabled
  91597. * @returns the current depth writing state
  91598. */
  91599. getDepthWrite(): boolean;
  91600. /**
  91601. * Enable or disable depth writing
  91602. * @param enable defines the state to set
  91603. */
  91604. setDepthWrite(enable: boolean): void;
  91605. /**
  91606. * Enable or disable color writing
  91607. * @param enable defines the state to set
  91608. */
  91609. setColorWrite(enable: boolean): void;
  91610. /**
  91611. * Gets a boolean indicating if color writing is enabled
  91612. * @returns the current color writing state
  91613. */
  91614. getColorWrite(): boolean;
  91615. /**
  91616. * Sets alpha constants used by some alpha blending modes
  91617. * @param r defines the red component
  91618. * @param g defines the green component
  91619. * @param b defines the blue component
  91620. * @param a defines the alpha component
  91621. */
  91622. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91623. /**
  91624. * Sets the current alpha mode
  91625. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91626. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91627. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91628. */
  91629. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91630. /**
  91631. * Gets the current alpha mode
  91632. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91633. * @returns the current alpha mode
  91634. */
  91635. getAlphaMode(): number;
  91636. /**
  91637. * Clears the list of texture accessible through engine.
  91638. * This can help preventing texture load conflict due to name collision.
  91639. */
  91640. clearInternalTexturesCache(): void;
  91641. /**
  91642. * Force the entire cache to be cleared
  91643. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91644. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91645. */
  91646. wipeCaches(bruteForce?: boolean): void;
  91647. /**
  91648. * Set the compressed texture format to use, based on the formats you have, and the formats
  91649. * supported by the hardware / browser.
  91650. *
  91651. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91652. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91653. * to API arguments needed to compressed textures. This puts the burden on the container
  91654. * generator to house the arcane code for determining these for current & future formats.
  91655. *
  91656. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91657. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91658. *
  91659. * Note: The result of this call is not taken into account when a texture is base64.
  91660. *
  91661. * @param formatsAvailable defines the list of those format families you have created
  91662. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91663. *
  91664. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91665. * @returns The extension selected.
  91666. */
  91667. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91668. /** @hidden */
  91669. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91670. min: number;
  91671. mag: number;
  91672. };
  91673. /** @hidden */
  91674. _createTexture(): WebGLTexture;
  91675. /**
  91676. * Usually called from Texture.ts.
  91677. * Passed information to create a WebGLTexture
  91678. * @param urlArg defines a value which contains one of the following:
  91679. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91680. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91681. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91682. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91683. * @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)
  91684. * @param scene needed for loading to the correct scene
  91685. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91686. * @param onLoad optional callback to be called upon successful completion
  91687. * @param onError optional callback to be called upon failure
  91688. * @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
  91689. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91690. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91691. * @param forcedExtension defines the extension to use to pick the right loader
  91692. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91693. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91694. */
  91695. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  91696. /**
  91697. * @hidden
  91698. * Rescales a texture
  91699. * @param source input texutre
  91700. * @param destination destination texture
  91701. * @param scene scene to use to render the resize
  91702. * @param internalFormat format to use when resizing
  91703. * @param onComplete callback to be called when resize has completed
  91704. */
  91705. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  91706. private _unpackFlipYCached;
  91707. /**
  91708. * In case you are sharing the context with other applications, it might
  91709. * be interested to not cache the unpack flip y state to ensure a consistent
  91710. * value would be set.
  91711. */
  91712. enableUnpackFlipYCached: boolean;
  91713. /** @hidden */
  91714. _unpackFlipY(value: boolean): void;
  91715. /** @hidden */
  91716. _getUnpackAlignement(): number;
  91717. /**
  91718. * Creates a dynamic texture
  91719. * @param width defines the width of the texture
  91720. * @param height defines the height of the texture
  91721. * @param generateMipMaps defines if the engine should generate the mip levels
  91722. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91723. * @returns the dynamic texture inside an InternalTexture
  91724. */
  91725. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  91726. /**
  91727. * Update the sampling mode of a given texture
  91728. * @param samplingMode defines the required sampling mode
  91729. * @param texture defines the texture to update
  91730. */
  91731. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  91732. /**
  91733. * Update the content of a dynamic texture
  91734. * @param texture defines the texture to update
  91735. * @param canvas defines the canvas containing the source
  91736. * @param invertY defines if data must be stored with Y axis inverted
  91737. * @param premulAlpha defines if alpha is stored as premultiplied
  91738. * @param format defines the format of the data
  91739. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  91740. */
  91741. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  91742. /**
  91743. * Update a video texture
  91744. * @param texture defines the texture to update
  91745. * @param video defines the video element to use
  91746. * @param invertY defines if data must be stored with Y axis inverted
  91747. */
  91748. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  91749. /**
  91750. * Updates a depth texture Comparison Mode and Function.
  91751. * If the comparison Function is equal to 0, the mode will be set to none.
  91752. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  91753. * @param texture The texture to set the comparison function for
  91754. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  91755. */
  91756. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  91757. /** @hidden */
  91758. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  91759. width: number;
  91760. height: number;
  91761. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  91762. /**
  91763. * Creates a depth stencil texture.
  91764. * This is only available in WebGL 2 or with the depth texture extension available.
  91765. * @param size The size of face edge in the texture.
  91766. * @param options The options defining the texture.
  91767. * @returns The texture
  91768. */
  91769. createDepthStencilTexture(size: number | {
  91770. width: number;
  91771. height: number;
  91772. }, options: DepthTextureCreationOptions): InternalTexture;
  91773. /**
  91774. * Creates a depth stencil texture.
  91775. * This is only available in WebGL 2 or with the depth texture extension available.
  91776. * @param size The size of face edge in the texture.
  91777. * @param options The options defining the texture.
  91778. * @returns The texture
  91779. */
  91780. private _createDepthStencilTexture;
  91781. /**
  91782. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  91783. * @param renderTarget The render target to set the frame buffer for
  91784. */
  91785. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  91786. /**
  91787. * Creates a new render target texture
  91788. * @param size defines the size of the texture
  91789. * @param options defines the options used to create the texture
  91790. * @returns a new render target texture stored in an InternalTexture
  91791. */
  91792. createRenderTargetTexture(size: number | {
  91793. width: number;
  91794. height: number;
  91795. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  91796. /** @hidden */
  91797. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  91798. /**
  91799. * Updates the sample count of a render target texture
  91800. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  91801. * @param texture defines the texture to update
  91802. * @param samples defines the sample count to set
  91803. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  91804. */
  91805. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  91806. /** @hidden */
  91807. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91808. /** @hidden */
  91809. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  91810. /** @hidden */
  91811. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91812. /** @hidden */
  91813. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  91814. /**
  91815. * @hidden
  91816. */
  91817. _setCubeMapTextureParams(loadMipmap: boolean): void;
  91818. private _prepareWebGLTextureContinuation;
  91819. private _prepareWebGLTexture;
  91820. /** @hidden */
  91821. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  91822. /** @hidden */
  91823. _releaseFramebufferObjects(texture: InternalTexture): void;
  91824. /** @hidden */
  91825. _releaseTexture(texture: InternalTexture): void;
  91826. private setProgram;
  91827. private _boundUniforms;
  91828. /**
  91829. * Binds an effect to the webGL context
  91830. * @param effect defines the effect to bind
  91831. */
  91832. bindSamplers(effect: Effect): void;
  91833. private _activateCurrentTexture;
  91834. /** @hidden */
  91835. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  91836. /** @hidden */
  91837. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  91838. /**
  91839. * Sets a texture to the webGL context from a postprocess
  91840. * @param channel defines the channel to use
  91841. * @param postProcess defines the source postprocess
  91842. */
  91843. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  91844. /**
  91845. * Binds the output of the passed in post process to the texture channel specified
  91846. * @param channel The channel the texture should be bound to
  91847. * @param postProcess The post process which's output should be bound
  91848. */
  91849. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  91850. /**
  91851. * Unbind all textures from the webGL context
  91852. */
  91853. unbindAllTextures(): void;
  91854. /**
  91855. * Sets a texture to the according uniform.
  91856. * @param channel The texture channel
  91857. * @param uniform The uniform to set
  91858. * @param texture The texture to apply
  91859. */
  91860. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  91861. /**
  91862. * Sets a depth stencil texture from a render target to the according uniform.
  91863. * @param channel The texture channel
  91864. * @param uniform The uniform to set
  91865. * @param texture The render target texture containing the depth stencil texture to apply
  91866. */
  91867. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  91868. private _bindSamplerUniformToChannel;
  91869. private _getTextureWrapMode;
  91870. private _setTexture;
  91871. /**
  91872. * Sets an array of texture to the webGL context
  91873. * @param channel defines the channel where the texture array must be set
  91874. * @param uniform defines the associated uniform location
  91875. * @param textures defines the array of textures to bind
  91876. */
  91877. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  91878. /** @hidden */
  91879. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  91880. private _setTextureParameterFloat;
  91881. private _setTextureParameterInteger;
  91882. /**
  91883. * Reads pixels from the current frame buffer. Please note that this function can be slow
  91884. * @param x defines the x coordinate of the rectangle where pixels must be read
  91885. * @param y defines the y coordinate of the rectangle where pixels must be read
  91886. * @param width defines the width of the rectangle where pixels must be read
  91887. * @param height defines the height of the rectangle where pixels must be read
  91888. * @returns a Uint8Array containing RGBA colors
  91889. */
  91890. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  91891. /**
  91892. * Add an externaly attached data from its key.
  91893. * This method call will fail and return false, if such key already exists.
  91894. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91895. * @param key the unique key that identifies the data
  91896. * @param data the data object to associate to the key for this Engine instance
  91897. * @return true if no such key were already present and the data was added successfully, false otherwise
  91898. */
  91899. addExternalData<T>(key: string, data: T): boolean;
  91900. /**
  91901. * Get an externaly attached data from its key
  91902. * @param key the unique key that identifies the data
  91903. * @return the associated data, if present (can be null), or undefined if not present
  91904. */
  91905. getExternalData<T>(key: string): T;
  91906. /**
  91907. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91908. * @param key the unique key that identifies the data
  91909. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91910. * @return the associated data, can be null if the factory returned null.
  91911. */
  91912. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91913. /**
  91914. * Remove an externaly attached data from the Engine instance
  91915. * @param key the unique key that identifies the data
  91916. * @return true if the data was successfully removed, false if it doesn't exist
  91917. */
  91918. removeExternalData(key: string): boolean;
  91919. /**
  91920. * Unbind all vertex attributes from the webGL context
  91921. */
  91922. unbindAllAttributes(): void;
  91923. /**
  91924. * 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
  91925. */
  91926. releaseEffects(): void;
  91927. /**
  91928. * Dispose and release all associated resources
  91929. */
  91930. dispose(): void;
  91931. /**
  91932. * Display the loading screen
  91933. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91934. */
  91935. displayLoadingUI(): void;
  91936. /**
  91937. * Hide the loading screen
  91938. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91939. */
  91940. hideLoadingUI(): void;
  91941. /**
  91942. * Gets the current loading screen object
  91943. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91944. */
  91945. /**
  91946. * Sets the current loading screen object
  91947. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91948. */
  91949. loadingScreen: ILoadingScreen;
  91950. /**
  91951. * Sets the current loading screen text
  91952. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91953. */
  91954. loadingUIText: string;
  91955. /**
  91956. * Sets the current loading screen background color
  91957. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91958. */
  91959. loadingUIBackgroundColor: string;
  91960. /**
  91961. * Attach a new callback raised when context lost event is fired
  91962. * @param callback defines the callback to call
  91963. */
  91964. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91965. /**
  91966. * Attach a new callback raised when context restored event is fired
  91967. * @param callback defines the callback to call
  91968. */
  91969. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91970. /**
  91971. * Gets the source code of the vertex shader associated with a specific webGL program
  91972. * @param program defines the program to use
  91973. * @returns a string containing the source code of the vertex shader associated with the program
  91974. */
  91975. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  91976. /**
  91977. * Gets the source code of the fragment shader associated with a specific webGL program
  91978. * @param program defines the program to use
  91979. * @returns a string containing the source code of the fragment shader associated with the program
  91980. */
  91981. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  91982. /**
  91983. * Get the current error code of the webGL context
  91984. * @returns the error code
  91985. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  91986. */
  91987. getError(): number;
  91988. /**
  91989. * Gets the current framerate
  91990. * @returns a number representing the framerate
  91991. */
  91992. getFps(): number;
  91993. /**
  91994. * Gets the time spent between current and previous frame
  91995. * @returns a number representing the delta time in ms
  91996. */
  91997. getDeltaTime(): number;
  91998. private _measureFps;
  91999. /** @hidden */
  92000. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  92001. private _canRenderToFloatFramebuffer;
  92002. private _canRenderToHalfFloatFramebuffer;
  92003. private _canRenderToFramebuffer;
  92004. /** @hidden */
  92005. _getWebGLTextureType(type: number): number;
  92006. /** @hidden */
  92007. _getInternalFormat(format: number): number;
  92008. /** @hidden */
  92009. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  92010. /** @hidden */
  92011. _getRGBAMultiSampleBufferFormat(type: number): number;
  92012. /** @hidden */
  92013. _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;
  92014. /** @hidden */
  92015. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92016. /**
  92017. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  92018. * @returns true if the engine can be created
  92019. * @ignorenaming
  92020. */
  92021. static isSupported(): boolean;
  92022. }
  92023. }
  92024. declare module BABYLON {
  92025. /**
  92026. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  92027. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  92028. */
  92029. export class EffectFallbacks {
  92030. private _defines;
  92031. private _currentRank;
  92032. private _maxRank;
  92033. private _mesh;
  92034. /**
  92035. * Removes the fallback from the bound mesh.
  92036. */
  92037. unBindMesh(): void;
  92038. /**
  92039. * Adds a fallback on the specified property.
  92040. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92041. * @param define The name of the define in the shader
  92042. */
  92043. addFallback(rank: number, define: string): void;
  92044. /**
  92045. * Sets the mesh to use CPU skinning when needing to fallback.
  92046. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92047. * @param mesh The mesh to use the fallbacks.
  92048. */
  92049. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  92050. /**
  92051. * Checks to see if more fallbacks are still availible.
  92052. */
  92053. readonly isMoreFallbacks: boolean;
  92054. /**
  92055. * Removes the defines that should be removed when falling back.
  92056. * @param currentDefines defines the current define statements for the shader.
  92057. * @param effect defines the current effect we try to compile
  92058. * @returns The resulting defines with defines of the current rank removed.
  92059. */
  92060. reduce(currentDefines: string, effect: Effect): string;
  92061. }
  92062. /**
  92063. * Options to be used when creating an effect.
  92064. */
  92065. export class EffectCreationOptions {
  92066. /**
  92067. * Atrributes that will be used in the shader.
  92068. */
  92069. attributes: string[];
  92070. /**
  92071. * Uniform varible names that will be set in the shader.
  92072. */
  92073. uniformsNames: string[];
  92074. /**
  92075. * Uniform buffer varible names that will be set in the shader.
  92076. */
  92077. uniformBuffersNames: string[];
  92078. /**
  92079. * Sampler texture variable names that will be set in the shader.
  92080. */
  92081. samplers: string[];
  92082. /**
  92083. * Define statements that will be set in the shader.
  92084. */
  92085. defines: any;
  92086. /**
  92087. * Possible fallbacks for this effect to improve performance when needed.
  92088. */
  92089. fallbacks: Nullable<EffectFallbacks>;
  92090. /**
  92091. * Callback that will be called when the shader is compiled.
  92092. */
  92093. onCompiled: Nullable<(effect: Effect) => void>;
  92094. /**
  92095. * Callback that will be called if an error occurs during shader compilation.
  92096. */
  92097. onError: Nullable<(effect: Effect, errors: string) => void>;
  92098. /**
  92099. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92100. */
  92101. indexParameters: any;
  92102. /**
  92103. * Max number of lights that can be used in the shader.
  92104. */
  92105. maxSimultaneousLights: number;
  92106. /**
  92107. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92108. */
  92109. transformFeedbackVaryings: Nullable<string[]>;
  92110. }
  92111. /**
  92112. * Effect containing vertex and fragment shader that can be executed on an object.
  92113. */
  92114. export class Effect implements IDisposable {
  92115. /**
  92116. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92117. */
  92118. static ShadersRepository: string;
  92119. /**
  92120. * Name of the effect.
  92121. */
  92122. name: any;
  92123. /**
  92124. * String container all the define statements that should be set on the shader.
  92125. */
  92126. defines: string;
  92127. /**
  92128. * Callback that will be called when the shader is compiled.
  92129. */
  92130. onCompiled: Nullable<(effect: Effect) => void>;
  92131. /**
  92132. * Callback that will be called if an error occurs during shader compilation.
  92133. */
  92134. onError: Nullable<(effect: Effect, errors: string) => void>;
  92135. /**
  92136. * Callback that will be called when effect is bound.
  92137. */
  92138. onBind: Nullable<(effect: Effect) => void>;
  92139. /**
  92140. * Unique ID of the effect.
  92141. */
  92142. uniqueId: number;
  92143. /**
  92144. * Observable that will be called when the shader is compiled.
  92145. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92146. */
  92147. onCompileObservable: Observable<Effect>;
  92148. /**
  92149. * Observable that will be called if an error occurs during shader compilation.
  92150. */
  92151. onErrorObservable: Observable<Effect>;
  92152. /** @hidden */
  92153. _onBindObservable: Nullable<Observable<Effect>>;
  92154. /**
  92155. * Observable that will be called when effect is bound.
  92156. */
  92157. readonly onBindObservable: Observable<Effect>;
  92158. /** @hidden */
  92159. _bonesComputationForcedToCPU: boolean;
  92160. private static _uniqueIdSeed;
  92161. private _engine;
  92162. private _uniformBuffersNames;
  92163. private _uniformsNames;
  92164. private _samplerList;
  92165. private _samplers;
  92166. private _isReady;
  92167. private _compilationError;
  92168. private _attributesNames;
  92169. private _attributes;
  92170. private _uniforms;
  92171. /**
  92172. * Key for the effect.
  92173. * @hidden
  92174. */
  92175. _key: string;
  92176. private _indexParameters;
  92177. private _fallbacks;
  92178. private _vertexSourceCode;
  92179. private _fragmentSourceCode;
  92180. private _vertexSourceCodeOverride;
  92181. private _fragmentSourceCodeOverride;
  92182. private _transformFeedbackVaryings;
  92183. /**
  92184. * Compiled shader to webGL program.
  92185. * @hidden
  92186. */
  92187. _pipelineContext: Nullable<IPipelineContext>;
  92188. private _valueCache;
  92189. private static _baseCache;
  92190. /**
  92191. * Instantiates an effect.
  92192. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92193. * @param baseName Name of the effect.
  92194. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92195. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92196. * @param samplers List of sampler variables that will be passed to the shader.
  92197. * @param engine Engine to be used to render the effect
  92198. * @param defines Define statements to be added to the shader.
  92199. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92200. * @param onCompiled Callback that will be called when the shader is compiled.
  92201. * @param onError Callback that will be called if an error occurs during shader compilation.
  92202. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92203. */
  92204. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  92205. private _useFinalCode;
  92206. /**
  92207. * Unique key for this effect
  92208. */
  92209. readonly key: string;
  92210. /**
  92211. * If the effect has been compiled and prepared.
  92212. * @returns if the effect is compiled and prepared.
  92213. */
  92214. isReady(): boolean;
  92215. /**
  92216. * The engine the effect was initialized with.
  92217. * @returns the engine.
  92218. */
  92219. getEngine(): Engine;
  92220. /**
  92221. * The pipeline context for this effect
  92222. * @returns the associated pipeline context
  92223. */
  92224. getPipelineContext(): Nullable<IPipelineContext>;
  92225. /**
  92226. * The set of names of attribute variables for the shader.
  92227. * @returns An array of attribute names.
  92228. */
  92229. getAttributesNames(): string[];
  92230. /**
  92231. * Returns the attribute at the given index.
  92232. * @param index The index of the attribute.
  92233. * @returns The location of the attribute.
  92234. */
  92235. getAttributeLocation(index: number): number;
  92236. /**
  92237. * Returns the attribute based on the name of the variable.
  92238. * @param name of the attribute to look up.
  92239. * @returns the attribute location.
  92240. */
  92241. getAttributeLocationByName(name: string): number;
  92242. /**
  92243. * The number of attributes.
  92244. * @returns the numnber of attributes.
  92245. */
  92246. getAttributesCount(): number;
  92247. /**
  92248. * Gets the index of a uniform variable.
  92249. * @param uniformName of the uniform to look up.
  92250. * @returns the index.
  92251. */
  92252. getUniformIndex(uniformName: string): number;
  92253. /**
  92254. * Returns the attribute based on the name of the variable.
  92255. * @param uniformName of the uniform to look up.
  92256. * @returns the location of the uniform.
  92257. */
  92258. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92259. /**
  92260. * Returns an array of sampler variable names
  92261. * @returns The array of sampler variable neames.
  92262. */
  92263. getSamplers(): string[];
  92264. /**
  92265. * The error from the last compilation.
  92266. * @returns the error string.
  92267. */
  92268. getCompilationError(): string;
  92269. /**
  92270. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92271. * @param func The callback to be used.
  92272. */
  92273. executeWhenCompiled(func: (effect: Effect) => void): void;
  92274. private _checkIsReady;
  92275. /** @hidden */
  92276. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92277. /** @hidden */
  92278. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92279. /** @hidden */
  92280. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92281. /**
  92282. * Recompiles the webGL program
  92283. * @param vertexSourceCode The source code for the vertex shader.
  92284. * @param fragmentSourceCode The source code for the fragment shader.
  92285. * @param onCompiled Callback called when completed.
  92286. * @param onError Callback called on error.
  92287. * @hidden
  92288. */
  92289. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92290. /**
  92291. * Prepares the effect
  92292. * @hidden
  92293. */
  92294. _prepareEffect(): void;
  92295. /**
  92296. * Checks if the effect is supported. (Must be called after compilation)
  92297. */
  92298. readonly isSupported: boolean;
  92299. /**
  92300. * Binds a texture to the engine to be used as output of the shader.
  92301. * @param channel Name of the output variable.
  92302. * @param texture Texture to bind.
  92303. * @hidden
  92304. */
  92305. _bindTexture(channel: string, texture: InternalTexture): void;
  92306. /**
  92307. * Sets a texture on the engine to be used in the shader.
  92308. * @param channel Name of the sampler variable.
  92309. * @param texture Texture to set.
  92310. */
  92311. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92312. /**
  92313. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92314. * @param channel Name of the sampler variable.
  92315. * @param texture Texture to set.
  92316. */
  92317. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92318. /**
  92319. * Sets an array of textures on the engine to be used in the shader.
  92320. * @param channel Name of the variable.
  92321. * @param textures Textures to set.
  92322. */
  92323. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92324. /**
  92325. * 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)
  92326. * @param channel Name of the sampler variable.
  92327. * @param postProcess Post process to get the input texture from.
  92328. */
  92329. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92330. /**
  92331. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92332. * 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)
  92333. * @param channel Name of the sampler variable.
  92334. * @param postProcess Post process to get the output texture from.
  92335. */
  92336. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92337. /** @hidden */
  92338. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  92339. /** @hidden */
  92340. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92341. /** @hidden */
  92342. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92343. /** @hidden */
  92344. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92345. /**
  92346. * Binds a buffer to a uniform.
  92347. * @param buffer Buffer to bind.
  92348. * @param name Name of the uniform variable to bind to.
  92349. */
  92350. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92351. /**
  92352. * Binds block to a uniform.
  92353. * @param blockName Name of the block to bind.
  92354. * @param index Index to bind.
  92355. */
  92356. bindUniformBlock(blockName: string, index: number): void;
  92357. /**
  92358. * Sets an interger value on a uniform variable.
  92359. * @param uniformName Name of the variable.
  92360. * @param value Value to be set.
  92361. * @returns this effect.
  92362. */
  92363. setInt(uniformName: string, value: number): Effect;
  92364. /**
  92365. * Sets an int array on a uniform variable.
  92366. * @param uniformName Name of the variable.
  92367. * @param array array to be set.
  92368. * @returns this effect.
  92369. */
  92370. setIntArray(uniformName: string, array: Int32Array): Effect;
  92371. /**
  92372. * 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)
  92373. * @param uniformName Name of the variable.
  92374. * @param array array to be set.
  92375. * @returns this effect.
  92376. */
  92377. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92378. /**
  92379. * 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)
  92380. * @param uniformName Name of the variable.
  92381. * @param array array to be set.
  92382. * @returns this effect.
  92383. */
  92384. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92385. /**
  92386. * 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)
  92387. * @param uniformName Name of the variable.
  92388. * @param array array to be set.
  92389. * @returns this effect.
  92390. */
  92391. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92392. /**
  92393. * Sets an float array on a uniform variable.
  92394. * @param uniformName Name of the variable.
  92395. * @param array array to be set.
  92396. * @returns this effect.
  92397. */
  92398. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92399. /**
  92400. * 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)
  92401. * @param uniformName Name of the variable.
  92402. * @param array array to be set.
  92403. * @returns this effect.
  92404. */
  92405. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92406. /**
  92407. * 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)
  92408. * @param uniformName Name of the variable.
  92409. * @param array array to be set.
  92410. * @returns this effect.
  92411. */
  92412. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92413. /**
  92414. * 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)
  92415. * @param uniformName Name of the variable.
  92416. * @param array array to be set.
  92417. * @returns this effect.
  92418. */
  92419. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92420. /**
  92421. * Sets an array on a uniform variable.
  92422. * @param uniformName Name of the variable.
  92423. * @param array array to be set.
  92424. * @returns this effect.
  92425. */
  92426. setArray(uniformName: string, array: number[]): Effect;
  92427. /**
  92428. * 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)
  92429. * @param uniformName Name of the variable.
  92430. * @param array array to be set.
  92431. * @returns this effect.
  92432. */
  92433. setArray2(uniformName: string, array: number[]): Effect;
  92434. /**
  92435. * 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)
  92436. * @param uniformName Name of the variable.
  92437. * @param array array to be set.
  92438. * @returns this effect.
  92439. */
  92440. setArray3(uniformName: string, array: number[]): Effect;
  92441. /**
  92442. * 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)
  92443. * @param uniformName Name of the variable.
  92444. * @param array array to be set.
  92445. * @returns this effect.
  92446. */
  92447. setArray4(uniformName: string, array: number[]): Effect;
  92448. /**
  92449. * Sets matrices on a uniform variable.
  92450. * @param uniformName Name of the variable.
  92451. * @param matrices matrices to be set.
  92452. * @returns this effect.
  92453. */
  92454. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92455. /**
  92456. * Sets matrix on a uniform variable.
  92457. * @param uniformName Name of the variable.
  92458. * @param matrix matrix to be set.
  92459. * @returns this effect.
  92460. */
  92461. setMatrix(uniformName: string, matrix: Matrix): Effect;
  92462. /**
  92463. * 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)
  92464. * @param uniformName Name of the variable.
  92465. * @param matrix matrix to be set.
  92466. * @returns this effect.
  92467. */
  92468. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92469. /**
  92470. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92471. * @param uniformName Name of the variable.
  92472. * @param matrix matrix to be set.
  92473. * @returns this effect.
  92474. */
  92475. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92476. /**
  92477. * Sets a float on a uniform variable.
  92478. * @param uniformName Name of the variable.
  92479. * @param value value to be set.
  92480. * @returns this effect.
  92481. */
  92482. setFloat(uniformName: string, value: number): Effect;
  92483. /**
  92484. * Sets a boolean on a uniform variable.
  92485. * @param uniformName Name of the variable.
  92486. * @param bool value to be set.
  92487. * @returns this effect.
  92488. */
  92489. setBool(uniformName: string, bool: boolean): Effect;
  92490. /**
  92491. * Sets a Vector2 on a uniform variable.
  92492. * @param uniformName Name of the variable.
  92493. * @param vector2 vector2 to be set.
  92494. * @returns this effect.
  92495. */
  92496. setVector2(uniformName: string, vector2: Vector2): Effect;
  92497. /**
  92498. * Sets a float2 on a uniform variable.
  92499. * @param uniformName Name of the variable.
  92500. * @param x First float in float2.
  92501. * @param y Second float in float2.
  92502. * @returns this effect.
  92503. */
  92504. setFloat2(uniformName: string, x: number, y: number): Effect;
  92505. /**
  92506. * Sets a Vector3 on a uniform variable.
  92507. * @param uniformName Name of the variable.
  92508. * @param vector3 Value to be set.
  92509. * @returns this effect.
  92510. */
  92511. setVector3(uniformName: string, vector3: Vector3): Effect;
  92512. /**
  92513. * Sets a float3 on a uniform variable.
  92514. * @param uniformName Name of the variable.
  92515. * @param x First float in float3.
  92516. * @param y Second float in float3.
  92517. * @param z Third float in float3.
  92518. * @returns this effect.
  92519. */
  92520. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92521. /**
  92522. * Sets a Vector4 on a uniform variable.
  92523. * @param uniformName Name of the variable.
  92524. * @param vector4 Value to be set.
  92525. * @returns this effect.
  92526. */
  92527. setVector4(uniformName: string, vector4: Vector4): Effect;
  92528. /**
  92529. * Sets a float4 on a uniform variable.
  92530. * @param uniformName Name of the variable.
  92531. * @param x First float in float4.
  92532. * @param y Second float in float4.
  92533. * @param z Third float in float4.
  92534. * @param w Fourth float in float4.
  92535. * @returns this effect.
  92536. */
  92537. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92538. /**
  92539. * Sets a Color3 on a uniform variable.
  92540. * @param uniformName Name of the variable.
  92541. * @param color3 Value to be set.
  92542. * @returns this effect.
  92543. */
  92544. setColor3(uniformName: string, color3: Color3): Effect;
  92545. /**
  92546. * Sets a Color4 on a uniform variable.
  92547. * @param uniformName Name of the variable.
  92548. * @param color3 Value to be set.
  92549. * @param alpha Alpha value to be set.
  92550. * @returns this effect.
  92551. */
  92552. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92553. /**
  92554. * Sets a Color4 on a uniform variable
  92555. * @param uniformName defines the name of the variable
  92556. * @param color4 defines the value to be set
  92557. * @returns this effect.
  92558. */
  92559. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92560. /** Release all associated resources */
  92561. dispose(): void;
  92562. /**
  92563. * This function will add a new shader to the shader store
  92564. * @param name the name of the shader
  92565. * @param pixelShader optional pixel shader content
  92566. * @param vertexShader optional vertex shader content
  92567. */
  92568. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92569. /**
  92570. * Store of each shader (The can be looked up using effect.key)
  92571. */
  92572. static ShadersStore: {
  92573. [key: string]: string;
  92574. };
  92575. /**
  92576. * Store of each included file for a shader (The can be looked up using effect.key)
  92577. */
  92578. static IncludesShadersStore: {
  92579. [key: string]: string;
  92580. };
  92581. /**
  92582. * Resets the cache of effects.
  92583. */
  92584. static ResetCache(): void;
  92585. }
  92586. }
  92587. declare module BABYLON {
  92588. /**
  92589. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92590. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92591. * 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;
  92592. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92593. */
  92594. export class ColorCurves {
  92595. private _dirty;
  92596. private _tempColor;
  92597. private _globalCurve;
  92598. private _highlightsCurve;
  92599. private _midtonesCurve;
  92600. private _shadowsCurve;
  92601. private _positiveCurve;
  92602. private _negativeCurve;
  92603. private _globalHue;
  92604. private _globalDensity;
  92605. private _globalSaturation;
  92606. private _globalExposure;
  92607. /**
  92608. * Gets the global Hue value.
  92609. * 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).
  92610. */
  92611. /**
  92612. * Sets the global Hue value.
  92613. * 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).
  92614. */
  92615. globalHue: number;
  92616. /**
  92617. * Gets the global Density value.
  92618. * 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.
  92619. * Values less than zero provide a filter of opposite hue.
  92620. */
  92621. /**
  92622. * Sets the global Density value.
  92623. * 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.
  92624. * Values less than zero provide a filter of opposite hue.
  92625. */
  92626. globalDensity: number;
  92627. /**
  92628. * Gets the global Saturation value.
  92629. * 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.
  92630. */
  92631. /**
  92632. * Sets the global Saturation value.
  92633. * 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.
  92634. */
  92635. globalSaturation: number;
  92636. /**
  92637. * Gets the global Exposure value.
  92638. * 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.
  92639. */
  92640. /**
  92641. * Sets the global Exposure value.
  92642. * 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.
  92643. */
  92644. globalExposure: number;
  92645. private _highlightsHue;
  92646. private _highlightsDensity;
  92647. private _highlightsSaturation;
  92648. private _highlightsExposure;
  92649. /**
  92650. * Gets the highlights Hue value.
  92651. * 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).
  92652. */
  92653. /**
  92654. * Sets the highlights Hue value.
  92655. * 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).
  92656. */
  92657. highlightsHue: number;
  92658. /**
  92659. * Gets the highlights Density value.
  92660. * 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.
  92661. * Values less than zero provide a filter of opposite hue.
  92662. */
  92663. /**
  92664. * Sets the highlights Density value.
  92665. * 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.
  92666. * Values less than zero provide a filter of opposite hue.
  92667. */
  92668. highlightsDensity: number;
  92669. /**
  92670. * Gets the highlights Saturation value.
  92671. * 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.
  92672. */
  92673. /**
  92674. * Sets the highlights Saturation value.
  92675. * 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.
  92676. */
  92677. highlightsSaturation: number;
  92678. /**
  92679. * Gets the highlights Exposure value.
  92680. * 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.
  92681. */
  92682. /**
  92683. * Sets the highlights Exposure value.
  92684. * 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.
  92685. */
  92686. highlightsExposure: number;
  92687. private _midtonesHue;
  92688. private _midtonesDensity;
  92689. private _midtonesSaturation;
  92690. private _midtonesExposure;
  92691. /**
  92692. * Gets the midtones Hue value.
  92693. * 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).
  92694. */
  92695. /**
  92696. * Sets the midtones Hue value.
  92697. * 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).
  92698. */
  92699. midtonesHue: number;
  92700. /**
  92701. * Gets the midtones Density value.
  92702. * 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.
  92703. * Values less than zero provide a filter of opposite hue.
  92704. */
  92705. /**
  92706. * Sets the midtones Density value.
  92707. * 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.
  92708. * Values less than zero provide a filter of opposite hue.
  92709. */
  92710. midtonesDensity: number;
  92711. /**
  92712. * Gets the midtones Saturation value.
  92713. * 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.
  92714. */
  92715. /**
  92716. * Sets the midtones Saturation value.
  92717. * 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.
  92718. */
  92719. midtonesSaturation: number;
  92720. /**
  92721. * Gets the midtones Exposure value.
  92722. * 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.
  92723. */
  92724. /**
  92725. * Sets the midtones Exposure value.
  92726. * 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.
  92727. */
  92728. midtonesExposure: number;
  92729. private _shadowsHue;
  92730. private _shadowsDensity;
  92731. private _shadowsSaturation;
  92732. private _shadowsExposure;
  92733. /**
  92734. * Gets the shadows Hue value.
  92735. * 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).
  92736. */
  92737. /**
  92738. * Sets the shadows Hue value.
  92739. * 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).
  92740. */
  92741. shadowsHue: number;
  92742. /**
  92743. * Gets the shadows Density value.
  92744. * 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.
  92745. * Values less than zero provide a filter of opposite hue.
  92746. */
  92747. /**
  92748. * Sets the shadows Density value.
  92749. * 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.
  92750. * Values less than zero provide a filter of opposite hue.
  92751. */
  92752. shadowsDensity: number;
  92753. /**
  92754. * Gets the shadows Saturation value.
  92755. * 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.
  92756. */
  92757. /**
  92758. * Sets the shadows Saturation value.
  92759. * 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.
  92760. */
  92761. shadowsSaturation: number;
  92762. /**
  92763. * Gets the shadows Exposure value.
  92764. * 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.
  92765. */
  92766. /**
  92767. * Sets the shadows Exposure value.
  92768. * 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.
  92769. */
  92770. shadowsExposure: number;
  92771. /**
  92772. * Returns the class name
  92773. * @returns The class name
  92774. */
  92775. getClassName(): string;
  92776. /**
  92777. * Binds the color curves to the shader.
  92778. * @param colorCurves The color curve to bind
  92779. * @param effect The effect to bind to
  92780. * @param positiveUniform The positive uniform shader parameter
  92781. * @param neutralUniform The neutral uniform shader parameter
  92782. * @param negativeUniform The negative uniform shader parameter
  92783. */
  92784. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92785. /**
  92786. * Prepare the list of uniforms associated with the ColorCurves effects.
  92787. * @param uniformsList The list of uniforms used in the effect
  92788. */
  92789. static PrepareUniforms(uniformsList: string[]): void;
  92790. /**
  92791. * Returns color grading data based on a hue, density, saturation and exposure value.
  92792. * @param filterHue The hue of the color filter.
  92793. * @param filterDensity The density of the color filter.
  92794. * @param saturation The saturation.
  92795. * @param exposure The exposure.
  92796. * @param result The result data container.
  92797. */
  92798. private getColorGradingDataToRef;
  92799. /**
  92800. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92801. * @param value The input slider value in range [-100,100].
  92802. * @returns Adjusted value.
  92803. */
  92804. private static applyColorGradingSliderNonlinear;
  92805. /**
  92806. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92807. * @param hue The hue (H) input.
  92808. * @param saturation The saturation (S) input.
  92809. * @param brightness The brightness (B) input.
  92810. * @result An RGBA color represented as Vector4.
  92811. */
  92812. private static fromHSBToRef;
  92813. /**
  92814. * Returns a value clamped between min and max
  92815. * @param value The value to clamp
  92816. * @param min The minimum of value
  92817. * @param max The maximum of value
  92818. * @returns The clamped value.
  92819. */
  92820. private static clamp;
  92821. /**
  92822. * Clones the current color curve instance.
  92823. * @return The cloned curves
  92824. */
  92825. clone(): ColorCurves;
  92826. /**
  92827. * Serializes the current color curve instance to a json representation.
  92828. * @return a JSON representation
  92829. */
  92830. serialize(): any;
  92831. /**
  92832. * Parses the color curve from a json representation.
  92833. * @param source the JSON source to parse
  92834. * @return The parsed curves
  92835. */
  92836. static Parse(source: any): ColorCurves;
  92837. }
  92838. }
  92839. declare module BABYLON {
  92840. /**
  92841. * Interface to follow in your material defines to integrate easily the
  92842. * Image proccessing functions.
  92843. * @hidden
  92844. */
  92845. export interface IImageProcessingConfigurationDefines {
  92846. IMAGEPROCESSING: boolean;
  92847. VIGNETTE: boolean;
  92848. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92849. VIGNETTEBLENDMODEOPAQUE: boolean;
  92850. TONEMAPPING: boolean;
  92851. TONEMAPPING_ACES: boolean;
  92852. CONTRAST: boolean;
  92853. EXPOSURE: boolean;
  92854. COLORCURVES: boolean;
  92855. COLORGRADING: boolean;
  92856. COLORGRADING3D: boolean;
  92857. SAMPLER3DGREENDEPTH: boolean;
  92858. SAMPLER3DBGRMAP: boolean;
  92859. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92860. }
  92861. /**
  92862. * @hidden
  92863. */
  92864. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  92865. IMAGEPROCESSING: boolean;
  92866. VIGNETTE: boolean;
  92867. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92868. VIGNETTEBLENDMODEOPAQUE: boolean;
  92869. TONEMAPPING: boolean;
  92870. TONEMAPPING_ACES: boolean;
  92871. CONTRAST: boolean;
  92872. COLORCURVES: boolean;
  92873. COLORGRADING: boolean;
  92874. COLORGRADING3D: boolean;
  92875. SAMPLER3DGREENDEPTH: boolean;
  92876. SAMPLER3DBGRMAP: boolean;
  92877. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92878. EXPOSURE: boolean;
  92879. constructor();
  92880. }
  92881. /**
  92882. * This groups together the common properties used for image processing either in direct forward pass
  92883. * or through post processing effect depending on the use of the image processing pipeline in your scene
  92884. * or not.
  92885. */
  92886. export class ImageProcessingConfiguration {
  92887. /**
  92888. * Default tone mapping applied in BabylonJS.
  92889. */
  92890. static readonly TONEMAPPING_STANDARD: number;
  92891. /**
  92892. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92893. * to other engines rendering to increase portability.
  92894. */
  92895. static readonly TONEMAPPING_ACES: number;
  92896. /**
  92897. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92898. */
  92899. colorCurves: Nullable<ColorCurves>;
  92900. private _colorCurvesEnabled;
  92901. /**
  92902. * Gets wether the color curves effect is enabled.
  92903. */
  92904. /**
  92905. * Sets wether the color curves effect is enabled.
  92906. */
  92907. colorCurvesEnabled: boolean;
  92908. private _colorGradingTexture;
  92909. /**
  92910. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92911. */
  92912. /**
  92913. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92914. */
  92915. colorGradingTexture: Nullable<BaseTexture>;
  92916. private _colorGradingEnabled;
  92917. /**
  92918. * Gets wether the color grading effect is enabled.
  92919. */
  92920. /**
  92921. * Sets wether the color grading effect is enabled.
  92922. */
  92923. colorGradingEnabled: boolean;
  92924. private _colorGradingWithGreenDepth;
  92925. /**
  92926. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  92927. */
  92928. /**
  92929. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  92930. */
  92931. colorGradingWithGreenDepth: boolean;
  92932. private _colorGradingBGR;
  92933. /**
  92934. * Gets wether the color grading texture contains BGR values.
  92935. */
  92936. /**
  92937. * Sets wether the color grading texture contains BGR values.
  92938. */
  92939. colorGradingBGR: boolean;
  92940. /** @hidden */
  92941. _exposure: number;
  92942. /**
  92943. * Gets the Exposure used in the effect.
  92944. */
  92945. /**
  92946. * Sets the Exposure used in the effect.
  92947. */
  92948. exposure: number;
  92949. private _toneMappingEnabled;
  92950. /**
  92951. * Gets wether the tone mapping effect is enabled.
  92952. */
  92953. /**
  92954. * Sets wether the tone mapping effect is enabled.
  92955. */
  92956. toneMappingEnabled: boolean;
  92957. private _toneMappingType;
  92958. /**
  92959. * Gets the type of tone mapping effect.
  92960. */
  92961. /**
  92962. * Sets the type of tone mapping effect used in BabylonJS.
  92963. */
  92964. toneMappingType: number;
  92965. protected _contrast: number;
  92966. /**
  92967. * Gets the contrast used in the effect.
  92968. */
  92969. /**
  92970. * Sets the contrast used in the effect.
  92971. */
  92972. contrast: number;
  92973. /**
  92974. * Vignette stretch size.
  92975. */
  92976. vignetteStretch: number;
  92977. /**
  92978. * Vignette centre X Offset.
  92979. */
  92980. vignetteCentreX: number;
  92981. /**
  92982. * Vignette centre Y Offset.
  92983. */
  92984. vignetteCentreY: number;
  92985. /**
  92986. * Vignette weight or intensity of the vignette effect.
  92987. */
  92988. vignetteWeight: number;
  92989. /**
  92990. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  92991. * if vignetteEnabled is set to true.
  92992. */
  92993. vignetteColor: Color4;
  92994. /**
  92995. * Camera field of view used by the Vignette effect.
  92996. */
  92997. vignetteCameraFov: number;
  92998. private _vignetteBlendMode;
  92999. /**
  93000. * Gets the vignette blend mode allowing different kind of effect.
  93001. */
  93002. /**
  93003. * Sets the vignette blend mode allowing different kind of effect.
  93004. */
  93005. vignetteBlendMode: number;
  93006. private _vignetteEnabled;
  93007. /**
  93008. * Gets wether the vignette effect is enabled.
  93009. */
  93010. /**
  93011. * Sets wether the vignette effect is enabled.
  93012. */
  93013. vignetteEnabled: boolean;
  93014. private _applyByPostProcess;
  93015. /**
  93016. * Gets wether the image processing is applied through a post process or not.
  93017. */
  93018. /**
  93019. * Sets wether the image processing is applied through a post process or not.
  93020. */
  93021. applyByPostProcess: boolean;
  93022. private _isEnabled;
  93023. /**
  93024. * Gets wether the image processing is enabled or not.
  93025. */
  93026. /**
  93027. * Sets wether the image processing is enabled or not.
  93028. */
  93029. isEnabled: boolean;
  93030. /**
  93031. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  93032. */
  93033. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  93034. /**
  93035. * Method called each time the image processing information changes requires to recompile the effect.
  93036. */
  93037. protected _updateParameters(): void;
  93038. /**
  93039. * Gets the current class name.
  93040. * @return "ImageProcessingConfiguration"
  93041. */
  93042. getClassName(): string;
  93043. /**
  93044. * Prepare the list of uniforms associated with the Image Processing effects.
  93045. * @param uniforms The list of uniforms used in the effect
  93046. * @param defines the list of defines currently in use
  93047. */
  93048. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  93049. /**
  93050. * Prepare the list of samplers associated with the Image Processing effects.
  93051. * @param samplersList The list of uniforms used in the effect
  93052. * @param defines the list of defines currently in use
  93053. */
  93054. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  93055. /**
  93056. * Prepare the list of defines associated to the shader.
  93057. * @param defines the list of defines to complete
  93058. * @param forPostProcess Define if we are currently in post process mode or not
  93059. */
  93060. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  93061. /**
  93062. * Returns true if all the image processing information are ready.
  93063. * @returns True if ready, otherwise, false
  93064. */
  93065. isReady(): boolean;
  93066. /**
  93067. * Binds the image processing to the shader.
  93068. * @param effect The effect to bind to
  93069. * @param aspectRatio Define the current aspect ratio of the effect
  93070. */
  93071. bind(effect: Effect, aspectRatio?: number): void;
  93072. /**
  93073. * Clones the current image processing instance.
  93074. * @return The cloned image processing
  93075. */
  93076. clone(): ImageProcessingConfiguration;
  93077. /**
  93078. * Serializes the current image processing instance to a json representation.
  93079. * @return a JSON representation
  93080. */
  93081. serialize(): any;
  93082. /**
  93083. * Parses the image processing from a json representation.
  93084. * @param source the JSON source to parse
  93085. * @return The parsed image processing
  93086. */
  93087. static Parse(source: any): ImageProcessingConfiguration;
  93088. private static _VIGNETTEMODE_MULTIPLY;
  93089. private static _VIGNETTEMODE_OPAQUE;
  93090. /**
  93091. * Used to apply the vignette as a mix with the pixel color.
  93092. */
  93093. static readonly VIGNETTEMODE_MULTIPLY: number;
  93094. /**
  93095. * Used to apply the vignette as a replacement of the pixel color.
  93096. */
  93097. static readonly VIGNETTEMODE_OPAQUE: number;
  93098. }
  93099. }
  93100. declare module BABYLON {
  93101. /**
  93102. * This represents all the required information to add a fresnel effect on a material:
  93103. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93104. */
  93105. export class FresnelParameters {
  93106. private _isEnabled;
  93107. /**
  93108. * Define if the fresnel effect is enable or not.
  93109. */
  93110. isEnabled: boolean;
  93111. /**
  93112. * Define the color used on edges (grazing angle)
  93113. */
  93114. leftColor: Color3;
  93115. /**
  93116. * Define the color used on center
  93117. */
  93118. rightColor: Color3;
  93119. /**
  93120. * Define bias applied to computed fresnel term
  93121. */
  93122. bias: number;
  93123. /**
  93124. * Defined the power exponent applied to fresnel term
  93125. */
  93126. power: number;
  93127. /**
  93128. * Clones the current fresnel and its valuues
  93129. * @returns a clone fresnel configuration
  93130. */
  93131. clone(): FresnelParameters;
  93132. /**
  93133. * Serializes the current fresnel parameters to a JSON representation.
  93134. * @return the JSON serialization
  93135. */
  93136. serialize(): any;
  93137. /**
  93138. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93139. * @param parsedFresnelParameters Define the JSON representation
  93140. * @returns the parsed parameters
  93141. */
  93142. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93143. }
  93144. }
  93145. declare module BABYLON {
  93146. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93147. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93148. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93149. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93150. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93151. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93152. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93153. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93154. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93155. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93156. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93157. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93158. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93159. /**
  93160. * Decorator used to define property that can be serialized as reference to a camera
  93161. * @param sourceName defines the name of the property to decorate
  93162. */
  93163. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93164. /**
  93165. * Class used to help serialization objects
  93166. */
  93167. export class SerializationHelper {
  93168. /** @hidden */
  93169. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93170. /** @hidden */
  93171. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93172. /** @hidden */
  93173. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93174. /** @hidden */
  93175. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93176. /**
  93177. * Appends the serialized animations from the source animations
  93178. * @param source Source containing the animations
  93179. * @param destination Target to store the animations
  93180. */
  93181. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93182. /**
  93183. * Static function used to serialized a specific entity
  93184. * @param entity defines the entity to serialize
  93185. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93186. * @returns a JSON compatible object representing the serialization of the entity
  93187. */
  93188. static Serialize<T>(entity: T, serializationObject?: any): any;
  93189. /**
  93190. * Creates a new entity from a serialization data object
  93191. * @param creationFunction defines a function used to instanciated the new entity
  93192. * @param source defines the source serialization data
  93193. * @param scene defines the hosting scene
  93194. * @param rootUrl defines the root url for resources
  93195. * @returns a new entity
  93196. */
  93197. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93198. /**
  93199. * Clones an object
  93200. * @param creationFunction defines the function used to instanciate the new object
  93201. * @param source defines the source object
  93202. * @returns the cloned object
  93203. */
  93204. static Clone<T>(creationFunction: () => T, source: T): T;
  93205. /**
  93206. * Instanciates a new object based on a source one (some data will be shared between both object)
  93207. * @param creationFunction defines the function used to instanciate the new object
  93208. * @param source defines the source object
  93209. * @returns the new object
  93210. */
  93211. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93212. }
  93213. }
  93214. declare module BABYLON {
  93215. /**
  93216. * This is the base class of all the camera used in the application.
  93217. * @see http://doc.babylonjs.com/features/cameras
  93218. */
  93219. export class Camera extends Node {
  93220. /** @hidden */
  93221. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93222. /**
  93223. * This is the default projection mode used by the cameras.
  93224. * It helps recreating a feeling of perspective and better appreciate depth.
  93225. * This is the best way to simulate real life cameras.
  93226. */
  93227. static readonly PERSPECTIVE_CAMERA: number;
  93228. /**
  93229. * This helps creating camera with an orthographic mode.
  93230. * 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.
  93231. */
  93232. static readonly ORTHOGRAPHIC_CAMERA: number;
  93233. /**
  93234. * This is the default FOV mode for perspective cameras.
  93235. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93236. */
  93237. static readonly FOVMODE_VERTICAL_FIXED: number;
  93238. /**
  93239. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93240. */
  93241. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93242. /**
  93243. * This specifies ther is no need for a camera rig.
  93244. * Basically only one eye is rendered corresponding to the camera.
  93245. */
  93246. static readonly RIG_MODE_NONE: number;
  93247. /**
  93248. * Simulates a camera Rig with one blue eye and one red eye.
  93249. * This can be use with 3d blue and red glasses.
  93250. */
  93251. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93252. /**
  93253. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93254. */
  93255. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93256. /**
  93257. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93258. */
  93259. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93260. /**
  93261. * Defines that both eyes of the camera will be rendered over under each other.
  93262. */
  93263. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93264. /**
  93265. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93266. */
  93267. static readonly RIG_MODE_VR: number;
  93268. /**
  93269. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93270. */
  93271. static readonly RIG_MODE_WEBVR: number;
  93272. /**
  93273. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93274. */
  93275. static readonly RIG_MODE_CUSTOM: number;
  93276. /**
  93277. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93278. */
  93279. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93280. /**
  93281. * Define the input manager associated with the camera.
  93282. */
  93283. inputs: CameraInputsManager<Camera>;
  93284. /** @hidden */
  93285. _position: Vector3;
  93286. /**
  93287. * Define the current local position of the camera in the scene
  93288. */
  93289. position: Vector3;
  93290. /**
  93291. * The vector the camera should consider as up.
  93292. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93293. */
  93294. upVector: Vector3;
  93295. /**
  93296. * Define the current limit on the left side for an orthographic camera
  93297. * In scene unit
  93298. */
  93299. orthoLeft: Nullable<number>;
  93300. /**
  93301. * Define the current limit on the right side for an orthographic camera
  93302. * In scene unit
  93303. */
  93304. orthoRight: Nullable<number>;
  93305. /**
  93306. * Define the current limit on the bottom side for an orthographic camera
  93307. * In scene unit
  93308. */
  93309. orthoBottom: Nullable<number>;
  93310. /**
  93311. * Define the current limit on the top side for an orthographic camera
  93312. * In scene unit
  93313. */
  93314. orthoTop: Nullable<number>;
  93315. /**
  93316. * Field Of View is set in Radians. (default is 0.8)
  93317. */
  93318. fov: number;
  93319. /**
  93320. * Define the minimum distance the camera can see from.
  93321. * This is important to note that the depth buffer are not infinite and the closer it starts
  93322. * the more your scene might encounter depth fighting issue.
  93323. */
  93324. minZ: number;
  93325. /**
  93326. * Define the maximum distance the camera can see to.
  93327. * This is important to note that the depth buffer are not infinite and the further it end
  93328. * the more your scene might encounter depth fighting issue.
  93329. */
  93330. maxZ: number;
  93331. /**
  93332. * Define the default inertia of the camera.
  93333. * This helps giving a smooth feeling to the camera movement.
  93334. */
  93335. inertia: number;
  93336. /**
  93337. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93338. */
  93339. mode: number;
  93340. /**
  93341. * Define wether the camera is intermediate.
  93342. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93343. */
  93344. isIntermediate: boolean;
  93345. /**
  93346. * Define the viewport of the camera.
  93347. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93348. */
  93349. viewport: Viewport;
  93350. /**
  93351. * Restricts the camera to viewing objects with the same layerMask.
  93352. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93353. */
  93354. layerMask: number;
  93355. /**
  93356. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93357. */
  93358. fovMode: number;
  93359. /**
  93360. * Rig mode of the camera.
  93361. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93362. * This is normally controlled byt the camera themselves as internal use.
  93363. */
  93364. cameraRigMode: number;
  93365. /**
  93366. * Defines the distance between both "eyes" in case of a RIG
  93367. */
  93368. interaxialDistance: number;
  93369. /**
  93370. * Defines if stereoscopic rendering is done side by side or over under.
  93371. */
  93372. isStereoscopicSideBySide: boolean;
  93373. /**
  93374. * 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
  93375. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93376. * else in the scene.
  93377. */
  93378. customRenderTargets: RenderTargetTexture[];
  93379. /**
  93380. * When set, the camera will render to this render target instead of the default canvas
  93381. */
  93382. outputRenderTarget: Nullable<RenderTargetTexture>;
  93383. /**
  93384. * Observable triggered when the camera view matrix has changed.
  93385. */
  93386. onViewMatrixChangedObservable: Observable<Camera>;
  93387. /**
  93388. * Observable triggered when the camera Projection matrix has changed.
  93389. */
  93390. onProjectionMatrixChangedObservable: Observable<Camera>;
  93391. /**
  93392. * Observable triggered when the inputs have been processed.
  93393. */
  93394. onAfterCheckInputsObservable: Observable<Camera>;
  93395. /**
  93396. * Observable triggered when reset has been called and applied to the camera.
  93397. */
  93398. onRestoreStateObservable: Observable<Camera>;
  93399. /** @hidden */
  93400. _cameraRigParams: any;
  93401. /** @hidden */
  93402. _rigCameras: Camera[];
  93403. /** @hidden */
  93404. _rigPostProcess: Nullable<PostProcess>;
  93405. protected _webvrViewMatrix: Matrix;
  93406. /** @hidden */
  93407. _skipRendering: boolean;
  93408. /** @hidden */
  93409. _projectionMatrix: Matrix;
  93410. /** @hidden */
  93411. _postProcesses: Nullable<PostProcess>[];
  93412. /** @hidden */
  93413. _activeMeshes: SmartArray<AbstractMesh>;
  93414. protected _globalPosition: Vector3;
  93415. /** @hidden */
  93416. _computedViewMatrix: Matrix;
  93417. private _doNotComputeProjectionMatrix;
  93418. private _transformMatrix;
  93419. private _frustumPlanes;
  93420. private _refreshFrustumPlanes;
  93421. private _storedFov;
  93422. private _stateStored;
  93423. /**
  93424. * Instantiates a new camera object.
  93425. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93426. * @see http://doc.babylonjs.com/features/cameras
  93427. * @param name Defines the name of the camera in the scene
  93428. * @param position Defines the position of the camera
  93429. * @param scene Defines the scene the camera belongs too
  93430. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93431. */
  93432. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93433. /**
  93434. * Store current camera state (fov, position, etc..)
  93435. * @returns the camera
  93436. */
  93437. storeState(): Camera;
  93438. /**
  93439. * Restores the camera state values if it has been stored. You must call storeState() first
  93440. */
  93441. protected _restoreStateValues(): boolean;
  93442. /**
  93443. * Restored camera state. You must call storeState() first.
  93444. * @returns true if restored and false otherwise
  93445. */
  93446. restoreState(): boolean;
  93447. /**
  93448. * Gets the class name of the camera.
  93449. * @returns the class name
  93450. */
  93451. getClassName(): string;
  93452. /** @hidden */
  93453. readonly _isCamera: boolean;
  93454. /**
  93455. * Gets a string representation of the camera useful for debug purpose.
  93456. * @param fullDetails Defines that a more verboe level of logging is required
  93457. * @returns the string representation
  93458. */
  93459. toString(fullDetails?: boolean): string;
  93460. /**
  93461. * Gets the current world space position of the camera.
  93462. */
  93463. readonly globalPosition: Vector3;
  93464. /**
  93465. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93466. * @returns the active meshe list
  93467. */
  93468. getActiveMeshes(): SmartArray<AbstractMesh>;
  93469. /**
  93470. * Check wether a mesh is part of the current active mesh list of the camera
  93471. * @param mesh Defines the mesh to check
  93472. * @returns true if active, false otherwise
  93473. */
  93474. isActiveMesh(mesh: Mesh): boolean;
  93475. /**
  93476. * Is this camera ready to be used/rendered
  93477. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93478. * @return true if the camera is ready
  93479. */
  93480. isReady(completeCheck?: boolean): boolean;
  93481. /** @hidden */
  93482. _initCache(): void;
  93483. /** @hidden */
  93484. _updateCache(ignoreParentClass?: boolean): void;
  93485. /** @hidden */
  93486. _isSynchronized(): boolean;
  93487. /** @hidden */
  93488. _isSynchronizedViewMatrix(): boolean;
  93489. /** @hidden */
  93490. _isSynchronizedProjectionMatrix(): boolean;
  93491. /**
  93492. * Attach the input controls to a specific dom element to get the input from.
  93493. * @param element Defines the element the controls should be listened from
  93494. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93495. */
  93496. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93497. /**
  93498. * Detach the current controls from the specified dom element.
  93499. * @param element Defines the element to stop listening the inputs from
  93500. */
  93501. detachControl(element: HTMLElement): void;
  93502. /**
  93503. * Update the camera state according to the different inputs gathered during the frame.
  93504. */
  93505. update(): void;
  93506. /** @hidden */
  93507. _checkInputs(): void;
  93508. /** @hidden */
  93509. readonly rigCameras: Camera[];
  93510. /**
  93511. * Gets the post process used by the rig cameras
  93512. */
  93513. readonly rigPostProcess: Nullable<PostProcess>;
  93514. /**
  93515. * Internal, gets the first post proces.
  93516. * @returns the first post process to be run on this camera.
  93517. */
  93518. _getFirstPostProcess(): Nullable<PostProcess>;
  93519. private _cascadePostProcessesToRigCams;
  93520. /**
  93521. * Attach a post process to the camera.
  93522. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93523. * @param postProcess The post process to attach to the camera
  93524. * @param insertAt The position of the post process in case several of them are in use in the scene
  93525. * @returns the position the post process has been inserted at
  93526. */
  93527. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93528. /**
  93529. * Detach a post process to the camera.
  93530. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93531. * @param postProcess The post process to detach from the camera
  93532. */
  93533. detachPostProcess(postProcess: PostProcess): void;
  93534. /**
  93535. * Gets the current world matrix of the camera
  93536. */
  93537. getWorldMatrix(): Matrix;
  93538. /** @hidden */
  93539. _getViewMatrix(): Matrix;
  93540. /**
  93541. * Gets the current view matrix of the camera.
  93542. * @param force forces the camera to recompute the matrix without looking at the cached state
  93543. * @returns the view matrix
  93544. */
  93545. getViewMatrix(force?: boolean): Matrix;
  93546. /**
  93547. * Freeze the projection matrix.
  93548. * It will prevent the cache check of the camera projection compute and can speed up perf
  93549. * if no parameter of the camera are meant to change
  93550. * @param projection Defines manually a projection if necessary
  93551. */
  93552. freezeProjectionMatrix(projection?: Matrix): void;
  93553. /**
  93554. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93555. */
  93556. unfreezeProjectionMatrix(): void;
  93557. /**
  93558. * Gets the current projection matrix of the camera.
  93559. * @param force forces the camera to recompute the matrix without looking at the cached state
  93560. * @returns the projection matrix
  93561. */
  93562. getProjectionMatrix(force?: boolean): Matrix;
  93563. /**
  93564. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93565. * @returns a Matrix
  93566. */
  93567. getTransformationMatrix(): Matrix;
  93568. private _updateFrustumPlanes;
  93569. /**
  93570. * Checks if a cullable object (mesh...) is in the camera frustum
  93571. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93572. * @param target The object to check
  93573. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93574. * @returns true if the object is in frustum otherwise false
  93575. */
  93576. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93577. /**
  93578. * Checks if a cullable object (mesh...) is in the camera frustum
  93579. * Unlike isInFrustum this cheks the full bounding box
  93580. * @param target The object to check
  93581. * @returns true if the object is in frustum otherwise false
  93582. */
  93583. isCompletelyInFrustum(target: ICullable): boolean;
  93584. /**
  93585. * Gets a ray in the forward direction from the camera.
  93586. * @param length Defines the length of the ray to create
  93587. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93588. * @param origin Defines the start point of the ray which defaults to the camera position
  93589. * @returns the forward ray
  93590. */
  93591. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93592. /**
  93593. * Releases resources associated with this node.
  93594. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93595. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93596. */
  93597. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93598. /** @hidden */
  93599. _isLeftCamera: boolean;
  93600. /**
  93601. * Gets the left camera of a rig setup in case of Rigged Camera
  93602. */
  93603. readonly isLeftCamera: boolean;
  93604. /** @hidden */
  93605. _isRightCamera: boolean;
  93606. /**
  93607. * Gets the right camera of a rig setup in case of Rigged Camera
  93608. */
  93609. readonly isRightCamera: boolean;
  93610. /**
  93611. * Gets the left camera of a rig setup in case of Rigged Camera
  93612. */
  93613. readonly leftCamera: Nullable<FreeCamera>;
  93614. /**
  93615. * Gets the right camera of a rig setup in case of Rigged Camera
  93616. */
  93617. readonly rightCamera: Nullable<FreeCamera>;
  93618. /**
  93619. * Gets the left camera target of a rig setup in case of Rigged Camera
  93620. * @returns the target position
  93621. */
  93622. getLeftTarget(): Nullable<Vector3>;
  93623. /**
  93624. * Gets the right camera target of a rig setup in case of Rigged Camera
  93625. * @returns the target position
  93626. */
  93627. getRightTarget(): Nullable<Vector3>;
  93628. /**
  93629. * @hidden
  93630. */
  93631. setCameraRigMode(mode: number, rigParams: any): void;
  93632. /** @hidden */
  93633. static _setStereoscopicRigMode(camera: Camera): void;
  93634. /** @hidden */
  93635. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93636. /** @hidden */
  93637. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93638. /** @hidden */
  93639. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93640. /** @hidden */
  93641. _getVRProjectionMatrix(): Matrix;
  93642. protected _updateCameraRotationMatrix(): void;
  93643. protected _updateWebVRCameraRotationMatrix(): void;
  93644. /**
  93645. * This function MUST be overwritten by the different WebVR cameras available.
  93646. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93647. * @hidden
  93648. */
  93649. _getWebVRProjectionMatrix(): Matrix;
  93650. /**
  93651. * This function MUST be overwritten by the different WebVR cameras available.
  93652. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93653. * @hidden
  93654. */
  93655. _getWebVRViewMatrix(): Matrix;
  93656. /** @hidden */
  93657. setCameraRigParameter(name: string, value: any): void;
  93658. /**
  93659. * needs to be overridden by children so sub has required properties to be copied
  93660. * @hidden
  93661. */
  93662. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93663. /**
  93664. * May need to be overridden by children
  93665. * @hidden
  93666. */
  93667. _updateRigCameras(): void;
  93668. /** @hidden */
  93669. _setupInputs(): void;
  93670. /**
  93671. * Serialiaze the camera setup to a json represention
  93672. * @returns the JSON representation
  93673. */
  93674. serialize(): any;
  93675. /**
  93676. * Clones the current camera.
  93677. * @param name The cloned camera name
  93678. * @returns the cloned camera
  93679. */
  93680. clone(name: string): Camera;
  93681. /**
  93682. * Gets the direction of the camera relative to a given local axis.
  93683. * @param localAxis Defines the reference axis to provide a relative direction.
  93684. * @return the direction
  93685. */
  93686. getDirection(localAxis: Vector3): Vector3;
  93687. /**
  93688. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93689. * @param localAxis Defines the reference axis to provide a relative direction.
  93690. * @param result Defines the vector to store the result in
  93691. */
  93692. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93693. /**
  93694. * Gets a camera constructor for a given camera type
  93695. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93696. * @param name The name of the camera the result will be able to instantiate
  93697. * @param scene The scene the result will construct the camera in
  93698. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93699. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93700. * @returns a factory method to construc the camera
  93701. */
  93702. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93703. /**
  93704. * Compute the world matrix of the camera.
  93705. * @returns the camera workd matrix
  93706. */
  93707. computeWorldMatrix(): Matrix;
  93708. /**
  93709. * Parse a JSON and creates the camera from the parsed information
  93710. * @param parsedCamera The JSON to parse
  93711. * @param scene The scene to instantiate the camera in
  93712. * @returns the newly constructed camera
  93713. */
  93714. static Parse(parsedCamera: any, scene: Scene): Camera;
  93715. }
  93716. }
  93717. declare module BABYLON {
  93718. /**
  93719. * Interface for any object that can request an animation frame
  93720. */
  93721. export interface ICustomAnimationFrameRequester {
  93722. /**
  93723. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93724. */
  93725. renderFunction?: Function;
  93726. /**
  93727. * Called to request the next frame to render to
  93728. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93729. */
  93730. requestAnimationFrame: Function;
  93731. /**
  93732. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93733. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93734. */
  93735. requestID?: number;
  93736. }
  93737. /**
  93738. * Interface containing an array of animations
  93739. */
  93740. export interface IAnimatable {
  93741. /**
  93742. * Array of animations
  93743. */
  93744. animations: Nullable<Array<Animation>>;
  93745. }
  93746. /** Interface used by value gradients (color, factor, ...) */
  93747. export interface IValueGradient {
  93748. /**
  93749. * Gets or sets the gradient value (between 0 and 1)
  93750. */
  93751. gradient: number;
  93752. }
  93753. /** Class used to store color4 gradient */
  93754. export class ColorGradient implements IValueGradient {
  93755. /**
  93756. * Gets or sets the gradient value (between 0 and 1)
  93757. */
  93758. gradient: number;
  93759. /**
  93760. * Gets or sets first associated color
  93761. */
  93762. color1: Color4;
  93763. /**
  93764. * Gets or sets second associated color
  93765. */
  93766. color2?: Color4;
  93767. /**
  93768. * Will get a color picked randomly between color1 and color2.
  93769. * If color2 is undefined then color1 will be used
  93770. * @param result defines the target Color4 to store the result in
  93771. */
  93772. getColorToRef(result: Color4): void;
  93773. }
  93774. /** Class used to store color 3 gradient */
  93775. export class Color3Gradient implements IValueGradient {
  93776. /**
  93777. * Gets or sets the gradient value (between 0 and 1)
  93778. */
  93779. gradient: number;
  93780. /**
  93781. * Gets or sets the associated color
  93782. */
  93783. color: Color3;
  93784. }
  93785. /** Class used to store factor gradient */
  93786. export class FactorGradient implements IValueGradient {
  93787. /**
  93788. * Gets or sets the gradient value (between 0 and 1)
  93789. */
  93790. gradient: number;
  93791. /**
  93792. * Gets or sets first associated factor
  93793. */
  93794. factor1: number;
  93795. /**
  93796. * Gets or sets second associated factor
  93797. */
  93798. factor2?: number;
  93799. /**
  93800. * Will get a number picked randomly between factor1 and factor2.
  93801. * If factor2 is undefined then factor1 will be used
  93802. * @returns the picked number
  93803. */
  93804. getFactor(): number;
  93805. }
  93806. /**
  93807. * @ignore
  93808. * Application error to support additional information when loading a file
  93809. */
  93810. export class LoadFileError extends Error {
  93811. /** defines the optional web request */
  93812. request?: WebRequest | undefined;
  93813. private static _setPrototypeOf;
  93814. /**
  93815. * Creates a new LoadFileError
  93816. * @param message defines the message of the error
  93817. * @param request defines the optional web request
  93818. */
  93819. constructor(message: string,
  93820. /** defines the optional web request */
  93821. request?: WebRequest | undefined);
  93822. }
  93823. /**
  93824. * Class used to define a retry strategy when error happens while loading assets
  93825. */
  93826. export class RetryStrategy {
  93827. /**
  93828. * Function used to defines an exponential back off strategy
  93829. * @param maxRetries defines the maximum number of retries (3 by default)
  93830. * @param baseInterval defines the interval between retries
  93831. * @returns the strategy function to use
  93832. */
  93833. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  93834. }
  93835. /**
  93836. * File request interface
  93837. */
  93838. export interface IFileRequest {
  93839. /**
  93840. * Raised when the request is complete (success or error).
  93841. */
  93842. onCompleteObservable: Observable<IFileRequest>;
  93843. /**
  93844. * Aborts the request for a file.
  93845. */
  93846. abort: () => void;
  93847. }
  93848. /**
  93849. * Class containing a set of static utilities functions
  93850. */
  93851. export class Tools {
  93852. /**
  93853. * Gets or sets the base URL to use to load assets
  93854. */
  93855. static BaseUrl: string;
  93856. /**
  93857. * Enable/Disable Custom HTTP Request Headers globally.
  93858. * default = false
  93859. * @see CustomRequestHeaders
  93860. */
  93861. static UseCustomRequestHeaders: boolean;
  93862. /**
  93863. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  93864. * i.e. when loading files, where the server/service expects an Authorization header
  93865. */
  93866. static CustomRequestHeaders: {
  93867. [key: string]: string;
  93868. };
  93869. /**
  93870. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  93871. */
  93872. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  93873. /**
  93874. * Default behaviour for cors in the application.
  93875. * It can be a string if the expected behavior is identical in the entire app.
  93876. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  93877. */
  93878. static CorsBehavior: string | ((url: string | string[]) => string);
  93879. /**
  93880. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  93881. * @ignorenaming
  93882. */
  93883. static UseFallbackTexture: boolean;
  93884. /**
  93885. * Use this object to register external classes like custom textures or material
  93886. * to allow the laoders to instantiate them
  93887. */
  93888. static RegisteredExternalClasses: {
  93889. [key: string]: Object;
  93890. };
  93891. /**
  93892. * Texture content used if a texture cannot loaded
  93893. * @ignorenaming
  93894. */
  93895. static fallbackTexture: string;
  93896. /**
  93897. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  93898. * @param u defines the coordinate on X axis
  93899. * @param v defines the coordinate on Y axis
  93900. * @param width defines the width of the source data
  93901. * @param height defines the height of the source data
  93902. * @param pixels defines the source byte array
  93903. * @param color defines the output color
  93904. */
  93905. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  93906. /**
  93907. * Interpolates between a and b via alpha
  93908. * @param a The lower value (returned when alpha = 0)
  93909. * @param b The upper value (returned when alpha = 1)
  93910. * @param alpha The interpolation-factor
  93911. * @return The mixed value
  93912. */
  93913. static Mix(a: number, b: number, alpha: number): number;
  93914. /**
  93915. * Tries to instantiate a new object from a given class name
  93916. * @param className defines the class name to instantiate
  93917. * @returns the new object or null if the system was not able to do the instantiation
  93918. */
  93919. static Instantiate(className: string): any;
  93920. /**
  93921. * Provides a slice function that will work even on IE
  93922. * @param data defines the array to slice
  93923. * @param start defines the start of the data (optional)
  93924. * @param end defines the end of the data (optional)
  93925. * @returns the new sliced array
  93926. */
  93927. static Slice<T>(data: T, start?: number, end?: number): T;
  93928. /**
  93929. * Polyfill for setImmediate
  93930. * @param action defines the action to execute after the current execution block
  93931. */
  93932. static SetImmediate(action: () => void): void;
  93933. /**
  93934. * Function indicating if a number is an exponent of 2
  93935. * @param value defines the value to test
  93936. * @returns true if the value is an exponent of 2
  93937. */
  93938. static IsExponentOfTwo(value: number): boolean;
  93939. private static _tmpFloatArray;
  93940. /**
  93941. * Returns the nearest 32-bit single precision float representation of a Number
  93942. * @param value A Number. If the parameter is of a different type, it will get converted
  93943. * to a number or to NaN if it cannot be converted
  93944. * @returns number
  93945. */
  93946. static FloatRound(value: number): number;
  93947. /**
  93948. * Find the next highest power of two.
  93949. * @param x Number to start search from.
  93950. * @return Next highest power of two.
  93951. */
  93952. static CeilingPOT(x: number): number;
  93953. /**
  93954. * Find the next lowest power of two.
  93955. * @param x Number to start search from.
  93956. * @return Next lowest power of two.
  93957. */
  93958. static FloorPOT(x: number): number;
  93959. /**
  93960. * Find the nearest power of two.
  93961. * @param x Number to start search from.
  93962. * @return Next nearest power of two.
  93963. */
  93964. static NearestPOT(x: number): number;
  93965. /**
  93966. * Get the closest exponent of two
  93967. * @param value defines the value to approximate
  93968. * @param max defines the maximum value to return
  93969. * @param mode defines how to define the closest value
  93970. * @returns closest exponent of two of the given value
  93971. */
  93972. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  93973. /**
  93974. * Extracts the filename from a path
  93975. * @param path defines the path to use
  93976. * @returns the filename
  93977. */
  93978. static GetFilename(path: string): string;
  93979. /**
  93980. * Extracts the "folder" part of a path (everything before the filename).
  93981. * @param uri The URI to extract the info from
  93982. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  93983. * @returns The "folder" part of the path
  93984. */
  93985. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  93986. /**
  93987. * Extracts text content from a DOM element hierarchy
  93988. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  93989. */
  93990. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  93991. /**
  93992. * Convert an angle in radians to degrees
  93993. * @param angle defines the angle to convert
  93994. * @returns the angle in degrees
  93995. */
  93996. static ToDegrees(angle: number): number;
  93997. /**
  93998. * Convert an angle in degrees to radians
  93999. * @param angle defines the angle to convert
  94000. * @returns the angle in radians
  94001. */
  94002. static ToRadians(angle: number): number;
  94003. /**
  94004. * Encode a buffer to a base64 string
  94005. * @param buffer defines the buffer to encode
  94006. * @returns the encoded string
  94007. */
  94008. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  94009. /**
  94010. * Extracts minimum and maximum values from a list of indexed positions
  94011. * @param positions defines the positions to use
  94012. * @param indices defines the indices to the positions
  94013. * @param indexStart defines the start index
  94014. * @param indexCount defines the end index
  94015. * @param bias defines bias value to add to the result
  94016. * @return minimum and maximum values
  94017. */
  94018. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  94019. minimum: Vector3;
  94020. maximum: Vector3;
  94021. };
  94022. /**
  94023. * Extracts minimum and maximum values from a list of positions
  94024. * @param positions defines the positions to use
  94025. * @param start defines the start index in the positions array
  94026. * @param count defines the number of positions to handle
  94027. * @param bias defines bias value to add to the result
  94028. * @param stride defines the stride size to use (distance between two positions in the positions array)
  94029. * @return minimum and maximum values
  94030. */
  94031. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  94032. minimum: Vector3;
  94033. maximum: Vector3;
  94034. };
  94035. /**
  94036. * Returns an array if obj is not an array
  94037. * @param obj defines the object to evaluate as an array
  94038. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  94039. * @returns either obj directly if obj is an array or a new array containing obj
  94040. */
  94041. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  94042. /**
  94043. * Gets the pointer prefix to use
  94044. * @returns "pointer" if touch is enabled. Else returns "mouse"
  94045. */
  94046. static GetPointerPrefix(): string;
  94047. /**
  94048. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  94049. * @param func - the function to be called
  94050. * @param requester - the object that will request the next frame. Falls back to window.
  94051. * @returns frame number
  94052. */
  94053. static QueueNewFrame(func: () => void, requester?: any): number;
  94054. /**
  94055. * Ask the browser to promote the current element to fullscreen rendering mode
  94056. * @param element defines the DOM element to promote
  94057. */
  94058. static RequestFullscreen(element: HTMLElement): void;
  94059. /**
  94060. * Asks the browser to exit fullscreen mode
  94061. */
  94062. static ExitFullscreen(): void;
  94063. /**
  94064. * Ask the browser to promote the current element to pointerlock mode
  94065. * @param element defines the DOM element to promote
  94066. */
  94067. static RequestPointerlock(element: HTMLElement): void;
  94068. /**
  94069. * Asks the browser to exit pointerlock mode
  94070. */
  94071. static ExitPointerlock(): void;
  94072. /**
  94073. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  94074. * @param url define the url we are trying
  94075. * @param element define the dom element where to configure the cors policy
  94076. */
  94077. static SetCorsBehavior(url: string | string[], element: {
  94078. crossOrigin: string | null;
  94079. }): void;
  94080. /**
  94081. * Removes unwanted characters from an url
  94082. * @param url defines the url to clean
  94083. * @returns the cleaned url
  94084. */
  94085. static CleanUrl(url: string): string;
  94086. /**
  94087. * Gets or sets a function used to pre-process url before using them to load assets
  94088. */
  94089. static PreprocessUrl: (url: string) => string;
  94090. /**
  94091. * Loads an image as an HTMLImageElement.
  94092. * @param input url string, ArrayBuffer, or Blob to load
  94093. * @param onLoad callback called when the image successfully loads
  94094. * @param onError callback called when the image fails to load
  94095. * @param offlineProvider offline provider for caching
  94096. * @returns the HTMLImageElement of the loaded image
  94097. */
  94098. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  94099. /**
  94100. * Loads a file
  94101. * @param url url string, ArrayBuffer, or Blob to load
  94102. * @param onSuccess callback called when the file successfully loads
  94103. * @param onProgress callback called while file is loading (if the server supports this mode)
  94104. * @param offlineProvider defines the offline provider for caching
  94105. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  94106. * @param onError callback called when the file fails to load
  94107. * @returns a file request object
  94108. */
  94109. 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;
  94110. /**
  94111. * Loads a file from a url
  94112. * @param url the file url to load
  94113. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  94114. */
  94115. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  94116. /**
  94117. * Load a script (identified by an url). When the url returns, the
  94118. * content of this file is added into a new script element, attached to the DOM (body element)
  94119. * @param scriptUrl defines the url of the script to laod
  94120. * @param onSuccess defines the callback called when the script is loaded
  94121. * @param onError defines the callback to call if an error occurs
  94122. * @param scriptId defines the id of the script element
  94123. */
  94124. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  94125. /**
  94126. * Load an asynchronous script (identified by an url). When the url returns, the
  94127. * content of this file is added into a new script element, attached to the DOM (body element)
  94128. * @param scriptUrl defines the url of the script to laod
  94129. * @param scriptId defines the id of the script element
  94130. * @returns a promise request object
  94131. */
  94132. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  94133. /**
  94134. * Loads a file from a blob
  94135. * @param fileToLoad defines the blob to use
  94136. * @param callback defines the callback to call when data is loaded
  94137. * @param progressCallback defines the callback to call during loading process
  94138. * @returns a file request object
  94139. */
  94140. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  94141. /**
  94142. * Loads a file
  94143. * @param fileToLoad defines the file to load
  94144. * @param callback defines the callback to call when data is loaded
  94145. * @param progressCallBack defines the callback to call during loading process
  94146. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  94147. * @returns a file request object
  94148. */
  94149. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  94150. /**
  94151. * Creates a data url from a given string content
  94152. * @param content defines the content to convert
  94153. * @returns the new data url link
  94154. */
  94155. static FileAsURL(content: string): string;
  94156. /**
  94157. * Format the given number to a specific decimal format
  94158. * @param value defines the number to format
  94159. * @param decimals defines the number of decimals to use
  94160. * @returns the formatted string
  94161. */
  94162. static Format(value: number, decimals?: number): string;
  94163. /**
  94164. * Checks if a given vector is inside a specific range
  94165. * @param v defines the vector to test
  94166. * @param min defines the minimum range
  94167. * @param max defines the maximum range
  94168. */
  94169. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  94170. /**
  94171. * Tries to copy an object by duplicating every property
  94172. * @param source defines the source object
  94173. * @param destination defines the target object
  94174. * @param doNotCopyList defines a list of properties to avoid
  94175. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  94176. */
  94177. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  94178. /**
  94179. * Gets a boolean indicating if the given object has no own property
  94180. * @param obj defines the object to test
  94181. * @returns true if object has no own property
  94182. */
  94183. static IsEmpty(obj: any): boolean;
  94184. /**
  94185. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  94186. * @param str Source string
  94187. * @param suffix Suffix to search for in the source string
  94188. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94189. */
  94190. static EndsWith(str: string, suffix: string): boolean;
  94191. /**
  94192. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  94193. * @param str Source string
  94194. * @param suffix Suffix to search for in the source string
  94195. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94196. */
  94197. static StartsWith(str: string, suffix: string): boolean;
  94198. /**
  94199. * Function used to register events at window level
  94200. * @param events defines the events to register
  94201. */
  94202. static RegisterTopRootEvents(events: {
  94203. name: string;
  94204. handler: Nullable<(e: FocusEvent) => any>;
  94205. }[]): void;
  94206. /**
  94207. * Function used to unregister events from window level
  94208. * @param events defines the events to unregister
  94209. */
  94210. static UnregisterTopRootEvents(events: {
  94211. name: string;
  94212. handler: Nullable<(e: FocusEvent) => any>;
  94213. }[]): void;
  94214. /**
  94215. * @ignore
  94216. */
  94217. static _ScreenshotCanvas: HTMLCanvasElement;
  94218. /**
  94219. * Dumps the current bound framebuffer
  94220. * @param width defines the rendering width
  94221. * @param height defines the rendering height
  94222. * @param engine defines the hosting engine
  94223. * @param successCallback defines the callback triggered once the data are available
  94224. * @param mimeType defines the mime type of the result
  94225. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  94226. */
  94227. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94228. /**
  94229. * Converts the canvas data to blob.
  94230. * This acts as a polyfill for browsers not supporting the to blob function.
  94231. * @param canvas Defines the canvas to extract the data from
  94232. * @param successCallback Defines the callback triggered once the data are available
  94233. * @param mimeType Defines the mime type of the result
  94234. */
  94235. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  94236. /**
  94237. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  94238. * @param successCallback defines the callback triggered once the data are available
  94239. * @param mimeType defines the mime type of the result
  94240. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  94241. */
  94242. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94243. /**
  94244. * Downloads a blob in the browser
  94245. * @param blob defines the blob to download
  94246. * @param fileName defines the name of the downloaded file
  94247. */
  94248. static Download(blob: Blob, fileName: string): void;
  94249. /**
  94250. * Captures a screenshot of the current rendering
  94251. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94252. * @param engine defines the rendering engine
  94253. * @param camera defines the source camera
  94254. * @param size This parameter can be set to a single number or to an object with the
  94255. * following (optional) properties: precision, width, height. If a single number is passed,
  94256. * it will be used for both width and height. If an object is passed, the screenshot size
  94257. * will be derived from the parameters. The precision property is a multiplier allowing
  94258. * rendering at a higher or lower resolution
  94259. * @param successCallback defines the callback receives a single parameter which contains the
  94260. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94261. * src parameter of an <img> to display it
  94262. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  94263. * Check your browser for supported MIME types
  94264. */
  94265. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  94266. /**
  94267. * Generates an image screenshot from the specified camera.
  94268. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94269. * @param engine The engine to use for rendering
  94270. * @param camera The camera to use for rendering
  94271. * @param size This parameter can be set to a single number or to an object with the
  94272. * following (optional) properties: precision, width, height. If a single number is passed,
  94273. * it will be used for both width and height. If an object is passed, the screenshot size
  94274. * will be derived from the parameters. The precision property is a multiplier allowing
  94275. * rendering at a higher or lower resolution
  94276. * @param successCallback The callback receives a single parameter which contains the
  94277. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94278. * src parameter of an <img> to display it
  94279. * @param mimeType The MIME type of the screenshot image (default: image/png).
  94280. * Check your browser for supported MIME types
  94281. * @param samples Texture samples (default: 1)
  94282. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  94283. * @param fileName A name for for the downloaded file.
  94284. */
  94285. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  94286. /**
  94287. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94288. * Be aware Math.random() could cause collisions, but:
  94289. * "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"
  94290. * @returns a pseudo random id
  94291. */
  94292. static RandomId(): string;
  94293. /**
  94294. * Test if the given uri is a base64 string
  94295. * @param uri The uri to test
  94296. * @return True if the uri is a base64 string or false otherwise
  94297. */
  94298. static IsBase64(uri: string): boolean;
  94299. /**
  94300. * Decode the given base64 uri.
  94301. * @param uri The uri to decode
  94302. * @return The decoded base64 data.
  94303. */
  94304. static DecodeBase64(uri: string): ArrayBuffer;
  94305. /**
  94306. * Gets the absolute url.
  94307. * @param url the input url
  94308. * @return the absolute url
  94309. */
  94310. static GetAbsoluteUrl(url: string): string;
  94311. /**
  94312. * No log
  94313. */
  94314. static readonly NoneLogLevel: number;
  94315. /**
  94316. * Only message logs
  94317. */
  94318. static readonly MessageLogLevel: number;
  94319. /**
  94320. * Only warning logs
  94321. */
  94322. static readonly WarningLogLevel: number;
  94323. /**
  94324. * Only error logs
  94325. */
  94326. static readonly ErrorLogLevel: number;
  94327. /**
  94328. * All logs
  94329. */
  94330. static readonly AllLogLevel: number;
  94331. /**
  94332. * Gets a value indicating the number of loading errors
  94333. * @ignorenaming
  94334. */
  94335. static readonly errorsCount: number;
  94336. /**
  94337. * Callback called when a new log is added
  94338. */
  94339. static OnNewCacheEntry: (entry: string) => void;
  94340. /**
  94341. * Log a message to the console
  94342. * @param message defines the message to log
  94343. */
  94344. static Log(message: string): void;
  94345. /**
  94346. * Write a warning message to the console
  94347. * @param message defines the message to log
  94348. */
  94349. static Warn(message: string): void;
  94350. /**
  94351. * Write an error message to the console
  94352. * @param message defines the message to log
  94353. */
  94354. static Error(message: string): void;
  94355. /**
  94356. * Gets current log cache (list of logs)
  94357. */
  94358. static readonly LogCache: string;
  94359. /**
  94360. * Clears the log cache
  94361. */
  94362. static ClearLogCache(): void;
  94363. /**
  94364. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94365. */
  94366. static LogLevels: number;
  94367. /**
  94368. * Checks if the loaded document was accessed via `file:`-Protocol.
  94369. * @returns boolean
  94370. */
  94371. static IsFileURL(): boolean;
  94372. /**
  94373. * Checks if the window object exists
  94374. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  94375. */
  94376. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  94377. /**
  94378. * No performance log
  94379. */
  94380. static readonly PerformanceNoneLogLevel: number;
  94381. /**
  94382. * Use user marks to log performance
  94383. */
  94384. static readonly PerformanceUserMarkLogLevel: number;
  94385. /**
  94386. * Log performance to the console
  94387. */
  94388. static readonly PerformanceConsoleLogLevel: number;
  94389. private static _performance;
  94390. /**
  94391. * Sets the current performance log level
  94392. */
  94393. static PerformanceLogLevel: number;
  94394. private static _StartPerformanceCounterDisabled;
  94395. private static _EndPerformanceCounterDisabled;
  94396. private static _StartUserMark;
  94397. private static _EndUserMark;
  94398. private static _StartPerformanceConsole;
  94399. private static _EndPerformanceConsole;
  94400. /**
  94401. * Starts a performance counter
  94402. */
  94403. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94404. /**
  94405. * Ends a specific performance coutner
  94406. */
  94407. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94408. /**
  94409. * Gets either window.performance.now() if supported or Date.now() else
  94410. */
  94411. static readonly Now: number;
  94412. /**
  94413. * This method will return the name of the class used to create the instance of the given object.
  94414. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  94415. * @param object the object to get the class name from
  94416. * @param isType defines if the object is actually a type
  94417. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  94418. */
  94419. static GetClassName(object: any, isType?: boolean): string;
  94420. /**
  94421. * Gets the first element of an array satisfying a given predicate
  94422. * @param array defines the array to browse
  94423. * @param predicate defines the predicate to use
  94424. * @returns null if not found or the element
  94425. */
  94426. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  94427. /**
  94428. * This method will return the name of the full name of the class, including its owning module (if any).
  94429. * 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).
  94430. * @param object the object to get the class name from
  94431. * @param isType defines if the object is actually a type
  94432. * @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.
  94433. * @ignorenaming
  94434. */
  94435. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  94436. /**
  94437. * Returns a promise that resolves after the given amount of time.
  94438. * @param delay Number of milliseconds to delay
  94439. * @returns Promise that resolves after the given amount of time
  94440. */
  94441. static DelayAsync(delay: number): Promise<void>;
  94442. /**
  94443. * Gets the current gradient from an array of IValueGradient
  94444. * @param ratio defines the current ratio to get
  94445. * @param gradients defines the array of IValueGradient
  94446. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  94447. */
  94448. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  94449. }
  94450. /**
  94451. * This class is used to track a performance counter which is number based.
  94452. * The user has access to many properties which give statistics of different nature.
  94453. *
  94454. * The implementer can track two kinds of Performance Counter: time and count.
  94455. * 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.
  94456. * 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.
  94457. */
  94458. export class PerfCounter {
  94459. /**
  94460. * Gets or sets a global boolean to turn on and off all the counters
  94461. */
  94462. static Enabled: boolean;
  94463. /**
  94464. * Returns the smallest value ever
  94465. */
  94466. readonly min: number;
  94467. /**
  94468. * Returns the biggest value ever
  94469. */
  94470. readonly max: number;
  94471. /**
  94472. * Returns the average value since the performance counter is running
  94473. */
  94474. readonly average: number;
  94475. /**
  94476. * Returns the average value of the last second the counter was monitored
  94477. */
  94478. readonly lastSecAverage: number;
  94479. /**
  94480. * Returns the current value
  94481. */
  94482. readonly current: number;
  94483. /**
  94484. * Gets the accumulated total
  94485. */
  94486. readonly total: number;
  94487. /**
  94488. * Gets the total value count
  94489. */
  94490. readonly count: number;
  94491. /**
  94492. * Creates a new counter
  94493. */
  94494. constructor();
  94495. /**
  94496. * Call this method to start monitoring a new frame.
  94497. * 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.
  94498. */
  94499. fetchNewFrame(): void;
  94500. /**
  94501. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94502. * @param newCount the count value to add to the monitored count
  94503. * @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.
  94504. */
  94505. addCount(newCount: number, fetchResult: boolean): void;
  94506. /**
  94507. * Start monitoring this performance counter
  94508. */
  94509. beginMonitoring(): void;
  94510. /**
  94511. * Compute the time lapsed since the previous beginMonitoring() call.
  94512. * @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
  94513. */
  94514. endMonitoring(newFrame?: boolean): void;
  94515. private _fetchResult;
  94516. private _startMonitoringTime;
  94517. private _min;
  94518. private _max;
  94519. private _average;
  94520. private _current;
  94521. private _totalValueCount;
  94522. private _totalAccumulated;
  94523. private _lastSecAverage;
  94524. private _lastSecAccumulated;
  94525. private _lastSecTime;
  94526. private _lastSecValueCount;
  94527. }
  94528. /**
  94529. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94530. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94531. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94532. * @param name The name of the class, case should be preserved
  94533. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94534. */
  94535. export function className(name: string, module?: string): (target: Object) => void;
  94536. /**
  94537. * An implementation of a loop for asynchronous functions.
  94538. */
  94539. export class AsyncLoop {
  94540. /**
  94541. * Defines the number of iterations for the loop
  94542. */
  94543. iterations: number;
  94544. /**
  94545. * Defines the current index of the loop.
  94546. */
  94547. index: number;
  94548. private _done;
  94549. private _fn;
  94550. private _successCallback;
  94551. /**
  94552. * Constructor.
  94553. * @param iterations the number of iterations.
  94554. * @param func the function to run each iteration
  94555. * @param successCallback the callback that will be called upon succesful execution
  94556. * @param offset starting offset.
  94557. */
  94558. constructor(
  94559. /**
  94560. * Defines the number of iterations for the loop
  94561. */
  94562. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94563. /**
  94564. * Execute the next iteration. Must be called after the last iteration was finished.
  94565. */
  94566. executeNext(): void;
  94567. /**
  94568. * Break the loop and run the success callback.
  94569. */
  94570. breakLoop(): void;
  94571. /**
  94572. * Create and run an async loop.
  94573. * @param iterations the number of iterations.
  94574. * @param fn the function to run each iteration
  94575. * @param successCallback the callback that will be called upon succesful execution
  94576. * @param offset starting offset.
  94577. * @returns the created async loop object
  94578. */
  94579. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94580. /**
  94581. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94582. * @param iterations total number of iterations
  94583. * @param syncedIterations number of synchronous iterations in each async iteration.
  94584. * @param fn the function to call each iteration.
  94585. * @param callback a success call back that will be called when iterating stops.
  94586. * @param breakFunction a break condition (optional)
  94587. * @param timeout timeout settings for the setTimeout function. default - 0.
  94588. * @returns the created async loop object
  94589. */
  94590. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94591. }
  94592. }
  94593. declare module BABYLON {
  94594. /** @hidden */
  94595. export interface ICollisionCoordinator {
  94596. createCollider(): Collider;
  94597. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94598. init(scene: Scene): void;
  94599. }
  94600. /** @hidden */
  94601. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94602. private _scene;
  94603. private _scaledPosition;
  94604. private _scaledVelocity;
  94605. private _finalPosition;
  94606. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94607. createCollider(): Collider;
  94608. init(scene: Scene): void;
  94609. private _collideWithWorld;
  94610. }
  94611. }
  94612. declare module BABYLON {
  94613. /**
  94614. * Class used to manage all inputs for the scene.
  94615. */
  94616. export class InputManager {
  94617. /** The distance in pixel that you have to move to prevent some events */
  94618. static DragMovementThreshold: number;
  94619. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94620. static LongPressDelay: number;
  94621. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94622. static DoubleClickDelay: number;
  94623. /** If you need to check double click without raising a single click at first click, enable this flag */
  94624. static ExclusiveDoubleClickMode: boolean;
  94625. private _wheelEventName;
  94626. private _onPointerMove;
  94627. private _onPointerDown;
  94628. private _onPointerUp;
  94629. private _initClickEvent;
  94630. private _initActionManager;
  94631. private _delayedSimpleClick;
  94632. private _delayedSimpleClickTimeout;
  94633. private _previousDelayedSimpleClickTimeout;
  94634. private _meshPickProceed;
  94635. private _previousButtonPressed;
  94636. private _currentPickResult;
  94637. private _previousPickResult;
  94638. private _totalPointersPressed;
  94639. private _doubleClickOccured;
  94640. private _pointerOverMesh;
  94641. private _pickedDownMesh;
  94642. private _pickedUpMesh;
  94643. private _pointerX;
  94644. private _pointerY;
  94645. private _unTranslatedPointerX;
  94646. private _unTranslatedPointerY;
  94647. private _startingPointerPosition;
  94648. private _previousStartingPointerPosition;
  94649. private _startingPointerTime;
  94650. private _previousStartingPointerTime;
  94651. private _pointerCaptures;
  94652. private _onKeyDown;
  94653. private _onKeyUp;
  94654. private _onCanvasFocusObserver;
  94655. private _onCanvasBlurObserver;
  94656. private _scene;
  94657. /**
  94658. * Creates a new InputManager
  94659. * @param scene defines the hosting scene
  94660. */
  94661. constructor(scene: Scene);
  94662. /**
  94663. * Gets the mesh that is currently under the pointer
  94664. */
  94665. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94666. /**
  94667. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94668. */
  94669. readonly unTranslatedPointer: Vector2;
  94670. /**
  94671. * Gets or sets the current on-screen X position of the pointer
  94672. */
  94673. pointerX: number;
  94674. /**
  94675. * Gets or sets the current on-screen Y position of the pointer
  94676. */
  94677. pointerY: number;
  94678. private _updatePointerPosition;
  94679. private _processPointerMove;
  94680. private _setRayOnPointerInfo;
  94681. private _checkPrePointerObservable;
  94682. /**
  94683. * Use this method to simulate a pointer move on a mesh
  94684. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94685. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94686. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94687. */
  94688. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94689. /**
  94690. * Use this method to simulate a pointer down on a mesh
  94691. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94692. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94693. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94694. */
  94695. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94696. private _processPointerDown;
  94697. /** @hidden */
  94698. _isPointerSwiping(): boolean;
  94699. /**
  94700. * Use this method to simulate a pointer up on a mesh
  94701. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94702. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94703. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94704. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94705. */
  94706. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  94707. private _processPointerUp;
  94708. /**
  94709. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94710. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94711. * @returns true if the pointer was captured
  94712. */
  94713. isPointerCaptured(pointerId?: number): boolean;
  94714. /**
  94715. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  94716. * @param attachUp defines if you want to attach events to pointerup
  94717. * @param attachDown defines if you want to attach events to pointerdown
  94718. * @param attachMove defines if you want to attach events to pointermove
  94719. */
  94720. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  94721. /**
  94722. * Detaches all event handlers
  94723. */
  94724. detachControl(): void;
  94725. /**
  94726. * Force the value of meshUnderPointer
  94727. * @param mesh defines the mesh to use
  94728. */
  94729. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  94730. /**
  94731. * Gets the mesh under the pointer
  94732. * @returns a Mesh or null if no mesh is under the pointer
  94733. */
  94734. getPointerOverMesh(): Nullable<AbstractMesh>;
  94735. }
  94736. }
  94737. declare module BABYLON {
  94738. /**
  94739. * This class defines the direct association between an animation and a target
  94740. */
  94741. export class TargetedAnimation {
  94742. /**
  94743. * Animation to perform
  94744. */
  94745. animation: Animation;
  94746. /**
  94747. * Target to animate
  94748. */
  94749. target: any;
  94750. /**
  94751. * Serialize the object
  94752. * @returns the JSON object representing the current entity
  94753. */
  94754. serialize(): any;
  94755. }
  94756. /**
  94757. * Use this class to create coordinated animations on multiple targets
  94758. */
  94759. export class AnimationGroup implements IDisposable {
  94760. /** The name of the animation group */
  94761. name: string;
  94762. private _scene;
  94763. private _targetedAnimations;
  94764. private _animatables;
  94765. private _from;
  94766. private _to;
  94767. private _isStarted;
  94768. private _isPaused;
  94769. private _speedRatio;
  94770. private _loopAnimation;
  94771. /**
  94772. * Gets or sets the unique id of the node
  94773. */
  94774. uniqueId: number;
  94775. /**
  94776. * This observable will notify when one animation have ended
  94777. */
  94778. onAnimationEndObservable: Observable<TargetedAnimation>;
  94779. /**
  94780. * Observer raised when one animation loops
  94781. */
  94782. onAnimationLoopObservable: Observable<TargetedAnimation>;
  94783. /**
  94784. * This observable will notify when all animations have ended.
  94785. */
  94786. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  94787. /**
  94788. * This observable will notify when all animations have paused.
  94789. */
  94790. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  94791. /**
  94792. * This observable will notify when all animations are playing.
  94793. */
  94794. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  94795. /**
  94796. * Gets the first frame
  94797. */
  94798. readonly from: number;
  94799. /**
  94800. * Gets the last frame
  94801. */
  94802. readonly to: number;
  94803. /**
  94804. * Define if the animations are started
  94805. */
  94806. readonly isStarted: boolean;
  94807. /**
  94808. * Gets a value indicating that the current group is playing
  94809. */
  94810. readonly isPlaying: boolean;
  94811. /**
  94812. * Gets or sets the speed ratio to use for all animations
  94813. */
  94814. /**
  94815. * Gets or sets the speed ratio to use for all animations
  94816. */
  94817. speedRatio: number;
  94818. /**
  94819. * Gets or sets if all animations should loop or not
  94820. */
  94821. loopAnimation: boolean;
  94822. /**
  94823. * Gets the targeted animations for this animation group
  94824. */
  94825. readonly targetedAnimations: Array<TargetedAnimation>;
  94826. /**
  94827. * returning the list of animatables controlled by this animation group.
  94828. */
  94829. readonly animatables: Array<Animatable>;
  94830. /**
  94831. * Instantiates a new Animation Group.
  94832. * This helps managing several animations at once.
  94833. * @see http://doc.babylonjs.com/how_to/group
  94834. * @param name Defines the name of the group
  94835. * @param scene Defines the scene the group belongs to
  94836. */
  94837. constructor(
  94838. /** The name of the animation group */
  94839. name: string, scene?: Nullable<Scene>);
  94840. /**
  94841. * Add an animation (with its target) in the group
  94842. * @param animation defines the animation we want to add
  94843. * @param target defines the target of the animation
  94844. * @returns the TargetedAnimation object
  94845. */
  94846. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  94847. /**
  94848. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  94849. * It can add constant keys at begin or end
  94850. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  94851. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  94852. * @returns the animation group
  94853. */
  94854. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  94855. /**
  94856. * Start all animations on given targets
  94857. * @param loop defines if animations must loop
  94858. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  94859. * @param from defines the from key (optional)
  94860. * @param to defines the to key (optional)
  94861. * @returns the current animation group
  94862. */
  94863. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  94864. /**
  94865. * Pause all animations
  94866. * @returns the animation group
  94867. */
  94868. pause(): AnimationGroup;
  94869. /**
  94870. * Play all animations to initial state
  94871. * This function will start() the animations if they were not started or will restart() them if they were paused
  94872. * @param loop defines if animations must loop
  94873. * @returns the animation group
  94874. */
  94875. play(loop?: boolean): AnimationGroup;
  94876. /**
  94877. * Reset all animations to initial state
  94878. * @returns the animation group
  94879. */
  94880. reset(): AnimationGroup;
  94881. /**
  94882. * Restart animations from key 0
  94883. * @returns the animation group
  94884. */
  94885. restart(): AnimationGroup;
  94886. /**
  94887. * Stop all animations
  94888. * @returns the animation group
  94889. */
  94890. stop(): AnimationGroup;
  94891. /**
  94892. * Set animation weight for all animatables
  94893. * @param weight defines the weight to use
  94894. * @return the animationGroup
  94895. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94896. */
  94897. setWeightForAllAnimatables(weight: number): AnimationGroup;
  94898. /**
  94899. * Synchronize and normalize all animatables with a source animatable
  94900. * @param root defines the root animatable to synchronize with
  94901. * @return the animationGroup
  94902. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94903. */
  94904. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  94905. /**
  94906. * Goes to a specific frame in this animation group
  94907. * @param frame the frame number to go to
  94908. * @return the animationGroup
  94909. */
  94910. goToFrame(frame: number): AnimationGroup;
  94911. /**
  94912. * Dispose all associated resources
  94913. */
  94914. dispose(): void;
  94915. private _checkAnimationGroupEnded;
  94916. /**
  94917. * Clone the current animation group and returns a copy
  94918. * @param newName defines the name of the new group
  94919. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  94920. * @returns the new aniamtion group
  94921. */
  94922. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  94923. /**
  94924. * Serializes the animationGroup to an object
  94925. * @returns Serialized object
  94926. */
  94927. serialize(): any;
  94928. /**
  94929. * Returns a new AnimationGroup object parsed from the source provided.
  94930. * @param parsedAnimationGroup defines the source
  94931. * @param scene defines the scene that will receive the animationGroup
  94932. * @returns a new AnimationGroup
  94933. */
  94934. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  94935. /**
  94936. * Returns the string "AnimationGroup"
  94937. * @returns "AnimationGroup"
  94938. */
  94939. getClassName(): string;
  94940. /**
  94941. * Creates a detailled string about the object
  94942. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  94943. * @returns a string representing the object
  94944. */
  94945. toString(fullDetails?: boolean): string;
  94946. }
  94947. }
  94948. declare module BABYLON {
  94949. /**
  94950. * Define an interface for all classes that will hold resources
  94951. */
  94952. export interface IDisposable {
  94953. /**
  94954. * Releases all held resources
  94955. */
  94956. dispose(): void;
  94957. }
  94958. /** Interface defining initialization parameters for Scene class */
  94959. export interface SceneOptions {
  94960. /**
  94961. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  94962. * It will improve performance when the number of geometries becomes important.
  94963. */
  94964. useGeometryUniqueIdsMap?: boolean;
  94965. /**
  94966. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  94967. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94968. */
  94969. useMaterialMeshMap?: boolean;
  94970. /**
  94971. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  94972. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94973. */
  94974. useClonedMeshhMap?: boolean;
  94975. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  94976. virtual?: boolean;
  94977. }
  94978. /**
  94979. * Represents a scene to be rendered by the engine.
  94980. * @see http://doc.babylonjs.com/features/scene
  94981. */
  94982. export class Scene extends AbstractScene implements IAnimatable {
  94983. private static _uniqueIdCounter;
  94984. /** The fog is deactivated */
  94985. static readonly FOGMODE_NONE: number;
  94986. /** The fog density is following an exponential function */
  94987. static readonly FOGMODE_EXP: number;
  94988. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  94989. static readonly FOGMODE_EXP2: number;
  94990. /** The fog density is following a linear function. */
  94991. static readonly FOGMODE_LINEAR: number;
  94992. /**
  94993. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  94994. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94995. */
  94996. static MinDeltaTime: number;
  94997. /**
  94998. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  94999. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95000. */
  95001. static MaxDeltaTime: number;
  95002. /**
  95003. * Factory used to create the default material.
  95004. * @param name The name of the material to create
  95005. * @param scene The scene to create the material for
  95006. * @returns The default material
  95007. */
  95008. static DefaultMaterialFactory(scene: Scene): Material;
  95009. /**
  95010. * Factory used to create the a collision coordinator.
  95011. * @returns The collision coordinator
  95012. */
  95013. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  95014. /** @hidden */
  95015. _inputManager: InputManager;
  95016. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  95017. cameraToUseForPointers: Nullable<Camera>;
  95018. /** @hidden */
  95019. readonly _isScene: boolean;
  95020. /**
  95021. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  95022. */
  95023. autoClear: boolean;
  95024. /**
  95025. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  95026. */
  95027. autoClearDepthAndStencil: boolean;
  95028. /**
  95029. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  95030. */
  95031. clearColor: Color4;
  95032. /**
  95033. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  95034. */
  95035. ambientColor: Color3;
  95036. /**
  95037. * This is use to store the default BRDF lookup for PBR materials in your scene.
  95038. * It should only be one of the following (if not the default embedded one):
  95039. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  95040. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  95041. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  95042. * The material properties need to be setup according to the type of texture in use.
  95043. */
  95044. environmentBRDFTexture: BaseTexture;
  95045. /** @hidden */
  95046. protected _environmentTexture: Nullable<BaseTexture>;
  95047. /**
  95048. * Texture used in all pbr material as the reflection texture.
  95049. * As in the majority of the scene they are the same (exception for multi room and so on),
  95050. * this is easier to reference from here than from all the materials.
  95051. */
  95052. /**
  95053. * Texture used in all pbr material as the reflection texture.
  95054. * As in the majority of the scene they are the same (exception for multi room and so on),
  95055. * this is easier to set here than in all the materials.
  95056. */
  95057. environmentTexture: Nullable<BaseTexture>;
  95058. /** @hidden */
  95059. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95060. /**
  95061. * Default image processing configuration used either in the rendering
  95062. * Forward main pass or through the imageProcessingPostProcess if present.
  95063. * As in the majority of the scene they are the same (exception for multi camera),
  95064. * this is easier to reference from here than from all the materials and post process.
  95065. *
  95066. * No setter as we it is a shared configuration, you can set the values instead.
  95067. */
  95068. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  95069. private _forceWireframe;
  95070. /**
  95071. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  95072. */
  95073. forceWireframe: boolean;
  95074. private _forcePointsCloud;
  95075. /**
  95076. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  95077. */
  95078. forcePointsCloud: boolean;
  95079. /**
  95080. * Gets or sets the active clipplane 1
  95081. */
  95082. clipPlane: Nullable<Plane>;
  95083. /**
  95084. * Gets or sets the active clipplane 2
  95085. */
  95086. clipPlane2: Nullable<Plane>;
  95087. /**
  95088. * Gets or sets the active clipplane 3
  95089. */
  95090. clipPlane3: Nullable<Plane>;
  95091. /**
  95092. * Gets or sets the active clipplane 4
  95093. */
  95094. clipPlane4: Nullable<Plane>;
  95095. /**
  95096. * Gets or sets a boolean indicating if animations are enabled
  95097. */
  95098. animationsEnabled: boolean;
  95099. private _animationPropertiesOverride;
  95100. /**
  95101. * Gets or sets the animation properties override
  95102. */
  95103. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95104. /**
  95105. * Gets or sets a boolean indicating if a constant deltatime has to be used
  95106. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  95107. */
  95108. useConstantAnimationDeltaTime: boolean;
  95109. /**
  95110. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  95111. * Please note that it requires to run a ray cast through the scene on every frame
  95112. */
  95113. constantlyUpdateMeshUnderPointer: boolean;
  95114. /**
  95115. * Defines the HTML cursor to use when hovering over interactive elements
  95116. */
  95117. hoverCursor: string;
  95118. /**
  95119. * Defines the HTML default cursor to use (empty by default)
  95120. */
  95121. defaultCursor: string;
  95122. /**
  95123. * This is used to call preventDefault() on pointer down
  95124. * in order to block unwanted artifacts like system double clicks
  95125. */
  95126. preventDefaultOnPointerDown: boolean;
  95127. /**
  95128. * This is used to call preventDefault() on pointer up
  95129. * in order to block unwanted artifacts like system double clicks
  95130. */
  95131. preventDefaultOnPointerUp: boolean;
  95132. /**
  95133. * Gets or sets user defined metadata
  95134. */
  95135. metadata: any;
  95136. /**
  95137. * For internal use only. Please do not use.
  95138. */
  95139. reservedDataStore: any;
  95140. /**
  95141. * Gets the name of the plugin used to load this scene (null by default)
  95142. */
  95143. loadingPluginName: string;
  95144. /**
  95145. * Use this array to add regular expressions used to disable offline support for specific urls
  95146. */
  95147. disableOfflineSupportExceptionRules: RegExp[];
  95148. /**
  95149. * An event triggered when the scene is disposed.
  95150. */
  95151. onDisposeObservable: Observable<Scene>;
  95152. private _onDisposeObserver;
  95153. /** Sets a function to be executed when this scene is disposed. */
  95154. onDispose: () => void;
  95155. /**
  95156. * An event triggered before rendering the scene (right after animations and physics)
  95157. */
  95158. onBeforeRenderObservable: Observable<Scene>;
  95159. private _onBeforeRenderObserver;
  95160. /** Sets a function to be executed before rendering this scene */
  95161. beforeRender: Nullable<() => void>;
  95162. /**
  95163. * An event triggered after rendering the scene
  95164. */
  95165. onAfterRenderObservable: Observable<Scene>;
  95166. /**
  95167. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  95168. */
  95169. onAfterRenderCameraObservable: Observable<Camera>;
  95170. private _onAfterRenderObserver;
  95171. /** Sets a function to be executed after rendering this scene */
  95172. afterRender: Nullable<() => void>;
  95173. /**
  95174. * An event triggered before animating the scene
  95175. */
  95176. onBeforeAnimationsObservable: Observable<Scene>;
  95177. /**
  95178. * An event triggered after animations processing
  95179. */
  95180. onAfterAnimationsObservable: Observable<Scene>;
  95181. /**
  95182. * An event triggered before draw calls are ready to be sent
  95183. */
  95184. onBeforeDrawPhaseObservable: Observable<Scene>;
  95185. /**
  95186. * An event triggered after draw calls have been sent
  95187. */
  95188. onAfterDrawPhaseObservable: Observable<Scene>;
  95189. /**
  95190. * An event triggered when the scene is ready
  95191. */
  95192. onReadyObservable: Observable<Scene>;
  95193. /**
  95194. * An event triggered before rendering a camera
  95195. */
  95196. onBeforeCameraRenderObservable: Observable<Camera>;
  95197. private _onBeforeCameraRenderObserver;
  95198. /** Sets a function to be executed before rendering a camera*/
  95199. beforeCameraRender: () => void;
  95200. /**
  95201. * An event triggered after rendering a camera
  95202. */
  95203. onAfterCameraRenderObservable: Observable<Camera>;
  95204. private _onAfterCameraRenderObserver;
  95205. /** Sets a function to be executed after rendering a camera*/
  95206. afterCameraRender: () => void;
  95207. /**
  95208. * An event triggered when active meshes evaluation is about to start
  95209. */
  95210. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  95211. /**
  95212. * An event triggered when active meshes evaluation is done
  95213. */
  95214. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  95215. /**
  95216. * An event triggered when particles rendering is about to start
  95217. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95218. */
  95219. onBeforeParticlesRenderingObservable: Observable<Scene>;
  95220. /**
  95221. * An event triggered when particles rendering is done
  95222. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95223. */
  95224. onAfterParticlesRenderingObservable: Observable<Scene>;
  95225. /**
  95226. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  95227. */
  95228. onDataLoadedObservable: Observable<Scene>;
  95229. /**
  95230. * An event triggered when a camera is created
  95231. */
  95232. onNewCameraAddedObservable: Observable<Camera>;
  95233. /**
  95234. * An event triggered when a camera is removed
  95235. */
  95236. onCameraRemovedObservable: Observable<Camera>;
  95237. /**
  95238. * An event triggered when a light is created
  95239. */
  95240. onNewLightAddedObservable: Observable<Light>;
  95241. /**
  95242. * An event triggered when a light is removed
  95243. */
  95244. onLightRemovedObservable: Observable<Light>;
  95245. /**
  95246. * An event triggered when a geometry is created
  95247. */
  95248. onNewGeometryAddedObservable: Observable<Geometry>;
  95249. /**
  95250. * An event triggered when a geometry is removed
  95251. */
  95252. onGeometryRemovedObservable: Observable<Geometry>;
  95253. /**
  95254. * An event triggered when a transform node is created
  95255. */
  95256. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  95257. /**
  95258. * An event triggered when a transform node is removed
  95259. */
  95260. onTransformNodeRemovedObservable: Observable<TransformNode>;
  95261. /**
  95262. * An event triggered when a mesh is created
  95263. */
  95264. onNewMeshAddedObservable: Observable<AbstractMesh>;
  95265. /**
  95266. * An event triggered when a mesh is removed
  95267. */
  95268. onMeshRemovedObservable: Observable<AbstractMesh>;
  95269. /**
  95270. * An event triggered when a skeleton is created
  95271. */
  95272. onNewSkeletonAddedObservable: Observable<Skeleton>;
  95273. /**
  95274. * An event triggered when a skeleton is removed
  95275. */
  95276. onSkeletonRemovedObservable: Observable<Skeleton>;
  95277. /**
  95278. * An event triggered when a material is created
  95279. */
  95280. onNewMaterialAddedObservable: Observable<Material>;
  95281. /**
  95282. * An event triggered when a material is removed
  95283. */
  95284. onMaterialRemovedObservable: Observable<Material>;
  95285. /**
  95286. * An event triggered when a texture is created
  95287. */
  95288. onNewTextureAddedObservable: Observable<BaseTexture>;
  95289. /**
  95290. * An event triggered when a texture is removed
  95291. */
  95292. onTextureRemovedObservable: Observable<BaseTexture>;
  95293. /**
  95294. * An event triggered when render targets are about to be rendered
  95295. * Can happen multiple times per frame.
  95296. */
  95297. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  95298. /**
  95299. * An event triggered when render targets were rendered.
  95300. * Can happen multiple times per frame.
  95301. */
  95302. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  95303. /**
  95304. * An event triggered before calculating deterministic simulation step
  95305. */
  95306. onBeforeStepObservable: Observable<Scene>;
  95307. /**
  95308. * An event triggered after calculating deterministic simulation step
  95309. */
  95310. onAfterStepObservable: Observable<Scene>;
  95311. /**
  95312. * An event triggered when the activeCamera property is updated
  95313. */
  95314. onActiveCameraChanged: Observable<Scene>;
  95315. /**
  95316. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  95317. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95318. * 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)
  95319. */
  95320. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95321. /**
  95322. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  95323. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95324. * 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)
  95325. */
  95326. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95327. /**
  95328. * This Observable will when a mesh has been imported into the scene.
  95329. */
  95330. onMeshImportedObservable: Observable<AbstractMesh>;
  95331. /**
  95332. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  95333. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  95334. */
  95335. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  95336. /** @hidden */
  95337. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  95338. /**
  95339. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  95340. */
  95341. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  95342. /**
  95343. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  95344. */
  95345. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  95346. /**
  95347. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  95348. */
  95349. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  95350. /** Callback called when a pointer move is detected */
  95351. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95352. /** Callback called when a pointer down is detected */
  95353. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95354. /** Callback called when a pointer up is detected */
  95355. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  95356. /** Callback called when a pointer pick is detected */
  95357. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  95358. /**
  95359. * 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).
  95360. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  95361. */
  95362. onPrePointerObservable: Observable<PointerInfoPre>;
  95363. /**
  95364. * Observable event triggered each time an input event is received from the rendering canvas
  95365. */
  95366. onPointerObservable: Observable<PointerInfo>;
  95367. /**
  95368. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  95369. */
  95370. readonly unTranslatedPointer: Vector2;
  95371. /**
  95372. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  95373. */
  95374. static DragMovementThreshold: number;
  95375. /**
  95376. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  95377. */
  95378. static LongPressDelay: number;
  95379. /**
  95380. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  95381. */
  95382. static DoubleClickDelay: number;
  95383. /** If you need to check double click without raising a single click at first click, enable this flag */
  95384. static ExclusiveDoubleClickMode: boolean;
  95385. /** @hidden */
  95386. _mirroredCameraPosition: Nullable<Vector3>;
  95387. /**
  95388. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  95389. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  95390. */
  95391. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  95392. /**
  95393. * Observable event triggered each time an keyboard event is received from the hosting window
  95394. */
  95395. onKeyboardObservable: Observable<KeyboardInfo>;
  95396. private _useRightHandedSystem;
  95397. /**
  95398. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  95399. */
  95400. useRightHandedSystem: boolean;
  95401. private _timeAccumulator;
  95402. private _currentStepId;
  95403. private _currentInternalStep;
  95404. /**
  95405. * Sets the step Id used by deterministic lock step
  95406. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95407. * @param newStepId defines the step Id
  95408. */
  95409. setStepId(newStepId: number): void;
  95410. /**
  95411. * Gets the step Id used by deterministic lock step
  95412. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95413. * @returns the step Id
  95414. */
  95415. getStepId(): number;
  95416. /**
  95417. * Gets the internal step used by deterministic lock step
  95418. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95419. * @returns the internal step
  95420. */
  95421. getInternalStep(): number;
  95422. private _fogEnabled;
  95423. /**
  95424. * Gets or sets a boolean indicating if fog is enabled on this scene
  95425. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95426. * (Default is true)
  95427. */
  95428. fogEnabled: boolean;
  95429. private _fogMode;
  95430. /**
  95431. * Gets or sets the fog mode to use
  95432. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95433. * | mode | value |
  95434. * | --- | --- |
  95435. * | FOGMODE_NONE | 0 |
  95436. * | FOGMODE_EXP | 1 |
  95437. * | FOGMODE_EXP2 | 2 |
  95438. * | FOGMODE_LINEAR | 3 |
  95439. */
  95440. fogMode: number;
  95441. /**
  95442. * Gets or sets the fog color to use
  95443. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95444. * (Default is Color3(0.2, 0.2, 0.3))
  95445. */
  95446. fogColor: Color3;
  95447. /**
  95448. * Gets or sets the fog density to use
  95449. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95450. * (Default is 0.1)
  95451. */
  95452. fogDensity: number;
  95453. /**
  95454. * Gets or sets the fog start distance to use
  95455. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95456. * (Default is 0)
  95457. */
  95458. fogStart: number;
  95459. /**
  95460. * Gets or sets the fog end distance to use
  95461. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95462. * (Default is 1000)
  95463. */
  95464. fogEnd: number;
  95465. private _shadowsEnabled;
  95466. /**
  95467. * Gets or sets a boolean indicating if shadows are enabled on this scene
  95468. */
  95469. shadowsEnabled: boolean;
  95470. private _lightsEnabled;
  95471. /**
  95472. * Gets or sets a boolean indicating if lights are enabled on this scene
  95473. */
  95474. lightsEnabled: boolean;
  95475. /** All of the active cameras added to this scene. */
  95476. activeCameras: Camera[];
  95477. /** @hidden */
  95478. _activeCamera: Nullable<Camera>;
  95479. /** Gets or sets the current active camera */
  95480. activeCamera: Nullable<Camera>;
  95481. private _defaultMaterial;
  95482. /** The default material used on meshes when no material is affected */
  95483. /** The default material used on meshes when no material is affected */
  95484. defaultMaterial: Material;
  95485. private _texturesEnabled;
  95486. /**
  95487. * Gets or sets a boolean indicating if textures are enabled on this scene
  95488. */
  95489. texturesEnabled: boolean;
  95490. /**
  95491. * Gets or sets a boolean indicating if particles are enabled on this scene
  95492. */
  95493. particlesEnabled: boolean;
  95494. /**
  95495. * Gets or sets a boolean indicating if sprites are enabled on this scene
  95496. */
  95497. spritesEnabled: boolean;
  95498. private _skeletonsEnabled;
  95499. /**
  95500. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  95501. */
  95502. skeletonsEnabled: boolean;
  95503. /**
  95504. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  95505. */
  95506. lensFlaresEnabled: boolean;
  95507. /**
  95508. * Gets or sets a boolean indicating if collisions are enabled on this scene
  95509. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95510. */
  95511. collisionsEnabled: boolean;
  95512. private _collisionCoordinator;
  95513. /** @hidden */
  95514. readonly collisionCoordinator: ICollisionCoordinator;
  95515. /**
  95516. * Defines the gravity applied to this scene (used only for collisions)
  95517. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95518. */
  95519. gravity: Vector3;
  95520. /**
  95521. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  95522. */
  95523. postProcessesEnabled: boolean;
  95524. /**
  95525. * The list of postprocesses added to the scene
  95526. */
  95527. postProcesses: PostProcess[];
  95528. /**
  95529. * Gets the current postprocess manager
  95530. */
  95531. postProcessManager: PostProcessManager;
  95532. /**
  95533. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95534. */
  95535. renderTargetsEnabled: boolean;
  95536. /**
  95537. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95538. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95539. */
  95540. dumpNextRenderTargets: boolean;
  95541. /**
  95542. * The list of user defined render targets added to the scene
  95543. */
  95544. customRenderTargets: RenderTargetTexture[];
  95545. /**
  95546. * Defines if texture loading must be delayed
  95547. * If true, textures will only be loaded when they need to be rendered
  95548. */
  95549. useDelayedTextureLoading: boolean;
  95550. /**
  95551. * Gets the list of meshes imported to the scene through SceneLoader
  95552. */
  95553. importedMeshesFiles: String[];
  95554. /**
  95555. * Gets or sets a boolean indicating if probes are enabled on this scene
  95556. */
  95557. probesEnabled: boolean;
  95558. /**
  95559. * Gets or sets the current offline provider to use to store scene data
  95560. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95561. */
  95562. offlineProvider: IOfflineProvider;
  95563. /**
  95564. * Gets or sets the action manager associated with the scene
  95565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95566. */
  95567. actionManager: AbstractActionManager;
  95568. private _meshesForIntersections;
  95569. /**
  95570. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95571. */
  95572. proceduralTexturesEnabled: boolean;
  95573. private _engine;
  95574. private _totalVertices;
  95575. /** @hidden */
  95576. _activeIndices: PerfCounter;
  95577. /** @hidden */
  95578. _activeParticles: PerfCounter;
  95579. /** @hidden */
  95580. _activeBones: PerfCounter;
  95581. private _animationRatio;
  95582. /** @hidden */
  95583. _animationTimeLast: number;
  95584. /** @hidden */
  95585. _animationTime: number;
  95586. /**
  95587. * Gets or sets a general scale for animation speed
  95588. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95589. */
  95590. animationTimeScale: number;
  95591. /** @hidden */
  95592. _cachedMaterial: Nullable<Material>;
  95593. /** @hidden */
  95594. _cachedEffect: Nullable<Effect>;
  95595. /** @hidden */
  95596. _cachedVisibility: Nullable<number>;
  95597. private _renderId;
  95598. private _frameId;
  95599. private _executeWhenReadyTimeoutId;
  95600. private _intermediateRendering;
  95601. private _viewUpdateFlag;
  95602. private _projectionUpdateFlag;
  95603. /** @hidden */
  95604. _toBeDisposed: Nullable<IDisposable>[];
  95605. private _activeRequests;
  95606. /** @hidden */
  95607. _pendingData: any[];
  95608. private _isDisposed;
  95609. /**
  95610. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95611. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95612. */
  95613. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95614. private _activeMeshes;
  95615. private _processedMaterials;
  95616. private _renderTargets;
  95617. /** @hidden */
  95618. _activeParticleSystems: SmartArray<IParticleSystem>;
  95619. private _activeSkeletons;
  95620. private _softwareSkinnedMeshes;
  95621. private _renderingManager;
  95622. /** @hidden */
  95623. _activeAnimatables: Animatable[];
  95624. private _transformMatrix;
  95625. private _sceneUbo;
  95626. /** @hidden */
  95627. _viewMatrix: Matrix;
  95628. private _projectionMatrix;
  95629. /** @hidden */
  95630. _forcedViewPosition: Nullable<Vector3>;
  95631. /** @hidden */
  95632. _frustumPlanes: Plane[];
  95633. /**
  95634. * Gets the list of frustum planes (built from the active camera)
  95635. */
  95636. readonly frustumPlanes: Plane[];
  95637. /**
  95638. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95639. * This is useful if there are more lights that the maximum simulteanous authorized
  95640. */
  95641. requireLightSorting: boolean;
  95642. /** @hidden */
  95643. readonly useMaterialMeshMap: boolean;
  95644. /** @hidden */
  95645. readonly useClonedMeshhMap: boolean;
  95646. private _externalData;
  95647. private _uid;
  95648. /**
  95649. * @hidden
  95650. * Backing store of defined scene components.
  95651. */
  95652. _components: ISceneComponent[];
  95653. /**
  95654. * @hidden
  95655. * Backing store of defined scene components.
  95656. */
  95657. _serializableComponents: ISceneSerializableComponent[];
  95658. /**
  95659. * List of components to register on the next registration step.
  95660. */
  95661. private _transientComponents;
  95662. /**
  95663. * Registers the transient components if needed.
  95664. */
  95665. private _registerTransientComponents;
  95666. /**
  95667. * @hidden
  95668. * Add a component to the scene.
  95669. * Note that the ccomponent could be registered on th next frame if this is called after
  95670. * the register component stage.
  95671. * @param component Defines the component to add to the scene
  95672. */
  95673. _addComponent(component: ISceneComponent): void;
  95674. /**
  95675. * @hidden
  95676. * Gets a component from the scene.
  95677. * @param name defines the name of the component to retrieve
  95678. * @returns the component or null if not present
  95679. */
  95680. _getComponent(name: string): Nullable<ISceneComponent>;
  95681. /**
  95682. * @hidden
  95683. * Defines the actions happening before camera updates.
  95684. */
  95685. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95686. /**
  95687. * @hidden
  95688. * Defines the actions happening before clear the canvas.
  95689. */
  95690. _beforeClearStage: Stage<SimpleStageAction>;
  95691. /**
  95692. * @hidden
  95693. * Defines the actions when collecting render targets for the frame.
  95694. */
  95695. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95696. /**
  95697. * @hidden
  95698. * Defines the actions happening for one camera in the frame.
  95699. */
  95700. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95701. /**
  95702. * @hidden
  95703. * Defines the actions happening during the per mesh ready checks.
  95704. */
  95705. _isReadyForMeshStage: Stage<MeshStageAction>;
  95706. /**
  95707. * @hidden
  95708. * Defines the actions happening before evaluate active mesh checks.
  95709. */
  95710. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  95711. /**
  95712. * @hidden
  95713. * Defines the actions happening during the evaluate sub mesh checks.
  95714. */
  95715. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  95716. /**
  95717. * @hidden
  95718. * Defines the actions happening during the active mesh stage.
  95719. */
  95720. _activeMeshStage: Stage<ActiveMeshStageAction>;
  95721. /**
  95722. * @hidden
  95723. * Defines the actions happening during the per camera render target step.
  95724. */
  95725. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  95726. /**
  95727. * @hidden
  95728. * Defines the actions happening just before the active camera is drawing.
  95729. */
  95730. _beforeCameraDrawStage: Stage<CameraStageAction>;
  95731. /**
  95732. * @hidden
  95733. * Defines the actions happening just before a render target is drawing.
  95734. */
  95735. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95736. /**
  95737. * @hidden
  95738. * Defines the actions happening just before a rendering group is drawing.
  95739. */
  95740. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95741. /**
  95742. * @hidden
  95743. * Defines the actions happening just before a mesh is drawing.
  95744. */
  95745. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95746. /**
  95747. * @hidden
  95748. * Defines the actions happening just after a mesh has been drawn.
  95749. */
  95750. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95751. /**
  95752. * @hidden
  95753. * Defines the actions happening just after a rendering group has been drawn.
  95754. */
  95755. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95756. /**
  95757. * @hidden
  95758. * Defines the actions happening just after the active camera has been drawn.
  95759. */
  95760. _afterCameraDrawStage: Stage<CameraStageAction>;
  95761. /**
  95762. * @hidden
  95763. * Defines the actions happening just after a render target has been drawn.
  95764. */
  95765. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95766. /**
  95767. * @hidden
  95768. * Defines the actions happening just after rendering all cameras and computing intersections.
  95769. */
  95770. _afterRenderStage: Stage<SimpleStageAction>;
  95771. /**
  95772. * @hidden
  95773. * Defines the actions happening when a pointer move event happens.
  95774. */
  95775. _pointerMoveStage: Stage<PointerMoveStageAction>;
  95776. /**
  95777. * @hidden
  95778. * Defines the actions happening when a pointer down event happens.
  95779. */
  95780. _pointerDownStage: Stage<PointerUpDownStageAction>;
  95781. /**
  95782. * @hidden
  95783. * Defines the actions happening when a pointer up event happens.
  95784. */
  95785. _pointerUpStage: Stage<PointerUpDownStageAction>;
  95786. /**
  95787. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  95788. */
  95789. private geometriesByUniqueId;
  95790. /**
  95791. * Creates a new Scene
  95792. * @param engine defines the engine to use to render this scene
  95793. * @param options defines the scene options
  95794. */
  95795. constructor(engine: Engine, options?: SceneOptions);
  95796. /**
  95797. * Gets a string idenfifying the name of the class
  95798. * @returns "Scene" string
  95799. */
  95800. getClassName(): string;
  95801. private _defaultMeshCandidates;
  95802. /**
  95803. * @hidden
  95804. */
  95805. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95806. private _defaultSubMeshCandidates;
  95807. /**
  95808. * @hidden
  95809. */
  95810. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95811. /**
  95812. * Sets the default candidate providers for the scene.
  95813. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  95814. * and getCollidingSubMeshCandidates to their default function
  95815. */
  95816. setDefaultCandidateProviders(): void;
  95817. /**
  95818. * Gets the mesh that is currently under the pointer
  95819. */
  95820. readonly meshUnderPointer: Nullable<AbstractMesh>;
  95821. /**
  95822. * Gets or sets the current on-screen X position of the pointer
  95823. */
  95824. pointerX: number;
  95825. /**
  95826. * Gets or sets the current on-screen Y position of the pointer
  95827. */
  95828. pointerY: number;
  95829. /**
  95830. * Gets the cached material (ie. the latest rendered one)
  95831. * @returns the cached material
  95832. */
  95833. getCachedMaterial(): Nullable<Material>;
  95834. /**
  95835. * Gets the cached effect (ie. the latest rendered one)
  95836. * @returns the cached effect
  95837. */
  95838. getCachedEffect(): Nullable<Effect>;
  95839. /**
  95840. * Gets the cached visibility state (ie. the latest rendered one)
  95841. * @returns the cached visibility state
  95842. */
  95843. getCachedVisibility(): Nullable<number>;
  95844. /**
  95845. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  95846. * @param material defines the current material
  95847. * @param effect defines the current effect
  95848. * @param visibility defines the current visibility state
  95849. * @returns true if one parameter is not cached
  95850. */
  95851. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  95852. /**
  95853. * Gets the engine associated with the scene
  95854. * @returns an Engine
  95855. */
  95856. getEngine(): Engine;
  95857. /**
  95858. * Gets the total number of vertices rendered per frame
  95859. * @returns the total number of vertices rendered per frame
  95860. */
  95861. getTotalVertices(): number;
  95862. /**
  95863. * Gets the performance counter for total vertices
  95864. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95865. */
  95866. readonly totalVerticesPerfCounter: PerfCounter;
  95867. /**
  95868. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  95869. * @returns the total number of active indices rendered per frame
  95870. */
  95871. getActiveIndices(): number;
  95872. /**
  95873. * Gets the performance counter for active indices
  95874. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95875. */
  95876. readonly totalActiveIndicesPerfCounter: PerfCounter;
  95877. /**
  95878. * Gets the total number of active particles rendered per frame
  95879. * @returns the total number of active particles rendered per frame
  95880. */
  95881. getActiveParticles(): number;
  95882. /**
  95883. * Gets the performance counter for active particles
  95884. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95885. */
  95886. readonly activeParticlesPerfCounter: PerfCounter;
  95887. /**
  95888. * Gets the total number of active bones rendered per frame
  95889. * @returns the total number of active bones rendered per frame
  95890. */
  95891. getActiveBones(): number;
  95892. /**
  95893. * Gets the performance counter for active bones
  95894. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95895. */
  95896. readonly activeBonesPerfCounter: PerfCounter;
  95897. /**
  95898. * Gets the array of active meshes
  95899. * @returns an array of AbstractMesh
  95900. */
  95901. getActiveMeshes(): SmartArray<AbstractMesh>;
  95902. /**
  95903. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  95904. * @returns a number
  95905. */
  95906. getAnimationRatio(): number;
  95907. /**
  95908. * Gets an unique Id for the current render phase
  95909. * @returns a number
  95910. */
  95911. getRenderId(): number;
  95912. /**
  95913. * Gets an unique Id for the current frame
  95914. * @returns a number
  95915. */
  95916. getFrameId(): number;
  95917. /** Call this function if you want to manually increment the render Id*/
  95918. incrementRenderId(): void;
  95919. private _createUbo;
  95920. /**
  95921. * Use this method to simulate a pointer move on a mesh
  95922. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95923. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95924. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95925. * @returns the current scene
  95926. */
  95927. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95928. /**
  95929. * Use this method to simulate a pointer down on a mesh
  95930. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95931. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95932. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95933. * @returns the current scene
  95934. */
  95935. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95936. /**
  95937. * Use this method to simulate a pointer up on a mesh
  95938. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95939. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95940. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95941. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  95942. * @returns the current scene
  95943. */
  95944. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  95945. /**
  95946. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  95947. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  95948. * @returns true if the pointer was captured
  95949. */
  95950. isPointerCaptured(pointerId?: number): boolean;
  95951. /**
  95952. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  95953. * @param attachUp defines if you want to attach events to pointerup
  95954. * @param attachDown defines if you want to attach events to pointerdown
  95955. * @param attachMove defines if you want to attach events to pointermove
  95956. */
  95957. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  95958. /** Detaches all event handlers*/
  95959. detachControl(): void;
  95960. /**
  95961. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  95962. * Delay loaded resources are not taking in account
  95963. * @return true if all required resources are ready
  95964. */
  95965. isReady(): boolean;
  95966. /** Resets all cached information relative to material (including effect and visibility) */
  95967. resetCachedMaterial(): void;
  95968. /**
  95969. * Registers a function to be called before every frame render
  95970. * @param func defines the function to register
  95971. */
  95972. registerBeforeRender(func: () => void): void;
  95973. /**
  95974. * Unregisters a function called before every frame render
  95975. * @param func defines the function to unregister
  95976. */
  95977. unregisterBeforeRender(func: () => void): void;
  95978. /**
  95979. * Registers a function to be called after every frame render
  95980. * @param func defines the function to register
  95981. */
  95982. registerAfterRender(func: () => void): void;
  95983. /**
  95984. * Unregisters a function called after every frame render
  95985. * @param func defines the function to unregister
  95986. */
  95987. unregisterAfterRender(func: () => void): void;
  95988. private _executeOnceBeforeRender;
  95989. /**
  95990. * The provided function will run before render once and will be disposed afterwards.
  95991. * A timeout delay can be provided so that the function will be executed in N ms.
  95992. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  95993. * @param func The function to be executed.
  95994. * @param timeout optional delay in ms
  95995. */
  95996. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  95997. /** @hidden */
  95998. _addPendingData(data: any): void;
  95999. /** @hidden */
  96000. _removePendingData(data: any): void;
  96001. /**
  96002. * Returns the number of items waiting to be loaded
  96003. * @returns the number of items waiting to be loaded
  96004. */
  96005. getWaitingItemsCount(): number;
  96006. /**
  96007. * Returns a boolean indicating if the scene is still loading data
  96008. */
  96009. readonly isLoading: boolean;
  96010. /**
  96011. * Registers a function to be executed when the scene is ready
  96012. * @param {Function} func - the function to be executed
  96013. */
  96014. executeWhenReady(func: () => void): void;
  96015. /**
  96016. * Returns a promise that resolves when the scene is ready
  96017. * @returns A promise that resolves when the scene is ready
  96018. */
  96019. whenReadyAsync(): Promise<void>;
  96020. /** @hidden */
  96021. _checkIsReady(): void;
  96022. /**
  96023. * Gets all animatable attached to the scene
  96024. */
  96025. readonly animatables: Animatable[];
  96026. /**
  96027. * Resets the last animation time frame.
  96028. * Useful to override when animations start running when loading a scene for the first time.
  96029. */
  96030. resetLastAnimationTimeFrame(): void;
  96031. /**
  96032. * Gets the current view matrix
  96033. * @returns a Matrix
  96034. */
  96035. getViewMatrix(): Matrix;
  96036. /**
  96037. * Gets the current projection matrix
  96038. * @returns a Matrix
  96039. */
  96040. getProjectionMatrix(): Matrix;
  96041. /**
  96042. * Gets the current transform matrix
  96043. * @returns a Matrix made of View * Projection
  96044. */
  96045. getTransformMatrix(): Matrix;
  96046. /**
  96047. * Sets the current transform matrix
  96048. * @param viewL defines the View matrix to use
  96049. * @param projectionL defines the Projection matrix to use
  96050. * @param viewR defines the right View matrix to use (if provided)
  96051. * @param projectionR defines the right Projection matrix to use (if provided)
  96052. */
  96053. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  96054. /**
  96055. * Gets the uniform buffer used to store scene data
  96056. * @returns a UniformBuffer
  96057. */
  96058. getSceneUniformBuffer(): UniformBuffer;
  96059. /**
  96060. * Gets an unique (relatively to the current scene) Id
  96061. * @returns an unique number for the scene
  96062. */
  96063. getUniqueId(): number;
  96064. /**
  96065. * Add a mesh to the list of scene's meshes
  96066. * @param newMesh defines the mesh to add
  96067. * @param recursive if all child meshes should also be added to the scene
  96068. */
  96069. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  96070. /**
  96071. * Remove a mesh for the list of scene's meshes
  96072. * @param toRemove defines the mesh to remove
  96073. * @param recursive if all child meshes should also be removed from the scene
  96074. * @returns the index where the mesh was in the mesh list
  96075. */
  96076. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  96077. /**
  96078. * Add a transform node to the list of scene's transform nodes
  96079. * @param newTransformNode defines the transform node to add
  96080. */
  96081. addTransformNode(newTransformNode: TransformNode): void;
  96082. /**
  96083. * Remove a transform node for the list of scene's transform nodes
  96084. * @param toRemove defines the transform node to remove
  96085. * @returns the index where the transform node was in the transform node list
  96086. */
  96087. removeTransformNode(toRemove: TransformNode): number;
  96088. /**
  96089. * Remove a skeleton for the list of scene's skeletons
  96090. * @param toRemove defines the skeleton to remove
  96091. * @returns the index where the skeleton was in the skeleton list
  96092. */
  96093. removeSkeleton(toRemove: Skeleton): number;
  96094. /**
  96095. * Remove a morph target for the list of scene's morph targets
  96096. * @param toRemove defines the morph target to remove
  96097. * @returns the index where the morph target was in the morph target list
  96098. */
  96099. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  96100. /**
  96101. * Remove a light for the list of scene's lights
  96102. * @param toRemove defines the light to remove
  96103. * @returns the index where the light was in the light list
  96104. */
  96105. removeLight(toRemove: Light): number;
  96106. /**
  96107. * Remove a camera for the list of scene's cameras
  96108. * @param toRemove defines the camera to remove
  96109. * @returns the index where the camera was in the camera list
  96110. */
  96111. removeCamera(toRemove: Camera): number;
  96112. /**
  96113. * Remove a particle system for the list of scene's particle systems
  96114. * @param toRemove defines the particle system to remove
  96115. * @returns the index where the particle system was in the particle system list
  96116. */
  96117. removeParticleSystem(toRemove: IParticleSystem): number;
  96118. /**
  96119. * Remove a animation for the list of scene's animations
  96120. * @param toRemove defines the animation to remove
  96121. * @returns the index where the animation was in the animation list
  96122. */
  96123. removeAnimation(toRemove: Animation): number;
  96124. /**
  96125. * Will stop the animation of the given target
  96126. * @param target - the target
  96127. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  96128. * @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)
  96129. */
  96130. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  96131. /**
  96132. * Removes the given animation group from this scene.
  96133. * @param toRemove The animation group to remove
  96134. * @returns The index of the removed animation group
  96135. */
  96136. removeAnimationGroup(toRemove: AnimationGroup): number;
  96137. /**
  96138. * Removes the given multi-material from this scene.
  96139. * @param toRemove The multi-material to remove
  96140. * @returns The index of the removed multi-material
  96141. */
  96142. removeMultiMaterial(toRemove: MultiMaterial): number;
  96143. /**
  96144. * Removes the given material from this scene.
  96145. * @param toRemove The material to remove
  96146. * @returns The index of the removed material
  96147. */
  96148. removeMaterial(toRemove: Material): number;
  96149. /**
  96150. * Removes the given action manager from this scene.
  96151. * @param toRemove The action manager to remove
  96152. * @returns The index of the removed action manager
  96153. */
  96154. removeActionManager(toRemove: AbstractActionManager): number;
  96155. /**
  96156. * Removes the given texture from this scene.
  96157. * @param toRemove The texture to remove
  96158. * @returns The index of the removed texture
  96159. */
  96160. removeTexture(toRemove: BaseTexture): number;
  96161. /**
  96162. * Adds the given light to this scene
  96163. * @param newLight The light to add
  96164. */
  96165. addLight(newLight: Light): void;
  96166. /**
  96167. * Sorts the list list based on light priorities
  96168. */
  96169. sortLightsByPriority(): void;
  96170. /**
  96171. * Adds the given camera to this scene
  96172. * @param newCamera The camera to add
  96173. */
  96174. addCamera(newCamera: Camera): void;
  96175. /**
  96176. * Adds the given skeleton to this scene
  96177. * @param newSkeleton The skeleton to add
  96178. */
  96179. addSkeleton(newSkeleton: Skeleton): void;
  96180. /**
  96181. * Adds the given particle system to this scene
  96182. * @param newParticleSystem The particle system to add
  96183. */
  96184. addParticleSystem(newParticleSystem: IParticleSystem): void;
  96185. /**
  96186. * Adds the given animation to this scene
  96187. * @param newAnimation The animation to add
  96188. */
  96189. addAnimation(newAnimation: Animation): void;
  96190. /**
  96191. * Adds the given animation group to this scene.
  96192. * @param newAnimationGroup The animation group to add
  96193. */
  96194. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  96195. /**
  96196. * Adds the given multi-material to this scene
  96197. * @param newMultiMaterial The multi-material to add
  96198. */
  96199. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  96200. /**
  96201. * Adds the given material to this scene
  96202. * @param newMaterial The material to add
  96203. */
  96204. addMaterial(newMaterial: Material): void;
  96205. /**
  96206. * Adds the given morph target to this scene
  96207. * @param newMorphTargetManager The morph target to add
  96208. */
  96209. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  96210. /**
  96211. * Adds the given geometry to this scene
  96212. * @param newGeometry The geometry to add
  96213. */
  96214. addGeometry(newGeometry: Geometry): void;
  96215. /**
  96216. * Adds the given action manager to this scene
  96217. * @param newActionManager The action manager to add
  96218. */
  96219. addActionManager(newActionManager: AbstractActionManager): void;
  96220. /**
  96221. * Adds the given texture to this scene.
  96222. * @param newTexture The texture to add
  96223. */
  96224. addTexture(newTexture: BaseTexture): void;
  96225. /**
  96226. * Switch active camera
  96227. * @param newCamera defines the new active camera
  96228. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  96229. */
  96230. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  96231. /**
  96232. * sets the active camera of the scene using its ID
  96233. * @param id defines the camera's ID
  96234. * @return the new active camera or null if none found.
  96235. */
  96236. setActiveCameraByID(id: string): Nullable<Camera>;
  96237. /**
  96238. * sets the active camera of the scene using its name
  96239. * @param name defines the camera's name
  96240. * @returns the new active camera or null if none found.
  96241. */
  96242. setActiveCameraByName(name: string): Nullable<Camera>;
  96243. /**
  96244. * get an animation group using its name
  96245. * @param name defines the material's name
  96246. * @return the animation group or null if none found.
  96247. */
  96248. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  96249. /**
  96250. * Get a material using its unique id
  96251. * @param uniqueId defines the material's unique id
  96252. * @return the material or null if none found.
  96253. */
  96254. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  96255. /**
  96256. * get a material using its id
  96257. * @param id defines the material's ID
  96258. * @return the material or null if none found.
  96259. */
  96260. getMaterialByID(id: string): Nullable<Material>;
  96261. /**
  96262. * Gets a the last added material using a given id
  96263. * @param id defines the material's ID
  96264. * @return the last material with the given id or null if none found.
  96265. */
  96266. getLastMaterialByID(id: string): Nullable<Material>;
  96267. /**
  96268. * Gets a material using its name
  96269. * @param name defines the material's name
  96270. * @return the material or null if none found.
  96271. */
  96272. getMaterialByName(name: string): Nullable<Material>;
  96273. /**
  96274. * Gets a camera using its id
  96275. * @param id defines the id to look for
  96276. * @returns the camera or null if not found
  96277. */
  96278. getCameraByID(id: string): Nullable<Camera>;
  96279. /**
  96280. * Gets a camera using its unique id
  96281. * @param uniqueId defines the unique id to look for
  96282. * @returns the camera or null if not found
  96283. */
  96284. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  96285. /**
  96286. * Gets a camera using its name
  96287. * @param name defines the camera's name
  96288. * @return the camera or null if none found.
  96289. */
  96290. getCameraByName(name: string): Nullable<Camera>;
  96291. /**
  96292. * Gets a bone using its id
  96293. * @param id defines the bone's id
  96294. * @return the bone or null if not found
  96295. */
  96296. getBoneByID(id: string): Nullable<Bone>;
  96297. /**
  96298. * Gets a bone using its id
  96299. * @param name defines the bone's name
  96300. * @return the bone or null if not found
  96301. */
  96302. getBoneByName(name: string): Nullable<Bone>;
  96303. /**
  96304. * Gets a light node using its name
  96305. * @param name defines the the light's name
  96306. * @return the light or null if none found.
  96307. */
  96308. getLightByName(name: string): Nullable<Light>;
  96309. /**
  96310. * Gets a light node using its id
  96311. * @param id defines the light's id
  96312. * @return the light or null if none found.
  96313. */
  96314. getLightByID(id: string): Nullable<Light>;
  96315. /**
  96316. * Gets a light node using its scene-generated unique ID
  96317. * @param uniqueId defines the light's unique id
  96318. * @return the light or null if none found.
  96319. */
  96320. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  96321. /**
  96322. * Gets a particle system by id
  96323. * @param id defines the particle system id
  96324. * @return the corresponding system or null if none found
  96325. */
  96326. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  96327. /**
  96328. * Gets a geometry using its ID
  96329. * @param id defines the geometry's id
  96330. * @return the geometry or null if none found.
  96331. */
  96332. getGeometryByID(id: string): Nullable<Geometry>;
  96333. private _getGeometryByUniqueID;
  96334. /**
  96335. * Add a new geometry to this scene
  96336. * @param geometry defines the geometry to be added to the scene.
  96337. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  96338. * @return a boolean defining if the geometry was added or not
  96339. */
  96340. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  96341. /**
  96342. * Removes an existing geometry
  96343. * @param geometry defines the geometry to be removed from the scene
  96344. * @return a boolean defining if the geometry was removed or not
  96345. */
  96346. removeGeometry(geometry: Geometry): boolean;
  96347. /**
  96348. * Gets the list of geometries attached to the scene
  96349. * @returns an array of Geometry
  96350. */
  96351. getGeometries(): Geometry[];
  96352. /**
  96353. * Gets the first added mesh found of a given ID
  96354. * @param id defines the id to search for
  96355. * @return the mesh found or null if not found at all
  96356. */
  96357. getMeshByID(id: string): Nullable<AbstractMesh>;
  96358. /**
  96359. * Gets a list of meshes using their id
  96360. * @param id defines the id to search for
  96361. * @returns a list of meshes
  96362. */
  96363. getMeshesByID(id: string): Array<AbstractMesh>;
  96364. /**
  96365. * Gets the first added transform node found of a given ID
  96366. * @param id defines the id to search for
  96367. * @return the found transform node or null if not found at all.
  96368. */
  96369. getTransformNodeByID(id: string): Nullable<TransformNode>;
  96370. /**
  96371. * Gets a transform node with its auto-generated unique id
  96372. * @param uniqueId efines the unique id to search for
  96373. * @return the found transform node or null if not found at all.
  96374. */
  96375. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  96376. /**
  96377. * Gets a list of transform nodes using their id
  96378. * @param id defines the id to search for
  96379. * @returns a list of transform nodes
  96380. */
  96381. getTransformNodesByID(id: string): Array<TransformNode>;
  96382. /**
  96383. * Gets a mesh with its auto-generated unique id
  96384. * @param uniqueId defines the unique id to search for
  96385. * @return the found mesh or null if not found at all.
  96386. */
  96387. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  96388. /**
  96389. * Gets a the last added mesh using a given id
  96390. * @param id defines the id to search for
  96391. * @return the found mesh or null if not found at all.
  96392. */
  96393. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  96394. /**
  96395. * Gets a the last added node (Mesh, Camera, Light) using a given id
  96396. * @param id defines the id to search for
  96397. * @return the found node or null if not found at all
  96398. */
  96399. getLastEntryByID(id: string): Nullable<Node>;
  96400. /**
  96401. * Gets a node (Mesh, Camera, Light) using a given id
  96402. * @param id defines the id to search for
  96403. * @return the found node or null if not found at all
  96404. */
  96405. getNodeByID(id: string): Nullable<Node>;
  96406. /**
  96407. * Gets a node (Mesh, Camera, Light) using a given name
  96408. * @param name defines the name to search for
  96409. * @return the found node or null if not found at all.
  96410. */
  96411. getNodeByName(name: string): Nullable<Node>;
  96412. /**
  96413. * Gets a mesh using a given name
  96414. * @param name defines the name to search for
  96415. * @return the found mesh or null if not found at all.
  96416. */
  96417. getMeshByName(name: string): Nullable<AbstractMesh>;
  96418. /**
  96419. * Gets a transform node using a given name
  96420. * @param name defines the name to search for
  96421. * @return the found transform node or null if not found at all.
  96422. */
  96423. getTransformNodeByName(name: string): Nullable<TransformNode>;
  96424. /**
  96425. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  96426. * @param id defines the id to search for
  96427. * @return the found skeleton or null if not found at all.
  96428. */
  96429. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  96430. /**
  96431. * Gets a skeleton using a given auto generated unique id
  96432. * @param uniqueId defines the unique id to search for
  96433. * @return the found skeleton or null if not found at all.
  96434. */
  96435. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  96436. /**
  96437. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  96438. * @param id defines the id to search for
  96439. * @return the found skeleton or null if not found at all.
  96440. */
  96441. getSkeletonById(id: string): Nullable<Skeleton>;
  96442. /**
  96443. * Gets a skeleton using a given name
  96444. * @param name defines the name to search for
  96445. * @return the found skeleton or null if not found at all.
  96446. */
  96447. getSkeletonByName(name: string): Nullable<Skeleton>;
  96448. /**
  96449. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  96450. * @param id defines the id to search for
  96451. * @return the found morph target manager or null if not found at all.
  96452. */
  96453. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  96454. /**
  96455. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  96456. * @param id defines the id to search for
  96457. * @return the found morph target or null if not found at all.
  96458. */
  96459. getMorphTargetById(id: string): Nullable<MorphTarget>;
  96460. /**
  96461. * Gets a boolean indicating if the given mesh is active
  96462. * @param mesh defines the mesh to look for
  96463. * @returns true if the mesh is in the active list
  96464. */
  96465. isActiveMesh(mesh: AbstractMesh): boolean;
  96466. /**
  96467. * Return a unique id as a string which can serve as an identifier for the scene
  96468. */
  96469. readonly uid: string;
  96470. /**
  96471. * Add an externaly attached data from its key.
  96472. * This method call will fail and return false, if such key already exists.
  96473. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96474. * @param key the unique key that identifies the data
  96475. * @param data the data object to associate to the key for this Engine instance
  96476. * @return true if no such key were already present and the data was added successfully, false otherwise
  96477. */
  96478. addExternalData<T>(key: string, data: T): boolean;
  96479. /**
  96480. * Get an externaly attached data from its key
  96481. * @param key the unique key that identifies the data
  96482. * @return the associated data, if present (can be null), or undefined if not present
  96483. */
  96484. getExternalData<T>(key: string): Nullable<T>;
  96485. /**
  96486. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96487. * @param key the unique key that identifies the data
  96488. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96489. * @return the associated data, can be null if the factory returned null.
  96490. */
  96491. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96492. /**
  96493. * Remove an externaly attached data from the Engine instance
  96494. * @param key the unique key that identifies the data
  96495. * @return true if the data was successfully removed, false if it doesn't exist
  96496. */
  96497. removeExternalData(key: string): boolean;
  96498. private _evaluateSubMesh;
  96499. /**
  96500. * Clear the processed materials smart array preventing retention point in material dispose.
  96501. */
  96502. freeProcessedMaterials(): void;
  96503. private _preventFreeActiveMeshesAndRenderingGroups;
  96504. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  96505. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  96506. * when disposing several meshes in a row or a hierarchy of meshes.
  96507. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  96508. */
  96509. blockfreeActiveMeshesAndRenderingGroups: boolean;
  96510. /**
  96511. * Clear the active meshes smart array preventing retention point in mesh dispose.
  96512. */
  96513. freeActiveMeshes(): void;
  96514. /**
  96515. * Clear the info related to rendering groups preventing retention points during dispose.
  96516. */
  96517. freeRenderingGroups(): void;
  96518. /** @hidden */
  96519. _isInIntermediateRendering(): boolean;
  96520. /**
  96521. * Lambda returning the list of potentially active meshes.
  96522. */
  96523. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  96524. /**
  96525. * Lambda returning the list of potentially active sub meshes.
  96526. */
  96527. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  96528. /**
  96529. * Lambda returning the list of potentially intersecting sub meshes.
  96530. */
  96531. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96532. /**
  96533. * Lambda returning the list of potentially colliding sub meshes.
  96534. */
  96535. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96536. private _activeMeshesFrozen;
  96537. /**
  96538. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96539. * @returns the current scene
  96540. */
  96541. freezeActiveMeshes(): Scene;
  96542. /**
  96543. * Use this function to restart evaluating active meshes on every frame
  96544. * @returns the current scene
  96545. */
  96546. unfreezeActiveMeshes(): Scene;
  96547. private _evaluateActiveMeshes;
  96548. private _activeMesh;
  96549. /**
  96550. * Update the transform matrix to update from the current active camera
  96551. * @param force defines a boolean used to force the update even if cache is up to date
  96552. */
  96553. updateTransformMatrix(force?: boolean): void;
  96554. private _bindFrameBuffer;
  96555. /** @hidden */
  96556. _allowPostProcessClearColor: boolean;
  96557. /** @hidden */
  96558. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96559. private _processSubCameras;
  96560. private _checkIntersections;
  96561. /** @hidden */
  96562. _advancePhysicsEngineStep(step: number): void;
  96563. /**
  96564. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96565. */
  96566. getDeterministicFrameTime: () => number;
  96567. /** @hidden */
  96568. _animate(): void;
  96569. /** Execute all animations (for a frame) */
  96570. animate(): void;
  96571. /**
  96572. * Render the scene
  96573. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96574. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96575. */
  96576. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96577. /**
  96578. * Freeze all materials
  96579. * A frozen material will not be updatable but should be faster to render
  96580. */
  96581. freezeMaterials(): void;
  96582. /**
  96583. * Unfreeze all materials
  96584. * A frozen material will not be updatable but should be faster to render
  96585. */
  96586. unfreezeMaterials(): void;
  96587. /**
  96588. * Releases all held ressources
  96589. */
  96590. dispose(): void;
  96591. /**
  96592. * Gets if the scene is already disposed
  96593. */
  96594. readonly isDisposed: boolean;
  96595. /**
  96596. * Call this function to reduce memory footprint of the scene.
  96597. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96598. */
  96599. clearCachedVertexData(): void;
  96600. /**
  96601. * This function will remove the local cached buffer data from texture.
  96602. * It will save memory but will prevent the texture from being rebuilt
  96603. */
  96604. cleanCachedTextureBuffer(): void;
  96605. /**
  96606. * Get the world extend vectors with an optional filter
  96607. *
  96608. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96609. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96610. */
  96611. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96612. min: Vector3;
  96613. max: Vector3;
  96614. };
  96615. /**
  96616. * Creates a ray that can be used to pick in the scene
  96617. * @param x defines the x coordinate of the origin (on-screen)
  96618. * @param y defines the y coordinate of the origin (on-screen)
  96619. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96620. * @param camera defines the camera to use for the picking
  96621. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96622. * @returns a Ray
  96623. */
  96624. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96625. /**
  96626. * Creates a ray that can be used to pick in the scene
  96627. * @param x defines the x coordinate of the origin (on-screen)
  96628. * @param y defines the y coordinate of the origin (on-screen)
  96629. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96630. * @param result defines the ray where to store the picking ray
  96631. * @param camera defines the camera to use for the picking
  96632. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96633. * @returns the current scene
  96634. */
  96635. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96636. /**
  96637. * Creates a ray that can be used to pick in the scene
  96638. * @param x defines the x coordinate of the origin (on-screen)
  96639. * @param y defines the y coordinate of the origin (on-screen)
  96640. * @param camera defines the camera to use for the picking
  96641. * @returns a Ray
  96642. */
  96643. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96644. /**
  96645. * Creates a ray that can be used to pick in the scene
  96646. * @param x defines the x coordinate of the origin (on-screen)
  96647. * @param y defines the y coordinate of the origin (on-screen)
  96648. * @param result defines the ray where to store the picking ray
  96649. * @param camera defines the camera to use for the picking
  96650. * @returns the current scene
  96651. */
  96652. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96653. /** Launch a ray to try to pick a mesh in the scene
  96654. * @param x position on screen
  96655. * @param y position on screen
  96656. * @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
  96657. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96658. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96659. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96660. * @returns a PickingInfo
  96661. */
  96662. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96663. /** Use the given ray to pick a mesh in the scene
  96664. * @param ray The ray to use to pick meshes
  96665. * @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
  96666. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96667. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96668. * @returns a PickingInfo
  96669. */
  96670. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96671. /**
  96672. * Launch a ray to try to pick a mesh in the scene
  96673. * @param x X position on screen
  96674. * @param y Y position on screen
  96675. * @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
  96676. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96677. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96678. * @returns an array of PickingInfo
  96679. */
  96680. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96681. /**
  96682. * Launch a ray to try to pick a mesh in the scene
  96683. * @param ray Ray to use
  96684. * @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
  96685. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96686. * @returns an array of PickingInfo
  96687. */
  96688. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96689. /**
  96690. * Force the value of meshUnderPointer
  96691. * @param mesh defines the mesh to use
  96692. */
  96693. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96694. /**
  96695. * Gets the mesh under the pointer
  96696. * @returns a Mesh or null if no mesh is under the pointer
  96697. */
  96698. getPointerOverMesh(): Nullable<AbstractMesh>;
  96699. /** @hidden */
  96700. _rebuildGeometries(): void;
  96701. /** @hidden */
  96702. _rebuildTextures(): void;
  96703. private _getByTags;
  96704. /**
  96705. * Get a list of meshes by tags
  96706. * @param tagsQuery defines the tags query to use
  96707. * @param forEach defines a predicate used to filter results
  96708. * @returns an array of Mesh
  96709. */
  96710. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  96711. /**
  96712. * Get a list of cameras by tags
  96713. * @param tagsQuery defines the tags query to use
  96714. * @param forEach defines a predicate used to filter results
  96715. * @returns an array of Camera
  96716. */
  96717. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  96718. /**
  96719. * Get a list of lights by tags
  96720. * @param tagsQuery defines the tags query to use
  96721. * @param forEach defines a predicate used to filter results
  96722. * @returns an array of Light
  96723. */
  96724. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  96725. /**
  96726. * Get a list of materials by tags
  96727. * @param tagsQuery defines the tags query to use
  96728. * @param forEach defines a predicate used to filter results
  96729. * @returns an array of Material
  96730. */
  96731. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  96732. /**
  96733. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96734. * This allowed control for front to back rendering or reversly depending of the special needs.
  96735. *
  96736. * @param renderingGroupId The rendering group id corresponding to its index
  96737. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96738. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96739. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96740. */
  96741. 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;
  96742. /**
  96743. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96744. *
  96745. * @param renderingGroupId The rendering group id corresponding to its index
  96746. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96747. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96748. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96749. */
  96750. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96751. /**
  96752. * Gets the current auto clear configuration for one rendering group of the rendering
  96753. * manager.
  96754. * @param index the rendering group index to get the information for
  96755. * @returns The auto clear setup for the requested rendering group
  96756. */
  96757. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96758. private _blockMaterialDirtyMechanism;
  96759. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  96760. blockMaterialDirtyMechanism: boolean;
  96761. /**
  96762. * Will flag all materials as dirty to trigger new shader compilation
  96763. * @param flag defines the flag used to specify which material part must be marked as dirty
  96764. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  96765. */
  96766. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  96767. /** @hidden */
  96768. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  96769. /** @hidden */
  96770. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96771. }
  96772. }
  96773. declare module BABYLON {
  96774. /**
  96775. * Set of assets to keep when moving a scene into an asset container.
  96776. */
  96777. export class KeepAssets extends AbstractScene {
  96778. }
  96779. /**
  96780. * Container with a set of assets that can be added or removed from a scene.
  96781. */
  96782. export class AssetContainer extends AbstractScene {
  96783. /**
  96784. * The scene the AssetContainer belongs to.
  96785. */
  96786. scene: Scene;
  96787. /**
  96788. * Instantiates an AssetContainer.
  96789. * @param scene The scene the AssetContainer belongs to.
  96790. */
  96791. constructor(scene: Scene);
  96792. /**
  96793. * Adds all the assets from the container to the scene.
  96794. */
  96795. addAllToScene(): void;
  96796. /**
  96797. * Removes all the assets in the container from the scene
  96798. */
  96799. removeAllFromScene(): void;
  96800. /**
  96801. * Disposes all the assets in the container
  96802. */
  96803. dispose(): void;
  96804. private _moveAssets;
  96805. /**
  96806. * Removes all the assets contained in the scene and adds them to the container.
  96807. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  96808. */
  96809. moveAllFromScene(keepAssets?: KeepAssets): void;
  96810. /**
  96811. * 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.
  96812. * @returns the root mesh
  96813. */
  96814. createRootMesh(): Mesh;
  96815. }
  96816. }
  96817. declare module BABYLON {
  96818. /**
  96819. * Defines how the parser contract is defined.
  96820. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  96821. */
  96822. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  96823. /**
  96824. * Defines how the individual parser contract is defined.
  96825. * These parser can parse an individual asset
  96826. */
  96827. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  96828. /**
  96829. * Base class of the scene acting as a container for the different elements composing a scene.
  96830. * This class is dynamically extended by the different components of the scene increasing
  96831. * flexibility and reducing coupling
  96832. */
  96833. export abstract class AbstractScene {
  96834. /**
  96835. * Stores the list of available parsers in the application.
  96836. */
  96837. private static _BabylonFileParsers;
  96838. /**
  96839. * Stores the list of available individual parsers in the application.
  96840. */
  96841. private static _IndividualBabylonFileParsers;
  96842. /**
  96843. * Adds a parser in the list of available ones
  96844. * @param name Defines the name of the parser
  96845. * @param parser Defines the parser to add
  96846. */
  96847. static AddParser(name: string, parser: BabylonFileParser): void;
  96848. /**
  96849. * Gets a general parser from the list of avaialble ones
  96850. * @param name Defines the name of the parser
  96851. * @returns the requested parser or null
  96852. */
  96853. static GetParser(name: string): Nullable<BabylonFileParser>;
  96854. /**
  96855. * Adds n individual parser in the list of available ones
  96856. * @param name Defines the name of the parser
  96857. * @param parser Defines the parser to add
  96858. */
  96859. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  96860. /**
  96861. * Gets an individual parser from the list of avaialble ones
  96862. * @param name Defines the name of the parser
  96863. * @returns the requested parser or null
  96864. */
  96865. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  96866. /**
  96867. * Parser json data and populate both a scene and its associated container object
  96868. * @param jsonData Defines the data to parse
  96869. * @param scene Defines the scene to parse the data for
  96870. * @param container Defines the container attached to the parsing sequence
  96871. * @param rootUrl Defines the root url of the data
  96872. */
  96873. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  96874. /**
  96875. * Gets the list of root nodes (ie. nodes with no parent)
  96876. */
  96877. rootNodes: Node[];
  96878. /** All of the cameras added to this scene
  96879. * @see http://doc.babylonjs.com/babylon101/cameras
  96880. */
  96881. cameras: Camera[];
  96882. /**
  96883. * All of the lights added to this scene
  96884. * @see http://doc.babylonjs.com/babylon101/lights
  96885. */
  96886. lights: Light[];
  96887. /**
  96888. * All of the (abstract) meshes added to this scene
  96889. */
  96890. meshes: AbstractMesh[];
  96891. /**
  96892. * The list of skeletons added to the scene
  96893. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96894. */
  96895. skeletons: Skeleton[];
  96896. /**
  96897. * All of the particle systems added to this scene
  96898. * @see http://doc.babylonjs.com/babylon101/particles
  96899. */
  96900. particleSystems: IParticleSystem[];
  96901. /**
  96902. * Gets a list of Animations associated with the scene
  96903. */
  96904. animations: Animation[];
  96905. /**
  96906. * All of the animation groups added to this scene
  96907. * @see http://doc.babylonjs.com/how_to/group
  96908. */
  96909. animationGroups: AnimationGroup[];
  96910. /**
  96911. * All of the multi-materials added to this scene
  96912. * @see http://doc.babylonjs.com/how_to/multi_materials
  96913. */
  96914. multiMaterials: MultiMaterial[];
  96915. /**
  96916. * All of the materials added to this scene
  96917. * In the context of a Scene, it is not supposed to be modified manually.
  96918. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  96919. * Note also that the order of the Material wihin the array is not significant and might change.
  96920. * @see http://doc.babylonjs.com/babylon101/materials
  96921. */
  96922. materials: Material[];
  96923. /**
  96924. * The list of morph target managers added to the scene
  96925. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  96926. */
  96927. morphTargetManagers: MorphTargetManager[];
  96928. /**
  96929. * The list of geometries used in the scene.
  96930. */
  96931. geometries: Geometry[];
  96932. /**
  96933. * All of the tranform nodes added to this scene
  96934. * In the context of a Scene, it is not supposed to be modified manually.
  96935. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  96936. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  96937. * @see http://doc.babylonjs.com/how_to/transformnode
  96938. */
  96939. transformNodes: TransformNode[];
  96940. /**
  96941. * ActionManagers available on the scene.
  96942. */
  96943. actionManagers: AbstractActionManager[];
  96944. /**
  96945. * Textures to keep.
  96946. */
  96947. textures: BaseTexture[];
  96948. /**
  96949. * Environment texture for the scene
  96950. */
  96951. environmentTexture: Nullable<BaseTexture>;
  96952. }
  96953. }
  96954. declare module BABYLON {
  96955. /**
  96956. * Interface used to define options for Sound class
  96957. */
  96958. export interface ISoundOptions {
  96959. /**
  96960. * Does the sound autoplay once loaded.
  96961. */
  96962. autoplay?: boolean;
  96963. /**
  96964. * Does the sound loop after it finishes playing once.
  96965. */
  96966. loop?: boolean;
  96967. /**
  96968. * Sound's volume
  96969. */
  96970. volume?: number;
  96971. /**
  96972. * Is it a spatial sound?
  96973. */
  96974. spatialSound?: boolean;
  96975. /**
  96976. * Maximum distance to hear that sound
  96977. */
  96978. maxDistance?: number;
  96979. /**
  96980. * Uses user defined attenuation function
  96981. */
  96982. useCustomAttenuation?: boolean;
  96983. /**
  96984. * Define the roll off factor of spatial sounds.
  96985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96986. */
  96987. rolloffFactor?: number;
  96988. /**
  96989. * Define the reference distance the sound should be heard perfectly.
  96990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96991. */
  96992. refDistance?: number;
  96993. /**
  96994. * Define the distance attenuation model the sound will follow.
  96995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96996. */
  96997. distanceModel?: string;
  96998. /**
  96999. * Defines the playback speed (1 by default)
  97000. */
  97001. playbackRate?: number;
  97002. /**
  97003. * Defines if the sound is from a streaming source
  97004. */
  97005. streaming?: boolean;
  97006. /**
  97007. * Defines an optional length (in seconds) inside the sound file
  97008. */
  97009. length?: number;
  97010. /**
  97011. * Defines an optional offset (in seconds) inside the sound file
  97012. */
  97013. offset?: number;
  97014. /**
  97015. * If true, URLs will not be required to state the audio file codec to use.
  97016. */
  97017. skipCodecCheck?: boolean;
  97018. }
  97019. /**
  97020. * Defines a sound that can be played in the application.
  97021. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  97022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97023. */
  97024. export class Sound {
  97025. /**
  97026. * The name of the sound in the scene.
  97027. */
  97028. name: string;
  97029. /**
  97030. * Does the sound autoplay once loaded.
  97031. */
  97032. autoplay: boolean;
  97033. /**
  97034. * Does the sound loop after it finishes playing once.
  97035. */
  97036. loop: boolean;
  97037. /**
  97038. * Does the sound use a custom attenuation curve to simulate the falloff
  97039. * happening when the source gets further away from the camera.
  97040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97041. */
  97042. useCustomAttenuation: boolean;
  97043. /**
  97044. * The sound track id this sound belongs to.
  97045. */
  97046. soundTrackId: number;
  97047. /**
  97048. * Is this sound currently played.
  97049. */
  97050. isPlaying: boolean;
  97051. /**
  97052. * Is this sound currently paused.
  97053. */
  97054. isPaused: boolean;
  97055. /**
  97056. * Does this sound enables spatial sound.
  97057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97058. */
  97059. spatialSound: boolean;
  97060. /**
  97061. * Define the reference distance the sound should be heard perfectly.
  97062. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97063. */
  97064. refDistance: number;
  97065. /**
  97066. * Define the roll off factor of spatial sounds.
  97067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97068. */
  97069. rolloffFactor: number;
  97070. /**
  97071. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  97072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97073. */
  97074. maxDistance: number;
  97075. /**
  97076. * Define the distance attenuation model the sound will follow.
  97077. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97078. */
  97079. distanceModel: string;
  97080. /**
  97081. * @hidden
  97082. * Back Compat
  97083. **/
  97084. onended: () => any;
  97085. /**
  97086. * Observable event when the current playing sound finishes.
  97087. */
  97088. onEndedObservable: Observable<Sound>;
  97089. private _panningModel;
  97090. private _playbackRate;
  97091. private _streaming;
  97092. private _startTime;
  97093. private _startOffset;
  97094. private _position;
  97095. /** @hidden */
  97096. _positionInEmitterSpace: boolean;
  97097. private _localDirection;
  97098. private _volume;
  97099. private _isReadyToPlay;
  97100. private _isDirectional;
  97101. private _readyToPlayCallback;
  97102. private _audioBuffer;
  97103. private _soundSource;
  97104. private _streamingSource;
  97105. private _soundPanner;
  97106. private _soundGain;
  97107. private _inputAudioNode;
  97108. private _outputAudioNode;
  97109. private _coneInnerAngle;
  97110. private _coneOuterAngle;
  97111. private _coneOuterGain;
  97112. private _scene;
  97113. private _connectedTransformNode;
  97114. private _customAttenuationFunction;
  97115. private _registerFunc;
  97116. private _isOutputConnected;
  97117. private _htmlAudioElement;
  97118. private _urlType;
  97119. private _length?;
  97120. private _offset?;
  97121. /** @hidden */
  97122. static _SceneComponentInitialization: (scene: Scene) => void;
  97123. /**
  97124. * Create a sound and attach it to a scene
  97125. * @param name Name of your sound
  97126. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  97127. * @param scene defines the scene the sound belongs to
  97128. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  97129. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  97130. */
  97131. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  97132. /**
  97133. * Release the sound and its associated resources
  97134. */
  97135. dispose(): void;
  97136. /**
  97137. * Gets if the sounds is ready to be played or not.
  97138. * @returns true if ready, otherwise false
  97139. */
  97140. isReady(): boolean;
  97141. private _soundLoaded;
  97142. /**
  97143. * Sets the data of the sound from an audiobuffer
  97144. * @param audioBuffer The audioBuffer containing the data
  97145. */
  97146. setAudioBuffer(audioBuffer: AudioBuffer): void;
  97147. /**
  97148. * Updates the current sounds options such as maxdistance, loop...
  97149. * @param options A JSON object containing values named as the object properties
  97150. */
  97151. updateOptions(options: ISoundOptions): void;
  97152. private _createSpatialParameters;
  97153. private _updateSpatialParameters;
  97154. /**
  97155. * Switch the panning model to HRTF:
  97156. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97158. */
  97159. switchPanningModelToHRTF(): void;
  97160. /**
  97161. * Switch the panning model to Equal Power:
  97162. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97163. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97164. */
  97165. switchPanningModelToEqualPower(): void;
  97166. private _switchPanningModel;
  97167. /**
  97168. * Connect this sound to a sound track audio node like gain...
  97169. * @param soundTrackAudioNode the sound track audio node to connect to
  97170. */
  97171. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  97172. /**
  97173. * Transform this sound into a directional source
  97174. * @param coneInnerAngle Size of the inner cone in degree
  97175. * @param coneOuterAngle Size of the outer cone in degree
  97176. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  97177. */
  97178. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  97179. /**
  97180. * Gets or sets the inner angle for the directional cone.
  97181. */
  97182. /**
  97183. * Gets or sets the inner angle for the directional cone.
  97184. */
  97185. directionalConeInnerAngle: number;
  97186. /**
  97187. * Gets or sets the outer angle for the directional cone.
  97188. */
  97189. /**
  97190. * Gets or sets the outer angle for the directional cone.
  97191. */
  97192. directionalConeOuterAngle: number;
  97193. /**
  97194. * Sets the position of the emitter if spatial sound is enabled
  97195. * @param newPosition Defines the new posisiton
  97196. */
  97197. setPosition(newPosition: Vector3): void;
  97198. /**
  97199. * Sets the local direction of the emitter if spatial sound is enabled
  97200. * @param newLocalDirection Defines the new local direction
  97201. */
  97202. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  97203. private _updateDirection;
  97204. /** @hidden */
  97205. updateDistanceFromListener(): void;
  97206. /**
  97207. * Sets a new custom attenuation function for the sound.
  97208. * @param callback Defines the function used for the attenuation
  97209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97210. */
  97211. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  97212. /**
  97213. * Play the sound
  97214. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  97215. * @param offset (optional) Start the sound at a specific time in seconds
  97216. * @param length (optional) Sound duration (in seconds)
  97217. */
  97218. play(time?: number, offset?: number, length?: number): void;
  97219. private _onended;
  97220. /**
  97221. * Stop the sound
  97222. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  97223. */
  97224. stop(time?: number): void;
  97225. /**
  97226. * Put the sound in pause
  97227. */
  97228. pause(): void;
  97229. /**
  97230. * Sets a dedicated volume for this sounds
  97231. * @param newVolume Define the new volume of the sound
  97232. * @param time Define time for gradual change to new volume
  97233. */
  97234. setVolume(newVolume: number, time?: number): void;
  97235. /**
  97236. * Set the sound play back rate
  97237. * @param newPlaybackRate Define the playback rate the sound should be played at
  97238. */
  97239. setPlaybackRate(newPlaybackRate: number): void;
  97240. /**
  97241. * Gets the volume of the sound.
  97242. * @returns the volume of the sound
  97243. */
  97244. getVolume(): number;
  97245. /**
  97246. * Attach the sound to a dedicated mesh
  97247. * @param transformNode The transform node to connect the sound with
  97248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97249. */
  97250. attachToMesh(transformNode: TransformNode): void;
  97251. /**
  97252. * Detach the sound from the previously attached mesh
  97253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97254. */
  97255. detachFromMesh(): void;
  97256. private _onRegisterAfterWorldMatrixUpdate;
  97257. /**
  97258. * Clone the current sound in the scene.
  97259. * @returns the new sound clone
  97260. */
  97261. clone(): Nullable<Sound>;
  97262. /**
  97263. * Gets the current underlying audio buffer containing the data
  97264. * @returns the audio buffer
  97265. */
  97266. getAudioBuffer(): Nullable<AudioBuffer>;
  97267. /**
  97268. * Serializes the Sound in a JSON representation
  97269. * @returns the JSON representation of the sound
  97270. */
  97271. serialize(): any;
  97272. /**
  97273. * Parse a JSON representation of a sound to innstantiate in a given scene
  97274. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  97275. * @param scene Define the scene the new parsed sound should be created in
  97276. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  97277. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  97278. * @returns the newly parsed sound
  97279. */
  97280. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  97281. }
  97282. }
  97283. declare module BABYLON {
  97284. /**
  97285. * This defines an action helpful to play a defined sound on a triggered action.
  97286. */
  97287. export class PlaySoundAction extends Action {
  97288. private _sound;
  97289. /**
  97290. * Instantiate the action
  97291. * @param triggerOptions defines the trigger options
  97292. * @param sound defines the sound to play
  97293. * @param condition defines the trigger related conditions
  97294. */
  97295. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97296. /** @hidden */
  97297. _prepare(): void;
  97298. /**
  97299. * Execute the action and play the sound.
  97300. */
  97301. execute(): void;
  97302. /**
  97303. * Serializes the actions and its related information.
  97304. * @param parent defines the object to serialize in
  97305. * @returns the serialized object
  97306. */
  97307. serialize(parent: any): any;
  97308. }
  97309. /**
  97310. * This defines an action helpful to stop a defined sound on a triggered action.
  97311. */
  97312. export class StopSoundAction extends Action {
  97313. private _sound;
  97314. /**
  97315. * Instantiate the action
  97316. * @param triggerOptions defines the trigger options
  97317. * @param sound defines the sound to stop
  97318. * @param condition defines the trigger related conditions
  97319. */
  97320. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97321. /** @hidden */
  97322. _prepare(): void;
  97323. /**
  97324. * Execute the action and stop the sound.
  97325. */
  97326. execute(): void;
  97327. /**
  97328. * Serializes the actions and its related information.
  97329. * @param parent defines the object to serialize in
  97330. * @returns the serialized object
  97331. */
  97332. serialize(parent: any): any;
  97333. }
  97334. }
  97335. declare module BABYLON {
  97336. /**
  97337. * This defines an action responsible to change the value of a property
  97338. * by interpolating between its current value and the newly set one once triggered.
  97339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97340. */
  97341. export class InterpolateValueAction extends Action {
  97342. /**
  97343. * Defines the path of the property where the value should be interpolated
  97344. */
  97345. propertyPath: string;
  97346. /**
  97347. * Defines the target value at the end of the interpolation.
  97348. */
  97349. value: any;
  97350. /**
  97351. * Defines the time it will take for the property to interpolate to the value.
  97352. */
  97353. duration: number;
  97354. /**
  97355. * Defines if the other scene animations should be stopped when the action has been triggered
  97356. */
  97357. stopOtherAnimations?: boolean;
  97358. /**
  97359. * Defines a callback raised once the interpolation animation has been done.
  97360. */
  97361. onInterpolationDone?: () => void;
  97362. /**
  97363. * Observable triggered once the interpolation animation has been done.
  97364. */
  97365. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  97366. private _target;
  97367. private _effectiveTarget;
  97368. private _property;
  97369. /**
  97370. * Instantiate the action
  97371. * @param triggerOptions defines the trigger options
  97372. * @param target defines the object containing the value to interpolate
  97373. * @param propertyPath defines the path to the property in the target object
  97374. * @param value defines the target value at the end of the interpolation
  97375. * @param duration deines the time it will take for the property to interpolate to the value.
  97376. * @param condition defines the trigger related conditions
  97377. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  97378. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  97379. */
  97380. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  97381. /** @hidden */
  97382. _prepare(): void;
  97383. /**
  97384. * Execute the action starts the value interpolation.
  97385. */
  97386. execute(): void;
  97387. /**
  97388. * Serializes the actions and its related information.
  97389. * @param parent defines the object to serialize in
  97390. * @returns the serialized object
  97391. */
  97392. serialize(parent: any): any;
  97393. }
  97394. }
  97395. declare module BABYLON {
  97396. /**
  97397. * Options allowed during the creation of a sound track.
  97398. */
  97399. export interface ISoundTrackOptions {
  97400. /**
  97401. * The volume the sound track should take during creation
  97402. */
  97403. volume?: number;
  97404. /**
  97405. * Define if the sound track is the main sound track of the scene
  97406. */
  97407. mainTrack?: boolean;
  97408. }
  97409. /**
  97410. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  97411. * It will be also used in a future release to apply effects on a specific track.
  97412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97413. */
  97414. export class SoundTrack {
  97415. /**
  97416. * The unique identifier of the sound track in the scene.
  97417. */
  97418. id: number;
  97419. /**
  97420. * The list of sounds included in the sound track.
  97421. */
  97422. soundCollection: Array<Sound>;
  97423. private _outputAudioNode;
  97424. private _scene;
  97425. private _isMainTrack;
  97426. private _connectedAnalyser;
  97427. private _options;
  97428. private _isInitialized;
  97429. /**
  97430. * Creates a new sound track.
  97431. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97432. * @param scene Define the scene the sound track belongs to
  97433. * @param options
  97434. */
  97435. constructor(scene: Scene, options?: ISoundTrackOptions);
  97436. private _initializeSoundTrackAudioGraph;
  97437. /**
  97438. * Release the sound track and its associated resources
  97439. */
  97440. dispose(): void;
  97441. /**
  97442. * Adds a sound to this sound track
  97443. * @param sound define the cound to add
  97444. * @ignoreNaming
  97445. */
  97446. AddSound(sound: Sound): void;
  97447. /**
  97448. * Removes a sound to this sound track
  97449. * @param sound define the cound to remove
  97450. * @ignoreNaming
  97451. */
  97452. RemoveSound(sound: Sound): void;
  97453. /**
  97454. * Set a global volume for the full sound track.
  97455. * @param newVolume Define the new volume of the sound track
  97456. */
  97457. setVolume(newVolume: number): void;
  97458. /**
  97459. * Switch the panning model to HRTF:
  97460. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97462. */
  97463. switchPanningModelToHRTF(): void;
  97464. /**
  97465. * Switch the panning model to Equal Power:
  97466. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97468. */
  97469. switchPanningModelToEqualPower(): void;
  97470. /**
  97471. * Connect the sound track to an audio analyser allowing some amazing
  97472. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97474. * @param analyser The analyser to connect to the engine
  97475. */
  97476. connectToAnalyser(analyser: Analyser): void;
  97477. }
  97478. }
  97479. declare module BABYLON {
  97480. interface AbstractScene {
  97481. /**
  97482. * The list of sounds used in the scene.
  97483. */
  97484. sounds: Nullable<Array<Sound>>;
  97485. }
  97486. interface Scene {
  97487. /**
  97488. * @hidden
  97489. * Backing field
  97490. */
  97491. _mainSoundTrack: SoundTrack;
  97492. /**
  97493. * The main sound track played by the scene.
  97494. * It cotains your primary collection of sounds.
  97495. */
  97496. mainSoundTrack: SoundTrack;
  97497. /**
  97498. * The list of sound tracks added to the scene
  97499. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97500. */
  97501. soundTracks: Nullable<Array<SoundTrack>>;
  97502. /**
  97503. * Gets a sound using a given name
  97504. * @param name defines the name to search for
  97505. * @return the found sound or null if not found at all.
  97506. */
  97507. getSoundByName(name: string): Nullable<Sound>;
  97508. /**
  97509. * Gets or sets if audio support is enabled
  97510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97511. */
  97512. audioEnabled: boolean;
  97513. /**
  97514. * Gets or sets if audio will be output to headphones
  97515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97516. */
  97517. headphone: boolean;
  97518. }
  97519. /**
  97520. * Defines the sound scene component responsible to manage any sounds
  97521. * in a given scene.
  97522. */
  97523. export class AudioSceneComponent implements ISceneSerializableComponent {
  97524. /**
  97525. * The component name helpfull to identify the component in the list of scene components.
  97526. */
  97527. readonly name: string;
  97528. /**
  97529. * The scene the component belongs to.
  97530. */
  97531. scene: Scene;
  97532. private _audioEnabled;
  97533. /**
  97534. * Gets whether audio is enabled or not.
  97535. * Please use related enable/disable method to switch state.
  97536. */
  97537. readonly audioEnabled: boolean;
  97538. private _headphone;
  97539. /**
  97540. * Gets whether audio is outputing to headphone or not.
  97541. * Please use the according Switch methods to change output.
  97542. */
  97543. readonly headphone: boolean;
  97544. /**
  97545. * Creates a new instance of the component for the given scene
  97546. * @param scene Defines the scene to register the component in
  97547. */
  97548. constructor(scene: Scene);
  97549. /**
  97550. * Registers the component in a given scene
  97551. */
  97552. register(): void;
  97553. /**
  97554. * Rebuilds the elements related to this component in case of
  97555. * context lost for instance.
  97556. */
  97557. rebuild(): void;
  97558. /**
  97559. * Serializes the component data to the specified json object
  97560. * @param serializationObject The object to serialize to
  97561. */
  97562. serialize(serializationObject: any): void;
  97563. /**
  97564. * Adds all the elements from the container to the scene
  97565. * @param container the container holding the elements
  97566. */
  97567. addFromContainer(container: AbstractScene): void;
  97568. /**
  97569. * Removes all the elements in the container from the scene
  97570. * @param container contains the elements to remove
  97571. * @param dispose if the removed element should be disposed (default: false)
  97572. */
  97573. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  97574. /**
  97575. * Disposes the component and the associated ressources.
  97576. */
  97577. dispose(): void;
  97578. /**
  97579. * Disables audio in the associated scene.
  97580. */
  97581. disableAudio(): void;
  97582. /**
  97583. * Enables audio in the associated scene.
  97584. */
  97585. enableAudio(): void;
  97586. /**
  97587. * Switch audio to headphone output.
  97588. */
  97589. switchAudioModeForHeadphones(): void;
  97590. /**
  97591. * Switch audio to normal speakers.
  97592. */
  97593. switchAudioModeForNormalSpeakers(): void;
  97594. private _afterRender;
  97595. }
  97596. }
  97597. declare module BABYLON {
  97598. /**
  97599. * Wraps one or more Sound objects and selects one with random weight for playback.
  97600. */
  97601. export class WeightedSound {
  97602. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97603. loop: boolean;
  97604. private _coneInnerAngle;
  97605. private _coneOuterAngle;
  97606. private _volume;
  97607. /** A Sound is currently playing. */
  97608. isPlaying: boolean;
  97609. /** A Sound is currently paused. */
  97610. isPaused: boolean;
  97611. private _sounds;
  97612. private _weights;
  97613. private _currentIndex?;
  97614. /**
  97615. * Creates a new WeightedSound from the list of sounds given.
  97616. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97617. * @param sounds Array of Sounds that will be selected from.
  97618. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97619. */
  97620. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97621. /**
  97622. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97623. */
  97624. /**
  97625. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97626. */
  97627. directionalConeInnerAngle: number;
  97628. /**
  97629. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97630. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97631. */
  97632. /**
  97633. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97634. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97635. */
  97636. directionalConeOuterAngle: number;
  97637. /**
  97638. * Playback volume.
  97639. */
  97640. /**
  97641. * Playback volume.
  97642. */
  97643. volume: number;
  97644. private _onended;
  97645. /**
  97646. * Suspend playback
  97647. */
  97648. pause(): void;
  97649. /**
  97650. * Stop playback
  97651. */
  97652. stop(): void;
  97653. /**
  97654. * Start playback.
  97655. * @param startOffset Position the clip head at a specific time in seconds.
  97656. */
  97657. play(startOffset?: number): void;
  97658. }
  97659. }
  97660. declare module BABYLON {
  97661. /**
  97662. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97663. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97664. */
  97665. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97666. /**
  97667. * Gets the name of the behavior.
  97668. */
  97669. readonly name: string;
  97670. /**
  97671. * The easing function used by animations
  97672. */
  97673. static EasingFunction: BackEase;
  97674. /**
  97675. * The easing mode used by animations
  97676. */
  97677. static EasingMode: number;
  97678. /**
  97679. * The duration of the animation, in milliseconds
  97680. */
  97681. transitionDuration: number;
  97682. /**
  97683. * Length of the distance animated by the transition when lower radius is reached
  97684. */
  97685. lowerRadiusTransitionRange: number;
  97686. /**
  97687. * Length of the distance animated by the transition when upper radius is reached
  97688. */
  97689. upperRadiusTransitionRange: number;
  97690. private _autoTransitionRange;
  97691. /**
  97692. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97693. */
  97694. /**
  97695. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97696. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97697. */
  97698. autoTransitionRange: boolean;
  97699. private _attachedCamera;
  97700. private _onAfterCheckInputsObserver;
  97701. private _onMeshTargetChangedObserver;
  97702. /**
  97703. * Initializes the behavior.
  97704. */
  97705. init(): void;
  97706. /**
  97707. * Attaches the behavior to its arc rotate camera.
  97708. * @param camera Defines the camera to attach the behavior to
  97709. */
  97710. attach(camera: ArcRotateCamera): void;
  97711. /**
  97712. * Detaches the behavior from its current arc rotate camera.
  97713. */
  97714. detach(): void;
  97715. private _radiusIsAnimating;
  97716. private _radiusBounceTransition;
  97717. private _animatables;
  97718. private _cachedWheelPrecision;
  97719. /**
  97720. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  97721. * @param radiusLimit The limit to check against.
  97722. * @return Bool to indicate if at limit.
  97723. */
  97724. private _isRadiusAtLimit;
  97725. /**
  97726. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  97727. * @param radiusDelta The delta by which to animate to. Can be negative.
  97728. */
  97729. private _applyBoundRadiusAnimation;
  97730. /**
  97731. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  97732. */
  97733. protected _clearAnimationLocks(): void;
  97734. /**
  97735. * Stops and removes all animations that have been applied to the camera
  97736. */
  97737. stopAllAnimations(): void;
  97738. }
  97739. }
  97740. declare module BABYLON {
  97741. /**
  97742. * 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.
  97743. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97744. */
  97745. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  97746. /**
  97747. * Gets the name of the behavior.
  97748. */
  97749. readonly name: string;
  97750. private _mode;
  97751. private _radiusScale;
  97752. private _positionScale;
  97753. private _defaultElevation;
  97754. private _elevationReturnTime;
  97755. private _elevationReturnWaitTime;
  97756. private _zoomStopsAnimation;
  97757. private _framingTime;
  97758. /**
  97759. * The easing function used by animations
  97760. */
  97761. static EasingFunction: ExponentialEase;
  97762. /**
  97763. * The easing mode used by animations
  97764. */
  97765. static EasingMode: number;
  97766. /**
  97767. * Sets the current mode used by the behavior
  97768. */
  97769. /**
  97770. * Gets current mode used by the behavior.
  97771. */
  97772. mode: number;
  97773. /**
  97774. * Sets the scale applied to the radius (1 by default)
  97775. */
  97776. /**
  97777. * Gets the scale applied to the radius
  97778. */
  97779. radiusScale: number;
  97780. /**
  97781. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97782. */
  97783. /**
  97784. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97785. */
  97786. positionScale: number;
  97787. /**
  97788. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97789. * behaviour is triggered, in radians.
  97790. */
  97791. /**
  97792. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97793. * behaviour is triggered, in radians.
  97794. */
  97795. defaultElevation: number;
  97796. /**
  97797. * Sets the time (in milliseconds) taken to return to the default beta position.
  97798. * Negative value indicates camera should not return to default.
  97799. */
  97800. /**
  97801. * Gets the time (in milliseconds) taken to return to the default beta position.
  97802. * Negative value indicates camera should not return to default.
  97803. */
  97804. elevationReturnTime: number;
  97805. /**
  97806. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97807. */
  97808. /**
  97809. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97810. */
  97811. elevationReturnWaitTime: number;
  97812. /**
  97813. * Sets the flag that indicates if user zooming should stop animation.
  97814. */
  97815. /**
  97816. * Gets the flag that indicates if user zooming should stop animation.
  97817. */
  97818. zoomStopsAnimation: boolean;
  97819. /**
  97820. * Sets the transition time when framing the mesh, in milliseconds
  97821. */
  97822. /**
  97823. * Gets the transition time when framing the mesh, in milliseconds
  97824. */
  97825. framingTime: number;
  97826. /**
  97827. * Define if the behavior should automatically change the configured
  97828. * camera limits and sensibilities.
  97829. */
  97830. autoCorrectCameraLimitsAndSensibility: boolean;
  97831. private _onPrePointerObservableObserver;
  97832. private _onAfterCheckInputsObserver;
  97833. private _onMeshTargetChangedObserver;
  97834. private _attachedCamera;
  97835. private _isPointerDown;
  97836. private _lastInteractionTime;
  97837. /**
  97838. * Initializes the behavior.
  97839. */
  97840. init(): void;
  97841. /**
  97842. * Attaches the behavior to its arc rotate camera.
  97843. * @param camera Defines the camera to attach the behavior to
  97844. */
  97845. attach(camera: ArcRotateCamera): void;
  97846. /**
  97847. * Detaches the behavior from its current arc rotate camera.
  97848. */
  97849. detach(): void;
  97850. private _animatables;
  97851. private _betaIsAnimating;
  97852. private _betaTransition;
  97853. private _radiusTransition;
  97854. private _vectorTransition;
  97855. /**
  97856. * Targets the given mesh and updates zoom level accordingly.
  97857. * @param mesh The mesh to target.
  97858. * @param radius Optional. If a cached radius position already exists, overrides default.
  97859. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97860. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97861. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97862. */
  97863. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97864. /**
  97865. * Targets the given mesh with its children and updates zoom level accordingly.
  97866. * @param mesh The mesh to target.
  97867. * @param radius Optional. If a cached radius position already exists, overrides default.
  97868. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97869. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97870. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97871. */
  97872. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97873. /**
  97874. * Targets the given meshes with their children and updates zoom level accordingly.
  97875. * @param meshes The mesh to target.
  97876. * @param radius Optional. If a cached radius position already exists, overrides default.
  97877. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97878. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97879. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97880. */
  97881. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97882. /**
  97883. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  97884. * @param minimumWorld Determines the smaller position of the bounding box extend
  97885. * @param maximumWorld Determines the bigger position of the bounding box extend
  97886. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97887. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97888. */
  97889. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97890. /**
  97891. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  97892. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  97893. * frustum width.
  97894. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  97895. * to fully enclose the mesh in the viewing frustum.
  97896. */
  97897. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  97898. /**
  97899. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  97900. * is automatically returned to its default position (expected to be above ground plane).
  97901. */
  97902. private _maintainCameraAboveGround;
  97903. /**
  97904. * Returns the frustum slope based on the canvas ratio and camera FOV
  97905. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  97906. */
  97907. private _getFrustumSlope;
  97908. /**
  97909. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  97910. */
  97911. private _clearAnimationLocks;
  97912. /**
  97913. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  97914. */
  97915. private _applyUserInteraction;
  97916. /**
  97917. * Stops and removes all animations that have been applied to the camera
  97918. */
  97919. stopAllAnimations(): void;
  97920. /**
  97921. * Gets a value indicating if the user is moving the camera
  97922. */
  97923. readonly isUserIsMoving: boolean;
  97924. /**
  97925. * The camera can move all the way towards the mesh.
  97926. */
  97927. static IgnoreBoundsSizeMode: number;
  97928. /**
  97929. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  97930. */
  97931. static FitFrustumSidesMode: number;
  97932. }
  97933. }
  97934. declare module BABYLON {
  97935. /**
  97936. * Base class for Camera Pointer Inputs.
  97937. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  97938. * for example usage.
  97939. */
  97940. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  97941. /**
  97942. * Defines the camera the input is attached to.
  97943. */
  97944. abstract camera: Camera;
  97945. /**
  97946. * Whether keyboard modifier keys are pressed at time of last mouse event.
  97947. */
  97948. protected _altKey: boolean;
  97949. protected _ctrlKey: boolean;
  97950. protected _metaKey: boolean;
  97951. protected _shiftKey: boolean;
  97952. /**
  97953. * Which mouse buttons were pressed at time of last mouse event.
  97954. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  97955. */
  97956. protected _buttonsPressed: number;
  97957. /**
  97958. * Defines the buttons associated with the input to handle camera move.
  97959. */
  97960. buttons: number[];
  97961. /**
  97962. * Attach the input controls to a specific dom element to get the input from.
  97963. * @param element Defines the element the controls should be listened from
  97964. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97965. */
  97966. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97967. /**
  97968. * Detach the current controls from the specified dom element.
  97969. * @param element Defines the element to stop listening the inputs from
  97970. */
  97971. detachControl(element: Nullable<HTMLElement>): void;
  97972. /**
  97973. * Gets the class name of the current input.
  97974. * @returns the class name
  97975. */
  97976. getClassName(): string;
  97977. /**
  97978. * Get the friendly name associated with the input class.
  97979. * @returns the input friendly name
  97980. */
  97981. getSimpleName(): string;
  97982. /**
  97983. * Called on pointer POINTERDOUBLETAP event.
  97984. * Override this method to provide functionality on POINTERDOUBLETAP event.
  97985. */
  97986. protected onDoubleTap(type: string): void;
  97987. /**
  97988. * Called on pointer POINTERMOVE event if only a single touch is active.
  97989. * Override this method to provide functionality.
  97990. */
  97991. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97992. /**
  97993. * Called on pointer POINTERMOVE event if multiple touches are active.
  97994. * Override this method to provide functionality.
  97995. */
  97996. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97997. /**
  97998. * Called on JS contextmenu event.
  97999. * Override this method to provide functionality.
  98000. */
  98001. protected onContextMenu(evt: PointerEvent): void;
  98002. /**
  98003. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98004. * press.
  98005. * Override this method to provide functionality.
  98006. */
  98007. protected onButtonDown(evt: PointerEvent): void;
  98008. /**
  98009. * Called each time a new POINTERUP event occurs. Ie, for each button
  98010. * release.
  98011. * Override this method to provide functionality.
  98012. */
  98013. protected onButtonUp(evt: PointerEvent): void;
  98014. /**
  98015. * Called when window becomes inactive.
  98016. * Override this method to provide functionality.
  98017. */
  98018. protected onLostFocus(): void;
  98019. private _pointerInput;
  98020. private _observer;
  98021. private _onLostFocus;
  98022. private pointA;
  98023. private pointB;
  98024. }
  98025. }
  98026. declare module BABYLON {
  98027. /**
  98028. * Manage the pointers inputs to control an arc rotate camera.
  98029. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98030. */
  98031. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  98032. /**
  98033. * Defines the camera the input is attached to.
  98034. */
  98035. camera: ArcRotateCamera;
  98036. /**
  98037. * Gets the class name of the current input.
  98038. * @returns the class name
  98039. */
  98040. getClassName(): string;
  98041. /**
  98042. * Defines the buttons associated with the input to handle camera move.
  98043. */
  98044. buttons: number[];
  98045. /**
  98046. * Defines the pointer angular sensibility along the X axis or how fast is
  98047. * the camera rotating.
  98048. */
  98049. angularSensibilityX: number;
  98050. /**
  98051. * Defines the pointer angular sensibility along the Y axis or how fast is
  98052. * the camera rotating.
  98053. */
  98054. angularSensibilityY: number;
  98055. /**
  98056. * Defines the pointer pinch precision or how fast is the camera zooming.
  98057. */
  98058. pinchPrecision: number;
  98059. /**
  98060. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  98061. * from 0.
  98062. * It defines the percentage of current camera.radius to use as delta when
  98063. * pinch zoom is used.
  98064. */
  98065. pinchDeltaPercentage: number;
  98066. /**
  98067. * Defines the pointer panning sensibility or how fast is the camera moving.
  98068. */
  98069. panningSensibility: number;
  98070. /**
  98071. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  98072. */
  98073. multiTouchPanning: boolean;
  98074. /**
  98075. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  98076. * zoom (pinch) through multitouch.
  98077. */
  98078. multiTouchPanAndZoom: boolean;
  98079. /**
  98080. * Revers pinch action direction.
  98081. */
  98082. pinchInwards: boolean;
  98083. private _isPanClick;
  98084. private _twoFingerActivityCount;
  98085. private _isPinching;
  98086. /**
  98087. * Called on pointer POINTERMOVE event if only a single touch is active.
  98088. */
  98089. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98090. /**
  98091. * Called on pointer POINTERDOUBLETAP event.
  98092. */
  98093. protected onDoubleTap(type: string): void;
  98094. /**
  98095. * Called on pointer POINTERMOVE event if multiple touches are active.
  98096. */
  98097. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98098. /**
  98099. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98100. * press.
  98101. */
  98102. protected onButtonDown(evt: PointerEvent): void;
  98103. /**
  98104. * Called each time a new POINTERUP event occurs. Ie, for each button
  98105. * release.
  98106. */
  98107. protected onButtonUp(evt: PointerEvent): void;
  98108. /**
  98109. * Called when window becomes inactive.
  98110. */
  98111. protected onLostFocus(): void;
  98112. }
  98113. }
  98114. declare module BABYLON {
  98115. /**
  98116. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  98117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98118. */
  98119. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  98120. /**
  98121. * Defines the camera the input is attached to.
  98122. */
  98123. camera: ArcRotateCamera;
  98124. /**
  98125. * Defines the list of key codes associated with the up action (increase alpha)
  98126. */
  98127. keysUp: number[];
  98128. /**
  98129. * Defines the list of key codes associated with the down action (decrease alpha)
  98130. */
  98131. keysDown: number[];
  98132. /**
  98133. * Defines the list of key codes associated with the left action (increase beta)
  98134. */
  98135. keysLeft: number[];
  98136. /**
  98137. * Defines the list of key codes associated with the right action (decrease beta)
  98138. */
  98139. keysRight: number[];
  98140. /**
  98141. * Defines the list of key codes associated with the reset action.
  98142. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  98143. */
  98144. keysReset: number[];
  98145. /**
  98146. * Defines the panning sensibility of the inputs.
  98147. * (How fast is the camera paning)
  98148. */
  98149. panningSensibility: number;
  98150. /**
  98151. * Defines the zooming sensibility of the inputs.
  98152. * (How fast is the camera zooming)
  98153. */
  98154. zoomingSensibility: number;
  98155. /**
  98156. * Defines wether maintaining the alt key down switch the movement mode from
  98157. * orientation to zoom.
  98158. */
  98159. useAltToZoom: boolean;
  98160. /**
  98161. * Rotation speed of the camera
  98162. */
  98163. angularSpeed: number;
  98164. private _keys;
  98165. private _ctrlPressed;
  98166. private _altPressed;
  98167. private _onCanvasBlurObserver;
  98168. private _onKeyboardObserver;
  98169. private _engine;
  98170. private _scene;
  98171. /**
  98172. * Attach the input controls to a specific dom element to get the input from.
  98173. * @param element Defines the element the controls should be listened from
  98174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98175. */
  98176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98177. /**
  98178. * Detach the current controls from the specified dom element.
  98179. * @param element Defines the element to stop listening the inputs from
  98180. */
  98181. detachControl(element: Nullable<HTMLElement>): void;
  98182. /**
  98183. * Update the current camera state depending on the inputs that have been used this frame.
  98184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98185. */
  98186. checkInputs(): void;
  98187. /**
  98188. * Gets the class name of the current intput.
  98189. * @returns the class name
  98190. */
  98191. getClassName(): string;
  98192. /**
  98193. * Get the friendly name associated with the input class.
  98194. * @returns the input friendly name
  98195. */
  98196. getSimpleName(): string;
  98197. }
  98198. }
  98199. declare module BABYLON {
  98200. /**
  98201. * Manage the mouse wheel inputs to control an arc rotate camera.
  98202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98203. */
  98204. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  98205. /**
  98206. * Defines the camera the input is attached to.
  98207. */
  98208. camera: ArcRotateCamera;
  98209. /**
  98210. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98211. */
  98212. wheelPrecision: number;
  98213. /**
  98214. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  98215. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  98216. */
  98217. wheelDeltaPercentage: number;
  98218. private _wheel;
  98219. private _observer;
  98220. private computeDeltaFromMouseWheelLegacyEvent;
  98221. /**
  98222. * Attach the input controls to a specific dom element to get the input from.
  98223. * @param element Defines the element the controls should be listened from
  98224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98225. */
  98226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98227. /**
  98228. * Detach the current controls from the specified dom element.
  98229. * @param element Defines the element to stop listening the inputs from
  98230. */
  98231. detachControl(element: Nullable<HTMLElement>): void;
  98232. /**
  98233. * Gets the class name of the current intput.
  98234. * @returns the class name
  98235. */
  98236. getClassName(): string;
  98237. /**
  98238. * Get the friendly name associated with the input class.
  98239. * @returns the input friendly name
  98240. */
  98241. getSimpleName(): string;
  98242. }
  98243. }
  98244. declare module BABYLON {
  98245. /**
  98246. * Default Inputs manager for the ArcRotateCamera.
  98247. * It groups all the default supported inputs for ease of use.
  98248. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98249. */
  98250. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  98251. /**
  98252. * Instantiates a new ArcRotateCameraInputsManager.
  98253. * @param camera Defines the camera the inputs belong to
  98254. */
  98255. constructor(camera: ArcRotateCamera);
  98256. /**
  98257. * Add mouse wheel input support to the input manager.
  98258. * @returns the current input manager
  98259. */
  98260. addMouseWheel(): ArcRotateCameraInputsManager;
  98261. /**
  98262. * Add pointers input support to the input manager.
  98263. * @returns the current input manager
  98264. */
  98265. addPointers(): ArcRotateCameraInputsManager;
  98266. /**
  98267. * Add keyboard input support to the input manager.
  98268. * @returns the current input manager
  98269. */
  98270. addKeyboard(): ArcRotateCameraInputsManager;
  98271. }
  98272. }
  98273. declare module BABYLON {
  98274. /**
  98275. * This represents an orbital type of camera.
  98276. *
  98277. * 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.
  98278. * 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.
  98279. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  98280. */
  98281. export class ArcRotateCamera extends TargetCamera {
  98282. /**
  98283. * Defines the rotation angle of the camera along the longitudinal axis.
  98284. */
  98285. alpha: number;
  98286. /**
  98287. * Defines the rotation angle of the camera along the latitudinal axis.
  98288. */
  98289. beta: number;
  98290. /**
  98291. * Defines the radius of the camera from it s target point.
  98292. */
  98293. radius: number;
  98294. protected _target: Vector3;
  98295. protected _targetHost: Nullable<AbstractMesh>;
  98296. /**
  98297. * Defines the target point of the camera.
  98298. * The camera looks towards it form the radius distance.
  98299. */
  98300. target: Vector3;
  98301. /**
  98302. * Define the current local position of the camera in the scene
  98303. */
  98304. position: Vector3;
  98305. protected _upVector: Vector3;
  98306. protected _upToYMatrix: Matrix;
  98307. protected _YToUpMatrix: Matrix;
  98308. /**
  98309. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  98310. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  98311. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  98312. */
  98313. upVector: Vector3;
  98314. /**
  98315. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  98316. */
  98317. setMatUp(): void;
  98318. /**
  98319. * Current inertia value on the longitudinal axis.
  98320. * The bigger this number the longer it will take for the camera to stop.
  98321. */
  98322. inertialAlphaOffset: number;
  98323. /**
  98324. * Current inertia value on the latitudinal axis.
  98325. * The bigger this number the longer it will take for the camera to stop.
  98326. */
  98327. inertialBetaOffset: number;
  98328. /**
  98329. * Current inertia value on the radius axis.
  98330. * The bigger this number the longer it will take for the camera to stop.
  98331. */
  98332. inertialRadiusOffset: number;
  98333. /**
  98334. * Minimum allowed angle on the longitudinal axis.
  98335. * This can help limiting how the Camera is able to move in the scene.
  98336. */
  98337. lowerAlphaLimit: Nullable<number>;
  98338. /**
  98339. * Maximum allowed angle on the longitudinal axis.
  98340. * This can help limiting how the Camera is able to move in the scene.
  98341. */
  98342. upperAlphaLimit: Nullable<number>;
  98343. /**
  98344. * Minimum allowed angle on the latitudinal axis.
  98345. * This can help limiting how the Camera is able to move in the scene.
  98346. */
  98347. lowerBetaLimit: number;
  98348. /**
  98349. * Maximum allowed angle on the latitudinal axis.
  98350. * This can help limiting how the Camera is able to move in the scene.
  98351. */
  98352. upperBetaLimit: number;
  98353. /**
  98354. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  98355. * This can help limiting how the Camera is able to move in the scene.
  98356. */
  98357. lowerRadiusLimit: Nullable<number>;
  98358. /**
  98359. * Maximum allowed distance of the camera to the target (The camera can not get further).
  98360. * This can help limiting how the Camera is able to move in the scene.
  98361. */
  98362. upperRadiusLimit: Nullable<number>;
  98363. /**
  98364. * Defines the current inertia value used during panning of the camera along the X axis.
  98365. */
  98366. inertialPanningX: number;
  98367. /**
  98368. * Defines the current inertia value used during panning of the camera along the Y axis.
  98369. */
  98370. inertialPanningY: number;
  98371. /**
  98372. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  98373. * Basically if your fingers moves away from more than this distance you will be considered
  98374. * in pinch mode.
  98375. */
  98376. pinchToPanMaxDistance: number;
  98377. /**
  98378. * Defines the maximum distance the camera can pan.
  98379. * This could help keeping the cammera always in your scene.
  98380. */
  98381. panningDistanceLimit: Nullable<number>;
  98382. /**
  98383. * Defines the target of the camera before paning.
  98384. */
  98385. panningOriginTarget: Vector3;
  98386. /**
  98387. * Defines the value of the inertia used during panning.
  98388. * 0 would mean stop inertia and one would mean no decelleration at all.
  98389. */
  98390. panningInertia: number;
  98391. /**
  98392. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  98393. */
  98394. angularSensibilityX: number;
  98395. /**
  98396. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  98397. */
  98398. angularSensibilityY: number;
  98399. /**
  98400. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  98401. */
  98402. pinchPrecision: number;
  98403. /**
  98404. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  98405. * It will be used instead of pinchDeltaPrecision if different from 0.
  98406. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98407. */
  98408. pinchDeltaPercentage: number;
  98409. /**
  98410. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  98411. */
  98412. panningSensibility: number;
  98413. /**
  98414. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  98415. */
  98416. keysUp: number[];
  98417. /**
  98418. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  98419. */
  98420. keysDown: number[];
  98421. /**
  98422. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  98423. */
  98424. keysLeft: number[];
  98425. /**
  98426. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  98427. */
  98428. keysRight: number[];
  98429. /**
  98430. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98431. */
  98432. wheelPrecision: number;
  98433. /**
  98434. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  98435. * It will be used instead of pinchDeltaPrecision if different from 0.
  98436. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98437. */
  98438. wheelDeltaPercentage: number;
  98439. /**
  98440. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  98441. */
  98442. zoomOnFactor: number;
  98443. /**
  98444. * Defines a screen offset for the camera position.
  98445. */
  98446. targetScreenOffset: Vector2;
  98447. /**
  98448. * Allows the camera to be completely reversed.
  98449. * If false the camera can not arrive upside down.
  98450. */
  98451. allowUpsideDown: boolean;
  98452. /**
  98453. * Define if double tap/click is used to restore the previously saved state of the camera.
  98454. */
  98455. useInputToRestoreState: boolean;
  98456. /** @hidden */
  98457. _viewMatrix: Matrix;
  98458. /** @hidden */
  98459. _useCtrlForPanning: boolean;
  98460. /** @hidden */
  98461. _panningMouseButton: number;
  98462. /**
  98463. * Defines the input associated to the camera.
  98464. */
  98465. inputs: ArcRotateCameraInputsManager;
  98466. /** @hidden */
  98467. _reset: () => void;
  98468. /**
  98469. * Defines the allowed panning axis.
  98470. */
  98471. panningAxis: Vector3;
  98472. protected _localDirection: Vector3;
  98473. protected _transformedDirection: Vector3;
  98474. private _bouncingBehavior;
  98475. /**
  98476. * Gets the bouncing behavior of the camera if it has been enabled.
  98477. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98478. */
  98479. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  98480. /**
  98481. * Defines if the bouncing behavior of the camera is enabled on the camera.
  98482. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98483. */
  98484. useBouncingBehavior: boolean;
  98485. private _framingBehavior;
  98486. /**
  98487. * Gets the framing behavior of the camera if it has been enabled.
  98488. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98489. */
  98490. readonly framingBehavior: Nullable<FramingBehavior>;
  98491. /**
  98492. * Defines if the framing behavior of the camera is enabled on the camera.
  98493. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98494. */
  98495. useFramingBehavior: boolean;
  98496. private _autoRotationBehavior;
  98497. /**
  98498. * Gets the auto rotation behavior of the camera if it has been enabled.
  98499. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98500. */
  98501. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  98502. /**
  98503. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  98504. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98505. */
  98506. useAutoRotationBehavior: boolean;
  98507. /**
  98508. * Observable triggered when the mesh target has been changed on the camera.
  98509. */
  98510. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  98511. /**
  98512. * Event raised when the camera is colliding with a mesh.
  98513. */
  98514. onCollide: (collidedMesh: AbstractMesh) => void;
  98515. /**
  98516. * Defines whether the camera should check collision with the objects oh the scene.
  98517. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  98518. */
  98519. checkCollisions: boolean;
  98520. /**
  98521. * Defines the collision radius of the camera.
  98522. * This simulates a sphere around the camera.
  98523. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98524. */
  98525. collisionRadius: Vector3;
  98526. protected _collider: Collider;
  98527. protected _previousPosition: Vector3;
  98528. protected _collisionVelocity: Vector3;
  98529. protected _newPosition: Vector3;
  98530. protected _previousAlpha: number;
  98531. protected _previousBeta: number;
  98532. protected _previousRadius: number;
  98533. protected _collisionTriggered: boolean;
  98534. protected _targetBoundingCenter: Nullable<Vector3>;
  98535. private _computationVector;
  98536. /**
  98537. * Instantiates a new ArcRotateCamera in a given scene
  98538. * @param name Defines the name of the camera
  98539. * @param alpha Defines the camera rotation along the logitudinal axis
  98540. * @param beta Defines the camera rotation along the latitudinal axis
  98541. * @param radius Defines the camera distance from its target
  98542. * @param target Defines the camera target
  98543. * @param scene Defines the scene the camera belongs to
  98544. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98545. */
  98546. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98547. /** @hidden */
  98548. _initCache(): void;
  98549. /** @hidden */
  98550. _updateCache(ignoreParentClass?: boolean): void;
  98551. protected _getTargetPosition(): Vector3;
  98552. private _storedAlpha;
  98553. private _storedBeta;
  98554. private _storedRadius;
  98555. private _storedTarget;
  98556. /**
  98557. * Stores the current state of the camera (alpha, beta, radius and target)
  98558. * @returns the camera itself
  98559. */
  98560. storeState(): Camera;
  98561. /**
  98562. * @hidden
  98563. * Restored camera state. You must call storeState() first
  98564. */
  98565. _restoreStateValues(): boolean;
  98566. /** @hidden */
  98567. _isSynchronizedViewMatrix(): boolean;
  98568. /**
  98569. * Attached controls to the current camera.
  98570. * @param element Defines the element the controls should be listened from
  98571. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98572. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  98573. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  98574. */
  98575. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  98576. /**
  98577. * Detach the current controls from the camera.
  98578. * The camera will stop reacting to inputs.
  98579. * @param element Defines the element to stop listening the inputs from
  98580. */
  98581. detachControl(element: HTMLElement): void;
  98582. /** @hidden */
  98583. _checkInputs(): void;
  98584. protected _checkLimits(): void;
  98585. /**
  98586. * Rebuilds angles (alpha, beta) and radius from the give position and target
  98587. */
  98588. rebuildAnglesAndRadius(): void;
  98589. /**
  98590. * Use a position to define the current camera related information like aplha, beta and radius
  98591. * @param position Defines the position to set the camera at
  98592. */
  98593. setPosition(position: Vector3): void;
  98594. /**
  98595. * Defines the target the camera should look at.
  98596. * This will automatically adapt alpha beta and radius to fit within the new target.
  98597. * @param target Defines the new target as a Vector or a mesh
  98598. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98599. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98600. */
  98601. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98602. /** @hidden */
  98603. _getViewMatrix(): Matrix;
  98604. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98605. /**
  98606. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98607. * @param meshes Defines the mesh to zoom on
  98608. * @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)
  98609. */
  98610. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98611. /**
  98612. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98613. * The target will be changed but the radius
  98614. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98615. * @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)
  98616. */
  98617. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98618. min: Vector3;
  98619. max: Vector3;
  98620. distance: number;
  98621. }, doNotUpdateMaxZ?: boolean): void;
  98622. /**
  98623. * @override
  98624. * Override Camera.createRigCamera
  98625. */
  98626. createRigCamera(name: string, cameraIndex: number): Camera;
  98627. /**
  98628. * @hidden
  98629. * @override
  98630. * Override Camera._updateRigCameras
  98631. */
  98632. _updateRigCameras(): void;
  98633. /**
  98634. * Destroy the camera and release the current resources hold by it.
  98635. */
  98636. dispose(): void;
  98637. /**
  98638. * Gets the current object class name.
  98639. * @return the class name
  98640. */
  98641. getClassName(): string;
  98642. }
  98643. }
  98644. declare module BABYLON {
  98645. /**
  98646. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98647. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98648. */
  98649. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98650. /**
  98651. * Gets the name of the behavior.
  98652. */
  98653. readonly name: string;
  98654. private _zoomStopsAnimation;
  98655. private _idleRotationSpeed;
  98656. private _idleRotationWaitTime;
  98657. private _idleRotationSpinupTime;
  98658. /**
  98659. * Sets the flag that indicates if user zooming should stop animation.
  98660. */
  98661. /**
  98662. * Gets the flag that indicates if user zooming should stop animation.
  98663. */
  98664. zoomStopsAnimation: boolean;
  98665. /**
  98666. * Sets the default speed at which the camera rotates around the model.
  98667. */
  98668. /**
  98669. * Gets the default speed at which the camera rotates around the model.
  98670. */
  98671. idleRotationSpeed: number;
  98672. /**
  98673. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98674. */
  98675. /**
  98676. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98677. */
  98678. idleRotationWaitTime: number;
  98679. /**
  98680. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98681. */
  98682. /**
  98683. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98684. */
  98685. idleRotationSpinupTime: number;
  98686. /**
  98687. * Gets a value indicating if the camera is currently rotating because of this behavior
  98688. */
  98689. readonly rotationInProgress: boolean;
  98690. private _onPrePointerObservableObserver;
  98691. private _onAfterCheckInputsObserver;
  98692. private _attachedCamera;
  98693. private _isPointerDown;
  98694. private _lastFrameTime;
  98695. private _lastInteractionTime;
  98696. private _cameraRotationSpeed;
  98697. /**
  98698. * Initializes the behavior.
  98699. */
  98700. init(): void;
  98701. /**
  98702. * Attaches the behavior to its arc rotate camera.
  98703. * @param camera Defines the camera to attach the behavior to
  98704. */
  98705. attach(camera: ArcRotateCamera): void;
  98706. /**
  98707. * Detaches the behavior from its current arc rotate camera.
  98708. */
  98709. detach(): void;
  98710. /**
  98711. * Returns true if user is scrolling.
  98712. * @return true if user is scrolling.
  98713. */
  98714. private _userIsZooming;
  98715. private _lastFrameRadius;
  98716. private _shouldAnimationStopForInteraction;
  98717. /**
  98718. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98719. */
  98720. private _applyUserInteraction;
  98721. private _userIsMoving;
  98722. }
  98723. }
  98724. declare module BABYLON {
  98725. /**
  98726. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  98727. */
  98728. export class AttachToBoxBehavior implements Behavior<Mesh> {
  98729. private ui;
  98730. /**
  98731. * The name of the behavior
  98732. */
  98733. name: string;
  98734. /**
  98735. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  98736. */
  98737. distanceAwayFromFace: number;
  98738. /**
  98739. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  98740. */
  98741. distanceAwayFromBottomOfFace: number;
  98742. private _faceVectors;
  98743. private _target;
  98744. private _scene;
  98745. private _onRenderObserver;
  98746. private _tmpMatrix;
  98747. private _tmpVector;
  98748. /**
  98749. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  98750. * @param ui The transform node that should be attched to the mesh
  98751. */
  98752. constructor(ui: TransformNode);
  98753. /**
  98754. * Initializes the behavior
  98755. */
  98756. init(): void;
  98757. private _closestFace;
  98758. private _zeroVector;
  98759. private _lookAtTmpMatrix;
  98760. private _lookAtToRef;
  98761. /**
  98762. * Attaches the AttachToBoxBehavior to the passed in mesh
  98763. * @param target The mesh that the specified node will be attached to
  98764. */
  98765. attach(target: Mesh): void;
  98766. /**
  98767. * Detaches the behavior from the mesh
  98768. */
  98769. detach(): void;
  98770. }
  98771. }
  98772. declare module BABYLON {
  98773. /**
  98774. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  98775. */
  98776. export class FadeInOutBehavior implements Behavior<Mesh> {
  98777. /**
  98778. * Time in milliseconds to delay before fading in (Default: 0)
  98779. */
  98780. delay: number;
  98781. /**
  98782. * Time in milliseconds for the mesh to fade in (Default: 300)
  98783. */
  98784. fadeInTime: number;
  98785. private _millisecondsPerFrame;
  98786. private _hovered;
  98787. private _hoverValue;
  98788. private _ownerNode;
  98789. /**
  98790. * Instatiates the FadeInOutBehavior
  98791. */
  98792. constructor();
  98793. /**
  98794. * The name of the behavior
  98795. */
  98796. readonly name: string;
  98797. /**
  98798. * Initializes the behavior
  98799. */
  98800. init(): void;
  98801. /**
  98802. * Attaches the fade behavior on the passed in mesh
  98803. * @param ownerNode The mesh that will be faded in/out once attached
  98804. */
  98805. attach(ownerNode: Mesh): void;
  98806. /**
  98807. * Detaches the behavior from the mesh
  98808. */
  98809. detach(): void;
  98810. /**
  98811. * Triggers the mesh to begin fading in or out
  98812. * @param value if the object should fade in or out (true to fade in)
  98813. */
  98814. fadeIn(value: boolean): void;
  98815. private _update;
  98816. private _setAllVisibility;
  98817. }
  98818. }
  98819. declare module BABYLON {
  98820. /**
  98821. * Class containing a set of static utilities functions for managing Pivots
  98822. * @hidden
  98823. */
  98824. export class PivotTools {
  98825. private static _PivotCached;
  98826. private static _OldPivotPoint;
  98827. private static _PivotTranslation;
  98828. private static _PivotTmpVector;
  98829. /** @hidden */
  98830. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  98831. /** @hidden */
  98832. static _RestorePivotPoint(mesh: AbstractMesh): void;
  98833. }
  98834. }
  98835. declare module BABYLON {
  98836. /**
  98837. * Class containing static functions to help procedurally build meshes
  98838. */
  98839. export class PlaneBuilder {
  98840. /**
  98841. * Creates a plane mesh
  98842. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  98843. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  98844. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  98845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98848. * @param name defines the name of the mesh
  98849. * @param options defines the options used to create the mesh
  98850. * @param scene defines the hosting scene
  98851. * @returns the plane mesh
  98852. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  98853. */
  98854. static CreatePlane(name: string, options: {
  98855. size?: number;
  98856. width?: number;
  98857. height?: number;
  98858. sideOrientation?: number;
  98859. frontUVs?: Vector4;
  98860. backUVs?: Vector4;
  98861. updatable?: boolean;
  98862. sourcePlane?: Plane;
  98863. }, scene?: Nullable<Scene>): Mesh;
  98864. }
  98865. }
  98866. declare module BABYLON {
  98867. /**
  98868. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  98869. */
  98870. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  98871. private static _AnyMouseID;
  98872. /**
  98873. * Abstract mesh the behavior is set on
  98874. */
  98875. attachedNode: AbstractMesh;
  98876. private _dragPlane;
  98877. private _scene;
  98878. private _pointerObserver;
  98879. private _beforeRenderObserver;
  98880. private static _planeScene;
  98881. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  98882. /**
  98883. * 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)
  98884. */
  98885. maxDragAngle: number;
  98886. /**
  98887. * @hidden
  98888. */
  98889. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  98890. /**
  98891. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98892. */
  98893. currentDraggingPointerID: number;
  98894. /**
  98895. * The last position where the pointer hit the drag plane in world space
  98896. */
  98897. lastDragPosition: Vector3;
  98898. /**
  98899. * If the behavior is currently in a dragging state
  98900. */
  98901. dragging: boolean;
  98902. /**
  98903. * 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)
  98904. */
  98905. dragDeltaRatio: number;
  98906. /**
  98907. * If the drag plane orientation should be updated during the dragging (Default: true)
  98908. */
  98909. updateDragPlane: boolean;
  98910. private _debugMode;
  98911. private _moving;
  98912. /**
  98913. * Fires each time the attached mesh is dragged with the pointer
  98914. * * delta between last drag position and current drag position in world space
  98915. * * dragDistance along the drag axis
  98916. * * dragPlaneNormal normal of the current drag plane used during the drag
  98917. * * dragPlanePoint in world space where the drag intersects the drag plane
  98918. */
  98919. onDragObservable: Observable<{
  98920. delta: Vector3;
  98921. dragPlanePoint: Vector3;
  98922. dragPlaneNormal: Vector3;
  98923. dragDistance: number;
  98924. pointerId: number;
  98925. }>;
  98926. /**
  98927. * Fires each time a drag begins (eg. mouse down on mesh)
  98928. */
  98929. onDragStartObservable: Observable<{
  98930. dragPlanePoint: Vector3;
  98931. pointerId: number;
  98932. }>;
  98933. /**
  98934. * Fires each time a drag ends (eg. mouse release after drag)
  98935. */
  98936. onDragEndObservable: Observable<{
  98937. dragPlanePoint: Vector3;
  98938. pointerId: number;
  98939. }>;
  98940. /**
  98941. * If the attached mesh should be moved when dragged
  98942. */
  98943. moveAttached: boolean;
  98944. /**
  98945. * If the drag behavior will react to drag events (Default: true)
  98946. */
  98947. enabled: boolean;
  98948. /**
  98949. * If pointer events should start and release the drag (Default: true)
  98950. */
  98951. startAndReleaseDragOnPointerEvents: boolean;
  98952. /**
  98953. * If camera controls should be detached during the drag
  98954. */
  98955. detachCameraControls: boolean;
  98956. /**
  98957. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  98958. */
  98959. useObjectOrienationForDragging: boolean;
  98960. private _options;
  98961. /**
  98962. * Creates a pointer drag behavior that can be attached to a mesh
  98963. * @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)
  98964. */
  98965. constructor(options?: {
  98966. dragAxis?: Vector3;
  98967. dragPlaneNormal?: Vector3;
  98968. });
  98969. /**
  98970. * Predicate to determine if it is valid to move the object to a new position when it is moved
  98971. */
  98972. validateDrag: (targetPosition: Vector3) => boolean;
  98973. /**
  98974. * The name of the behavior
  98975. */
  98976. readonly name: string;
  98977. /**
  98978. * Initializes the behavior
  98979. */
  98980. init(): void;
  98981. private _tmpVector;
  98982. private _alternatePickedPoint;
  98983. private _worldDragAxis;
  98984. private _targetPosition;
  98985. private _attachedElement;
  98986. /**
  98987. * Attaches the drag behavior the passed in mesh
  98988. * @param ownerNode The mesh that will be dragged around once attached
  98989. */
  98990. attach(ownerNode: AbstractMesh): void;
  98991. /**
  98992. * Force relase the drag action by code.
  98993. */
  98994. releaseDrag(): void;
  98995. private _startDragRay;
  98996. private _lastPointerRay;
  98997. /**
  98998. * Simulates the start of a pointer drag event on the behavior
  98999. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  99000. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  99001. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  99002. */
  99003. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  99004. private _startDrag;
  99005. private _dragDelta;
  99006. private _moveDrag;
  99007. private _pickWithRayOnDragPlane;
  99008. private _pointA;
  99009. private _pointB;
  99010. private _pointC;
  99011. private _lineA;
  99012. private _lineB;
  99013. private _localAxis;
  99014. private _lookAt;
  99015. private _updateDragPlanePosition;
  99016. /**
  99017. * Detaches the behavior from the mesh
  99018. */
  99019. detach(): void;
  99020. }
  99021. }
  99022. declare module BABYLON {
  99023. /**
  99024. * A behavior that when attached to a mesh will allow the mesh to be scaled
  99025. */
  99026. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  99027. private _dragBehaviorA;
  99028. private _dragBehaviorB;
  99029. private _startDistance;
  99030. private _initialScale;
  99031. private _targetScale;
  99032. private _ownerNode;
  99033. private _sceneRenderObserver;
  99034. /**
  99035. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  99036. */
  99037. constructor();
  99038. /**
  99039. * The name of the behavior
  99040. */
  99041. readonly name: string;
  99042. /**
  99043. * Initializes the behavior
  99044. */
  99045. init(): void;
  99046. private _getCurrentDistance;
  99047. /**
  99048. * Attaches the scale behavior the passed in mesh
  99049. * @param ownerNode The mesh that will be scaled around once attached
  99050. */
  99051. attach(ownerNode: Mesh): void;
  99052. /**
  99053. * Detaches the behavior from the mesh
  99054. */
  99055. detach(): void;
  99056. }
  99057. }
  99058. declare module BABYLON {
  99059. /**
  99060. * 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
  99061. */
  99062. export class SixDofDragBehavior implements Behavior<Mesh> {
  99063. private static _virtualScene;
  99064. private _ownerNode;
  99065. private _sceneRenderObserver;
  99066. private _scene;
  99067. private _targetPosition;
  99068. private _virtualOriginMesh;
  99069. private _virtualDragMesh;
  99070. private _pointerObserver;
  99071. private _moving;
  99072. private _startingOrientation;
  99073. /**
  99074. * 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)
  99075. */
  99076. private zDragFactor;
  99077. /**
  99078. * If the object should rotate to face the drag origin
  99079. */
  99080. rotateDraggedObject: boolean;
  99081. /**
  99082. * If the behavior is currently in a dragging state
  99083. */
  99084. dragging: boolean;
  99085. /**
  99086. * 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)
  99087. */
  99088. dragDeltaRatio: number;
  99089. /**
  99090. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  99091. */
  99092. currentDraggingPointerID: number;
  99093. /**
  99094. * If camera controls should be detached during the drag
  99095. */
  99096. detachCameraControls: boolean;
  99097. /**
  99098. * Fires each time a drag starts
  99099. */
  99100. onDragStartObservable: Observable<{}>;
  99101. /**
  99102. * Fires each time a drag ends (eg. mouse release after drag)
  99103. */
  99104. onDragEndObservable: Observable<{}>;
  99105. /**
  99106. * 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
  99107. */
  99108. constructor();
  99109. /**
  99110. * The name of the behavior
  99111. */
  99112. readonly name: string;
  99113. /**
  99114. * Initializes the behavior
  99115. */
  99116. init(): void;
  99117. /**
  99118. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  99119. */
  99120. private readonly _pointerCamera;
  99121. /**
  99122. * Attaches the scale behavior the passed in mesh
  99123. * @param ownerNode The mesh that will be scaled around once attached
  99124. */
  99125. attach(ownerNode: Mesh): void;
  99126. /**
  99127. * Detaches the behavior from the mesh
  99128. */
  99129. detach(): void;
  99130. }
  99131. }
  99132. declare module BABYLON {
  99133. /**
  99134. * Class used to apply inverse kinematics to bones
  99135. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  99136. */
  99137. export class BoneIKController {
  99138. private static _tmpVecs;
  99139. private static _tmpQuat;
  99140. private static _tmpMats;
  99141. /**
  99142. * Gets or sets the target mesh
  99143. */
  99144. targetMesh: AbstractMesh;
  99145. /** Gets or sets the mesh used as pole */
  99146. poleTargetMesh: AbstractMesh;
  99147. /**
  99148. * Gets or sets the bone used as pole
  99149. */
  99150. poleTargetBone: Nullable<Bone>;
  99151. /**
  99152. * Gets or sets the target position
  99153. */
  99154. targetPosition: Vector3;
  99155. /**
  99156. * Gets or sets the pole target position
  99157. */
  99158. poleTargetPosition: Vector3;
  99159. /**
  99160. * Gets or sets the pole target local offset
  99161. */
  99162. poleTargetLocalOffset: Vector3;
  99163. /**
  99164. * Gets or sets the pole angle
  99165. */
  99166. poleAngle: number;
  99167. /**
  99168. * Gets or sets the mesh associated with the controller
  99169. */
  99170. mesh: AbstractMesh;
  99171. /**
  99172. * 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)
  99173. */
  99174. slerpAmount: number;
  99175. private _bone1Quat;
  99176. private _bone1Mat;
  99177. private _bone2Ang;
  99178. private _bone1;
  99179. private _bone2;
  99180. private _bone1Length;
  99181. private _bone2Length;
  99182. private _maxAngle;
  99183. private _maxReach;
  99184. private _rightHandedSystem;
  99185. private _bendAxis;
  99186. private _slerping;
  99187. private _adjustRoll;
  99188. /**
  99189. * Gets or sets maximum allowed angle
  99190. */
  99191. maxAngle: number;
  99192. /**
  99193. * Creates a new BoneIKController
  99194. * @param mesh defines the mesh to control
  99195. * @param bone defines the bone to control
  99196. * @param options defines options to set up the controller
  99197. */
  99198. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  99199. targetMesh?: AbstractMesh;
  99200. poleTargetMesh?: AbstractMesh;
  99201. poleTargetBone?: Bone;
  99202. poleTargetLocalOffset?: Vector3;
  99203. poleAngle?: number;
  99204. bendAxis?: Vector3;
  99205. maxAngle?: number;
  99206. slerpAmount?: number;
  99207. });
  99208. private _setMaxAngle;
  99209. /**
  99210. * Force the controller to update the bones
  99211. */
  99212. update(): void;
  99213. }
  99214. }
  99215. declare module BABYLON {
  99216. /**
  99217. * Class used to make a bone look toward a point in space
  99218. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  99219. */
  99220. export class BoneLookController {
  99221. private static _tmpVecs;
  99222. private static _tmpQuat;
  99223. private static _tmpMats;
  99224. /**
  99225. * The target Vector3 that the bone will look at
  99226. */
  99227. target: Vector3;
  99228. /**
  99229. * The mesh that the bone is attached to
  99230. */
  99231. mesh: AbstractMesh;
  99232. /**
  99233. * The bone that will be looking to the target
  99234. */
  99235. bone: Bone;
  99236. /**
  99237. * The up axis of the coordinate system that is used when the bone is rotated
  99238. */
  99239. upAxis: Vector3;
  99240. /**
  99241. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  99242. */
  99243. upAxisSpace: Space;
  99244. /**
  99245. * Used to make an adjustment to the yaw of the bone
  99246. */
  99247. adjustYaw: number;
  99248. /**
  99249. * Used to make an adjustment to the pitch of the bone
  99250. */
  99251. adjustPitch: number;
  99252. /**
  99253. * Used to make an adjustment to the roll of the bone
  99254. */
  99255. adjustRoll: number;
  99256. /**
  99257. * 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)
  99258. */
  99259. slerpAmount: number;
  99260. private _minYaw;
  99261. private _maxYaw;
  99262. private _minPitch;
  99263. private _maxPitch;
  99264. private _minYawSin;
  99265. private _minYawCos;
  99266. private _maxYawSin;
  99267. private _maxYawCos;
  99268. private _midYawConstraint;
  99269. private _minPitchTan;
  99270. private _maxPitchTan;
  99271. private _boneQuat;
  99272. private _slerping;
  99273. private _transformYawPitch;
  99274. private _transformYawPitchInv;
  99275. private _firstFrameSkipped;
  99276. private _yawRange;
  99277. private _fowardAxis;
  99278. /**
  99279. * Gets or sets the minimum yaw angle that the bone can look to
  99280. */
  99281. minYaw: number;
  99282. /**
  99283. * Gets or sets the maximum yaw angle that the bone can look to
  99284. */
  99285. maxYaw: number;
  99286. /**
  99287. * Gets or sets the minimum pitch angle that the bone can look to
  99288. */
  99289. minPitch: number;
  99290. /**
  99291. * Gets or sets the maximum pitch angle that the bone can look to
  99292. */
  99293. maxPitch: number;
  99294. /**
  99295. * Create a BoneLookController
  99296. * @param mesh the mesh that the bone belongs to
  99297. * @param bone the bone that will be looking to the target
  99298. * @param target the target Vector3 to look at
  99299. * @param options optional settings:
  99300. * * maxYaw: the maximum angle the bone will yaw to
  99301. * * minYaw: the minimum angle the bone will yaw to
  99302. * * maxPitch: the maximum angle the bone will pitch to
  99303. * * minPitch: the minimum angle the bone will yaw to
  99304. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  99305. * * upAxis: the up axis of the coordinate system
  99306. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  99307. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  99308. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  99309. * * adjustYaw: used to make an adjustment to the yaw of the bone
  99310. * * adjustPitch: used to make an adjustment to the pitch of the bone
  99311. * * adjustRoll: used to make an adjustment to the roll of the bone
  99312. **/
  99313. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  99314. maxYaw?: number;
  99315. minYaw?: number;
  99316. maxPitch?: number;
  99317. minPitch?: number;
  99318. slerpAmount?: number;
  99319. upAxis?: Vector3;
  99320. upAxisSpace?: Space;
  99321. yawAxis?: Vector3;
  99322. pitchAxis?: Vector3;
  99323. adjustYaw?: number;
  99324. adjustPitch?: number;
  99325. adjustRoll?: number;
  99326. });
  99327. /**
  99328. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  99329. */
  99330. update(): void;
  99331. private _getAngleDiff;
  99332. private _getAngleBetween;
  99333. private _isAngleBetween;
  99334. }
  99335. }
  99336. declare module BABYLON {
  99337. /**
  99338. * Manage the gamepad inputs to control an arc rotate camera.
  99339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99340. */
  99341. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  99342. /**
  99343. * Defines the camera the input is attached to.
  99344. */
  99345. camera: ArcRotateCamera;
  99346. /**
  99347. * Defines the gamepad the input is gathering event from.
  99348. */
  99349. gamepad: Nullable<Gamepad>;
  99350. /**
  99351. * Defines the gamepad rotation sensiblity.
  99352. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99353. */
  99354. gamepadRotationSensibility: number;
  99355. /**
  99356. * Defines the gamepad move sensiblity.
  99357. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99358. */
  99359. gamepadMoveSensibility: number;
  99360. private _onGamepadConnectedObserver;
  99361. private _onGamepadDisconnectedObserver;
  99362. /**
  99363. * Attach the input controls to a specific dom element to get the input from.
  99364. * @param element Defines the element the controls should be listened from
  99365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99366. */
  99367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99368. /**
  99369. * Detach the current controls from the specified dom element.
  99370. * @param element Defines the element to stop listening the inputs from
  99371. */
  99372. detachControl(element: Nullable<HTMLElement>): void;
  99373. /**
  99374. * Update the current camera state depending on the inputs that have been used this frame.
  99375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99376. */
  99377. checkInputs(): void;
  99378. /**
  99379. * Gets the class name of the current intput.
  99380. * @returns the class name
  99381. */
  99382. getClassName(): string;
  99383. /**
  99384. * Get the friendly name associated with the input class.
  99385. * @returns the input friendly name
  99386. */
  99387. getSimpleName(): string;
  99388. }
  99389. }
  99390. declare module BABYLON {
  99391. interface ArcRotateCameraInputsManager {
  99392. /**
  99393. * Add orientation input support to the input manager.
  99394. * @returns the current input manager
  99395. */
  99396. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  99397. }
  99398. /**
  99399. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  99400. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99401. */
  99402. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  99403. /**
  99404. * Defines the camera the input is attached to.
  99405. */
  99406. camera: ArcRotateCamera;
  99407. /**
  99408. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  99409. */
  99410. alphaCorrection: number;
  99411. /**
  99412. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  99413. */
  99414. gammaCorrection: number;
  99415. private _alpha;
  99416. private _gamma;
  99417. private _dirty;
  99418. private _deviceOrientationHandler;
  99419. /**
  99420. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  99421. */
  99422. constructor();
  99423. /**
  99424. * Attach the input controls to a specific dom element to get the input from.
  99425. * @param element Defines the element the controls should be listened from
  99426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99427. */
  99428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99429. /** @hidden */
  99430. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  99431. /**
  99432. * Update the current camera state depending on the inputs that have been used this frame.
  99433. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99434. */
  99435. checkInputs(): void;
  99436. /**
  99437. * Detach the current controls from the specified dom element.
  99438. * @param element Defines the element to stop listening the inputs from
  99439. */
  99440. detachControl(element: Nullable<HTMLElement>): void;
  99441. /**
  99442. * Gets the class name of the current intput.
  99443. * @returns the class name
  99444. */
  99445. getClassName(): string;
  99446. /**
  99447. * Get the friendly name associated with the input class.
  99448. * @returns the input friendly name
  99449. */
  99450. getSimpleName(): string;
  99451. }
  99452. }
  99453. declare module BABYLON {
  99454. /**
  99455. * Listen to mouse events to control the camera.
  99456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99457. */
  99458. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  99459. /**
  99460. * Defines the camera the input is attached to.
  99461. */
  99462. camera: FlyCamera;
  99463. /**
  99464. * Defines if touch is enabled. (Default is true.)
  99465. */
  99466. touchEnabled: boolean;
  99467. /**
  99468. * Defines the buttons associated with the input to handle camera rotation.
  99469. */
  99470. buttons: number[];
  99471. /**
  99472. * Assign buttons for Yaw control.
  99473. */
  99474. buttonsYaw: number[];
  99475. /**
  99476. * Assign buttons for Pitch control.
  99477. */
  99478. buttonsPitch: number[];
  99479. /**
  99480. * Assign buttons for Roll control.
  99481. */
  99482. buttonsRoll: number[];
  99483. /**
  99484. * Detect if any button is being pressed while mouse is moved.
  99485. * -1 = Mouse locked.
  99486. * 0 = Left button.
  99487. * 1 = Middle Button.
  99488. * 2 = Right Button.
  99489. */
  99490. activeButton: number;
  99491. /**
  99492. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  99493. * Higher values reduce its sensitivity.
  99494. */
  99495. angularSensibility: number;
  99496. private _mousemoveCallback;
  99497. private _observer;
  99498. private _rollObserver;
  99499. private previousPosition;
  99500. private noPreventDefault;
  99501. private element;
  99502. /**
  99503. * Listen to mouse events to control the camera.
  99504. * @param touchEnabled Define if touch is enabled. (Default is true.)
  99505. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99506. */
  99507. constructor(touchEnabled?: boolean);
  99508. /**
  99509. * Attach the mouse control to the HTML DOM element.
  99510. * @param element Defines the element that listens to the input events.
  99511. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  99512. */
  99513. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99514. /**
  99515. * Detach the current controls from the specified dom element.
  99516. * @param element Defines the element to stop listening the inputs from
  99517. */
  99518. detachControl(element: Nullable<HTMLElement>): void;
  99519. /**
  99520. * Gets the class name of the current input.
  99521. * @returns the class name.
  99522. */
  99523. getClassName(): string;
  99524. /**
  99525. * Get the friendly name associated with the input class.
  99526. * @returns the input's friendly name.
  99527. */
  99528. getSimpleName(): string;
  99529. private _pointerInput;
  99530. private _onMouseMove;
  99531. /**
  99532. * Rotate camera by mouse offset.
  99533. */
  99534. private rotateCamera;
  99535. }
  99536. }
  99537. declare module BABYLON {
  99538. /**
  99539. * Default Inputs manager for the FlyCamera.
  99540. * It groups all the default supported inputs for ease of use.
  99541. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99542. */
  99543. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  99544. /**
  99545. * Instantiates a new FlyCameraInputsManager.
  99546. * @param camera Defines the camera the inputs belong to.
  99547. */
  99548. constructor(camera: FlyCamera);
  99549. /**
  99550. * Add keyboard input support to the input manager.
  99551. * @returns the new FlyCameraKeyboardMoveInput().
  99552. */
  99553. addKeyboard(): FlyCameraInputsManager;
  99554. /**
  99555. * Add mouse input support to the input manager.
  99556. * @param touchEnabled Enable touch screen support.
  99557. * @returns the new FlyCameraMouseInput().
  99558. */
  99559. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  99560. }
  99561. }
  99562. declare module BABYLON {
  99563. /**
  99564. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99565. * such as in a 3D Space Shooter or a Flight Simulator.
  99566. */
  99567. export class FlyCamera extends TargetCamera {
  99568. /**
  99569. * Define the collision ellipsoid of the camera.
  99570. * This is helpful for simulating a camera body, like a player's body.
  99571. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99572. */
  99573. ellipsoid: Vector3;
  99574. /**
  99575. * Define an offset for the position of the ellipsoid around the camera.
  99576. * This can be helpful if the camera is attached away from the player's body center,
  99577. * such as at its head.
  99578. */
  99579. ellipsoidOffset: Vector3;
  99580. /**
  99581. * Enable or disable collisions of the camera with the rest of the scene objects.
  99582. */
  99583. checkCollisions: boolean;
  99584. /**
  99585. * Enable or disable gravity on the camera.
  99586. */
  99587. applyGravity: boolean;
  99588. /**
  99589. * Define the current direction the camera is moving to.
  99590. */
  99591. cameraDirection: Vector3;
  99592. /**
  99593. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  99594. * This overrides and empties cameraRotation.
  99595. */
  99596. rotationQuaternion: Quaternion;
  99597. /**
  99598. * Track Roll to maintain the wanted Rolling when looking around.
  99599. */
  99600. _trackRoll: number;
  99601. /**
  99602. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  99603. */
  99604. rollCorrect: number;
  99605. /**
  99606. * Mimic a banked turn, Rolling the camera when Yawing.
  99607. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99608. */
  99609. bankedTurn: boolean;
  99610. /**
  99611. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99612. */
  99613. bankedTurnLimit: number;
  99614. /**
  99615. * Value of 0 disables the banked Roll.
  99616. * Value of 1 is equal to the Yaw angle in radians.
  99617. */
  99618. bankedTurnMultiplier: number;
  99619. /**
  99620. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99621. */
  99622. inputs: FlyCameraInputsManager;
  99623. /**
  99624. * Gets the input sensibility for mouse input.
  99625. * Higher values reduce sensitivity.
  99626. */
  99627. /**
  99628. * Sets the input sensibility for a mouse input.
  99629. * Higher values reduce sensitivity.
  99630. */
  99631. angularSensibility: number;
  99632. /**
  99633. * Get the keys for camera movement forward.
  99634. */
  99635. /**
  99636. * Set the keys for camera movement forward.
  99637. */
  99638. keysForward: number[];
  99639. /**
  99640. * Get the keys for camera movement backward.
  99641. */
  99642. keysBackward: number[];
  99643. /**
  99644. * Get the keys for camera movement up.
  99645. */
  99646. /**
  99647. * Set the keys for camera movement up.
  99648. */
  99649. keysUp: number[];
  99650. /**
  99651. * Get the keys for camera movement down.
  99652. */
  99653. /**
  99654. * Set the keys for camera movement down.
  99655. */
  99656. keysDown: number[];
  99657. /**
  99658. * Get the keys for camera movement left.
  99659. */
  99660. /**
  99661. * Set the keys for camera movement left.
  99662. */
  99663. keysLeft: number[];
  99664. /**
  99665. * Set the keys for camera movement right.
  99666. */
  99667. /**
  99668. * Set the keys for camera movement right.
  99669. */
  99670. keysRight: number[];
  99671. /**
  99672. * Event raised when the camera collides with a mesh in the scene.
  99673. */
  99674. onCollide: (collidedMesh: AbstractMesh) => void;
  99675. private _collider;
  99676. private _needMoveForGravity;
  99677. private _oldPosition;
  99678. private _diffPosition;
  99679. private _newPosition;
  99680. /** @hidden */
  99681. _localDirection: Vector3;
  99682. /** @hidden */
  99683. _transformedDirection: Vector3;
  99684. /**
  99685. * Instantiates a FlyCamera.
  99686. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99687. * such as in a 3D Space Shooter or a Flight Simulator.
  99688. * @param name Define the name of the camera in the scene.
  99689. * @param position Define the starting position of the camera in the scene.
  99690. * @param scene Define the scene the camera belongs to.
  99691. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99692. */
  99693. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99694. /**
  99695. * Attach a control to the HTML DOM element.
  99696. * @param element Defines the element that listens to the input events.
  99697. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99698. */
  99699. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99700. /**
  99701. * Detach a control from the HTML DOM element.
  99702. * The camera will stop reacting to that input.
  99703. * @param element Defines the element that listens to the input events.
  99704. */
  99705. detachControl(element: HTMLElement): void;
  99706. private _collisionMask;
  99707. /**
  99708. * Get the mask that the camera ignores in collision events.
  99709. */
  99710. /**
  99711. * Set the mask that the camera ignores in collision events.
  99712. */
  99713. collisionMask: number;
  99714. /** @hidden */
  99715. _collideWithWorld(displacement: Vector3): void;
  99716. /** @hidden */
  99717. private _onCollisionPositionChange;
  99718. /** @hidden */
  99719. _checkInputs(): void;
  99720. /** @hidden */
  99721. _decideIfNeedsToMove(): boolean;
  99722. /** @hidden */
  99723. _updatePosition(): void;
  99724. /**
  99725. * Restore the Roll to its target value at the rate specified.
  99726. * @param rate - Higher means slower restoring.
  99727. * @hidden
  99728. */
  99729. restoreRoll(rate: number): void;
  99730. /**
  99731. * Destroy the camera and release the current resources held by it.
  99732. */
  99733. dispose(): void;
  99734. /**
  99735. * Get the current object class name.
  99736. * @returns the class name.
  99737. */
  99738. getClassName(): string;
  99739. }
  99740. }
  99741. declare module BABYLON {
  99742. /**
  99743. * Listen to keyboard events to control the camera.
  99744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99745. */
  99746. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  99747. /**
  99748. * Defines the camera the input is attached to.
  99749. */
  99750. camera: FlyCamera;
  99751. /**
  99752. * The list of keyboard keys used to control the forward move of the camera.
  99753. */
  99754. keysForward: number[];
  99755. /**
  99756. * The list of keyboard keys used to control the backward move of the camera.
  99757. */
  99758. keysBackward: number[];
  99759. /**
  99760. * The list of keyboard keys used to control the forward move of the camera.
  99761. */
  99762. keysUp: number[];
  99763. /**
  99764. * The list of keyboard keys used to control the backward move of the camera.
  99765. */
  99766. keysDown: number[];
  99767. /**
  99768. * The list of keyboard keys used to control the right strafe move of the camera.
  99769. */
  99770. keysRight: number[];
  99771. /**
  99772. * The list of keyboard keys used to control the left strafe move of the camera.
  99773. */
  99774. keysLeft: number[];
  99775. private _keys;
  99776. private _onCanvasBlurObserver;
  99777. private _onKeyboardObserver;
  99778. private _engine;
  99779. private _scene;
  99780. /**
  99781. * Attach the input controls to a specific dom element to get the input from.
  99782. * @param element Defines the element the controls should be listened from
  99783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99784. */
  99785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99786. /**
  99787. * Detach the current controls from the specified dom element.
  99788. * @param element Defines the element to stop listening the inputs from
  99789. */
  99790. detachControl(element: Nullable<HTMLElement>): void;
  99791. /**
  99792. * Gets the class name of the current intput.
  99793. * @returns the class name
  99794. */
  99795. getClassName(): string;
  99796. /** @hidden */
  99797. _onLostFocus(e: FocusEvent): void;
  99798. /**
  99799. * Get the friendly name associated with the input class.
  99800. * @returns the input friendly name
  99801. */
  99802. getSimpleName(): string;
  99803. /**
  99804. * Update the current camera state depending on the inputs that have been used this frame.
  99805. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99806. */
  99807. checkInputs(): void;
  99808. }
  99809. }
  99810. declare module BABYLON {
  99811. /**
  99812. * Manage the mouse wheel inputs to control a follow camera.
  99813. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99814. */
  99815. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  99816. /**
  99817. * Defines the camera the input is attached to.
  99818. */
  99819. camera: FollowCamera;
  99820. /**
  99821. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  99822. */
  99823. axisControlRadius: boolean;
  99824. /**
  99825. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  99826. */
  99827. axisControlHeight: boolean;
  99828. /**
  99829. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  99830. */
  99831. axisControlRotation: boolean;
  99832. /**
  99833. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  99834. * relation to mouseWheel events.
  99835. */
  99836. wheelPrecision: number;
  99837. /**
  99838. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99839. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99840. */
  99841. wheelDeltaPercentage: number;
  99842. private _wheel;
  99843. private _observer;
  99844. /**
  99845. * Attach the input controls to a specific dom element to get the input from.
  99846. * @param element Defines the element the controls should be listened from
  99847. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99848. */
  99849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99850. /**
  99851. * Detach the current controls from the specified dom element.
  99852. * @param element Defines the element to stop listening the inputs from
  99853. */
  99854. detachControl(element: Nullable<HTMLElement>): void;
  99855. /**
  99856. * Gets the class name of the current intput.
  99857. * @returns the class name
  99858. */
  99859. getClassName(): string;
  99860. /**
  99861. * Get the friendly name associated with the input class.
  99862. * @returns the input friendly name
  99863. */
  99864. getSimpleName(): string;
  99865. }
  99866. }
  99867. declare module BABYLON {
  99868. /**
  99869. * Manage the pointers inputs to control an follow camera.
  99870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99871. */
  99872. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  99873. /**
  99874. * Defines the camera the input is attached to.
  99875. */
  99876. camera: FollowCamera;
  99877. /**
  99878. * Gets the class name of the current input.
  99879. * @returns the class name
  99880. */
  99881. getClassName(): string;
  99882. /**
  99883. * Defines the pointer angular sensibility along the X axis or how fast is
  99884. * the camera rotating.
  99885. * A negative number will reverse the axis direction.
  99886. */
  99887. angularSensibilityX: number;
  99888. /**
  99889. * Defines the pointer angular sensibility along the Y axis or how fast is
  99890. * the camera rotating.
  99891. * A negative number will reverse the axis direction.
  99892. */
  99893. angularSensibilityY: number;
  99894. /**
  99895. * Defines the pointer pinch precision or how fast is the camera zooming.
  99896. * A negative number will reverse the axis direction.
  99897. */
  99898. pinchPrecision: number;
  99899. /**
  99900. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99901. * from 0.
  99902. * It defines the percentage of current camera.radius to use as delta when
  99903. * pinch zoom is used.
  99904. */
  99905. pinchDeltaPercentage: number;
  99906. /**
  99907. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  99908. */
  99909. axisXControlRadius: boolean;
  99910. /**
  99911. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  99912. */
  99913. axisXControlHeight: boolean;
  99914. /**
  99915. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  99916. */
  99917. axisXControlRotation: boolean;
  99918. /**
  99919. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  99920. */
  99921. axisYControlRadius: boolean;
  99922. /**
  99923. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  99924. */
  99925. axisYControlHeight: boolean;
  99926. /**
  99927. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  99928. */
  99929. axisYControlRotation: boolean;
  99930. /**
  99931. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  99932. */
  99933. axisPinchControlRadius: boolean;
  99934. /**
  99935. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  99936. */
  99937. axisPinchControlHeight: boolean;
  99938. /**
  99939. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  99940. */
  99941. axisPinchControlRotation: boolean;
  99942. /**
  99943. * Log error messages if basic misconfiguration has occurred.
  99944. */
  99945. warningEnable: boolean;
  99946. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99947. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99948. private _warningCounter;
  99949. private _warning;
  99950. }
  99951. }
  99952. declare module BABYLON {
  99953. /**
  99954. * Default Inputs manager for the FollowCamera.
  99955. * It groups all the default supported inputs for ease of use.
  99956. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99957. */
  99958. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  99959. /**
  99960. * Instantiates a new FollowCameraInputsManager.
  99961. * @param camera Defines the camera the inputs belong to
  99962. */
  99963. constructor(camera: FollowCamera);
  99964. /**
  99965. * Add keyboard input support to the input manager.
  99966. * @returns the current input manager
  99967. */
  99968. addKeyboard(): FollowCameraInputsManager;
  99969. /**
  99970. * Add mouse wheel input support to the input manager.
  99971. * @returns the current input manager
  99972. */
  99973. addMouseWheel(): FollowCameraInputsManager;
  99974. /**
  99975. * Add pointers input support to the input manager.
  99976. * @returns the current input manager
  99977. */
  99978. addPointers(): FollowCameraInputsManager;
  99979. /**
  99980. * Add orientation input support to the input manager.
  99981. * @returns the current input manager
  99982. */
  99983. addVRDeviceOrientation(): FollowCameraInputsManager;
  99984. }
  99985. }
  99986. declare module BABYLON {
  99987. /**
  99988. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  99989. * an arc rotate version arcFollowCamera are available.
  99990. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99991. */
  99992. export class FollowCamera extends TargetCamera {
  99993. /**
  99994. * Distance the follow camera should follow an object at
  99995. */
  99996. radius: number;
  99997. /**
  99998. * Minimum allowed distance of the camera to the axis of rotation
  99999. * (The camera can not get closer).
  100000. * This can help limiting how the Camera is able to move in the scene.
  100001. */
  100002. lowerRadiusLimit: Nullable<number>;
  100003. /**
  100004. * Maximum allowed distance of the camera to the axis of rotation
  100005. * (The camera can not get further).
  100006. * This can help limiting how the Camera is able to move in the scene.
  100007. */
  100008. upperRadiusLimit: Nullable<number>;
  100009. /**
  100010. * Define a rotation offset between the camera and the object it follows
  100011. */
  100012. rotationOffset: number;
  100013. /**
  100014. * Minimum allowed angle to camera position relative to target object.
  100015. * This can help limiting how the Camera is able to move in the scene.
  100016. */
  100017. lowerRotationOffsetLimit: Nullable<number>;
  100018. /**
  100019. * Maximum allowed angle to camera position relative to target object.
  100020. * This can help limiting how the Camera is able to move in the scene.
  100021. */
  100022. upperRotationOffsetLimit: Nullable<number>;
  100023. /**
  100024. * Define a height offset between the camera and the object it follows.
  100025. * It can help following an object from the top (like a car chaing a plane)
  100026. */
  100027. heightOffset: number;
  100028. /**
  100029. * Minimum allowed height of camera position relative to target object.
  100030. * This can help limiting how the Camera is able to move in the scene.
  100031. */
  100032. lowerHeightOffsetLimit: Nullable<number>;
  100033. /**
  100034. * Maximum allowed height of camera position relative to target object.
  100035. * This can help limiting how the Camera is able to move in the scene.
  100036. */
  100037. upperHeightOffsetLimit: Nullable<number>;
  100038. /**
  100039. * Define how fast the camera can accelerate to follow it s target.
  100040. */
  100041. cameraAcceleration: number;
  100042. /**
  100043. * Define the speed limit of the camera following an object.
  100044. */
  100045. maxCameraSpeed: number;
  100046. /**
  100047. * Define the target of the camera.
  100048. */
  100049. lockedTarget: Nullable<AbstractMesh>;
  100050. /**
  100051. * Defines the input associated with the camera.
  100052. */
  100053. inputs: FollowCameraInputsManager;
  100054. /**
  100055. * Instantiates the follow camera.
  100056. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100057. * @param name Define the name of the camera in the scene
  100058. * @param position Define the position of the camera
  100059. * @param scene Define the scene the camera belong to
  100060. * @param lockedTarget Define the target of the camera
  100061. */
  100062. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  100063. private _follow;
  100064. /**
  100065. * Attached controls to the current camera.
  100066. * @param element Defines the element the controls should be listened from
  100067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100068. */
  100069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100070. /**
  100071. * Detach the current controls from the camera.
  100072. * The camera will stop reacting to inputs.
  100073. * @param element Defines the element to stop listening the inputs from
  100074. */
  100075. detachControl(element: HTMLElement): void;
  100076. /** @hidden */
  100077. _checkInputs(): void;
  100078. private _checkLimits;
  100079. /**
  100080. * Gets the camera class name.
  100081. * @returns the class name
  100082. */
  100083. getClassName(): string;
  100084. }
  100085. /**
  100086. * Arc Rotate version of the follow camera.
  100087. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  100088. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100089. */
  100090. export class ArcFollowCamera extends TargetCamera {
  100091. /** The longitudinal angle of the camera */
  100092. alpha: number;
  100093. /** The latitudinal angle of the camera */
  100094. beta: number;
  100095. /** The radius of the camera from its target */
  100096. radius: number;
  100097. /** Define the camera target (the messh it should follow) */
  100098. target: Nullable<AbstractMesh>;
  100099. private _cartesianCoordinates;
  100100. /**
  100101. * Instantiates a new ArcFollowCamera
  100102. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100103. * @param name Define the name of the camera
  100104. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  100105. * @param beta Define the rotation angle of the camera around the elevation axis
  100106. * @param radius Define the radius of the camera from its target point
  100107. * @param target Define the target of the camera
  100108. * @param scene Define the scene the camera belongs to
  100109. */
  100110. constructor(name: string,
  100111. /** The longitudinal angle of the camera */
  100112. alpha: number,
  100113. /** The latitudinal angle of the camera */
  100114. beta: number,
  100115. /** The radius of the camera from its target */
  100116. radius: number,
  100117. /** Define the camera target (the messh it should follow) */
  100118. target: Nullable<AbstractMesh>, scene: Scene);
  100119. private _follow;
  100120. /** @hidden */
  100121. _checkInputs(): void;
  100122. /**
  100123. * Returns the class name of the object.
  100124. * It is mostly used internally for serialization purposes.
  100125. */
  100126. getClassName(): string;
  100127. }
  100128. }
  100129. declare module BABYLON {
  100130. /**
  100131. * Manage the keyboard inputs to control the movement of a follow camera.
  100132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100133. */
  100134. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  100135. /**
  100136. * Defines the camera the input is attached to.
  100137. */
  100138. camera: FollowCamera;
  100139. /**
  100140. * Defines the list of key codes associated with the up action (increase heightOffset)
  100141. */
  100142. keysHeightOffsetIncr: number[];
  100143. /**
  100144. * Defines the list of key codes associated with the down action (decrease heightOffset)
  100145. */
  100146. keysHeightOffsetDecr: number[];
  100147. /**
  100148. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  100149. */
  100150. keysHeightOffsetModifierAlt: boolean;
  100151. /**
  100152. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  100153. */
  100154. keysHeightOffsetModifierCtrl: boolean;
  100155. /**
  100156. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  100157. */
  100158. keysHeightOffsetModifierShift: boolean;
  100159. /**
  100160. * Defines the list of key codes associated with the left action (increase rotationOffset)
  100161. */
  100162. keysRotationOffsetIncr: number[];
  100163. /**
  100164. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  100165. */
  100166. keysRotationOffsetDecr: number[];
  100167. /**
  100168. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  100169. */
  100170. keysRotationOffsetModifierAlt: boolean;
  100171. /**
  100172. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  100173. */
  100174. keysRotationOffsetModifierCtrl: boolean;
  100175. /**
  100176. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  100177. */
  100178. keysRotationOffsetModifierShift: boolean;
  100179. /**
  100180. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  100181. */
  100182. keysRadiusIncr: number[];
  100183. /**
  100184. * Defines the list of key codes associated with the zoom-out action (increase radius)
  100185. */
  100186. keysRadiusDecr: number[];
  100187. /**
  100188. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  100189. */
  100190. keysRadiusModifierAlt: boolean;
  100191. /**
  100192. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  100193. */
  100194. keysRadiusModifierCtrl: boolean;
  100195. /**
  100196. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  100197. */
  100198. keysRadiusModifierShift: boolean;
  100199. /**
  100200. * Defines the rate of change of heightOffset.
  100201. */
  100202. heightSensibility: number;
  100203. /**
  100204. * Defines the rate of change of rotationOffset.
  100205. */
  100206. rotationSensibility: number;
  100207. /**
  100208. * Defines the rate of change of radius.
  100209. */
  100210. radiusSensibility: number;
  100211. private _keys;
  100212. private _ctrlPressed;
  100213. private _altPressed;
  100214. private _shiftPressed;
  100215. private _onCanvasBlurObserver;
  100216. private _onKeyboardObserver;
  100217. private _engine;
  100218. private _scene;
  100219. /**
  100220. * Attach the input controls to a specific dom element to get the input from.
  100221. * @param element Defines the element the controls should be listened from
  100222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100223. */
  100224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100225. /**
  100226. * Detach the current controls from the specified dom element.
  100227. * @param element Defines the element to stop listening the inputs from
  100228. */
  100229. detachControl(element: Nullable<HTMLElement>): void;
  100230. /**
  100231. * Update the current camera state depending on the inputs that have been used this frame.
  100232. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100233. */
  100234. checkInputs(): void;
  100235. /**
  100236. * Gets the class name of the current input.
  100237. * @returns the class name
  100238. */
  100239. getClassName(): string;
  100240. /**
  100241. * Get the friendly name associated with the input class.
  100242. * @returns the input friendly name
  100243. */
  100244. getSimpleName(): string;
  100245. /**
  100246. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100247. * allow modification of the heightOffset value.
  100248. */
  100249. private _modifierHeightOffset;
  100250. /**
  100251. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100252. * allow modification of the rotationOffset value.
  100253. */
  100254. private _modifierRotationOffset;
  100255. /**
  100256. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100257. * allow modification of the radius value.
  100258. */
  100259. private _modifierRadius;
  100260. }
  100261. }
  100262. declare module BABYLON {
  100263. interface FreeCameraInputsManager {
  100264. /**
  100265. * @hidden
  100266. */
  100267. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  100268. /**
  100269. * Add orientation input support to the input manager.
  100270. * @returns the current input manager
  100271. */
  100272. addDeviceOrientation(): FreeCameraInputsManager;
  100273. }
  100274. /**
  100275. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  100276. * Screen rotation is taken into account.
  100277. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100278. */
  100279. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  100280. private _camera;
  100281. private _screenOrientationAngle;
  100282. private _constantTranform;
  100283. private _screenQuaternion;
  100284. private _alpha;
  100285. private _beta;
  100286. private _gamma;
  100287. /**
  100288. * Can be used to detect if a device orientation sensor is availible on a device
  100289. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  100290. * @returns a promise that will resolve on orientation change
  100291. */
  100292. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  100293. /**
  100294. * @hidden
  100295. */
  100296. _onDeviceOrientationChangedObservable: Observable<void>;
  100297. /**
  100298. * Instantiates a new input
  100299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100300. */
  100301. constructor();
  100302. /**
  100303. * Define the camera controlled by the input.
  100304. */
  100305. camera: FreeCamera;
  100306. /**
  100307. * Attach the input controls to a specific dom element to get the input from.
  100308. * @param element Defines the element the controls should be listened from
  100309. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100310. */
  100311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100312. private _orientationChanged;
  100313. private _deviceOrientation;
  100314. /**
  100315. * Detach the current controls from the specified dom element.
  100316. * @param element Defines the element to stop listening the inputs from
  100317. */
  100318. detachControl(element: Nullable<HTMLElement>): void;
  100319. /**
  100320. * Update the current camera state depending on the inputs that have been used this frame.
  100321. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100322. */
  100323. checkInputs(): void;
  100324. /**
  100325. * Gets the class name of the current intput.
  100326. * @returns the class name
  100327. */
  100328. getClassName(): string;
  100329. /**
  100330. * Get the friendly name associated with the input class.
  100331. * @returns the input friendly name
  100332. */
  100333. getSimpleName(): string;
  100334. }
  100335. }
  100336. declare module BABYLON {
  100337. /**
  100338. * Manage the gamepad inputs to control a free camera.
  100339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100340. */
  100341. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  100342. /**
  100343. * Define the camera the input is attached to.
  100344. */
  100345. camera: FreeCamera;
  100346. /**
  100347. * Define the Gamepad controlling the input
  100348. */
  100349. gamepad: Nullable<Gamepad>;
  100350. /**
  100351. * Defines the gamepad rotation sensiblity.
  100352. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100353. */
  100354. gamepadAngularSensibility: number;
  100355. /**
  100356. * Defines the gamepad move sensiblity.
  100357. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100358. */
  100359. gamepadMoveSensibility: number;
  100360. private _onGamepadConnectedObserver;
  100361. private _onGamepadDisconnectedObserver;
  100362. private _cameraTransform;
  100363. private _deltaTransform;
  100364. private _vector3;
  100365. private _vector2;
  100366. /**
  100367. * Attach the input controls to a specific dom element to get the input from.
  100368. * @param element Defines the element the controls should be listened from
  100369. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100370. */
  100371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100372. /**
  100373. * Detach the current controls from the specified dom element.
  100374. * @param element Defines the element to stop listening the inputs from
  100375. */
  100376. detachControl(element: Nullable<HTMLElement>): void;
  100377. /**
  100378. * Update the current camera state depending on the inputs that have been used this frame.
  100379. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100380. */
  100381. checkInputs(): void;
  100382. /**
  100383. * Gets the class name of the current intput.
  100384. * @returns the class name
  100385. */
  100386. getClassName(): string;
  100387. /**
  100388. * Get the friendly name associated with the input class.
  100389. * @returns the input friendly name
  100390. */
  100391. getSimpleName(): string;
  100392. }
  100393. }
  100394. declare module BABYLON {
  100395. /**
  100396. * Defines the potential axis of a Joystick
  100397. */
  100398. export enum JoystickAxis {
  100399. /** X axis */
  100400. X = 0,
  100401. /** Y axis */
  100402. Y = 1,
  100403. /** Z axis */
  100404. Z = 2
  100405. }
  100406. /**
  100407. * Class used to define virtual joystick (used in touch mode)
  100408. */
  100409. export class VirtualJoystick {
  100410. /**
  100411. * Gets or sets a boolean indicating that left and right values must be inverted
  100412. */
  100413. reverseLeftRight: boolean;
  100414. /**
  100415. * Gets or sets a boolean indicating that up and down values must be inverted
  100416. */
  100417. reverseUpDown: boolean;
  100418. /**
  100419. * Gets the offset value for the position (ie. the change of the position value)
  100420. */
  100421. deltaPosition: Vector3;
  100422. /**
  100423. * Gets a boolean indicating if the virtual joystick was pressed
  100424. */
  100425. pressed: boolean;
  100426. /**
  100427. * Canvas the virtual joystick will render onto, default z-index of this is 5
  100428. */
  100429. static Canvas: Nullable<HTMLCanvasElement>;
  100430. private static _globalJoystickIndex;
  100431. private static vjCanvasContext;
  100432. private static vjCanvasWidth;
  100433. private static vjCanvasHeight;
  100434. private static halfWidth;
  100435. private _action;
  100436. private _axisTargetedByLeftAndRight;
  100437. private _axisTargetedByUpAndDown;
  100438. private _joystickSensibility;
  100439. private _inversedSensibility;
  100440. private _joystickPointerID;
  100441. private _joystickColor;
  100442. private _joystickPointerPos;
  100443. private _joystickPreviousPointerPos;
  100444. private _joystickPointerStartPos;
  100445. private _deltaJoystickVector;
  100446. private _leftJoystick;
  100447. private _touches;
  100448. private _onPointerDownHandlerRef;
  100449. private _onPointerMoveHandlerRef;
  100450. private _onPointerUpHandlerRef;
  100451. private _onResize;
  100452. /**
  100453. * Creates a new virtual joystick
  100454. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100455. */
  100456. constructor(leftJoystick?: boolean);
  100457. /**
  100458. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100459. * @param newJoystickSensibility defines the new sensibility
  100460. */
  100461. setJoystickSensibility(newJoystickSensibility: number): void;
  100462. private _onPointerDown;
  100463. private _onPointerMove;
  100464. private _onPointerUp;
  100465. /**
  100466. * Change the color of the virtual joystick
  100467. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100468. */
  100469. setJoystickColor(newColor: string): void;
  100470. /**
  100471. * Defines a callback to call when the joystick is touched
  100472. * @param action defines the callback
  100473. */
  100474. setActionOnTouch(action: () => any): void;
  100475. /**
  100476. * Defines which axis you'd like to control for left & right
  100477. * @param axis defines the axis to use
  100478. */
  100479. setAxisForLeftRight(axis: JoystickAxis): void;
  100480. /**
  100481. * Defines which axis you'd like to control for up & down
  100482. * @param axis defines the axis to use
  100483. */
  100484. setAxisForUpDown(axis: JoystickAxis): void;
  100485. private _drawVirtualJoystick;
  100486. /**
  100487. * Release internal HTML canvas
  100488. */
  100489. releaseCanvas(): void;
  100490. }
  100491. }
  100492. declare module BABYLON {
  100493. interface FreeCameraInputsManager {
  100494. /**
  100495. * Add virtual joystick input support to the input manager.
  100496. * @returns the current input manager
  100497. */
  100498. addVirtualJoystick(): FreeCameraInputsManager;
  100499. }
  100500. /**
  100501. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  100502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100503. */
  100504. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  100505. /**
  100506. * Defines the camera the input is attached to.
  100507. */
  100508. camera: FreeCamera;
  100509. private _leftjoystick;
  100510. private _rightjoystick;
  100511. /**
  100512. * Gets the left stick of the virtual joystick.
  100513. * @returns The virtual Joystick
  100514. */
  100515. getLeftJoystick(): VirtualJoystick;
  100516. /**
  100517. * Gets the right stick of the virtual joystick.
  100518. * @returns The virtual Joystick
  100519. */
  100520. getRightJoystick(): VirtualJoystick;
  100521. /**
  100522. * Update the current camera state depending on the inputs that have been used this frame.
  100523. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100524. */
  100525. checkInputs(): void;
  100526. /**
  100527. * Attach the input controls to a specific dom element to get the input from.
  100528. * @param element Defines the element the controls should be listened from
  100529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100530. */
  100531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100532. /**
  100533. * Detach the current controls from the specified dom element.
  100534. * @param element Defines the element to stop listening the inputs from
  100535. */
  100536. detachControl(element: Nullable<HTMLElement>): void;
  100537. /**
  100538. * Gets the class name of the current intput.
  100539. * @returns the class name
  100540. */
  100541. getClassName(): string;
  100542. /**
  100543. * Get the friendly name associated with the input class.
  100544. * @returns the input friendly name
  100545. */
  100546. getSimpleName(): string;
  100547. }
  100548. }
  100549. declare module BABYLON {
  100550. /**
  100551. * This represents a FPS type of camera controlled by touch.
  100552. * This is like a universal camera minus the Gamepad controls.
  100553. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100554. */
  100555. export class TouchCamera extends FreeCamera {
  100556. /**
  100557. * Defines the touch sensibility for rotation.
  100558. * The higher the faster.
  100559. */
  100560. touchAngularSensibility: number;
  100561. /**
  100562. * Defines the touch sensibility for move.
  100563. * The higher the faster.
  100564. */
  100565. touchMoveSensibility: number;
  100566. /**
  100567. * Instantiates a new touch camera.
  100568. * This represents a FPS type of camera controlled by touch.
  100569. * This is like a universal camera minus the Gamepad controls.
  100570. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100571. * @param name Define the name of the camera in the scene
  100572. * @param position Define the start position of the camera in the scene
  100573. * @param scene Define the scene the camera belongs to
  100574. */
  100575. constructor(name: string, position: Vector3, scene: Scene);
  100576. /**
  100577. * Gets the current object class name.
  100578. * @return the class name
  100579. */
  100580. getClassName(): string;
  100581. /** @hidden */
  100582. _setupInputs(): void;
  100583. }
  100584. }
  100585. declare module BABYLON {
  100586. /**
  100587. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  100588. * being tilted forward or back and left or right.
  100589. */
  100590. export class DeviceOrientationCamera extends FreeCamera {
  100591. private _initialQuaternion;
  100592. private _quaternionCache;
  100593. private _tmpDragQuaternion;
  100594. /**
  100595. * Creates a new device orientation camera
  100596. * @param name The name of the camera
  100597. * @param position The start position camera
  100598. * @param scene The scene the camera belongs to
  100599. */
  100600. constructor(name: string, position: Vector3, scene: Scene);
  100601. /**
  100602. * @hidden
  100603. * Disabled pointer input on first orientation sensor update (Default: true)
  100604. */
  100605. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  100606. private _dragFactor;
  100607. /**
  100608. * Enabled turning on the y axis when the orientation sensor is active
  100609. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  100610. */
  100611. enableHorizontalDragging(dragFactor?: number): void;
  100612. /**
  100613. * Gets the current instance class name ("DeviceOrientationCamera").
  100614. * This helps avoiding instanceof at run time.
  100615. * @returns the class name
  100616. */
  100617. getClassName(): string;
  100618. /**
  100619. * @hidden
  100620. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100621. */
  100622. _checkInputs(): void;
  100623. /**
  100624. * Reset the camera to its default orientation on the specified axis only.
  100625. * @param axis The axis to reset
  100626. */
  100627. resetToCurrentRotation(axis?: Axis): void;
  100628. }
  100629. }
  100630. declare module BABYLON {
  100631. /**
  100632. * Defines supported buttons for XBox360 compatible gamepads
  100633. */
  100634. export enum Xbox360Button {
  100635. /** A */
  100636. A = 0,
  100637. /** B */
  100638. B = 1,
  100639. /** X */
  100640. X = 2,
  100641. /** Y */
  100642. Y = 3,
  100643. /** Start */
  100644. Start = 4,
  100645. /** Back */
  100646. Back = 5,
  100647. /** Left button */
  100648. LB = 6,
  100649. /** Right button */
  100650. RB = 7,
  100651. /** Left stick */
  100652. LeftStick = 8,
  100653. /** Right stick */
  100654. RightStick = 9
  100655. }
  100656. /** Defines values for XBox360 DPad */
  100657. export enum Xbox360Dpad {
  100658. /** Up */
  100659. Up = 0,
  100660. /** Down */
  100661. Down = 1,
  100662. /** Left */
  100663. Left = 2,
  100664. /** Right */
  100665. Right = 3
  100666. }
  100667. /**
  100668. * Defines a XBox360 gamepad
  100669. */
  100670. export class Xbox360Pad extends Gamepad {
  100671. private _leftTrigger;
  100672. private _rightTrigger;
  100673. private _onlefttriggerchanged;
  100674. private _onrighttriggerchanged;
  100675. private _onbuttondown;
  100676. private _onbuttonup;
  100677. private _ondpaddown;
  100678. private _ondpadup;
  100679. /** Observable raised when a button is pressed */
  100680. onButtonDownObservable: Observable<Xbox360Button>;
  100681. /** Observable raised when a button is released */
  100682. onButtonUpObservable: Observable<Xbox360Button>;
  100683. /** Observable raised when a pad is pressed */
  100684. onPadDownObservable: Observable<Xbox360Dpad>;
  100685. /** Observable raised when a pad is released */
  100686. onPadUpObservable: Observable<Xbox360Dpad>;
  100687. private _buttonA;
  100688. private _buttonB;
  100689. private _buttonX;
  100690. private _buttonY;
  100691. private _buttonBack;
  100692. private _buttonStart;
  100693. private _buttonLB;
  100694. private _buttonRB;
  100695. private _buttonLeftStick;
  100696. private _buttonRightStick;
  100697. private _dPadUp;
  100698. private _dPadDown;
  100699. private _dPadLeft;
  100700. private _dPadRight;
  100701. private _isXboxOnePad;
  100702. /**
  100703. * Creates a new XBox360 gamepad object
  100704. * @param id defines the id of this gamepad
  100705. * @param index defines its index
  100706. * @param gamepad defines the internal HTML gamepad object
  100707. * @param xboxOne defines if it is a XBox One gamepad
  100708. */
  100709. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  100710. /**
  100711. * Defines the callback to call when left trigger is pressed
  100712. * @param callback defines the callback to use
  100713. */
  100714. onlefttriggerchanged(callback: (value: number) => void): void;
  100715. /**
  100716. * Defines the callback to call when right trigger is pressed
  100717. * @param callback defines the callback to use
  100718. */
  100719. onrighttriggerchanged(callback: (value: number) => void): void;
  100720. /**
  100721. * Gets the left trigger value
  100722. */
  100723. /**
  100724. * Sets the left trigger value
  100725. */
  100726. leftTrigger: number;
  100727. /**
  100728. * Gets the right trigger value
  100729. */
  100730. /**
  100731. * Sets the right trigger value
  100732. */
  100733. rightTrigger: number;
  100734. /**
  100735. * Defines the callback to call when a button is pressed
  100736. * @param callback defines the callback to use
  100737. */
  100738. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  100739. /**
  100740. * Defines the callback to call when a button is released
  100741. * @param callback defines the callback to use
  100742. */
  100743. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  100744. /**
  100745. * Defines the callback to call when a pad is pressed
  100746. * @param callback defines the callback to use
  100747. */
  100748. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  100749. /**
  100750. * Defines the callback to call when a pad is released
  100751. * @param callback defines the callback to use
  100752. */
  100753. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  100754. private _setButtonValue;
  100755. private _setDPadValue;
  100756. /**
  100757. * Gets the value of the `A` button
  100758. */
  100759. /**
  100760. * Sets the value of the `A` button
  100761. */
  100762. buttonA: number;
  100763. /**
  100764. * Gets the value of the `B` button
  100765. */
  100766. /**
  100767. * Sets the value of the `B` button
  100768. */
  100769. buttonB: number;
  100770. /**
  100771. * Gets the value of the `X` button
  100772. */
  100773. /**
  100774. * Sets the value of the `X` button
  100775. */
  100776. buttonX: number;
  100777. /**
  100778. * Gets the value of the `Y` button
  100779. */
  100780. /**
  100781. * Sets the value of the `Y` button
  100782. */
  100783. buttonY: number;
  100784. /**
  100785. * Gets the value of the `Start` button
  100786. */
  100787. /**
  100788. * Sets the value of the `Start` button
  100789. */
  100790. buttonStart: number;
  100791. /**
  100792. * Gets the value of the `Back` button
  100793. */
  100794. /**
  100795. * Sets the value of the `Back` button
  100796. */
  100797. buttonBack: number;
  100798. /**
  100799. * Gets the value of the `Left` button
  100800. */
  100801. /**
  100802. * Sets the value of the `Left` button
  100803. */
  100804. buttonLB: number;
  100805. /**
  100806. * Gets the value of the `Right` button
  100807. */
  100808. /**
  100809. * Sets the value of the `Right` button
  100810. */
  100811. buttonRB: number;
  100812. /**
  100813. * Gets the value of the Left joystick
  100814. */
  100815. /**
  100816. * Sets the value of the Left joystick
  100817. */
  100818. buttonLeftStick: number;
  100819. /**
  100820. * Gets the value of the Right joystick
  100821. */
  100822. /**
  100823. * Sets the value of the Right joystick
  100824. */
  100825. buttonRightStick: number;
  100826. /**
  100827. * Gets the value of D-pad up
  100828. */
  100829. /**
  100830. * Sets the value of D-pad up
  100831. */
  100832. dPadUp: number;
  100833. /**
  100834. * Gets the value of D-pad down
  100835. */
  100836. /**
  100837. * Sets the value of D-pad down
  100838. */
  100839. dPadDown: number;
  100840. /**
  100841. * Gets the value of D-pad left
  100842. */
  100843. /**
  100844. * Sets the value of D-pad left
  100845. */
  100846. dPadLeft: number;
  100847. /**
  100848. * Gets the value of D-pad right
  100849. */
  100850. /**
  100851. * Sets the value of D-pad right
  100852. */
  100853. dPadRight: number;
  100854. /**
  100855. * Force the gamepad to synchronize with device values
  100856. */
  100857. update(): void;
  100858. /**
  100859. * Disposes the gamepad
  100860. */
  100861. dispose(): void;
  100862. }
  100863. }
  100864. declare module BABYLON {
  100865. /**
  100866. * Manager for handling gamepads
  100867. */
  100868. export class GamepadManager {
  100869. private _scene?;
  100870. private _babylonGamepads;
  100871. private _oneGamepadConnected;
  100872. /** @hidden */
  100873. _isMonitoring: boolean;
  100874. private _gamepadEventSupported;
  100875. private _gamepadSupport;
  100876. /**
  100877. * observable to be triggered when the gamepad controller has been connected
  100878. */
  100879. onGamepadConnectedObservable: Observable<Gamepad>;
  100880. /**
  100881. * observable to be triggered when the gamepad controller has been disconnected
  100882. */
  100883. onGamepadDisconnectedObservable: Observable<Gamepad>;
  100884. private _onGamepadConnectedEvent;
  100885. private _onGamepadDisconnectedEvent;
  100886. /**
  100887. * Initializes the gamepad manager
  100888. * @param _scene BabylonJS scene
  100889. */
  100890. constructor(_scene?: Scene | undefined);
  100891. /**
  100892. * The gamepads in the game pad manager
  100893. */
  100894. readonly gamepads: Gamepad[];
  100895. /**
  100896. * Get the gamepad controllers based on type
  100897. * @param type The type of gamepad controller
  100898. * @returns Nullable gamepad
  100899. */
  100900. getGamepadByType(type?: number): Nullable<Gamepad>;
  100901. /**
  100902. * Disposes the gamepad manager
  100903. */
  100904. dispose(): void;
  100905. private _addNewGamepad;
  100906. private _startMonitoringGamepads;
  100907. private _stopMonitoringGamepads;
  100908. /** @hidden */
  100909. _checkGamepadsStatus(): void;
  100910. private _updateGamepadObjects;
  100911. }
  100912. }
  100913. declare module BABYLON {
  100914. interface Scene {
  100915. /** @hidden */
  100916. _gamepadManager: Nullable<GamepadManager>;
  100917. /**
  100918. * Gets the gamepad manager associated with the scene
  100919. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  100920. */
  100921. gamepadManager: GamepadManager;
  100922. }
  100923. /**
  100924. * Interface representing a free camera inputs manager
  100925. */
  100926. interface FreeCameraInputsManager {
  100927. /**
  100928. * Adds gamepad input support to the FreeCameraInputsManager.
  100929. * @returns the FreeCameraInputsManager
  100930. */
  100931. addGamepad(): FreeCameraInputsManager;
  100932. }
  100933. /**
  100934. * Interface representing an arc rotate camera inputs manager
  100935. */
  100936. interface ArcRotateCameraInputsManager {
  100937. /**
  100938. * Adds gamepad input support to the ArcRotateCamera InputManager.
  100939. * @returns the camera inputs manager
  100940. */
  100941. addGamepad(): ArcRotateCameraInputsManager;
  100942. }
  100943. /**
  100944. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  100945. */
  100946. export class GamepadSystemSceneComponent implements ISceneComponent {
  100947. /**
  100948. * The component name helpfull to identify the component in the list of scene components.
  100949. */
  100950. readonly name: string;
  100951. /**
  100952. * The scene the component belongs to.
  100953. */
  100954. scene: Scene;
  100955. /**
  100956. * Creates a new instance of the component for the given scene
  100957. * @param scene Defines the scene to register the component in
  100958. */
  100959. constructor(scene: Scene);
  100960. /**
  100961. * Registers the component in a given scene
  100962. */
  100963. register(): void;
  100964. /**
  100965. * Rebuilds the elements related to this component in case of
  100966. * context lost for instance.
  100967. */
  100968. rebuild(): void;
  100969. /**
  100970. * Disposes the component and the associated ressources
  100971. */
  100972. dispose(): void;
  100973. private _beforeCameraUpdate;
  100974. }
  100975. }
  100976. declare module BABYLON {
  100977. /**
  100978. * 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,
  100979. * which still works and will still be found in many Playgrounds.
  100980. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100981. */
  100982. export class UniversalCamera extends TouchCamera {
  100983. /**
  100984. * Defines the gamepad rotation sensiblity.
  100985. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100986. */
  100987. gamepadAngularSensibility: number;
  100988. /**
  100989. * Defines the gamepad move sensiblity.
  100990. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100991. */
  100992. gamepadMoveSensibility: number;
  100993. /**
  100994. * 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,
  100995. * which still works and will still be found in many Playgrounds.
  100996. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100997. * @param name Define the name of the camera in the scene
  100998. * @param position Define the start position of the camera in the scene
  100999. * @param scene Define the scene the camera belongs to
  101000. */
  101001. constructor(name: string, position: Vector3, scene: Scene);
  101002. /**
  101003. * Gets the current object class name.
  101004. * @return the class name
  101005. */
  101006. getClassName(): string;
  101007. }
  101008. }
  101009. declare module BABYLON {
  101010. /**
  101011. * This represents a FPS type of camera. This is only here for back compat purpose.
  101012. * Please use the UniversalCamera instead as both are identical.
  101013. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101014. */
  101015. export class GamepadCamera extends UniversalCamera {
  101016. /**
  101017. * Instantiates a new Gamepad Camera
  101018. * This represents a FPS type of camera. This is only here for back compat purpose.
  101019. * Please use the UniversalCamera instead as both are identical.
  101020. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101021. * @param name Define the name of the camera in the scene
  101022. * @param position Define the start position of the camera in the scene
  101023. * @param scene Define the scene the camera belongs to
  101024. */
  101025. constructor(name: string, position: Vector3, scene: Scene);
  101026. /**
  101027. * Gets the current object class name.
  101028. * @return the class name
  101029. */
  101030. getClassName(): string;
  101031. }
  101032. }
  101033. declare module BABYLON {
  101034. /** @hidden */
  101035. export var passPixelShader: {
  101036. name: string;
  101037. shader: string;
  101038. };
  101039. }
  101040. declare module BABYLON {
  101041. /** @hidden */
  101042. export var passCubePixelShader: {
  101043. name: string;
  101044. shader: string;
  101045. };
  101046. }
  101047. declare module BABYLON {
  101048. /**
  101049. * PassPostProcess which produces an output the same as it's input
  101050. */
  101051. export class PassPostProcess extends PostProcess {
  101052. /**
  101053. * Creates the PassPostProcess
  101054. * @param name The name of the effect.
  101055. * @param options The required width/height ratio to downsize to before computing the render pass.
  101056. * @param camera The camera to apply the render pass to.
  101057. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101058. * @param engine The engine which the post process will be applied. (default: current engine)
  101059. * @param reusable If the post process can be reused on the same frame. (default: false)
  101060. * @param textureType The type of texture to be used when performing the post processing.
  101061. * @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)
  101062. */
  101063. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101064. }
  101065. /**
  101066. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  101067. */
  101068. export class PassCubePostProcess extends PostProcess {
  101069. private _face;
  101070. /**
  101071. * Gets or sets the cube face to display.
  101072. * * 0 is +X
  101073. * * 1 is -X
  101074. * * 2 is +Y
  101075. * * 3 is -Y
  101076. * * 4 is +Z
  101077. * * 5 is -Z
  101078. */
  101079. face: number;
  101080. /**
  101081. * Creates the PassCubePostProcess
  101082. * @param name The name of the effect.
  101083. * @param options The required width/height ratio to downsize to before computing the render pass.
  101084. * @param camera The camera to apply the render pass to.
  101085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101086. * @param engine The engine which the post process will be applied. (default: current engine)
  101087. * @param reusable If the post process can be reused on the same frame. (default: false)
  101088. * @param textureType The type of texture to be used when performing the post processing.
  101089. * @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)
  101090. */
  101091. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101092. }
  101093. }
  101094. declare module BABYLON {
  101095. /** @hidden */
  101096. export var anaglyphPixelShader: {
  101097. name: string;
  101098. shader: string;
  101099. };
  101100. }
  101101. declare module BABYLON {
  101102. /**
  101103. * Postprocess used to generate anaglyphic rendering
  101104. */
  101105. export class AnaglyphPostProcess extends PostProcess {
  101106. private _passedProcess;
  101107. /**
  101108. * Creates a new AnaglyphPostProcess
  101109. * @param name defines postprocess name
  101110. * @param options defines creation options or target ratio scale
  101111. * @param rigCameras defines cameras using this postprocess
  101112. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  101113. * @param engine defines hosting engine
  101114. * @param reusable defines if the postprocess will be reused multiple times per frame
  101115. */
  101116. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  101117. }
  101118. }
  101119. declare module BABYLON {
  101120. /**
  101121. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  101122. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101123. */
  101124. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  101125. /**
  101126. * Creates a new AnaglyphArcRotateCamera
  101127. * @param name defines camera name
  101128. * @param alpha defines alpha angle (in radians)
  101129. * @param beta defines beta angle (in radians)
  101130. * @param radius defines radius
  101131. * @param target defines camera target
  101132. * @param interaxialDistance defines distance between each color axis
  101133. * @param scene defines the hosting scene
  101134. */
  101135. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  101136. /**
  101137. * Gets camera class name
  101138. * @returns AnaglyphArcRotateCamera
  101139. */
  101140. getClassName(): string;
  101141. }
  101142. }
  101143. declare module BABYLON {
  101144. /**
  101145. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  101146. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101147. */
  101148. export class AnaglyphFreeCamera extends FreeCamera {
  101149. /**
  101150. * Creates a new AnaglyphFreeCamera
  101151. * @param name defines camera name
  101152. * @param position defines initial position
  101153. * @param interaxialDistance defines distance between each color axis
  101154. * @param scene defines the hosting scene
  101155. */
  101156. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101157. /**
  101158. * Gets camera class name
  101159. * @returns AnaglyphFreeCamera
  101160. */
  101161. getClassName(): string;
  101162. }
  101163. }
  101164. declare module BABYLON {
  101165. /**
  101166. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  101167. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101168. */
  101169. export class AnaglyphGamepadCamera extends GamepadCamera {
  101170. /**
  101171. * Creates a new AnaglyphGamepadCamera
  101172. * @param name defines camera name
  101173. * @param position defines initial position
  101174. * @param interaxialDistance defines distance between each color axis
  101175. * @param scene defines the hosting scene
  101176. */
  101177. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101178. /**
  101179. * Gets camera class name
  101180. * @returns AnaglyphGamepadCamera
  101181. */
  101182. getClassName(): string;
  101183. }
  101184. }
  101185. declare module BABYLON {
  101186. /**
  101187. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  101188. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101189. */
  101190. export class AnaglyphUniversalCamera extends UniversalCamera {
  101191. /**
  101192. * Creates a new AnaglyphUniversalCamera
  101193. * @param name defines camera name
  101194. * @param position defines initial position
  101195. * @param interaxialDistance defines distance between each color axis
  101196. * @param scene defines the hosting scene
  101197. */
  101198. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101199. /**
  101200. * Gets camera class name
  101201. * @returns AnaglyphUniversalCamera
  101202. */
  101203. getClassName(): string;
  101204. }
  101205. }
  101206. declare module BABYLON {
  101207. /** @hidden */
  101208. export var stereoscopicInterlacePixelShader: {
  101209. name: string;
  101210. shader: string;
  101211. };
  101212. }
  101213. declare module BABYLON {
  101214. /**
  101215. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  101216. */
  101217. export class StereoscopicInterlacePostProcess extends PostProcess {
  101218. private _stepSize;
  101219. private _passedProcess;
  101220. /**
  101221. * Initializes a StereoscopicInterlacePostProcess
  101222. * @param name The name of the effect.
  101223. * @param rigCameras The rig cameras to be appled to the post process
  101224. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  101225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101226. * @param engine The engine which the post process will be applied. (default: current engine)
  101227. * @param reusable If the post process can be reused on the same frame. (default: false)
  101228. */
  101229. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  101230. }
  101231. }
  101232. declare module BABYLON {
  101233. /**
  101234. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  101235. * @see http://doc.babylonjs.com/features/cameras
  101236. */
  101237. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  101238. /**
  101239. * Creates a new StereoscopicArcRotateCamera
  101240. * @param name defines camera name
  101241. * @param alpha defines alpha angle (in radians)
  101242. * @param beta defines beta angle (in radians)
  101243. * @param radius defines radius
  101244. * @param target defines camera target
  101245. * @param interaxialDistance defines distance between each color axis
  101246. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101247. * @param scene defines the hosting scene
  101248. */
  101249. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101250. /**
  101251. * Gets camera class name
  101252. * @returns StereoscopicArcRotateCamera
  101253. */
  101254. getClassName(): string;
  101255. }
  101256. }
  101257. declare module BABYLON {
  101258. /**
  101259. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  101260. * @see http://doc.babylonjs.com/features/cameras
  101261. */
  101262. export class StereoscopicFreeCamera extends FreeCamera {
  101263. /**
  101264. * Creates a new StereoscopicFreeCamera
  101265. * @param name defines camera name
  101266. * @param position defines initial position
  101267. * @param interaxialDistance defines distance between each color axis
  101268. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101269. * @param scene defines the hosting scene
  101270. */
  101271. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101272. /**
  101273. * Gets camera class name
  101274. * @returns StereoscopicFreeCamera
  101275. */
  101276. getClassName(): string;
  101277. }
  101278. }
  101279. declare module BABYLON {
  101280. /**
  101281. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  101282. * @see http://doc.babylonjs.com/features/cameras
  101283. */
  101284. export class StereoscopicGamepadCamera extends GamepadCamera {
  101285. /**
  101286. * Creates a new StereoscopicGamepadCamera
  101287. * @param name defines camera name
  101288. * @param position defines initial position
  101289. * @param interaxialDistance defines distance between each color axis
  101290. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101291. * @param scene defines the hosting scene
  101292. */
  101293. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101294. /**
  101295. * Gets camera class name
  101296. * @returns StereoscopicGamepadCamera
  101297. */
  101298. getClassName(): string;
  101299. }
  101300. }
  101301. declare module BABYLON {
  101302. /**
  101303. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  101304. * @see http://doc.babylonjs.com/features/cameras
  101305. */
  101306. export class StereoscopicUniversalCamera extends UniversalCamera {
  101307. /**
  101308. * Creates a new StereoscopicUniversalCamera
  101309. * @param name defines camera name
  101310. * @param position defines initial position
  101311. * @param interaxialDistance defines distance between each color axis
  101312. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101313. * @param scene defines the hosting scene
  101314. */
  101315. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101316. /**
  101317. * Gets camera class name
  101318. * @returns StereoscopicUniversalCamera
  101319. */
  101320. getClassName(): string;
  101321. }
  101322. }
  101323. declare module BABYLON {
  101324. /**
  101325. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  101326. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101327. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101328. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101329. */
  101330. export class VirtualJoysticksCamera extends FreeCamera {
  101331. /**
  101332. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  101333. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101334. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101335. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101336. * @param name Define the name of the camera in the scene
  101337. * @param position Define the start position of the camera in the scene
  101338. * @param scene Define the scene the camera belongs to
  101339. */
  101340. constructor(name: string, position: Vector3, scene: Scene);
  101341. /**
  101342. * Gets the current object class name.
  101343. * @return the class name
  101344. */
  101345. getClassName(): string;
  101346. }
  101347. }
  101348. declare module BABYLON {
  101349. /**
  101350. * This represents all the required metrics to create a VR camera.
  101351. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  101352. */
  101353. export class VRCameraMetrics {
  101354. /**
  101355. * Define the horizontal resolution off the screen.
  101356. */
  101357. hResolution: number;
  101358. /**
  101359. * Define the vertical resolution off the screen.
  101360. */
  101361. vResolution: number;
  101362. /**
  101363. * Define the horizontal screen size.
  101364. */
  101365. hScreenSize: number;
  101366. /**
  101367. * Define the vertical screen size.
  101368. */
  101369. vScreenSize: number;
  101370. /**
  101371. * Define the vertical screen center position.
  101372. */
  101373. vScreenCenter: number;
  101374. /**
  101375. * Define the distance of the eyes to the screen.
  101376. */
  101377. eyeToScreenDistance: number;
  101378. /**
  101379. * Define the distance between both lenses
  101380. */
  101381. lensSeparationDistance: number;
  101382. /**
  101383. * Define the distance between both viewer's eyes.
  101384. */
  101385. interpupillaryDistance: number;
  101386. /**
  101387. * Define the distortion factor of the VR postprocess.
  101388. * Please, touch with care.
  101389. */
  101390. distortionK: number[];
  101391. /**
  101392. * Define the chromatic aberration correction factors for the VR post process.
  101393. */
  101394. chromaAbCorrection: number[];
  101395. /**
  101396. * Define the scale factor of the post process.
  101397. * The smaller the better but the slower.
  101398. */
  101399. postProcessScaleFactor: number;
  101400. /**
  101401. * Define an offset for the lens center.
  101402. */
  101403. lensCenterOffset: number;
  101404. /**
  101405. * Define if the current vr camera should compensate the distortion of the lense or not.
  101406. */
  101407. compensateDistortion: boolean;
  101408. /**
  101409. * Defines if multiview should be enabled when rendering (Default: false)
  101410. */
  101411. multiviewEnabled: boolean;
  101412. /**
  101413. * Gets the rendering aspect ratio based on the provided resolutions.
  101414. */
  101415. readonly aspectRatio: number;
  101416. /**
  101417. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  101418. */
  101419. readonly aspectRatioFov: number;
  101420. /**
  101421. * @hidden
  101422. */
  101423. readonly leftHMatrix: Matrix;
  101424. /**
  101425. * @hidden
  101426. */
  101427. readonly rightHMatrix: Matrix;
  101428. /**
  101429. * @hidden
  101430. */
  101431. readonly leftPreViewMatrix: Matrix;
  101432. /**
  101433. * @hidden
  101434. */
  101435. readonly rightPreViewMatrix: Matrix;
  101436. /**
  101437. * Get the default VRMetrics based on the most generic setup.
  101438. * @returns the default vr metrics
  101439. */
  101440. static GetDefault(): VRCameraMetrics;
  101441. }
  101442. }
  101443. declare module BABYLON {
  101444. /** @hidden */
  101445. export var vrDistortionCorrectionPixelShader: {
  101446. name: string;
  101447. shader: string;
  101448. };
  101449. }
  101450. declare module BABYLON {
  101451. /**
  101452. * VRDistortionCorrectionPostProcess used for mobile VR
  101453. */
  101454. export class VRDistortionCorrectionPostProcess extends PostProcess {
  101455. private _isRightEye;
  101456. private _distortionFactors;
  101457. private _postProcessScaleFactor;
  101458. private _lensCenterOffset;
  101459. private _scaleIn;
  101460. private _scaleFactor;
  101461. private _lensCenter;
  101462. /**
  101463. * Initializes the VRDistortionCorrectionPostProcess
  101464. * @param name The name of the effect.
  101465. * @param camera The camera to apply the render pass to.
  101466. * @param isRightEye If this is for the right eye distortion
  101467. * @param vrMetrics All the required metrics for the VR camera
  101468. */
  101469. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  101470. }
  101471. }
  101472. declare module BABYLON {
  101473. /**
  101474. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  101475. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101476. */
  101477. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  101478. /**
  101479. * Creates a new VRDeviceOrientationArcRotateCamera
  101480. * @param name defines camera name
  101481. * @param alpha defines the camera rotation along the logitudinal axis
  101482. * @param beta defines the camera rotation along the latitudinal axis
  101483. * @param radius defines the camera distance from its target
  101484. * @param target defines the camera target
  101485. * @param scene defines the scene the camera belongs to
  101486. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101487. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101488. */
  101489. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101490. /**
  101491. * Gets camera class name
  101492. * @returns VRDeviceOrientationArcRotateCamera
  101493. */
  101494. getClassName(): string;
  101495. }
  101496. }
  101497. declare module BABYLON {
  101498. /**
  101499. * Camera used to simulate VR rendering (based on FreeCamera)
  101500. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101501. */
  101502. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  101503. /**
  101504. * Creates a new VRDeviceOrientationFreeCamera
  101505. * @param name defines camera name
  101506. * @param position defines the start position of the camera
  101507. * @param scene defines the scene the camera belongs to
  101508. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101509. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101510. */
  101511. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101512. /**
  101513. * Gets camera class name
  101514. * @returns VRDeviceOrientationFreeCamera
  101515. */
  101516. getClassName(): string;
  101517. }
  101518. }
  101519. declare module BABYLON {
  101520. /**
  101521. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  101522. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101523. */
  101524. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  101525. /**
  101526. * Creates a new VRDeviceOrientationGamepadCamera
  101527. * @param name defines camera name
  101528. * @param position defines the start position of the camera
  101529. * @param scene defines the scene the camera belongs to
  101530. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101531. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101532. */
  101533. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101534. /**
  101535. * Gets camera class name
  101536. * @returns VRDeviceOrientationGamepadCamera
  101537. */
  101538. getClassName(): string;
  101539. }
  101540. }
  101541. declare module BABYLON {
  101542. /**
  101543. * Base class of materials working in push mode in babylon JS
  101544. * @hidden
  101545. */
  101546. export class PushMaterial extends Material {
  101547. protected _activeEffect: Effect;
  101548. protected _normalMatrix: Matrix;
  101549. /**
  101550. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  101551. * This means that the material can keep using a previous shader while a new one is being compiled.
  101552. * This is mostly used when shader parallel compilation is supported (true by default)
  101553. */
  101554. allowShaderHotSwapping: boolean;
  101555. constructor(name: string, scene: Scene);
  101556. getEffect(): Effect;
  101557. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101558. /**
  101559. * Binds the given world matrix to the active effect
  101560. *
  101561. * @param world the matrix to bind
  101562. */
  101563. bindOnlyWorldMatrix(world: Matrix): void;
  101564. /**
  101565. * Binds the given normal matrix to the active effect
  101566. *
  101567. * @param normalMatrix the matrix to bind
  101568. */
  101569. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101570. bind(world: Matrix, mesh?: Mesh): void;
  101571. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101572. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101573. }
  101574. }
  101575. declare module BABYLON {
  101576. /**
  101577. * This groups all the flags used to control the materials channel.
  101578. */
  101579. export class MaterialFlags {
  101580. private static _DiffuseTextureEnabled;
  101581. /**
  101582. * Are diffuse textures enabled in the application.
  101583. */
  101584. static DiffuseTextureEnabled: boolean;
  101585. private static _AmbientTextureEnabled;
  101586. /**
  101587. * Are ambient textures enabled in the application.
  101588. */
  101589. static AmbientTextureEnabled: boolean;
  101590. private static _OpacityTextureEnabled;
  101591. /**
  101592. * Are opacity textures enabled in the application.
  101593. */
  101594. static OpacityTextureEnabled: boolean;
  101595. private static _ReflectionTextureEnabled;
  101596. /**
  101597. * Are reflection textures enabled in the application.
  101598. */
  101599. static ReflectionTextureEnabled: boolean;
  101600. private static _EmissiveTextureEnabled;
  101601. /**
  101602. * Are emissive textures enabled in the application.
  101603. */
  101604. static EmissiveTextureEnabled: boolean;
  101605. private static _SpecularTextureEnabled;
  101606. /**
  101607. * Are specular textures enabled in the application.
  101608. */
  101609. static SpecularTextureEnabled: boolean;
  101610. private static _BumpTextureEnabled;
  101611. /**
  101612. * Are bump textures enabled in the application.
  101613. */
  101614. static BumpTextureEnabled: boolean;
  101615. private static _LightmapTextureEnabled;
  101616. /**
  101617. * Are lightmap textures enabled in the application.
  101618. */
  101619. static LightmapTextureEnabled: boolean;
  101620. private static _RefractionTextureEnabled;
  101621. /**
  101622. * Are refraction textures enabled in the application.
  101623. */
  101624. static RefractionTextureEnabled: boolean;
  101625. private static _ColorGradingTextureEnabled;
  101626. /**
  101627. * Are color grading textures enabled in the application.
  101628. */
  101629. static ColorGradingTextureEnabled: boolean;
  101630. private static _FresnelEnabled;
  101631. /**
  101632. * Are fresnels enabled in the application.
  101633. */
  101634. static FresnelEnabled: boolean;
  101635. private static _ClearCoatTextureEnabled;
  101636. /**
  101637. * Are clear coat textures enabled in the application.
  101638. */
  101639. static ClearCoatTextureEnabled: boolean;
  101640. private static _ClearCoatBumpTextureEnabled;
  101641. /**
  101642. * Are clear coat bump textures enabled in the application.
  101643. */
  101644. static ClearCoatBumpTextureEnabled: boolean;
  101645. private static _ClearCoatTintTextureEnabled;
  101646. /**
  101647. * Are clear coat tint textures enabled in the application.
  101648. */
  101649. static ClearCoatTintTextureEnabled: boolean;
  101650. private static _SheenTextureEnabled;
  101651. /**
  101652. * Are sheen textures enabled in the application.
  101653. */
  101654. static SheenTextureEnabled: boolean;
  101655. private static _AnisotropicTextureEnabled;
  101656. /**
  101657. * Are anisotropic textures enabled in the application.
  101658. */
  101659. static AnisotropicTextureEnabled: boolean;
  101660. private static _ThicknessTextureEnabled;
  101661. /**
  101662. * Are thickness textures enabled in the application.
  101663. */
  101664. static ThicknessTextureEnabled: boolean;
  101665. }
  101666. }
  101667. declare module BABYLON {
  101668. /** @hidden */
  101669. export var defaultFragmentDeclaration: {
  101670. name: string;
  101671. shader: string;
  101672. };
  101673. }
  101674. declare module BABYLON {
  101675. /** @hidden */
  101676. export var defaultUboDeclaration: {
  101677. name: string;
  101678. shader: string;
  101679. };
  101680. }
  101681. declare module BABYLON {
  101682. /** @hidden */
  101683. export var lightFragmentDeclaration: {
  101684. name: string;
  101685. shader: string;
  101686. };
  101687. }
  101688. declare module BABYLON {
  101689. /** @hidden */
  101690. export var lightUboDeclaration: {
  101691. name: string;
  101692. shader: string;
  101693. };
  101694. }
  101695. declare module BABYLON {
  101696. /** @hidden */
  101697. export var lightsFragmentFunctions: {
  101698. name: string;
  101699. shader: string;
  101700. };
  101701. }
  101702. declare module BABYLON {
  101703. /** @hidden */
  101704. export var shadowsFragmentFunctions: {
  101705. name: string;
  101706. shader: string;
  101707. };
  101708. }
  101709. declare module BABYLON {
  101710. /** @hidden */
  101711. export var fresnelFunction: {
  101712. name: string;
  101713. shader: string;
  101714. };
  101715. }
  101716. declare module BABYLON {
  101717. /** @hidden */
  101718. export var reflectionFunction: {
  101719. name: string;
  101720. shader: string;
  101721. };
  101722. }
  101723. declare module BABYLON {
  101724. /** @hidden */
  101725. export var bumpFragmentFunctions: {
  101726. name: string;
  101727. shader: string;
  101728. };
  101729. }
  101730. declare module BABYLON {
  101731. /** @hidden */
  101732. export var logDepthDeclaration: {
  101733. name: string;
  101734. shader: string;
  101735. };
  101736. }
  101737. declare module BABYLON {
  101738. /** @hidden */
  101739. export var bumpFragment: {
  101740. name: string;
  101741. shader: string;
  101742. };
  101743. }
  101744. declare module BABYLON {
  101745. /** @hidden */
  101746. export var depthPrePass: {
  101747. name: string;
  101748. shader: string;
  101749. };
  101750. }
  101751. declare module BABYLON {
  101752. /** @hidden */
  101753. export var lightFragment: {
  101754. name: string;
  101755. shader: string;
  101756. };
  101757. }
  101758. declare module BABYLON {
  101759. /** @hidden */
  101760. export var logDepthFragment: {
  101761. name: string;
  101762. shader: string;
  101763. };
  101764. }
  101765. declare module BABYLON {
  101766. /** @hidden */
  101767. export var defaultPixelShader: {
  101768. name: string;
  101769. shader: string;
  101770. };
  101771. }
  101772. declare module BABYLON {
  101773. /** @hidden */
  101774. export var defaultVertexDeclaration: {
  101775. name: string;
  101776. shader: string;
  101777. };
  101778. }
  101779. declare module BABYLON {
  101780. /** @hidden */
  101781. export var bumpVertexDeclaration: {
  101782. name: string;
  101783. shader: string;
  101784. };
  101785. }
  101786. declare module BABYLON {
  101787. /** @hidden */
  101788. export var bumpVertex: {
  101789. name: string;
  101790. shader: string;
  101791. };
  101792. }
  101793. declare module BABYLON {
  101794. /** @hidden */
  101795. export var fogVertex: {
  101796. name: string;
  101797. shader: string;
  101798. };
  101799. }
  101800. declare module BABYLON {
  101801. /** @hidden */
  101802. export var shadowsVertex: {
  101803. name: string;
  101804. shader: string;
  101805. };
  101806. }
  101807. declare module BABYLON {
  101808. /** @hidden */
  101809. export var pointCloudVertex: {
  101810. name: string;
  101811. shader: string;
  101812. };
  101813. }
  101814. declare module BABYLON {
  101815. /** @hidden */
  101816. export var logDepthVertex: {
  101817. name: string;
  101818. shader: string;
  101819. };
  101820. }
  101821. declare module BABYLON {
  101822. /** @hidden */
  101823. export var defaultVertexShader: {
  101824. name: string;
  101825. shader: string;
  101826. };
  101827. }
  101828. declare module BABYLON {
  101829. /** @hidden */
  101830. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101831. MAINUV1: boolean;
  101832. MAINUV2: boolean;
  101833. DIFFUSE: boolean;
  101834. DIFFUSEDIRECTUV: number;
  101835. AMBIENT: boolean;
  101836. AMBIENTDIRECTUV: number;
  101837. OPACITY: boolean;
  101838. OPACITYDIRECTUV: number;
  101839. OPACITYRGB: boolean;
  101840. REFLECTION: boolean;
  101841. EMISSIVE: boolean;
  101842. EMISSIVEDIRECTUV: number;
  101843. SPECULAR: boolean;
  101844. SPECULARDIRECTUV: number;
  101845. BUMP: boolean;
  101846. BUMPDIRECTUV: number;
  101847. PARALLAX: boolean;
  101848. PARALLAXOCCLUSION: boolean;
  101849. SPECULAROVERALPHA: boolean;
  101850. CLIPPLANE: boolean;
  101851. CLIPPLANE2: boolean;
  101852. CLIPPLANE3: boolean;
  101853. CLIPPLANE4: boolean;
  101854. ALPHATEST: boolean;
  101855. DEPTHPREPASS: boolean;
  101856. ALPHAFROMDIFFUSE: boolean;
  101857. POINTSIZE: boolean;
  101858. FOG: boolean;
  101859. SPECULARTERM: boolean;
  101860. DIFFUSEFRESNEL: boolean;
  101861. OPACITYFRESNEL: boolean;
  101862. REFLECTIONFRESNEL: boolean;
  101863. REFRACTIONFRESNEL: boolean;
  101864. EMISSIVEFRESNEL: boolean;
  101865. FRESNEL: boolean;
  101866. NORMAL: boolean;
  101867. UV1: boolean;
  101868. UV2: boolean;
  101869. VERTEXCOLOR: boolean;
  101870. VERTEXALPHA: boolean;
  101871. NUM_BONE_INFLUENCERS: number;
  101872. BonesPerMesh: number;
  101873. BONETEXTURE: boolean;
  101874. INSTANCES: boolean;
  101875. GLOSSINESS: boolean;
  101876. ROUGHNESS: boolean;
  101877. EMISSIVEASILLUMINATION: boolean;
  101878. LINKEMISSIVEWITHDIFFUSE: boolean;
  101879. REFLECTIONFRESNELFROMSPECULAR: boolean;
  101880. LIGHTMAP: boolean;
  101881. LIGHTMAPDIRECTUV: number;
  101882. OBJECTSPACE_NORMALMAP: boolean;
  101883. USELIGHTMAPASSHADOWMAP: boolean;
  101884. REFLECTIONMAP_3D: boolean;
  101885. REFLECTIONMAP_SPHERICAL: boolean;
  101886. REFLECTIONMAP_PLANAR: boolean;
  101887. REFLECTIONMAP_CUBIC: boolean;
  101888. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  101889. REFLECTIONMAP_PROJECTION: boolean;
  101890. REFLECTIONMAP_SKYBOX: boolean;
  101891. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  101892. REFLECTIONMAP_EXPLICIT: boolean;
  101893. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  101894. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  101895. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  101896. INVERTCUBICMAP: boolean;
  101897. LOGARITHMICDEPTH: boolean;
  101898. REFRACTION: boolean;
  101899. REFRACTIONMAP_3D: boolean;
  101900. REFLECTIONOVERALPHA: boolean;
  101901. TWOSIDEDLIGHTING: boolean;
  101902. SHADOWFLOAT: boolean;
  101903. MORPHTARGETS: boolean;
  101904. MORPHTARGETS_NORMAL: boolean;
  101905. MORPHTARGETS_TANGENT: boolean;
  101906. MORPHTARGETS_UV: boolean;
  101907. NUM_MORPH_INFLUENCERS: number;
  101908. NONUNIFORMSCALING: boolean;
  101909. PREMULTIPLYALPHA: boolean;
  101910. IMAGEPROCESSING: boolean;
  101911. VIGNETTE: boolean;
  101912. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101913. VIGNETTEBLENDMODEOPAQUE: boolean;
  101914. TONEMAPPING: boolean;
  101915. TONEMAPPING_ACES: boolean;
  101916. CONTRAST: boolean;
  101917. COLORCURVES: boolean;
  101918. COLORGRADING: boolean;
  101919. COLORGRADING3D: boolean;
  101920. SAMPLER3DGREENDEPTH: boolean;
  101921. SAMPLER3DBGRMAP: boolean;
  101922. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101923. MULTIVIEW: boolean;
  101924. /**
  101925. * If the reflection texture on this material is in linear color space
  101926. * @hidden
  101927. */
  101928. IS_REFLECTION_LINEAR: boolean;
  101929. /**
  101930. * If the refraction texture on this material is in linear color space
  101931. * @hidden
  101932. */
  101933. IS_REFRACTION_LINEAR: boolean;
  101934. EXPOSURE: boolean;
  101935. constructor();
  101936. setReflectionMode(modeToEnable: string): void;
  101937. }
  101938. /**
  101939. * This is the default material used in Babylon. It is the best trade off between quality
  101940. * and performances.
  101941. * @see http://doc.babylonjs.com/babylon101/materials
  101942. */
  101943. export class StandardMaterial extends PushMaterial {
  101944. private _diffuseTexture;
  101945. /**
  101946. * The basic texture of the material as viewed under a light.
  101947. */
  101948. diffuseTexture: Nullable<BaseTexture>;
  101949. private _ambientTexture;
  101950. /**
  101951. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  101952. */
  101953. ambientTexture: Nullable<BaseTexture>;
  101954. private _opacityTexture;
  101955. /**
  101956. * Define the transparency of the material from a texture.
  101957. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  101958. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  101959. */
  101960. opacityTexture: Nullable<BaseTexture>;
  101961. private _reflectionTexture;
  101962. /**
  101963. * Define the texture used to display the reflection.
  101964. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101965. */
  101966. reflectionTexture: Nullable<BaseTexture>;
  101967. private _emissiveTexture;
  101968. /**
  101969. * Define texture of the material as if self lit.
  101970. * This will be mixed in the final result even in the absence of light.
  101971. */
  101972. emissiveTexture: Nullable<BaseTexture>;
  101973. private _specularTexture;
  101974. /**
  101975. * Define how the color and intensity of the highlight given by the light in the material.
  101976. */
  101977. specularTexture: Nullable<BaseTexture>;
  101978. private _bumpTexture;
  101979. /**
  101980. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101981. * 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.
  101982. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101983. */
  101984. bumpTexture: Nullable<BaseTexture>;
  101985. private _lightmapTexture;
  101986. /**
  101987. * Complex lighting can be computationally expensive to compute at runtime.
  101988. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101989. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101990. */
  101991. lightmapTexture: Nullable<BaseTexture>;
  101992. private _refractionTexture;
  101993. /**
  101994. * Define the texture used to display the refraction.
  101995. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101996. */
  101997. refractionTexture: Nullable<BaseTexture>;
  101998. /**
  101999. * The color of the material lit by the environmental background lighting.
  102000. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  102001. */
  102002. ambientColor: Color3;
  102003. /**
  102004. * The basic color of the material as viewed under a light.
  102005. */
  102006. diffuseColor: Color3;
  102007. /**
  102008. * Define how the color and intensity of the highlight given by the light in the material.
  102009. */
  102010. specularColor: Color3;
  102011. /**
  102012. * Define the color of the material as if self lit.
  102013. * This will be mixed in the final result even in the absence of light.
  102014. */
  102015. emissiveColor: Color3;
  102016. /**
  102017. * Defines how sharp are the highlights in the material.
  102018. * The bigger the value the sharper giving a more glossy feeling to the result.
  102019. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  102020. */
  102021. specularPower: number;
  102022. private _useAlphaFromDiffuseTexture;
  102023. /**
  102024. * Does the transparency come from the diffuse texture alpha channel.
  102025. */
  102026. useAlphaFromDiffuseTexture: boolean;
  102027. private _useEmissiveAsIllumination;
  102028. /**
  102029. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  102030. */
  102031. useEmissiveAsIllumination: boolean;
  102032. private _linkEmissiveWithDiffuse;
  102033. /**
  102034. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  102035. * the emissive level when the final color is close to one.
  102036. */
  102037. linkEmissiveWithDiffuse: boolean;
  102038. private _useSpecularOverAlpha;
  102039. /**
  102040. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102041. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102042. */
  102043. useSpecularOverAlpha: boolean;
  102044. private _useReflectionOverAlpha;
  102045. /**
  102046. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102047. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102048. */
  102049. useReflectionOverAlpha: boolean;
  102050. private _disableLighting;
  102051. /**
  102052. * Does lights from the scene impacts this material.
  102053. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  102054. */
  102055. disableLighting: boolean;
  102056. private _useObjectSpaceNormalMap;
  102057. /**
  102058. * Allows using an object space normal map (instead of tangent space).
  102059. */
  102060. useObjectSpaceNormalMap: boolean;
  102061. private _useParallax;
  102062. /**
  102063. * Is parallax enabled or not.
  102064. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102065. */
  102066. useParallax: boolean;
  102067. private _useParallaxOcclusion;
  102068. /**
  102069. * Is parallax occlusion enabled or not.
  102070. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  102071. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102072. */
  102073. useParallaxOcclusion: boolean;
  102074. /**
  102075. * 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.
  102076. */
  102077. parallaxScaleBias: number;
  102078. private _roughness;
  102079. /**
  102080. * Helps to define how blurry the reflections should appears in the material.
  102081. */
  102082. roughness: number;
  102083. /**
  102084. * In case of refraction, define the value of the index of refraction.
  102085. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102086. */
  102087. indexOfRefraction: number;
  102088. /**
  102089. * Invert the refraction texture alongside the y axis.
  102090. * It can be useful with procedural textures or probe for instance.
  102091. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102092. */
  102093. invertRefractionY: boolean;
  102094. /**
  102095. * Defines the alpha limits in alpha test mode.
  102096. */
  102097. alphaCutOff: number;
  102098. private _useLightmapAsShadowmap;
  102099. /**
  102100. * In case of light mapping, define whether the map contains light or shadow informations.
  102101. */
  102102. useLightmapAsShadowmap: boolean;
  102103. private _diffuseFresnelParameters;
  102104. /**
  102105. * Define the diffuse fresnel parameters of the material.
  102106. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102107. */
  102108. diffuseFresnelParameters: FresnelParameters;
  102109. private _opacityFresnelParameters;
  102110. /**
  102111. * Define the opacity fresnel parameters of the material.
  102112. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102113. */
  102114. opacityFresnelParameters: FresnelParameters;
  102115. private _reflectionFresnelParameters;
  102116. /**
  102117. * Define the reflection fresnel parameters of the material.
  102118. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102119. */
  102120. reflectionFresnelParameters: FresnelParameters;
  102121. private _refractionFresnelParameters;
  102122. /**
  102123. * Define the refraction fresnel parameters of the material.
  102124. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102125. */
  102126. refractionFresnelParameters: FresnelParameters;
  102127. private _emissiveFresnelParameters;
  102128. /**
  102129. * Define the emissive fresnel parameters of the material.
  102130. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102131. */
  102132. emissiveFresnelParameters: FresnelParameters;
  102133. private _useReflectionFresnelFromSpecular;
  102134. /**
  102135. * If true automatically deducts the fresnels values from the material specularity.
  102136. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102137. */
  102138. useReflectionFresnelFromSpecular: boolean;
  102139. private _useGlossinessFromSpecularMapAlpha;
  102140. /**
  102141. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  102142. */
  102143. useGlossinessFromSpecularMapAlpha: boolean;
  102144. private _maxSimultaneousLights;
  102145. /**
  102146. * Defines the maximum number of lights that can be used in the material
  102147. */
  102148. maxSimultaneousLights: number;
  102149. private _invertNormalMapX;
  102150. /**
  102151. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102152. */
  102153. invertNormalMapX: boolean;
  102154. private _invertNormalMapY;
  102155. /**
  102156. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102157. */
  102158. invertNormalMapY: boolean;
  102159. private _twoSidedLighting;
  102160. /**
  102161. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102162. */
  102163. twoSidedLighting: boolean;
  102164. /**
  102165. * Default configuration related to image processing available in the standard Material.
  102166. */
  102167. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102168. /**
  102169. * Gets the image processing configuration used either in this material.
  102170. */
  102171. /**
  102172. * Sets the Default image processing configuration used either in the this material.
  102173. *
  102174. * If sets to null, the scene one is in use.
  102175. */
  102176. imageProcessingConfiguration: ImageProcessingConfiguration;
  102177. /**
  102178. * Keep track of the image processing observer to allow dispose and replace.
  102179. */
  102180. private _imageProcessingObserver;
  102181. /**
  102182. * Attaches a new image processing configuration to the Standard Material.
  102183. * @param configuration
  102184. */
  102185. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102186. /**
  102187. * Gets wether the color curves effect is enabled.
  102188. */
  102189. /**
  102190. * Sets wether the color curves effect is enabled.
  102191. */
  102192. cameraColorCurvesEnabled: boolean;
  102193. /**
  102194. * Gets wether the color grading effect is enabled.
  102195. */
  102196. /**
  102197. * Gets wether the color grading effect is enabled.
  102198. */
  102199. cameraColorGradingEnabled: boolean;
  102200. /**
  102201. * Gets wether tonemapping is enabled or not.
  102202. */
  102203. /**
  102204. * Sets wether tonemapping is enabled or not
  102205. */
  102206. cameraToneMappingEnabled: boolean;
  102207. /**
  102208. * The camera exposure used on this material.
  102209. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102210. * This corresponds to a photographic exposure.
  102211. */
  102212. /**
  102213. * The camera exposure used on this material.
  102214. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102215. * This corresponds to a photographic exposure.
  102216. */
  102217. cameraExposure: number;
  102218. /**
  102219. * Gets The camera contrast used on this material.
  102220. */
  102221. /**
  102222. * Sets The camera contrast used on this material.
  102223. */
  102224. cameraContrast: number;
  102225. /**
  102226. * Gets the Color Grading 2D Lookup Texture.
  102227. */
  102228. /**
  102229. * Sets the Color Grading 2D Lookup Texture.
  102230. */
  102231. cameraColorGradingTexture: Nullable<BaseTexture>;
  102232. /**
  102233. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102234. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102235. * 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;
  102236. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102237. */
  102238. /**
  102239. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102240. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102241. * 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;
  102242. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102243. */
  102244. cameraColorCurves: Nullable<ColorCurves>;
  102245. /**
  102246. * Custom callback helping to override the default shader used in the material.
  102247. */
  102248. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  102249. protected _renderTargets: SmartArray<RenderTargetTexture>;
  102250. protected _worldViewProjectionMatrix: Matrix;
  102251. protected _globalAmbientColor: Color3;
  102252. protected _useLogarithmicDepth: boolean;
  102253. /**
  102254. * Instantiates a new standard material.
  102255. * This is the default material used in Babylon. It is the best trade off between quality
  102256. * and performances.
  102257. * @see http://doc.babylonjs.com/babylon101/materials
  102258. * @param name Define the name of the material in the scene
  102259. * @param scene Define the scene the material belong to
  102260. */
  102261. constructor(name: string, scene: Scene);
  102262. /**
  102263. * Gets a boolean indicating that current material needs to register RTT
  102264. */
  102265. readonly hasRenderTargetTextures: boolean;
  102266. /**
  102267. * Gets the current class name of the material e.g. "StandardMaterial"
  102268. * Mainly use in serialization.
  102269. * @returns the class name
  102270. */
  102271. getClassName(): string;
  102272. /**
  102273. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  102274. * You can try switching to logarithmic depth.
  102275. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  102276. */
  102277. useLogarithmicDepth: boolean;
  102278. /**
  102279. * Specifies if the material will require alpha blending
  102280. * @returns a boolean specifying if alpha blending is needed
  102281. */
  102282. needAlphaBlending(): boolean;
  102283. /**
  102284. * Specifies if this material should be rendered in alpha test mode
  102285. * @returns a boolean specifying if an alpha test is needed.
  102286. */
  102287. needAlphaTesting(): boolean;
  102288. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  102289. /**
  102290. * Get the texture used for alpha test purpose.
  102291. * @returns the diffuse texture in case of the standard material.
  102292. */
  102293. getAlphaTestTexture(): Nullable<BaseTexture>;
  102294. /**
  102295. * Get if the submesh is ready to be used and all its information available.
  102296. * Child classes can use it to update shaders
  102297. * @param mesh defines the mesh to check
  102298. * @param subMesh defines which submesh to check
  102299. * @param useInstances specifies that instances should be used
  102300. * @returns a boolean indicating that the submesh is ready or not
  102301. */
  102302. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102303. /**
  102304. * Builds the material UBO layouts.
  102305. * Used internally during the effect preparation.
  102306. */
  102307. buildUniformLayout(): void;
  102308. /**
  102309. * Unbinds the material from the mesh
  102310. */
  102311. unbind(): void;
  102312. /**
  102313. * Binds the submesh to this material by preparing the effect and shader to draw
  102314. * @param world defines the world transformation matrix
  102315. * @param mesh defines the mesh containing the submesh
  102316. * @param subMesh defines the submesh to bind the material to
  102317. */
  102318. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102319. /**
  102320. * Get the list of animatables in the material.
  102321. * @returns the list of animatables object used in the material
  102322. */
  102323. getAnimatables(): IAnimatable[];
  102324. /**
  102325. * Gets the active textures from the material
  102326. * @returns an array of textures
  102327. */
  102328. getActiveTextures(): BaseTexture[];
  102329. /**
  102330. * Specifies if the material uses a texture
  102331. * @param texture defines the texture to check against the material
  102332. * @returns a boolean specifying if the material uses the texture
  102333. */
  102334. hasTexture(texture: BaseTexture): boolean;
  102335. /**
  102336. * Disposes the material
  102337. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102338. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102339. */
  102340. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102341. /**
  102342. * Makes a duplicate of the material, and gives it a new name
  102343. * @param name defines the new name for the duplicated material
  102344. * @returns the cloned material
  102345. */
  102346. clone(name: string): StandardMaterial;
  102347. /**
  102348. * Serializes this material in a JSON representation
  102349. * @returns the serialized material object
  102350. */
  102351. serialize(): any;
  102352. /**
  102353. * Creates a standard material from parsed material data
  102354. * @param source defines the JSON representation of the material
  102355. * @param scene defines the hosting scene
  102356. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102357. * @returns a new standard material
  102358. */
  102359. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  102360. /**
  102361. * Are diffuse textures enabled in the application.
  102362. */
  102363. static DiffuseTextureEnabled: boolean;
  102364. /**
  102365. * Are ambient textures enabled in the application.
  102366. */
  102367. static AmbientTextureEnabled: boolean;
  102368. /**
  102369. * Are opacity textures enabled in the application.
  102370. */
  102371. static OpacityTextureEnabled: boolean;
  102372. /**
  102373. * Are reflection textures enabled in the application.
  102374. */
  102375. static ReflectionTextureEnabled: boolean;
  102376. /**
  102377. * Are emissive textures enabled in the application.
  102378. */
  102379. static EmissiveTextureEnabled: boolean;
  102380. /**
  102381. * Are specular textures enabled in the application.
  102382. */
  102383. static SpecularTextureEnabled: boolean;
  102384. /**
  102385. * Are bump textures enabled in the application.
  102386. */
  102387. static BumpTextureEnabled: boolean;
  102388. /**
  102389. * Are lightmap textures enabled in the application.
  102390. */
  102391. static LightmapTextureEnabled: boolean;
  102392. /**
  102393. * Are refraction textures enabled in the application.
  102394. */
  102395. static RefractionTextureEnabled: boolean;
  102396. /**
  102397. * Are color grading textures enabled in the application.
  102398. */
  102399. static ColorGradingTextureEnabled: boolean;
  102400. /**
  102401. * Are fresnels enabled in the application.
  102402. */
  102403. static FresnelEnabled: boolean;
  102404. }
  102405. }
  102406. declare module BABYLON {
  102407. /**
  102408. * A class extending Texture allowing drawing on a texture
  102409. * @see http://doc.babylonjs.com/how_to/dynamictexture
  102410. */
  102411. export class DynamicTexture extends Texture {
  102412. private _generateMipMaps;
  102413. private _canvas;
  102414. private _context;
  102415. private _engine;
  102416. /**
  102417. * Creates a DynamicTexture
  102418. * @param name defines the name of the texture
  102419. * @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
  102420. * @param scene defines the scene where you want the texture
  102421. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  102422. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  102423. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  102424. */
  102425. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  102426. /**
  102427. * Get the current class name of the texture useful for serialization or dynamic coding.
  102428. * @returns "DynamicTexture"
  102429. */
  102430. getClassName(): string;
  102431. /**
  102432. * Gets the current state of canRescale
  102433. */
  102434. readonly canRescale: boolean;
  102435. private _recreate;
  102436. /**
  102437. * Scales the texture
  102438. * @param ratio the scale factor to apply to both width and height
  102439. */
  102440. scale(ratio: number): void;
  102441. /**
  102442. * Resizes the texture
  102443. * @param width the new width
  102444. * @param height the new height
  102445. */
  102446. scaleTo(width: number, height: number): void;
  102447. /**
  102448. * Gets the context of the canvas used by the texture
  102449. * @returns the canvas context of the dynamic texture
  102450. */
  102451. getContext(): CanvasRenderingContext2D;
  102452. /**
  102453. * Clears the texture
  102454. */
  102455. clear(): void;
  102456. /**
  102457. * Updates the texture
  102458. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102459. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  102460. */
  102461. update(invertY?: boolean, premulAlpha?: boolean): void;
  102462. /**
  102463. * Draws text onto the texture
  102464. * @param text defines the text to be drawn
  102465. * @param x defines the placement of the text from the left
  102466. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  102467. * @param font defines the font to be used with font-style, font-size, font-name
  102468. * @param color defines the color used for the text
  102469. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  102470. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102471. * @param update defines whether texture is immediately update (default is true)
  102472. */
  102473. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  102474. /**
  102475. * Clones the texture
  102476. * @returns the clone of the texture.
  102477. */
  102478. clone(): DynamicTexture;
  102479. /**
  102480. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  102481. * @returns a serialized dynamic texture object
  102482. */
  102483. serialize(): any;
  102484. /** @hidden */
  102485. _rebuild(): void;
  102486. }
  102487. }
  102488. declare module BABYLON {
  102489. /** @hidden */
  102490. export var imageProcessingPixelShader: {
  102491. name: string;
  102492. shader: string;
  102493. };
  102494. }
  102495. declare module BABYLON {
  102496. /**
  102497. * ImageProcessingPostProcess
  102498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102499. */
  102500. export class ImageProcessingPostProcess extends PostProcess {
  102501. /**
  102502. * Default configuration related to image processing available in the PBR Material.
  102503. */
  102504. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102505. /**
  102506. * Gets the image processing configuration used either in this material.
  102507. */
  102508. /**
  102509. * Sets the Default image processing configuration used either in the this material.
  102510. *
  102511. * If sets to null, the scene one is in use.
  102512. */
  102513. imageProcessingConfiguration: ImageProcessingConfiguration;
  102514. /**
  102515. * Keep track of the image processing observer to allow dispose and replace.
  102516. */
  102517. private _imageProcessingObserver;
  102518. /**
  102519. * Attaches a new image processing configuration to the PBR Material.
  102520. * @param configuration
  102521. */
  102522. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102523. /**
  102524. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102525. */
  102526. /**
  102527. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102528. */
  102529. colorCurves: Nullable<ColorCurves>;
  102530. /**
  102531. * Gets wether the color curves effect is enabled.
  102532. */
  102533. /**
  102534. * Sets wether the color curves effect is enabled.
  102535. */
  102536. colorCurvesEnabled: boolean;
  102537. /**
  102538. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102539. */
  102540. /**
  102541. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102542. */
  102543. colorGradingTexture: Nullable<BaseTexture>;
  102544. /**
  102545. * Gets wether the color grading effect is enabled.
  102546. */
  102547. /**
  102548. * Gets wether the color grading effect is enabled.
  102549. */
  102550. colorGradingEnabled: boolean;
  102551. /**
  102552. * Gets exposure used in the effect.
  102553. */
  102554. /**
  102555. * Sets exposure used in the effect.
  102556. */
  102557. exposure: number;
  102558. /**
  102559. * Gets wether tonemapping is enabled or not.
  102560. */
  102561. /**
  102562. * Sets wether tonemapping is enabled or not
  102563. */
  102564. toneMappingEnabled: boolean;
  102565. /**
  102566. * Gets the type of tone mapping effect.
  102567. */
  102568. /**
  102569. * Sets the type of tone mapping effect.
  102570. */
  102571. toneMappingType: number;
  102572. /**
  102573. * Gets contrast used in the effect.
  102574. */
  102575. /**
  102576. * Sets contrast used in the effect.
  102577. */
  102578. contrast: number;
  102579. /**
  102580. * Gets Vignette stretch size.
  102581. */
  102582. /**
  102583. * Sets Vignette stretch size.
  102584. */
  102585. vignetteStretch: number;
  102586. /**
  102587. * Gets Vignette centre X Offset.
  102588. */
  102589. /**
  102590. * Sets Vignette centre X Offset.
  102591. */
  102592. vignetteCentreX: number;
  102593. /**
  102594. * Gets Vignette centre Y Offset.
  102595. */
  102596. /**
  102597. * Sets Vignette centre Y Offset.
  102598. */
  102599. vignetteCentreY: number;
  102600. /**
  102601. * Gets Vignette weight or intensity of the vignette effect.
  102602. */
  102603. /**
  102604. * Sets Vignette weight or intensity of the vignette effect.
  102605. */
  102606. vignetteWeight: number;
  102607. /**
  102608. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102609. * if vignetteEnabled is set to true.
  102610. */
  102611. /**
  102612. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102613. * if vignetteEnabled is set to true.
  102614. */
  102615. vignetteColor: Color4;
  102616. /**
  102617. * Gets Camera field of view used by the Vignette effect.
  102618. */
  102619. /**
  102620. * Sets Camera field of view used by the Vignette effect.
  102621. */
  102622. vignetteCameraFov: number;
  102623. /**
  102624. * Gets the vignette blend mode allowing different kind of effect.
  102625. */
  102626. /**
  102627. * Sets the vignette blend mode allowing different kind of effect.
  102628. */
  102629. vignetteBlendMode: number;
  102630. /**
  102631. * Gets wether the vignette effect is enabled.
  102632. */
  102633. /**
  102634. * Sets wether the vignette effect is enabled.
  102635. */
  102636. vignetteEnabled: boolean;
  102637. private _fromLinearSpace;
  102638. /**
  102639. * Gets wether the input of the processing is in Gamma or Linear Space.
  102640. */
  102641. /**
  102642. * Sets wether the input of the processing is in Gamma or Linear Space.
  102643. */
  102644. fromLinearSpace: boolean;
  102645. /**
  102646. * Defines cache preventing GC.
  102647. */
  102648. private _defines;
  102649. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102650. /**
  102651. * "ImageProcessingPostProcess"
  102652. * @returns "ImageProcessingPostProcess"
  102653. */
  102654. getClassName(): string;
  102655. protected _updateParameters(): void;
  102656. dispose(camera?: Camera): void;
  102657. }
  102658. }
  102659. declare module BABYLON {
  102660. /**
  102661. * Class containing static functions to help procedurally build meshes
  102662. */
  102663. export class GroundBuilder {
  102664. /**
  102665. * Creates a ground mesh
  102666. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102667. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102669. * @param name defines the name of the mesh
  102670. * @param options defines the options used to create the mesh
  102671. * @param scene defines the hosting scene
  102672. * @returns the ground mesh
  102673. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102674. */
  102675. static CreateGround(name: string, options: {
  102676. width?: number;
  102677. height?: number;
  102678. subdivisions?: number;
  102679. subdivisionsX?: number;
  102680. subdivisionsY?: number;
  102681. updatable?: boolean;
  102682. }, scene: any): Mesh;
  102683. /**
  102684. * Creates a tiled ground mesh
  102685. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102686. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102687. * * 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
  102688. * * 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
  102689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102690. * @param name defines the name of the mesh
  102691. * @param options defines the options used to create the mesh
  102692. * @param scene defines the hosting scene
  102693. * @returns the tiled ground mesh
  102694. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102695. */
  102696. static CreateTiledGround(name: string, options: {
  102697. xmin: number;
  102698. zmin: number;
  102699. xmax: number;
  102700. zmax: number;
  102701. subdivisions?: {
  102702. w: number;
  102703. h: number;
  102704. };
  102705. precision?: {
  102706. w: number;
  102707. h: number;
  102708. };
  102709. updatable?: boolean;
  102710. }, scene?: Nullable<Scene>): Mesh;
  102711. /**
  102712. * Creates a ground mesh from a height map
  102713. * * The parameter `url` sets the URL of the height map image resource.
  102714. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  102715. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  102716. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  102717. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  102718. * * 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.
  102719. * * 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).
  102720. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  102721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102722. * @param name defines the name of the mesh
  102723. * @param url defines the url to the height map
  102724. * @param options defines the options used to create the mesh
  102725. * @param scene defines the hosting scene
  102726. * @returns the ground mesh
  102727. * @see https://doc.babylonjs.com/babylon101/height_map
  102728. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  102729. */
  102730. static CreateGroundFromHeightMap(name: string, url: string, options: {
  102731. width?: number;
  102732. height?: number;
  102733. subdivisions?: number;
  102734. minHeight?: number;
  102735. maxHeight?: number;
  102736. colorFilter?: Color3;
  102737. alphaFilter?: number;
  102738. updatable?: boolean;
  102739. onReady?: (mesh: GroundMesh) => void;
  102740. }, scene?: Nullable<Scene>): GroundMesh;
  102741. }
  102742. }
  102743. declare module BABYLON {
  102744. /**
  102745. * Class containing static functions to help procedurally build meshes
  102746. */
  102747. export class TorusBuilder {
  102748. /**
  102749. * Creates a torus mesh
  102750. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  102751. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  102752. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  102753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102756. * @param name defines the name of the mesh
  102757. * @param options defines the options used to create the mesh
  102758. * @param scene defines the hosting scene
  102759. * @returns the torus mesh
  102760. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  102761. */
  102762. static CreateTorus(name: string, options: {
  102763. diameter?: number;
  102764. thickness?: number;
  102765. tessellation?: number;
  102766. updatable?: boolean;
  102767. sideOrientation?: number;
  102768. frontUVs?: Vector4;
  102769. backUVs?: Vector4;
  102770. }, scene: any): Mesh;
  102771. }
  102772. }
  102773. declare module BABYLON {
  102774. /**
  102775. * Class containing static functions to help procedurally build meshes
  102776. */
  102777. export class CylinderBuilder {
  102778. /**
  102779. * Creates a cylinder or a cone mesh
  102780. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  102781. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  102782. * * 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.
  102783. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  102784. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  102785. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  102786. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  102787. * * 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).
  102788. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  102789. * * 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).
  102790. * * 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
  102791. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  102792. * * 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
  102793. * * 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.
  102794. * * If `enclose` is false, a ring surface is one element.
  102795. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  102796. * * 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
  102797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102798. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102800. * @param name defines the name of the mesh
  102801. * @param options defines the options used to create the mesh
  102802. * @param scene defines the hosting scene
  102803. * @returns the cylinder mesh
  102804. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  102805. */
  102806. static CreateCylinder(name: string, options: {
  102807. height?: number;
  102808. diameterTop?: number;
  102809. diameterBottom?: number;
  102810. diameter?: number;
  102811. tessellation?: number;
  102812. subdivisions?: number;
  102813. arc?: number;
  102814. faceColors?: Color4[];
  102815. faceUV?: Vector4[];
  102816. updatable?: boolean;
  102817. hasRings?: boolean;
  102818. enclose?: boolean;
  102819. cap?: number;
  102820. sideOrientation?: number;
  102821. frontUVs?: Vector4;
  102822. backUVs?: Vector4;
  102823. }, scene: any): Mesh;
  102824. }
  102825. }
  102826. declare module BABYLON {
  102827. /**
  102828. * Options to modify the vr teleportation behavior.
  102829. */
  102830. export interface VRTeleportationOptions {
  102831. /**
  102832. * The name of the mesh which should be used as the teleportation floor. (default: null)
  102833. */
  102834. floorMeshName?: string;
  102835. /**
  102836. * A list of meshes to be used as the teleportation floor. (default: empty)
  102837. */
  102838. floorMeshes?: Mesh[];
  102839. }
  102840. /**
  102841. * Options to modify the vr experience helper's behavior.
  102842. */
  102843. export interface VRExperienceHelperOptions extends WebVROptions {
  102844. /**
  102845. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  102846. */
  102847. createDeviceOrientationCamera?: boolean;
  102848. /**
  102849. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  102850. */
  102851. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  102852. /**
  102853. * Uses the main button on the controller to toggle the laser casted. (default: true)
  102854. */
  102855. laserToggle?: boolean;
  102856. /**
  102857. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  102858. */
  102859. floorMeshes?: Mesh[];
  102860. /**
  102861. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  102862. */
  102863. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  102864. }
  102865. /**
  102866. * Event containing information after VR has been entered
  102867. */
  102868. export class OnAfterEnteringVRObservableEvent {
  102869. /**
  102870. * If entering vr was successful
  102871. */
  102872. success: boolean;
  102873. }
  102874. /**
  102875. * Helps to quickly add VR support to an existing scene.
  102876. * See http://doc.babylonjs.com/how_to/webvr_helper
  102877. */
  102878. export class VRExperienceHelper {
  102879. /** Options to modify the vr experience helper's behavior. */
  102880. webVROptions: VRExperienceHelperOptions;
  102881. private _scene;
  102882. private _position;
  102883. private _btnVR;
  102884. private _btnVRDisplayed;
  102885. private _webVRsupported;
  102886. private _webVRready;
  102887. private _webVRrequesting;
  102888. private _webVRpresenting;
  102889. private _hasEnteredVR;
  102890. private _fullscreenVRpresenting;
  102891. private _canvas;
  102892. private _webVRCamera;
  102893. private _vrDeviceOrientationCamera;
  102894. private _deviceOrientationCamera;
  102895. private _existingCamera;
  102896. private _onKeyDown;
  102897. private _onVrDisplayPresentChange;
  102898. private _onVRDisplayChanged;
  102899. private _onVRRequestPresentStart;
  102900. private _onVRRequestPresentComplete;
  102901. /**
  102902. * Observable raised right before entering VR.
  102903. */
  102904. onEnteringVRObservable: Observable<VRExperienceHelper>;
  102905. /**
  102906. * Observable raised when entering VR has completed.
  102907. */
  102908. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  102909. /**
  102910. * Observable raised when exiting VR.
  102911. */
  102912. onExitingVRObservable: Observable<VRExperienceHelper>;
  102913. /**
  102914. * Observable raised when controller mesh is loaded.
  102915. */
  102916. onControllerMeshLoadedObservable: Observable<WebVRController>;
  102917. /** Return this.onEnteringVRObservable
  102918. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  102919. */
  102920. readonly onEnteringVR: Observable<VRExperienceHelper>;
  102921. /** Return this.onExitingVRObservable
  102922. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  102923. */
  102924. readonly onExitingVR: Observable<VRExperienceHelper>;
  102925. /** Return this.onControllerMeshLoadedObservable
  102926. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  102927. */
  102928. readonly onControllerMeshLoaded: Observable<WebVRController>;
  102929. private _rayLength;
  102930. private _useCustomVRButton;
  102931. private _teleportationRequested;
  102932. private _teleportActive;
  102933. private _floorMeshName;
  102934. private _floorMeshesCollection;
  102935. private _rotationAllowed;
  102936. private _teleportBackwardsVector;
  102937. private _teleportationTarget;
  102938. private _isDefaultTeleportationTarget;
  102939. private _postProcessMove;
  102940. private _teleportationFillColor;
  102941. private _teleportationBorderColor;
  102942. private _rotationAngle;
  102943. private _haloCenter;
  102944. private _cameraGazer;
  102945. private _padSensibilityUp;
  102946. private _padSensibilityDown;
  102947. private _leftController;
  102948. private _rightController;
  102949. /**
  102950. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  102951. */
  102952. onNewMeshSelected: Observable<AbstractMesh>;
  102953. /**
  102954. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  102955. */
  102956. onNewMeshPicked: Observable<PickingInfo>;
  102957. private _circleEase;
  102958. /**
  102959. * Observable raised before camera teleportation
  102960. */
  102961. onBeforeCameraTeleport: Observable<Vector3>;
  102962. /**
  102963. * Observable raised after camera teleportation
  102964. */
  102965. onAfterCameraTeleport: Observable<Vector3>;
  102966. /**
  102967. * Observable raised when current selected mesh gets unselected
  102968. */
  102969. onSelectedMeshUnselected: Observable<AbstractMesh>;
  102970. private _raySelectionPredicate;
  102971. /**
  102972. * To be optionaly changed by user to define custom ray selection
  102973. */
  102974. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  102975. /**
  102976. * To be optionaly changed by user to define custom selection logic (after ray selection)
  102977. */
  102978. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  102979. /**
  102980. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  102981. */
  102982. teleportationEnabled: boolean;
  102983. private _defaultHeight;
  102984. private _teleportationInitialized;
  102985. private _interactionsEnabled;
  102986. private _interactionsRequested;
  102987. private _displayGaze;
  102988. private _displayLaserPointer;
  102989. /**
  102990. * The mesh used to display where the user is going to teleport.
  102991. */
  102992. /**
  102993. * Sets the mesh to be used to display where the user is going to teleport.
  102994. */
  102995. teleportationTarget: Mesh;
  102996. /**
  102997. * 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
  102998. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  102999. * See http://doc.babylonjs.com/resources/baking_transformations
  103000. */
  103001. gazeTrackerMesh: Mesh;
  103002. /**
  103003. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  103004. */
  103005. updateGazeTrackerScale: boolean;
  103006. /**
  103007. * If the gaze trackers color should be updated when selecting meshes
  103008. */
  103009. updateGazeTrackerColor: boolean;
  103010. /**
  103011. * The gaze tracking mesh corresponding to the left controller
  103012. */
  103013. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  103014. /**
  103015. * The gaze tracking mesh corresponding to the right controller
  103016. */
  103017. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  103018. /**
  103019. * If the ray of the gaze should be displayed.
  103020. */
  103021. /**
  103022. * Sets if the ray of the gaze should be displayed.
  103023. */
  103024. displayGaze: boolean;
  103025. /**
  103026. * If the ray of the LaserPointer should be displayed.
  103027. */
  103028. /**
  103029. * Sets if the ray of the LaserPointer should be displayed.
  103030. */
  103031. displayLaserPointer: boolean;
  103032. /**
  103033. * The deviceOrientationCamera used as the camera when not in VR.
  103034. */
  103035. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  103036. /**
  103037. * Based on the current WebVR support, returns the current VR camera used.
  103038. */
  103039. readonly currentVRCamera: Nullable<Camera>;
  103040. /**
  103041. * The webVRCamera which is used when in VR.
  103042. */
  103043. readonly webVRCamera: WebVRFreeCamera;
  103044. /**
  103045. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  103046. */
  103047. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  103048. private readonly _teleportationRequestInitiated;
  103049. /**
  103050. * Defines wether or not Pointer lock should be requested when switching to
  103051. * full screen.
  103052. */
  103053. requestPointerLockOnFullScreen: boolean;
  103054. /**
  103055. * Instantiates a VRExperienceHelper.
  103056. * Helps to quickly add VR support to an existing scene.
  103057. * @param scene The scene the VRExperienceHelper belongs to.
  103058. * @param webVROptions Options to modify the vr experience helper's behavior.
  103059. */
  103060. constructor(scene: Scene,
  103061. /** Options to modify the vr experience helper's behavior. */
  103062. webVROptions?: VRExperienceHelperOptions);
  103063. private _onDefaultMeshLoaded;
  103064. private _onResize;
  103065. private _onFullscreenChange;
  103066. /**
  103067. * Gets a value indicating if we are currently in VR mode.
  103068. */
  103069. readonly isInVRMode: boolean;
  103070. private onVrDisplayPresentChange;
  103071. private onVRDisplayChanged;
  103072. private moveButtonToBottomRight;
  103073. private displayVRButton;
  103074. private updateButtonVisibility;
  103075. private _cachedAngularSensibility;
  103076. /**
  103077. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  103078. * Otherwise, will use the fullscreen API.
  103079. */
  103080. enterVR(): void;
  103081. /**
  103082. * Attempt to exit VR, or fullscreen.
  103083. */
  103084. exitVR(): void;
  103085. /**
  103086. * The position of the vr experience helper.
  103087. */
  103088. /**
  103089. * Sets the position of the vr experience helper.
  103090. */
  103091. position: Vector3;
  103092. /**
  103093. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  103094. */
  103095. enableInteractions(): void;
  103096. private readonly _noControllerIsActive;
  103097. private beforeRender;
  103098. private _isTeleportationFloor;
  103099. /**
  103100. * Adds a floor mesh to be used for teleportation.
  103101. * @param floorMesh the mesh to be used for teleportation.
  103102. */
  103103. addFloorMesh(floorMesh: Mesh): void;
  103104. /**
  103105. * Removes a floor mesh from being used for teleportation.
  103106. * @param floorMesh the mesh to be removed.
  103107. */
  103108. removeFloorMesh(floorMesh: Mesh): void;
  103109. /**
  103110. * Enables interactions and teleportation using the VR controllers and gaze.
  103111. * @param vrTeleportationOptions options to modify teleportation behavior.
  103112. */
  103113. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  103114. private _onNewGamepadConnected;
  103115. private _tryEnableInteractionOnController;
  103116. private _onNewGamepadDisconnected;
  103117. private _enableInteractionOnController;
  103118. private _checkTeleportWithRay;
  103119. private _checkRotate;
  103120. private _checkTeleportBackwards;
  103121. private _enableTeleportationOnController;
  103122. private _createTeleportationCircles;
  103123. private _displayTeleportationTarget;
  103124. private _hideTeleportationTarget;
  103125. private _rotateCamera;
  103126. private _moveTeleportationSelectorTo;
  103127. private _workingVector;
  103128. private _workingQuaternion;
  103129. private _workingMatrix;
  103130. /**
  103131. * Teleports the users feet to the desired location
  103132. * @param location The location where the user's feet should be placed
  103133. */
  103134. teleportCamera(location: Vector3): void;
  103135. private _convertNormalToDirectionOfRay;
  103136. private _castRayAndSelectObject;
  103137. private _notifySelectedMeshUnselected;
  103138. /**
  103139. * Sets the color of the laser ray from the vr controllers.
  103140. * @param color new color for the ray.
  103141. */
  103142. changeLaserColor(color: Color3): void;
  103143. /**
  103144. * Sets the color of the ray from the vr headsets gaze.
  103145. * @param color new color for the ray.
  103146. */
  103147. changeGazeColor(color: Color3): void;
  103148. /**
  103149. * Exits VR and disposes of the vr experience helper
  103150. */
  103151. dispose(): void;
  103152. /**
  103153. * Gets the name of the VRExperienceHelper class
  103154. * @returns "VRExperienceHelper"
  103155. */
  103156. getClassName(): string;
  103157. }
  103158. }
  103159. declare module BABYLON {
  103160. /**
  103161. * Manages an XRSession to work with Babylon's engine
  103162. * @see https://doc.babylonjs.com/how_to/webxr
  103163. */
  103164. export class WebXRSessionManager implements IDisposable {
  103165. private scene;
  103166. /**
  103167. * Fires every time a new xrFrame arrives which can be used to update the camera
  103168. */
  103169. onXRFrameObservable: Observable<any>;
  103170. /**
  103171. * Fires when the xr session is ended either by the device or manually done
  103172. */
  103173. onXRSessionEnded: Observable<any>;
  103174. /**
  103175. * Underlying xr session
  103176. */
  103177. session: XRSession;
  103178. /**
  103179. * Type of reference space used when creating the session
  103180. */
  103181. referenceSpace: XRReferenceSpace;
  103182. /** @hidden */
  103183. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  103184. /**
  103185. * Current XR frame
  103186. */
  103187. currentFrame: Nullable<XRFrame>;
  103188. private _xrNavigator;
  103189. private baseLayer;
  103190. /**
  103191. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  103192. * @param scene The scene which the session should be created for
  103193. */
  103194. constructor(scene: Scene);
  103195. /**
  103196. * Initializes the manager
  103197. * After initialization enterXR can be called to start an XR session
  103198. * @returns Promise which resolves after it is initialized
  103199. */
  103200. initializeAsync(): Promise<void>;
  103201. /**
  103202. * Initializes an xr session
  103203. * @param xrSessionMode mode to initialize
  103204. * @returns a promise which will resolve once the session has been initialized
  103205. */
  103206. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  103207. /**
  103208. * Sets the reference space on the xr session
  103209. * @param referenceSpace space to set
  103210. * @returns a promise that will resolve once the reference space has been set
  103211. */
  103212. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  103213. /**
  103214. * Updates the render state of the session
  103215. * @param state state to set
  103216. * @returns a promise that resolves once the render state has been updated
  103217. */
  103218. updateRenderStateAsync(state: any): Promise<void>;
  103219. /**
  103220. * Starts rendering to the xr layer
  103221. * @returns a promise that will resolve once rendering has started
  103222. */
  103223. startRenderingToXRAsync(): Promise<void>;
  103224. /**
  103225. * Stops the xrSession and restores the renderloop
  103226. * @returns Promise which resolves after it exits XR
  103227. */
  103228. exitXRAsync(): Promise<void>;
  103229. /**
  103230. * Checks if a session would be supported for the creation options specified
  103231. * @param sessionMode session mode to check if supported eg. immersive-vr
  103232. * @returns true if supported
  103233. */
  103234. supportsSessionAsync(sessionMode: XRSessionMode): any;
  103235. /**
  103236. * @hidden
  103237. * Converts the render layer of xrSession to a render target
  103238. * @param session session to create render target for
  103239. * @param scene scene the new render target should be created for
  103240. */
  103241. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  103242. /**
  103243. * Disposes of the session manager
  103244. */
  103245. dispose(): void;
  103246. }
  103247. }
  103248. declare module BABYLON {
  103249. /**
  103250. * WebXR Camera which holds the views for the xrSession
  103251. * @see https://doc.babylonjs.com/how_to/webxr
  103252. */
  103253. export class WebXRCamera extends FreeCamera {
  103254. private static _TmpMatrix;
  103255. /**
  103256. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  103257. * @param name the name of the camera
  103258. * @param scene the scene to add the camera to
  103259. */
  103260. constructor(name: string, scene: Scene);
  103261. private _updateNumberOfRigCameras;
  103262. /** @hidden */
  103263. _updateForDualEyeDebugging(pupilDistance?: number): void;
  103264. /**
  103265. * Updates the cameras position from the current pose information of the XR session
  103266. * @param xrSessionManager the session containing pose information
  103267. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  103268. */
  103269. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  103270. }
  103271. }
  103272. declare module BABYLON {
  103273. /**
  103274. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  103275. */
  103276. export class WebXRManagedOutputCanvas implements IDisposable {
  103277. private helper;
  103278. private _canvas;
  103279. /**
  103280. * xrpresent context of the canvas which can be used to display/mirror xr content
  103281. */
  103282. canvasContext: WebGLRenderingContext;
  103283. /**
  103284. * xr layer for the canvas
  103285. */
  103286. xrLayer: Nullable<XRWebGLLayer>;
  103287. /**
  103288. * Initializes the xr layer for the session
  103289. * @param xrSession xr session
  103290. * @returns a promise that will resolve once the XR Layer has been created
  103291. */
  103292. initializeXRLayerAsync(xrSession: any): any;
  103293. /**
  103294. * Initializes the canvas to be added/removed upon entering/exiting xr
  103295. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  103296. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  103297. */
  103298. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  103299. /**
  103300. * Disposes of the object
  103301. */
  103302. dispose(): void;
  103303. private _setManagedOutputCanvas;
  103304. private _addCanvas;
  103305. private _removeCanvas;
  103306. }
  103307. }
  103308. declare module BABYLON {
  103309. /**
  103310. * States of the webXR experience
  103311. */
  103312. export enum WebXRState {
  103313. /**
  103314. * Transitioning to being in XR mode
  103315. */
  103316. ENTERING_XR = 0,
  103317. /**
  103318. * Transitioning to non XR mode
  103319. */
  103320. EXITING_XR = 1,
  103321. /**
  103322. * In XR mode and presenting
  103323. */
  103324. IN_XR = 2,
  103325. /**
  103326. * Not entered XR mode
  103327. */
  103328. NOT_IN_XR = 3
  103329. }
  103330. /**
  103331. * Helper class used to enable XR
  103332. * @see https://doc.babylonjs.com/how_to/webxr
  103333. */
  103334. export class WebXRExperienceHelper implements IDisposable {
  103335. private scene;
  103336. /**
  103337. * 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
  103338. */
  103339. container: AbstractMesh;
  103340. /**
  103341. * Camera used to render xr content
  103342. */
  103343. camera: WebXRCamera;
  103344. /**
  103345. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  103346. */
  103347. state: WebXRState;
  103348. private _setState;
  103349. private static _TmpVector;
  103350. /**
  103351. * Fires when the state of the experience helper has changed
  103352. */
  103353. onStateChangedObservable: Observable<WebXRState>;
  103354. /** Session manager used to keep track of xr session */
  103355. sessionManager: WebXRSessionManager;
  103356. private _nonVRCamera;
  103357. private _originalSceneAutoClear;
  103358. private _supported;
  103359. /**
  103360. * Creates the experience helper
  103361. * @param scene the scene to attach the experience helper to
  103362. * @returns a promise for the experience helper
  103363. */
  103364. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  103365. /**
  103366. * Creates a WebXRExperienceHelper
  103367. * @param scene The scene the helper should be created in
  103368. */
  103369. private constructor();
  103370. /**
  103371. * Exits XR mode and returns the scene to its original state
  103372. * @returns promise that resolves after xr mode has exited
  103373. */
  103374. exitXRAsync(): Promise<void>;
  103375. /**
  103376. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  103377. * @param sessionCreationOptions options for the XR session
  103378. * @param referenceSpaceType frame of reference of the XR session
  103379. * @param outputCanvas the output canvas that will be used to enter XR mode
  103380. * @returns promise that resolves after xr mode has entered
  103381. */
  103382. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  103383. /**
  103384. * Updates the global position of the camera by moving the camera's container
  103385. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  103386. * @param position The desired global position of the camera
  103387. */
  103388. setPositionOfCameraUsingContainer(position: Vector3): void;
  103389. /**
  103390. * Rotates the xr camera by rotating the camera's container around the camera's position
  103391. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  103392. * @param rotation the desired quaternion rotation to apply to the camera
  103393. */
  103394. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  103395. /**
  103396. * Disposes of the experience helper
  103397. */
  103398. dispose(): void;
  103399. }
  103400. }
  103401. declare module BABYLON {
  103402. /**
  103403. * Button which can be used to enter a different mode of XR
  103404. */
  103405. export class WebXREnterExitUIButton {
  103406. /** button element */
  103407. element: HTMLElement;
  103408. /** XR initialization options for the button */
  103409. sessionMode: XRSessionMode;
  103410. /** Reference space type */
  103411. referenceSpaceType: XRReferenceSpaceType;
  103412. /**
  103413. * Creates a WebXREnterExitUIButton
  103414. * @param element button element
  103415. * @param sessionMode XR initialization session mode
  103416. * @param referenceSpaceType the type of reference space to be used
  103417. */
  103418. constructor(
  103419. /** button element */
  103420. element: HTMLElement,
  103421. /** XR initialization options for the button */
  103422. sessionMode: XRSessionMode,
  103423. /** Reference space type */
  103424. referenceSpaceType: XRReferenceSpaceType);
  103425. /**
  103426. * Overwritable function which can be used to update the button's visuals when the state changes
  103427. * @param activeButton the current active button in the UI
  103428. */
  103429. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  103430. }
  103431. /**
  103432. * Options to create the webXR UI
  103433. */
  103434. export class WebXREnterExitUIOptions {
  103435. /**
  103436. * Context to enter xr with
  103437. */
  103438. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  103439. /**
  103440. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  103441. */
  103442. customButtons?: Array<WebXREnterExitUIButton>;
  103443. }
  103444. /**
  103445. * UI to allow the user to enter/exit XR mode
  103446. */
  103447. export class WebXREnterExitUI implements IDisposable {
  103448. private scene;
  103449. private _overlay;
  103450. private _buttons;
  103451. private _activeButton;
  103452. /**
  103453. * Fired every time the active button is changed.
  103454. *
  103455. * When xr is entered via a button that launches xr that button will be the callback parameter
  103456. *
  103457. * When exiting xr the callback parameter will be null)
  103458. */
  103459. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  103460. /**
  103461. * Creates UI to allow the user to enter/exit XR mode
  103462. * @param scene the scene to add the ui to
  103463. * @param helper the xr experience helper to enter/exit xr with
  103464. * @param options options to configure the UI
  103465. * @returns the created ui
  103466. */
  103467. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  103468. private constructor();
  103469. private _updateButtons;
  103470. /**
  103471. * Disposes of the object
  103472. */
  103473. dispose(): void;
  103474. }
  103475. }
  103476. declare module BABYLON {
  103477. /**
  103478. * Represents an XR input
  103479. */
  103480. export class WebXRController {
  103481. private scene;
  103482. /** The underlying input source for the controller */
  103483. inputSource: XRInputSource;
  103484. private parentContainer;
  103485. /**
  103486. * 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
  103487. */
  103488. grip?: AbstractMesh;
  103489. /**
  103490. * Pointer which can be used to select objects or attach a visible laser to
  103491. */
  103492. pointer: AbstractMesh;
  103493. private _tmpMatrix;
  103494. /**
  103495. * Creates the controller
  103496. * @see https://doc.babylonjs.com/how_to/webxr
  103497. * @param scene the scene which the controller should be associated to
  103498. * @param inputSource the underlying input source for the controller
  103499. * @param parentContainer parent that the controller meshes should be children of
  103500. */
  103501. constructor(scene: Scene,
  103502. /** The underlying input source for the controller */
  103503. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  103504. /**
  103505. * Updates the controller pose based on the given XRFrame
  103506. * @param xrFrame xr frame to update the pose with
  103507. * @param referenceSpace reference space to use
  103508. */
  103509. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  103510. /**
  103511. * Disposes of the object
  103512. */
  103513. dispose(): void;
  103514. }
  103515. /**
  103516. * XR input used to track XR inputs such as controllers/rays
  103517. */
  103518. export class WebXRInput implements IDisposable {
  103519. private helper;
  103520. /**
  103521. * XR controllers being tracked
  103522. */
  103523. controllers: Array<WebXRController>;
  103524. private _frameObserver;
  103525. /**
  103526. * Event when a controller has been connected/added
  103527. */
  103528. onControllerAddedObservable: Observable<WebXRController>;
  103529. /**
  103530. * Event when a controller has been removed/disconnected
  103531. */
  103532. onControllerRemovedObservable: Observable<WebXRController>;
  103533. /**
  103534. * Initializes the WebXRInput
  103535. * @param helper experience helper which the input should be created for
  103536. */
  103537. constructor(helper: WebXRExperienceHelper);
  103538. private _onInputSourcesChange;
  103539. private _addAndRemoveControllers;
  103540. /**
  103541. * Disposes of the object
  103542. */
  103543. dispose(): void;
  103544. }
  103545. }
  103546. declare module BABYLON {
  103547. /**
  103548. * Contains an array of blocks representing the octree
  103549. */
  103550. export interface IOctreeContainer<T> {
  103551. /**
  103552. * Blocks within the octree
  103553. */
  103554. blocks: Array<OctreeBlock<T>>;
  103555. }
  103556. /**
  103557. * Class used to store a cell in an octree
  103558. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103559. */
  103560. export class OctreeBlock<T> {
  103561. /**
  103562. * Gets the content of the current block
  103563. */
  103564. entries: T[];
  103565. /**
  103566. * Gets the list of block children
  103567. */
  103568. blocks: Array<OctreeBlock<T>>;
  103569. private _depth;
  103570. private _maxDepth;
  103571. private _capacity;
  103572. private _minPoint;
  103573. private _maxPoint;
  103574. private _boundingVectors;
  103575. private _creationFunc;
  103576. /**
  103577. * Creates a new block
  103578. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  103579. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  103580. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103581. * @param depth defines the current depth of this block in the octree
  103582. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  103583. * @param creationFunc defines a callback to call when an element is added to the block
  103584. */
  103585. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  103586. /**
  103587. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103588. */
  103589. readonly capacity: number;
  103590. /**
  103591. * Gets the minimum vector (in world space) of the block's bounding box
  103592. */
  103593. readonly minPoint: Vector3;
  103594. /**
  103595. * Gets the maximum vector (in world space) of the block's bounding box
  103596. */
  103597. readonly maxPoint: Vector3;
  103598. /**
  103599. * Add a new element to this block
  103600. * @param entry defines the element to add
  103601. */
  103602. addEntry(entry: T): void;
  103603. /**
  103604. * Remove an element from this block
  103605. * @param entry defines the element to remove
  103606. */
  103607. removeEntry(entry: T): void;
  103608. /**
  103609. * Add an array of elements to this block
  103610. * @param entries defines the array of elements to add
  103611. */
  103612. addEntries(entries: T[]): void;
  103613. /**
  103614. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  103615. * @param frustumPlanes defines the frustum planes to test
  103616. * @param selection defines the array to store current content if selection is positive
  103617. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103618. */
  103619. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103620. /**
  103621. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  103622. * @param sphereCenter defines the bounding sphere center
  103623. * @param sphereRadius defines the bounding sphere radius
  103624. * @param selection defines the array to store current content if selection is positive
  103625. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103626. */
  103627. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103628. /**
  103629. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  103630. * @param ray defines the ray to test with
  103631. * @param selection defines the array to store current content if selection is positive
  103632. */
  103633. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  103634. /**
  103635. * Subdivide the content into child blocks (this block will then be empty)
  103636. */
  103637. createInnerBlocks(): void;
  103638. /**
  103639. * @hidden
  103640. */
  103641. 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;
  103642. }
  103643. }
  103644. declare module BABYLON {
  103645. /**
  103646. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  103647. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103648. */
  103649. export class Octree<T> {
  103650. /** 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.) */
  103651. maxDepth: number;
  103652. /**
  103653. * Blocks within the octree containing objects
  103654. */
  103655. blocks: Array<OctreeBlock<T>>;
  103656. /**
  103657. * Content stored in the octree
  103658. */
  103659. dynamicContent: T[];
  103660. private _maxBlockCapacity;
  103661. private _selectionContent;
  103662. private _creationFunc;
  103663. /**
  103664. * Creates a octree
  103665. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103666. * @param creationFunc function to be used to instatiate the octree
  103667. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  103668. * @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.)
  103669. */
  103670. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  103671. /** 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.) */
  103672. maxDepth?: number);
  103673. /**
  103674. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  103675. * @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);
  103676. * @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);
  103677. * @param entries meshes to be added to the octree blocks
  103678. */
  103679. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  103680. /**
  103681. * Adds a mesh to the octree
  103682. * @param entry Mesh to add to the octree
  103683. */
  103684. addMesh(entry: T): void;
  103685. /**
  103686. * Remove an element from the octree
  103687. * @param entry defines the element to remove
  103688. */
  103689. removeMesh(entry: T): void;
  103690. /**
  103691. * Selects an array of meshes within the frustum
  103692. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  103693. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  103694. * @returns array of meshes within the frustum
  103695. */
  103696. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  103697. /**
  103698. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  103699. * @param sphereCenter defines the bounding sphere center
  103700. * @param sphereRadius defines the bounding sphere radius
  103701. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103702. * @returns an array of objects that intersect the sphere
  103703. */
  103704. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  103705. /**
  103706. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  103707. * @param ray defines the ray to test with
  103708. * @returns array of intersected objects
  103709. */
  103710. intersectsRay(ray: Ray): SmartArray<T>;
  103711. /**
  103712. * Adds a mesh into the octree block if it intersects the block
  103713. */
  103714. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  103715. /**
  103716. * Adds a submesh into the octree block if it intersects the block
  103717. */
  103718. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  103719. }
  103720. }
  103721. declare module BABYLON {
  103722. interface Scene {
  103723. /**
  103724. * @hidden
  103725. * Backing Filed
  103726. */
  103727. _selectionOctree: Octree<AbstractMesh>;
  103728. /**
  103729. * Gets the octree used to boost mesh selection (picking)
  103730. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103731. */
  103732. selectionOctree: Octree<AbstractMesh>;
  103733. /**
  103734. * Creates or updates the octree used to boost selection (picking)
  103735. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103736. * @param maxCapacity defines the maximum capacity per leaf
  103737. * @param maxDepth defines the maximum depth of the octree
  103738. * @returns an octree of AbstractMesh
  103739. */
  103740. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  103741. }
  103742. interface AbstractMesh {
  103743. /**
  103744. * @hidden
  103745. * Backing Field
  103746. */
  103747. _submeshesOctree: Octree<SubMesh>;
  103748. /**
  103749. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  103750. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103751. * @param maxCapacity defines the maximum size of each block (64 by default)
  103752. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  103753. * @returns the new octree
  103754. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  103755. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103756. */
  103757. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  103758. }
  103759. /**
  103760. * Defines the octree scene component responsible to manage any octrees
  103761. * in a given scene.
  103762. */
  103763. export class OctreeSceneComponent {
  103764. /**
  103765. * The component name help to identify the component in the list of scene components.
  103766. */
  103767. readonly name: string;
  103768. /**
  103769. * The scene the component belongs to.
  103770. */
  103771. scene: Scene;
  103772. /**
  103773. * Indicates if the meshes have been checked to make sure they are isEnabled()
  103774. */
  103775. readonly checksIsEnabled: boolean;
  103776. /**
  103777. * Creates a new instance of the component for the given scene
  103778. * @param scene Defines the scene to register the component in
  103779. */
  103780. constructor(scene: Scene);
  103781. /**
  103782. * Registers the component in a given scene
  103783. */
  103784. register(): void;
  103785. /**
  103786. * Return the list of active meshes
  103787. * @returns the list of active meshes
  103788. */
  103789. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  103790. /**
  103791. * Return the list of active sub meshes
  103792. * @param mesh The mesh to get the candidates sub meshes from
  103793. * @returns the list of active sub meshes
  103794. */
  103795. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  103796. private _tempRay;
  103797. /**
  103798. * Return the list of sub meshes intersecting with a given local ray
  103799. * @param mesh defines the mesh to find the submesh for
  103800. * @param localRay defines the ray in local space
  103801. * @returns the list of intersecting sub meshes
  103802. */
  103803. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  103804. /**
  103805. * Return the list of sub meshes colliding with a collider
  103806. * @param mesh defines the mesh to find the submesh for
  103807. * @param collider defines the collider to evaluate the collision against
  103808. * @returns the list of colliding sub meshes
  103809. */
  103810. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  103811. /**
  103812. * Rebuilds the elements related to this component in case of
  103813. * context lost for instance.
  103814. */
  103815. rebuild(): void;
  103816. /**
  103817. * Disposes the component and the associated ressources.
  103818. */
  103819. dispose(): void;
  103820. }
  103821. }
  103822. declare module BABYLON {
  103823. /**
  103824. * Renders a layer on top of an existing scene
  103825. */
  103826. export class UtilityLayerRenderer implements IDisposable {
  103827. /** the original scene that will be rendered on top of */
  103828. originalScene: Scene;
  103829. private _pointerCaptures;
  103830. private _lastPointerEvents;
  103831. private static _DefaultUtilityLayer;
  103832. private static _DefaultKeepDepthUtilityLayer;
  103833. private _sharedGizmoLight;
  103834. private _renderCamera;
  103835. /**
  103836. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  103837. * @returns the camera that is used when rendering the utility layer
  103838. */
  103839. getRenderCamera(): Nullable<Camera>;
  103840. /**
  103841. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  103842. * @param cam the camera that should be used when rendering the utility layer
  103843. */
  103844. setRenderCamera(cam: Nullable<Camera>): void;
  103845. /**
  103846. * @hidden
  103847. * Light which used by gizmos to get light shading
  103848. */
  103849. _getSharedGizmoLight(): HemisphericLight;
  103850. /**
  103851. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  103852. */
  103853. pickUtilitySceneFirst: boolean;
  103854. /**
  103855. * 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)
  103856. */
  103857. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  103858. /**
  103859. * 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)
  103860. */
  103861. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  103862. /**
  103863. * The scene that is rendered on top of the original scene
  103864. */
  103865. utilityLayerScene: Scene;
  103866. /**
  103867. * If the utility layer should automatically be rendered on top of existing scene
  103868. */
  103869. shouldRender: boolean;
  103870. /**
  103871. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  103872. */
  103873. onlyCheckPointerDownEvents: boolean;
  103874. /**
  103875. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  103876. */
  103877. processAllEvents: boolean;
  103878. /**
  103879. * Observable raised when the pointer move from the utility layer scene to the main scene
  103880. */
  103881. onPointerOutObservable: Observable<number>;
  103882. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  103883. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  103884. private _afterRenderObserver;
  103885. private _sceneDisposeObserver;
  103886. private _originalPointerObserver;
  103887. /**
  103888. * Instantiates a UtilityLayerRenderer
  103889. * @param originalScene the original scene that will be rendered on top of
  103890. * @param handleEvents boolean indicating if the utility layer should handle events
  103891. */
  103892. constructor(
  103893. /** the original scene that will be rendered on top of */
  103894. originalScene: Scene, handleEvents?: boolean);
  103895. private _notifyObservers;
  103896. /**
  103897. * Renders the utility layers scene on top of the original scene
  103898. */
  103899. render(): void;
  103900. /**
  103901. * Disposes of the renderer
  103902. */
  103903. dispose(): void;
  103904. private _updateCamera;
  103905. }
  103906. }
  103907. declare module BABYLON {
  103908. /**
  103909. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  103910. */
  103911. export class Gizmo implements IDisposable {
  103912. /** The utility layer the gizmo will be added to */
  103913. gizmoLayer: UtilityLayerRenderer;
  103914. /**
  103915. * The root mesh of the gizmo
  103916. */
  103917. _rootMesh: Mesh;
  103918. private _attachedMesh;
  103919. /**
  103920. * Ratio for the scale of the gizmo (Default: 1)
  103921. */
  103922. scaleRatio: number;
  103923. /**
  103924. * If a custom mesh has been set (Default: false)
  103925. */
  103926. protected _customMeshSet: boolean;
  103927. /**
  103928. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  103929. * * When set, interactions will be enabled
  103930. */
  103931. attachedMesh: Nullable<AbstractMesh>;
  103932. /**
  103933. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  103934. * @param mesh The mesh to replace the default mesh of the gizmo
  103935. */
  103936. setCustomMesh(mesh: Mesh): void;
  103937. /**
  103938. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  103939. */
  103940. updateGizmoRotationToMatchAttachedMesh: boolean;
  103941. /**
  103942. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  103943. */
  103944. updateGizmoPositionToMatchAttachedMesh: boolean;
  103945. /**
  103946. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  103947. */
  103948. protected _updateScale: boolean;
  103949. protected _interactionsEnabled: boolean;
  103950. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103951. private _beforeRenderObserver;
  103952. private _tempVector;
  103953. /**
  103954. * Creates a gizmo
  103955. * @param gizmoLayer The utility layer the gizmo will be added to
  103956. */
  103957. constructor(
  103958. /** The utility layer the gizmo will be added to */
  103959. gizmoLayer?: UtilityLayerRenderer);
  103960. /**
  103961. * Updates the gizmo to match the attached mesh's position/rotation
  103962. */
  103963. protected _update(): void;
  103964. /**
  103965. * Disposes of the gizmo
  103966. */
  103967. dispose(): void;
  103968. }
  103969. }
  103970. declare module BABYLON {
  103971. /**
  103972. * Single plane drag gizmo
  103973. */
  103974. export class PlaneDragGizmo extends Gizmo {
  103975. /**
  103976. * Drag behavior responsible for the gizmos dragging interactions
  103977. */
  103978. dragBehavior: PointerDragBehavior;
  103979. private _pointerObserver;
  103980. /**
  103981. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103982. */
  103983. snapDistance: number;
  103984. /**
  103985. * Event that fires each time the gizmo snaps to a new location.
  103986. * * snapDistance is the the change in distance
  103987. */
  103988. onSnapObservable: Observable<{
  103989. snapDistance: number;
  103990. }>;
  103991. private _plane;
  103992. private _coloredMaterial;
  103993. private _hoverMaterial;
  103994. private _isEnabled;
  103995. private _parent;
  103996. /** @hidden */
  103997. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  103998. /** @hidden */
  103999. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  104000. /**
  104001. * Creates a PlaneDragGizmo
  104002. * @param gizmoLayer The utility layer the gizmo will be added to
  104003. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  104004. * @param color The color of the gizmo
  104005. */
  104006. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  104007. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104008. /**
  104009. * If the gizmo is enabled
  104010. */
  104011. isEnabled: boolean;
  104012. /**
  104013. * Disposes of the gizmo
  104014. */
  104015. dispose(): void;
  104016. }
  104017. }
  104018. declare module BABYLON {
  104019. /**
  104020. * Gizmo that enables dragging a mesh along 3 axis
  104021. */
  104022. export class PositionGizmo extends Gizmo {
  104023. /**
  104024. * Internal gizmo used for interactions on the x axis
  104025. */
  104026. xGizmo: AxisDragGizmo;
  104027. /**
  104028. * Internal gizmo used for interactions on the y axis
  104029. */
  104030. yGizmo: AxisDragGizmo;
  104031. /**
  104032. * Internal gizmo used for interactions on the z axis
  104033. */
  104034. zGizmo: AxisDragGizmo;
  104035. /**
  104036. * Internal gizmo used for interactions on the yz plane
  104037. */
  104038. xPlaneGizmo: PlaneDragGizmo;
  104039. /**
  104040. * Internal gizmo used for interactions on the xz plane
  104041. */
  104042. yPlaneGizmo: PlaneDragGizmo;
  104043. /**
  104044. * Internal gizmo used for interactions on the xy plane
  104045. */
  104046. zPlaneGizmo: PlaneDragGizmo;
  104047. /**
  104048. * private variables
  104049. */
  104050. private _meshAttached;
  104051. private _updateGizmoRotationToMatchAttachedMesh;
  104052. private _snapDistance;
  104053. private _scaleRatio;
  104054. /** Fires an event when any of it's sub gizmos are dragged */
  104055. onDragStartObservable: Observable<unknown>;
  104056. /** Fires an event when any of it's sub gizmos are released from dragging */
  104057. onDragEndObservable: Observable<unknown>;
  104058. /**
  104059. * If set to true, planar drag is enabled
  104060. */
  104061. private _planarGizmoEnabled;
  104062. attachedMesh: Nullable<AbstractMesh>;
  104063. /**
  104064. * Creates a PositionGizmo
  104065. * @param gizmoLayer The utility layer the gizmo will be added to
  104066. */
  104067. constructor(gizmoLayer?: UtilityLayerRenderer);
  104068. /**
  104069. * If the planar drag gizmo is enabled
  104070. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  104071. */
  104072. planarGizmoEnabled: boolean;
  104073. updateGizmoRotationToMatchAttachedMesh: boolean;
  104074. /**
  104075. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104076. */
  104077. snapDistance: number;
  104078. /**
  104079. * Ratio for the scale of the gizmo (Default: 1)
  104080. */
  104081. scaleRatio: number;
  104082. /**
  104083. * Disposes of the gizmo
  104084. */
  104085. dispose(): void;
  104086. /**
  104087. * CustomMeshes are not supported by this gizmo
  104088. * @param mesh The mesh to replace the default mesh of the gizmo
  104089. */
  104090. setCustomMesh(mesh: Mesh): void;
  104091. }
  104092. }
  104093. declare module BABYLON {
  104094. /**
  104095. * Single axis drag gizmo
  104096. */
  104097. export class AxisDragGizmo extends Gizmo {
  104098. /**
  104099. * Drag behavior responsible for the gizmos dragging interactions
  104100. */
  104101. dragBehavior: PointerDragBehavior;
  104102. private _pointerObserver;
  104103. /**
  104104. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104105. */
  104106. snapDistance: number;
  104107. /**
  104108. * Event that fires each time the gizmo snaps to a new location.
  104109. * * snapDistance is the the change in distance
  104110. */
  104111. onSnapObservable: Observable<{
  104112. snapDistance: number;
  104113. }>;
  104114. private _isEnabled;
  104115. private _parent;
  104116. private _arrow;
  104117. private _coloredMaterial;
  104118. private _hoverMaterial;
  104119. /** @hidden */
  104120. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  104121. /** @hidden */
  104122. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  104123. /**
  104124. * Creates an AxisDragGizmo
  104125. * @param gizmoLayer The utility layer the gizmo will be added to
  104126. * @param dragAxis The axis which the gizmo will be able to drag on
  104127. * @param color The color of the gizmo
  104128. */
  104129. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  104130. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104131. /**
  104132. * If the gizmo is enabled
  104133. */
  104134. isEnabled: boolean;
  104135. /**
  104136. * Disposes of the gizmo
  104137. */
  104138. dispose(): void;
  104139. }
  104140. }
  104141. declare module BABYLON.Debug {
  104142. /**
  104143. * The Axes viewer will show 3 axes in a specific point in space
  104144. */
  104145. export class AxesViewer {
  104146. private _xAxis;
  104147. private _yAxis;
  104148. private _zAxis;
  104149. private _scaleLinesFactor;
  104150. private _instanced;
  104151. /**
  104152. * Gets the hosting scene
  104153. */
  104154. scene: Scene;
  104155. /**
  104156. * Gets or sets a number used to scale line length
  104157. */
  104158. scaleLines: number;
  104159. /** Gets the node hierarchy used to render x-axis */
  104160. readonly xAxis: TransformNode;
  104161. /** Gets the node hierarchy used to render y-axis */
  104162. readonly yAxis: TransformNode;
  104163. /** Gets the node hierarchy used to render z-axis */
  104164. readonly zAxis: TransformNode;
  104165. /**
  104166. * Creates a new AxesViewer
  104167. * @param scene defines the hosting scene
  104168. * @param scaleLines defines a number used to scale line length (1 by default)
  104169. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  104170. * @param xAxis defines the node hierarchy used to render the x-axis
  104171. * @param yAxis defines the node hierarchy used to render the y-axis
  104172. * @param zAxis defines the node hierarchy used to render the z-axis
  104173. */
  104174. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  104175. /**
  104176. * Force the viewer to update
  104177. * @param position defines the position of the viewer
  104178. * @param xaxis defines the x axis of the viewer
  104179. * @param yaxis defines the y axis of the viewer
  104180. * @param zaxis defines the z axis of the viewer
  104181. */
  104182. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  104183. /**
  104184. * Creates an instance of this axes viewer.
  104185. * @returns a new axes viewer with instanced meshes
  104186. */
  104187. createInstance(): AxesViewer;
  104188. /** Releases resources */
  104189. dispose(): void;
  104190. private static _SetRenderingGroupId;
  104191. }
  104192. }
  104193. declare module BABYLON.Debug {
  104194. /**
  104195. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  104196. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  104197. */
  104198. export class BoneAxesViewer extends AxesViewer {
  104199. /**
  104200. * Gets or sets the target mesh where to display the axes viewer
  104201. */
  104202. mesh: Nullable<Mesh>;
  104203. /**
  104204. * Gets or sets the target bone where to display the axes viewer
  104205. */
  104206. bone: Nullable<Bone>;
  104207. /** Gets current position */
  104208. pos: Vector3;
  104209. /** Gets direction of X axis */
  104210. xaxis: Vector3;
  104211. /** Gets direction of Y axis */
  104212. yaxis: Vector3;
  104213. /** Gets direction of Z axis */
  104214. zaxis: Vector3;
  104215. /**
  104216. * Creates a new BoneAxesViewer
  104217. * @param scene defines the hosting scene
  104218. * @param bone defines the target bone
  104219. * @param mesh defines the target mesh
  104220. * @param scaleLines defines a scaling factor for line length (1 by default)
  104221. */
  104222. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  104223. /**
  104224. * Force the viewer to update
  104225. */
  104226. update(): void;
  104227. /** Releases resources */
  104228. dispose(): void;
  104229. }
  104230. }
  104231. declare module BABYLON {
  104232. /**
  104233. * Interface used to define scene explorer extensibility option
  104234. */
  104235. export interface IExplorerExtensibilityOption {
  104236. /**
  104237. * Define the option label
  104238. */
  104239. label: string;
  104240. /**
  104241. * Defines the action to execute on click
  104242. */
  104243. action: (entity: any) => void;
  104244. }
  104245. /**
  104246. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  104247. */
  104248. export interface IExplorerExtensibilityGroup {
  104249. /**
  104250. * Defines a predicate to test if a given type mut be extended
  104251. */
  104252. predicate: (entity: any) => boolean;
  104253. /**
  104254. * Gets the list of options added to a type
  104255. */
  104256. entries: IExplorerExtensibilityOption[];
  104257. }
  104258. /**
  104259. * Interface used to define the options to use to create the Inspector
  104260. */
  104261. export interface IInspectorOptions {
  104262. /**
  104263. * Display in overlay mode (default: false)
  104264. */
  104265. overlay?: boolean;
  104266. /**
  104267. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  104268. */
  104269. globalRoot?: HTMLElement;
  104270. /**
  104271. * Display the Scene explorer
  104272. */
  104273. showExplorer?: boolean;
  104274. /**
  104275. * Display the property inspector
  104276. */
  104277. showInspector?: boolean;
  104278. /**
  104279. * Display in embed mode (both panes on the right)
  104280. */
  104281. embedMode?: boolean;
  104282. /**
  104283. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  104284. */
  104285. handleResize?: boolean;
  104286. /**
  104287. * Allow the panes to popup (default: true)
  104288. */
  104289. enablePopup?: boolean;
  104290. /**
  104291. * Allow the panes to be closed by users (default: true)
  104292. */
  104293. enableClose?: boolean;
  104294. /**
  104295. * Optional list of extensibility entries
  104296. */
  104297. explorerExtensibility?: IExplorerExtensibilityGroup[];
  104298. /**
  104299. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  104300. */
  104301. inspectorURL?: string;
  104302. }
  104303. interface Scene {
  104304. /**
  104305. * @hidden
  104306. * Backing field
  104307. */
  104308. _debugLayer: DebugLayer;
  104309. /**
  104310. * Gets the debug layer (aka Inspector) associated with the scene
  104311. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104312. */
  104313. debugLayer: DebugLayer;
  104314. }
  104315. /**
  104316. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104317. * what is happening in your scene
  104318. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104319. */
  104320. export class DebugLayer {
  104321. /**
  104322. * Define the url to get the inspector script from.
  104323. * By default it uses the babylonjs CDN.
  104324. * @ignoreNaming
  104325. */
  104326. static InspectorURL: string;
  104327. private _scene;
  104328. private BJSINSPECTOR;
  104329. private _onPropertyChangedObservable?;
  104330. /**
  104331. * Observable triggered when a property is changed through the inspector.
  104332. */
  104333. readonly onPropertyChangedObservable: any;
  104334. /**
  104335. * Instantiates a new debug layer.
  104336. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104337. * what is happening in your scene
  104338. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104339. * @param scene Defines the scene to inspect
  104340. */
  104341. constructor(scene: Scene);
  104342. /** Creates the inspector window. */
  104343. private _createInspector;
  104344. /**
  104345. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  104346. * @param entity defines the entity to select
  104347. * @param lineContainerTitle defines the specific block to highlight
  104348. */
  104349. select(entity: any, lineContainerTitle?: string): void;
  104350. /** Get the inspector from bundle or global */
  104351. private _getGlobalInspector;
  104352. /**
  104353. * Get if the inspector is visible or not.
  104354. * @returns true if visible otherwise, false
  104355. */
  104356. isVisible(): boolean;
  104357. /**
  104358. * Hide the inspector and close its window.
  104359. */
  104360. hide(): void;
  104361. /**
  104362. * Launch the debugLayer.
  104363. * @param config Define the configuration of the inspector
  104364. * @return a promise fulfilled when the debug layer is visible
  104365. */
  104366. show(config?: IInspectorOptions): Promise<DebugLayer>;
  104367. }
  104368. }
  104369. declare module BABYLON {
  104370. /**
  104371. * Class containing static functions to help procedurally build meshes
  104372. */
  104373. export class BoxBuilder {
  104374. /**
  104375. * Creates a box mesh
  104376. * * The parameter `size` sets the size (float) of each box side (default 1)
  104377. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  104378. * * 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)
  104379. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104381. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104383. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  104384. * @param name defines the name of the mesh
  104385. * @param options defines the options used to create the mesh
  104386. * @param scene defines the hosting scene
  104387. * @returns the box mesh
  104388. */
  104389. static CreateBox(name: string, options: {
  104390. size?: number;
  104391. width?: number;
  104392. height?: number;
  104393. depth?: number;
  104394. faceUV?: Vector4[];
  104395. faceColors?: Color4[];
  104396. sideOrientation?: number;
  104397. frontUVs?: Vector4;
  104398. backUVs?: Vector4;
  104399. wrap?: boolean;
  104400. topBaseAt?: number;
  104401. bottomBaseAt?: number;
  104402. updatable?: boolean;
  104403. }, scene?: Nullable<Scene>): Mesh;
  104404. }
  104405. }
  104406. declare module BABYLON {
  104407. /**
  104408. * Class containing static functions to help procedurally build meshes
  104409. */
  104410. export class SphereBuilder {
  104411. /**
  104412. * Creates a sphere mesh
  104413. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  104414. * * 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`)
  104415. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  104416. * * 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
  104417. * * 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)
  104418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104421. * @param name defines the name of the mesh
  104422. * @param options defines the options used to create the mesh
  104423. * @param scene defines the hosting scene
  104424. * @returns the sphere mesh
  104425. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  104426. */
  104427. static CreateSphere(name: string, options: {
  104428. segments?: number;
  104429. diameter?: number;
  104430. diameterX?: number;
  104431. diameterY?: number;
  104432. diameterZ?: number;
  104433. arc?: number;
  104434. slice?: number;
  104435. sideOrientation?: number;
  104436. frontUVs?: Vector4;
  104437. backUVs?: Vector4;
  104438. updatable?: boolean;
  104439. }, scene: any): Mesh;
  104440. }
  104441. }
  104442. declare module BABYLON.Debug {
  104443. /**
  104444. * Used to show the physics impostor around the specific mesh
  104445. */
  104446. export class PhysicsViewer {
  104447. /** @hidden */
  104448. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  104449. /** @hidden */
  104450. protected _meshes: Array<Nullable<AbstractMesh>>;
  104451. /** @hidden */
  104452. protected _scene: Nullable<Scene>;
  104453. /** @hidden */
  104454. protected _numMeshes: number;
  104455. /** @hidden */
  104456. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  104457. private _renderFunction;
  104458. private _utilityLayer;
  104459. private _debugBoxMesh;
  104460. private _debugSphereMesh;
  104461. private _debugCylinderMesh;
  104462. private _debugMaterial;
  104463. private _debugMeshMeshes;
  104464. /**
  104465. * Creates a new PhysicsViewer
  104466. * @param scene defines the hosting scene
  104467. */
  104468. constructor(scene: Scene);
  104469. /** @hidden */
  104470. protected _updateDebugMeshes(): void;
  104471. /**
  104472. * Renders a specified physic impostor
  104473. * @param impostor defines the impostor to render
  104474. * @param targetMesh defines the mesh represented by the impostor
  104475. * @returns the new debug mesh used to render the impostor
  104476. */
  104477. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  104478. /**
  104479. * Hides a specified physic impostor
  104480. * @param impostor defines the impostor to hide
  104481. */
  104482. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  104483. private _getDebugMaterial;
  104484. private _getDebugBoxMesh;
  104485. private _getDebugSphereMesh;
  104486. private _getDebugCylinderMesh;
  104487. private _getDebugMeshMesh;
  104488. private _getDebugMesh;
  104489. /** Releases all resources */
  104490. dispose(): void;
  104491. }
  104492. }
  104493. declare module BABYLON {
  104494. /**
  104495. * Class containing static functions to help procedurally build meshes
  104496. */
  104497. export class LinesBuilder {
  104498. /**
  104499. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  104500. * * 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
  104501. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  104502. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  104503. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  104504. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  104505. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  104506. * * 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
  104507. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  104508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104509. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  104510. * @param name defines the name of the new line system
  104511. * @param options defines the options used to create the line system
  104512. * @param scene defines the hosting scene
  104513. * @returns a new line system mesh
  104514. */
  104515. static CreateLineSystem(name: string, options: {
  104516. lines: Vector3[][];
  104517. updatable?: boolean;
  104518. instance?: Nullable<LinesMesh>;
  104519. colors?: Nullable<Color4[][]>;
  104520. useVertexAlpha?: boolean;
  104521. }, scene: Nullable<Scene>): LinesMesh;
  104522. /**
  104523. * Creates a line mesh
  104524. * 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
  104525. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104526. * * The parameter `points` is an array successive Vector3
  104527. * * 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
  104528. * * The optional parameter `colors` is an array of successive Color4, one per line point
  104529. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  104530. * * When updating an instance, remember that only point positions can change, not the number of points
  104531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104532. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  104533. * @param name defines the name of the new line system
  104534. * @param options defines the options used to create the line system
  104535. * @param scene defines the hosting scene
  104536. * @returns a new line mesh
  104537. */
  104538. static CreateLines(name: string, options: {
  104539. points: Vector3[];
  104540. updatable?: boolean;
  104541. instance?: Nullable<LinesMesh>;
  104542. colors?: Color4[];
  104543. useVertexAlpha?: boolean;
  104544. }, scene?: Nullable<Scene>): LinesMesh;
  104545. /**
  104546. * Creates a dashed line mesh
  104547. * * 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
  104548. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104549. * * The parameter `points` is an array successive Vector3
  104550. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  104551. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  104552. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104553. * * 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
  104554. * * When updating an instance, remember that only point positions can change, not the number of points
  104555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104556. * @param name defines the name of the mesh
  104557. * @param options defines the options used to create the mesh
  104558. * @param scene defines the hosting scene
  104559. * @returns the dashed line mesh
  104560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104561. */
  104562. static CreateDashedLines(name: string, options: {
  104563. points: Vector3[];
  104564. dashSize?: number;
  104565. gapSize?: number;
  104566. dashNb?: number;
  104567. updatable?: boolean;
  104568. instance?: LinesMesh;
  104569. }, scene?: Nullable<Scene>): LinesMesh;
  104570. }
  104571. }
  104572. declare module BABYLON {
  104573. /**
  104574. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104575. * in order to better appreciate the issue one might have.
  104576. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104577. */
  104578. export class RayHelper {
  104579. /**
  104580. * Defines the ray we are currently tryin to visualize.
  104581. */
  104582. ray: Nullable<Ray>;
  104583. private _renderPoints;
  104584. private _renderLine;
  104585. private _renderFunction;
  104586. private _scene;
  104587. private _updateToMeshFunction;
  104588. private _attachedToMesh;
  104589. private _meshSpaceDirection;
  104590. private _meshSpaceOrigin;
  104591. /**
  104592. * Helper function to create a colored helper in a scene in one line.
  104593. * @param ray Defines the ray we are currently tryin to visualize
  104594. * @param scene Defines the scene the ray is used in
  104595. * @param color Defines the color we want to see the ray in
  104596. * @returns The newly created ray helper.
  104597. */
  104598. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  104599. /**
  104600. * Instantiate a new ray helper.
  104601. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104602. * in order to better appreciate the issue one might have.
  104603. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104604. * @param ray Defines the ray we are currently tryin to visualize
  104605. */
  104606. constructor(ray: Ray);
  104607. /**
  104608. * Shows the ray we are willing to debug.
  104609. * @param scene Defines the scene the ray needs to be rendered in
  104610. * @param color Defines the color the ray needs to be rendered in
  104611. */
  104612. show(scene: Scene, color?: Color3): void;
  104613. /**
  104614. * Hides the ray we are debugging.
  104615. */
  104616. hide(): void;
  104617. private _render;
  104618. /**
  104619. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  104620. * @param mesh Defines the mesh we want the helper attached to
  104621. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  104622. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  104623. * @param length Defines the length of the ray
  104624. */
  104625. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  104626. /**
  104627. * Detach the ray helper from the mesh it has previously been attached to.
  104628. */
  104629. detachFromMesh(): void;
  104630. private _updateToMesh;
  104631. /**
  104632. * Dispose the helper and release its associated resources.
  104633. */
  104634. dispose(): void;
  104635. }
  104636. }
  104637. declare module BABYLON.Debug {
  104638. /**
  104639. * Class used to render a debug view of a given skeleton
  104640. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  104641. */
  104642. export class SkeletonViewer {
  104643. /** defines the skeleton to render */
  104644. skeleton: Skeleton;
  104645. /** defines the mesh attached to the skeleton */
  104646. mesh: AbstractMesh;
  104647. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104648. autoUpdateBonesMatrices: boolean;
  104649. /** defines the rendering group id to use with the viewer */
  104650. renderingGroupId: number;
  104651. /** Gets or sets the color used to render the skeleton */
  104652. color: Color3;
  104653. private _scene;
  104654. private _debugLines;
  104655. private _debugMesh;
  104656. private _isEnabled;
  104657. private _renderFunction;
  104658. private _utilityLayer;
  104659. /**
  104660. * Returns the mesh used to render the bones
  104661. */
  104662. readonly debugMesh: Nullable<LinesMesh>;
  104663. /**
  104664. * Creates a new SkeletonViewer
  104665. * @param skeleton defines the skeleton to render
  104666. * @param mesh defines the mesh attached to the skeleton
  104667. * @param scene defines the hosting scene
  104668. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  104669. * @param renderingGroupId defines the rendering group id to use with the viewer
  104670. */
  104671. constructor(
  104672. /** defines the skeleton to render */
  104673. skeleton: Skeleton,
  104674. /** defines the mesh attached to the skeleton */
  104675. mesh: AbstractMesh, scene: Scene,
  104676. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104677. autoUpdateBonesMatrices?: boolean,
  104678. /** defines the rendering group id to use with the viewer */
  104679. renderingGroupId?: number);
  104680. /** Gets or sets a boolean indicating if the viewer is enabled */
  104681. isEnabled: boolean;
  104682. private _getBonePosition;
  104683. private _getLinesForBonesWithLength;
  104684. private _getLinesForBonesNoLength;
  104685. /** Update the viewer to sync with current skeleton state */
  104686. update(): void;
  104687. /** Release associated resources */
  104688. dispose(): void;
  104689. }
  104690. }
  104691. declare module BABYLON {
  104692. /**
  104693. * Options to create the null engine
  104694. */
  104695. export class NullEngineOptions {
  104696. /**
  104697. * Render width (Default: 512)
  104698. */
  104699. renderWidth: number;
  104700. /**
  104701. * Render height (Default: 256)
  104702. */
  104703. renderHeight: number;
  104704. /**
  104705. * Texture size (Default: 512)
  104706. */
  104707. textureSize: number;
  104708. /**
  104709. * If delta time between frames should be constant
  104710. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104711. */
  104712. deterministicLockstep: boolean;
  104713. /**
  104714. * Maximum about of steps between frames (Default: 4)
  104715. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104716. */
  104717. lockstepMaxSteps: number;
  104718. }
  104719. /**
  104720. * The null engine class provides support for headless version of babylon.js.
  104721. * This can be used in server side scenario or for testing purposes
  104722. */
  104723. export class NullEngine extends Engine {
  104724. private _options;
  104725. /**
  104726. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104727. */
  104728. isDeterministicLockStep(): boolean;
  104729. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  104730. getLockstepMaxSteps(): number;
  104731. /**
  104732. * Sets hardware scaling, used to save performance if needed
  104733. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  104734. */
  104735. getHardwareScalingLevel(): number;
  104736. constructor(options?: NullEngineOptions);
  104737. createVertexBuffer(vertices: FloatArray): DataBuffer;
  104738. createIndexBuffer(indices: IndicesArray): DataBuffer;
  104739. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104740. getRenderWidth(useScreen?: boolean): number;
  104741. getRenderHeight(useScreen?: boolean): number;
  104742. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  104743. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  104744. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104745. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104746. bindSamplers(effect: Effect): void;
  104747. enableEffect(effect: Effect): void;
  104748. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104749. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  104750. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  104751. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  104752. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  104753. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  104754. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  104755. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  104756. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  104757. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  104758. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  104759. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  104760. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  104761. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  104762. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  104763. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104764. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104765. setFloat(uniform: WebGLUniformLocation, value: number): void;
  104766. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  104767. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  104768. setBool(uniform: WebGLUniformLocation, bool: number): void;
  104769. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  104770. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  104771. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  104772. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104773. bindBuffers(vertexBuffers: {
  104774. [key: string]: VertexBuffer;
  104775. }, indexBuffer: DataBuffer, effect: Effect): void;
  104776. wipeCaches(bruteForce?: boolean): void;
  104777. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104778. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104779. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104780. /** @hidden */
  104781. _createTexture(): WebGLTexture;
  104782. /** @hidden */
  104783. _releaseTexture(texture: InternalTexture): void;
  104784. 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;
  104785. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  104786. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  104787. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  104788. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104789. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  104790. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  104791. areAllEffectsReady(): boolean;
  104792. /**
  104793. * @hidden
  104794. * Get the current error code of the webGL context
  104795. * @returns the error code
  104796. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104797. */
  104798. getError(): number;
  104799. /** @hidden */
  104800. _getUnpackAlignement(): number;
  104801. /** @hidden */
  104802. _unpackFlipY(value: boolean): void;
  104803. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  104804. /**
  104805. * Updates a dynamic vertex buffer.
  104806. * @param vertexBuffer the vertex buffer to update
  104807. * @param data the data used to update the vertex buffer
  104808. * @param byteOffset the byte offset of the data (optional)
  104809. * @param byteLength the byte length of the data (optional)
  104810. */
  104811. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  104812. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  104813. /** @hidden */
  104814. _bindTexture(channel: number, texture: InternalTexture): void;
  104815. /** @hidden */
  104816. _releaseBuffer(buffer: DataBuffer): boolean;
  104817. releaseEffects(): void;
  104818. displayLoadingUI(): void;
  104819. hideLoadingUI(): void;
  104820. /** @hidden */
  104821. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104822. /** @hidden */
  104823. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104824. /** @hidden */
  104825. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104826. /** @hidden */
  104827. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  104828. }
  104829. }
  104830. declare module BABYLON {
  104831. /** @hidden */
  104832. export class _OcclusionDataStorage {
  104833. /** @hidden */
  104834. occlusionInternalRetryCounter: number;
  104835. /** @hidden */
  104836. isOcclusionQueryInProgress: boolean;
  104837. /** @hidden */
  104838. isOccluded: boolean;
  104839. /** @hidden */
  104840. occlusionRetryCount: number;
  104841. /** @hidden */
  104842. occlusionType: number;
  104843. /** @hidden */
  104844. occlusionQueryAlgorithmType: number;
  104845. }
  104846. interface Engine {
  104847. /**
  104848. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  104849. * @return the new query
  104850. */
  104851. createQuery(): WebGLQuery;
  104852. /**
  104853. * Delete and release a webGL query
  104854. * @param query defines the query to delete
  104855. * @return the current engine
  104856. */
  104857. deleteQuery(query: WebGLQuery): Engine;
  104858. /**
  104859. * Check if a given query has resolved and got its value
  104860. * @param query defines the query to check
  104861. * @returns true if the query got its value
  104862. */
  104863. isQueryResultAvailable(query: WebGLQuery): boolean;
  104864. /**
  104865. * Gets the value of a given query
  104866. * @param query defines the query to check
  104867. * @returns the value of the query
  104868. */
  104869. getQueryResult(query: WebGLQuery): number;
  104870. /**
  104871. * Initiates an occlusion query
  104872. * @param algorithmType defines the algorithm to use
  104873. * @param query defines the query to use
  104874. * @returns the current engine
  104875. * @see http://doc.babylonjs.com/features/occlusionquery
  104876. */
  104877. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  104878. /**
  104879. * Ends an occlusion query
  104880. * @see http://doc.babylonjs.com/features/occlusionquery
  104881. * @param algorithmType defines the algorithm to use
  104882. * @returns the current engine
  104883. */
  104884. endOcclusionQuery(algorithmType: number): Engine;
  104885. /**
  104886. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  104887. * Please note that only one query can be issued at a time
  104888. * @returns a time token used to track the time span
  104889. */
  104890. startTimeQuery(): Nullable<_TimeToken>;
  104891. /**
  104892. * Ends a time query
  104893. * @param token defines the token used to measure the time span
  104894. * @returns the time spent (in ns)
  104895. */
  104896. endTimeQuery(token: _TimeToken): int;
  104897. /** @hidden */
  104898. _currentNonTimestampToken: Nullable<_TimeToken>;
  104899. /** @hidden */
  104900. _createTimeQuery(): WebGLQuery;
  104901. /** @hidden */
  104902. _deleteTimeQuery(query: WebGLQuery): void;
  104903. /** @hidden */
  104904. _getGlAlgorithmType(algorithmType: number): number;
  104905. /** @hidden */
  104906. _getTimeQueryResult(query: WebGLQuery): any;
  104907. /** @hidden */
  104908. _getTimeQueryAvailability(query: WebGLQuery): any;
  104909. }
  104910. interface AbstractMesh {
  104911. /**
  104912. * Backing filed
  104913. * @hidden
  104914. */
  104915. __occlusionDataStorage: _OcclusionDataStorage;
  104916. /**
  104917. * Access property
  104918. * @hidden
  104919. */
  104920. _occlusionDataStorage: _OcclusionDataStorage;
  104921. /**
  104922. * 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.
  104923. * The default value is -1 which means don't break the query and wait till the result
  104924. * @see http://doc.babylonjs.com/features/occlusionquery
  104925. */
  104926. occlusionRetryCount: number;
  104927. /**
  104928. * 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:
  104929. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  104930. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  104931. * * 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.
  104932. * @see http://doc.babylonjs.com/features/occlusionquery
  104933. */
  104934. occlusionType: number;
  104935. /**
  104936. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  104937. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  104938. * * 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.
  104939. * @see http://doc.babylonjs.com/features/occlusionquery
  104940. */
  104941. occlusionQueryAlgorithmType: number;
  104942. /**
  104943. * 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
  104944. * @see http://doc.babylonjs.com/features/occlusionquery
  104945. */
  104946. isOccluded: boolean;
  104947. /**
  104948. * Flag to check the progress status of the query
  104949. * @see http://doc.babylonjs.com/features/occlusionquery
  104950. */
  104951. isOcclusionQueryInProgress: boolean;
  104952. }
  104953. }
  104954. declare module BABYLON {
  104955. /** @hidden */
  104956. export var _forceTransformFeedbackToBundle: boolean;
  104957. interface Engine {
  104958. /**
  104959. * Creates a webGL transform feedback object
  104960. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  104961. * @returns the webGL transform feedback object
  104962. */
  104963. createTransformFeedback(): WebGLTransformFeedback;
  104964. /**
  104965. * Delete a webGL transform feedback object
  104966. * @param value defines the webGL transform feedback object to delete
  104967. */
  104968. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  104969. /**
  104970. * Bind a webGL transform feedback object to the webgl context
  104971. * @param value defines the webGL transform feedback object to bind
  104972. */
  104973. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  104974. /**
  104975. * Begins a transform feedback operation
  104976. * @param usePoints defines if points or triangles must be used
  104977. */
  104978. beginTransformFeedback(usePoints: boolean): void;
  104979. /**
  104980. * Ends a transform feedback operation
  104981. */
  104982. endTransformFeedback(): void;
  104983. /**
  104984. * Specify the varyings to use with transform feedback
  104985. * @param program defines the associated webGL program
  104986. * @param value defines the list of strings representing the varying names
  104987. */
  104988. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  104989. /**
  104990. * Bind a webGL buffer for a transform feedback operation
  104991. * @param value defines the webGL buffer to bind
  104992. */
  104993. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  104994. }
  104995. }
  104996. declare module BABYLON {
  104997. /**
  104998. * Creation options of the multi render target texture.
  104999. */
  105000. export interface IMultiRenderTargetOptions {
  105001. /**
  105002. * Define if the texture needs to create mip maps after render.
  105003. */
  105004. generateMipMaps?: boolean;
  105005. /**
  105006. * Define the types of all the draw buffers we want to create
  105007. */
  105008. types?: number[];
  105009. /**
  105010. * Define the sampling modes of all the draw buffers we want to create
  105011. */
  105012. samplingModes?: number[];
  105013. /**
  105014. * Define if a depth buffer is required
  105015. */
  105016. generateDepthBuffer?: boolean;
  105017. /**
  105018. * Define if a stencil buffer is required
  105019. */
  105020. generateStencilBuffer?: boolean;
  105021. /**
  105022. * Define if a depth texture is required instead of a depth buffer
  105023. */
  105024. generateDepthTexture?: boolean;
  105025. /**
  105026. * Define the number of desired draw buffers
  105027. */
  105028. textureCount?: number;
  105029. /**
  105030. * Define if aspect ratio should be adapted to the texture or stay the scene one
  105031. */
  105032. doNotChangeAspectRatio?: boolean;
  105033. /**
  105034. * Define the default type of the buffers we are creating
  105035. */
  105036. defaultType?: number;
  105037. }
  105038. /**
  105039. * A multi render target, like a render target provides the ability to render to a texture.
  105040. * Unlike the render target, it can render to several draw buffers in one draw.
  105041. * This is specially interesting in deferred rendering or for any effects requiring more than
  105042. * just one color from a single pass.
  105043. */
  105044. export class MultiRenderTarget extends RenderTargetTexture {
  105045. private _internalTextures;
  105046. private _textures;
  105047. private _multiRenderTargetOptions;
  105048. /**
  105049. * Get if draw buffers are currently supported by the used hardware and browser.
  105050. */
  105051. readonly isSupported: boolean;
  105052. /**
  105053. * Get the list of textures generated by the multi render target.
  105054. */
  105055. readonly textures: Texture[];
  105056. /**
  105057. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  105058. */
  105059. readonly depthTexture: Texture;
  105060. /**
  105061. * Set the wrapping mode on U of all the textures we are rendering to.
  105062. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  105063. */
  105064. wrapU: number;
  105065. /**
  105066. * Set the wrapping mode on V of all the textures we are rendering to.
  105067. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  105068. */
  105069. wrapV: number;
  105070. /**
  105071. * Instantiate a new multi render target texture.
  105072. * A multi render target, like a render target provides the ability to render to a texture.
  105073. * Unlike the render target, it can render to several draw buffers in one draw.
  105074. * This is specially interesting in deferred rendering or for any effects requiring more than
  105075. * just one color from a single pass.
  105076. * @param name Define the name of the texture
  105077. * @param size Define the size of the buffers to render to
  105078. * @param count Define the number of target we are rendering into
  105079. * @param scene Define the scene the texture belongs to
  105080. * @param options Define the options used to create the multi render target
  105081. */
  105082. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  105083. /** @hidden */
  105084. _rebuild(): void;
  105085. private _createInternalTextures;
  105086. private _createTextures;
  105087. /**
  105088. * Define the number of samples used if MSAA is enabled.
  105089. */
  105090. samples: number;
  105091. /**
  105092. * Resize all the textures in the multi render target.
  105093. * Be carrefull as it will recreate all the data in the new texture.
  105094. * @param size Define the new size
  105095. */
  105096. resize(size: any): void;
  105097. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  105098. /**
  105099. * Dispose the render targets and their associated resources
  105100. */
  105101. dispose(): void;
  105102. /**
  105103. * Release all the underlying texture used as draw buffers.
  105104. */
  105105. releaseInternalTextures(): void;
  105106. }
  105107. }
  105108. declare module BABYLON {
  105109. interface Engine {
  105110. /**
  105111. * Unbind a list of render target textures from the webGL context
  105112. * This is used only when drawBuffer extension or webGL2 are active
  105113. * @param textures defines the render target textures to unbind
  105114. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105115. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105116. */
  105117. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  105118. /**
  105119. * Create a multi render target texture
  105120. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  105121. * @param size defines the size of the texture
  105122. * @param options defines the creation options
  105123. * @returns the cube texture as an InternalTexture
  105124. */
  105125. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  105126. /**
  105127. * Update the sample count for a given multiple render target texture
  105128. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  105129. * @param textures defines the textures to update
  105130. * @param samples defines the sample count to set
  105131. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  105132. */
  105133. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  105134. }
  105135. }
  105136. declare module BABYLON {
  105137. /**
  105138. * Gather the list of clipboard event types as constants.
  105139. */
  105140. export class ClipboardEventTypes {
  105141. /**
  105142. * The clipboard event is fired when a copy command is active (pressed).
  105143. */
  105144. static readonly COPY: number;
  105145. /**
  105146. * The clipboard event is fired when a cut command is active (pressed).
  105147. */
  105148. static readonly CUT: number;
  105149. /**
  105150. * The clipboard event is fired when a paste command is active (pressed).
  105151. */
  105152. static readonly PASTE: number;
  105153. }
  105154. /**
  105155. * This class is used to store clipboard related info for the onClipboardObservable event.
  105156. */
  105157. export class ClipboardInfo {
  105158. /**
  105159. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105160. */
  105161. type: number;
  105162. /**
  105163. * Defines the related dom event
  105164. */
  105165. event: ClipboardEvent;
  105166. /**
  105167. *Creates an instance of ClipboardInfo.
  105168. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  105169. * @param event Defines the related dom event
  105170. */
  105171. constructor(
  105172. /**
  105173. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105174. */
  105175. type: number,
  105176. /**
  105177. * Defines the related dom event
  105178. */
  105179. event: ClipboardEvent);
  105180. /**
  105181. * Get the clipboard event's type from the keycode.
  105182. * @param keyCode Defines the keyCode for the current keyboard event.
  105183. * @return {number}
  105184. */
  105185. static GetTypeFromCharacter(keyCode: number): number;
  105186. }
  105187. }
  105188. declare module BABYLON {
  105189. /**
  105190. * Class used to represent data loading progression
  105191. */
  105192. export class SceneLoaderProgressEvent {
  105193. /** defines if data length to load can be evaluated */
  105194. readonly lengthComputable: boolean;
  105195. /** defines the loaded data length */
  105196. readonly loaded: number;
  105197. /** defines the data length to load */
  105198. readonly total: number;
  105199. /**
  105200. * Create a new progress event
  105201. * @param lengthComputable defines if data length to load can be evaluated
  105202. * @param loaded defines the loaded data length
  105203. * @param total defines the data length to load
  105204. */
  105205. constructor(
  105206. /** defines if data length to load can be evaluated */
  105207. lengthComputable: boolean,
  105208. /** defines the loaded data length */
  105209. loaded: number,
  105210. /** defines the data length to load */
  105211. total: number);
  105212. /**
  105213. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  105214. * @param event defines the source event
  105215. * @returns a new SceneLoaderProgressEvent
  105216. */
  105217. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  105218. }
  105219. /**
  105220. * Interface used by SceneLoader plugins to define supported file extensions
  105221. */
  105222. export interface ISceneLoaderPluginExtensions {
  105223. /**
  105224. * Defines the list of supported extensions
  105225. */
  105226. [extension: string]: {
  105227. isBinary: boolean;
  105228. };
  105229. }
  105230. /**
  105231. * Interface used by SceneLoader plugin factory
  105232. */
  105233. export interface ISceneLoaderPluginFactory {
  105234. /**
  105235. * Defines the name of the factory
  105236. */
  105237. name: string;
  105238. /**
  105239. * Function called to create a new plugin
  105240. * @return the new plugin
  105241. */
  105242. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  105243. /**
  105244. * Boolean indicating if the plugin can direct load specific data
  105245. */
  105246. canDirectLoad?: (data: string) => boolean;
  105247. }
  105248. /**
  105249. * Interface used to define a SceneLoader plugin
  105250. */
  105251. export interface ISceneLoaderPlugin {
  105252. /**
  105253. * The friendly name of this plugin.
  105254. */
  105255. name: string;
  105256. /**
  105257. * The file extensions supported by this plugin.
  105258. */
  105259. extensions: string | ISceneLoaderPluginExtensions;
  105260. /**
  105261. * Import meshes into a scene.
  105262. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105263. * @param scene The scene to import into
  105264. * @param data The data to import
  105265. * @param rootUrl The root url for scene and resources
  105266. * @param meshes The meshes array to import into
  105267. * @param particleSystems The particle systems array to import into
  105268. * @param skeletons The skeletons array to import into
  105269. * @param onError The callback when import fails
  105270. * @returns True if successful or false otherwise
  105271. */
  105272. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105273. /**
  105274. * Load into a scene.
  105275. * @param scene The scene to load into
  105276. * @param data The data to import
  105277. * @param rootUrl The root url for scene and resources
  105278. * @param onError The callback when import fails
  105279. * @returns true if successful or false otherwise
  105280. */
  105281. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105282. /**
  105283. * The callback that returns true if the data can be directly loaded.
  105284. */
  105285. canDirectLoad?: (data: string) => boolean;
  105286. /**
  105287. * The callback that allows custom handling of the root url based on the response url.
  105288. */
  105289. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105290. /**
  105291. * Load into an asset container.
  105292. * @param scene The scene to load into
  105293. * @param data The data to import
  105294. * @param rootUrl The root url for scene and resources
  105295. * @param onError The callback when import fails
  105296. * @returns The loaded asset container
  105297. */
  105298. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105299. }
  105300. /**
  105301. * Interface used to define an async SceneLoader plugin
  105302. */
  105303. export interface ISceneLoaderPluginAsync {
  105304. /**
  105305. * The friendly name of this plugin.
  105306. */
  105307. name: string;
  105308. /**
  105309. * The file extensions supported by this plugin.
  105310. */
  105311. extensions: string | ISceneLoaderPluginExtensions;
  105312. /**
  105313. * Import meshes into a scene.
  105314. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105315. * @param scene The scene to import into
  105316. * @param data The data to import
  105317. * @param rootUrl The root url for scene and resources
  105318. * @param onProgress The callback when the load progresses
  105319. * @param fileName Defines the name of the file to load
  105320. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105321. */
  105322. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105323. meshes: AbstractMesh[];
  105324. particleSystems: IParticleSystem[];
  105325. skeletons: Skeleton[];
  105326. animationGroups: AnimationGroup[];
  105327. }>;
  105328. /**
  105329. * Load into a scene.
  105330. * @param scene The scene to load into
  105331. * @param data The data to import
  105332. * @param rootUrl The root url for scene and resources
  105333. * @param onProgress The callback when the load progresses
  105334. * @param fileName Defines the name of the file to load
  105335. * @returns Nothing
  105336. */
  105337. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105338. /**
  105339. * The callback that returns true if the data can be directly loaded.
  105340. */
  105341. canDirectLoad?: (data: string) => boolean;
  105342. /**
  105343. * The callback that allows custom handling of the root url based on the response url.
  105344. */
  105345. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105346. /**
  105347. * Load into an asset container.
  105348. * @param scene The scene to load into
  105349. * @param data The data to import
  105350. * @param rootUrl The root url for scene and resources
  105351. * @param onProgress The callback when the load progresses
  105352. * @param fileName Defines the name of the file to load
  105353. * @returns The loaded asset container
  105354. */
  105355. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105356. }
  105357. /**
  105358. * Class used to load scene from various file formats using registered plugins
  105359. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105360. */
  105361. export class SceneLoader {
  105362. /**
  105363. * No logging while loading
  105364. */
  105365. static readonly NO_LOGGING: number;
  105366. /**
  105367. * Minimal logging while loading
  105368. */
  105369. static readonly MINIMAL_LOGGING: number;
  105370. /**
  105371. * Summary logging while loading
  105372. */
  105373. static readonly SUMMARY_LOGGING: number;
  105374. /**
  105375. * Detailled logging while loading
  105376. */
  105377. static readonly DETAILED_LOGGING: number;
  105378. /**
  105379. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105380. */
  105381. static ForceFullSceneLoadingForIncremental: boolean;
  105382. /**
  105383. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105384. */
  105385. static ShowLoadingScreen: boolean;
  105386. /**
  105387. * Defines the current logging level (while loading the scene)
  105388. * @ignorenaming
  105389. */
  105390. static loggingLevel: number;
  105391. /**
  105392. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105393. */
  105394. static CleanBoneMatrixWeights: boolean;
  105395. /**
  105396. * Event raised when a plugin is used to load a scene
  105397. */
  105398. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105399. private static _registeredPlugins;
  105400. private static _getDefaultPlugin;
  105401. private static _getPluginForExtension;
  105402. private static _getPluginForDirectLoad;
  105403. private static _getPluginForFilename;
  105404. private static _getDirectLoad;
  105405. private static _loadData;
  105406. private static _getFileInfo;
  105407. /**
  105408. * Gets a plugin that can load the given extension
  105409. * @param extension defines the extension to load
  105410. * @returns a plugin or null if none works
  105411. */
  105412. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105413. /**
  105414. * Gets a boolean indicating that the given extension can be loaded
  105415. * @param extension defines the extension to load
  105416. * @returns true if the extension is supported
  105417. */
  105418. static IsPluginForExtensionAvailable(extension: string): boolean;
  105419. /**
  105420. * Adds a new plugin to the list of registered plugins
  105421. * @param plugin defines the plugin to add
  105422. */
  105423. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105424. /**
  105425. * Import meshes into a scene
  105426. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105427. * @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)
  105428. * @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)
  105429. * @param scene the instance of BABYLON.Scene to append to
  105430. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105431. * @param onProgress a callback with a progress event for each file being loaded
  105432. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105433. * @param pluginExtension the extension used to determine the plugin
  105434. * @returns The loaded plugin
  105435. */
  105436. 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>;
  105437. /**
  105438. * Import meshes into a scene
  105439. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105440. * @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)
  105441. * @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)
  105442. * @param scene the instance of BABYLON.Scene to append to
  105443. * @param onProgress a callback with a progress event for each file being loaded
  105444. * @param pluginExtension the extension used to determine the plugin
  105445. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105446. */
  105447. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105448. meshes: AbstractMesh[];
  105449. particleSystems: IParticleSystem[];
  105450. skeletons: Skeleton[];
  105451. animationGroups: AnimationGroup[];
  105452. }>;
  105453. /**
  105454. * Load a scene
  105455. * @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)
  105456. * @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)
  105457. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105458. * @param onSuccess a callback with the scene when import succeeds
  105459. * @param onProgress a callback with a progress event for each file being loaded
  105460. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105461. * @param pluginExtension the extension used to determine the plugin
  105462. * @returns The loaded plugin
  105463. */
  105464. 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>;
  105465. /**
  105466. * Load a scene
  105467. * @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)
  105468. * @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)
  105469. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105470. * @param onProgress a callback with a progress event for each file being loaded
  105471. * @param pluginExtension the extension used to determine the plugin
  105472. * @returns The loaded scene
  105473. */
  105474. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105475. /**
  105476. * Append a scene
  105477. * @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)
  105478. * @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)
  105479. * @param scene is the instance of BABYLON.Scene to append to
  105480. * @param onSuccess a callback with the scene when import succeeds
  105481. * @param onProgress a callback with a progress event for each file being loaded
  105482. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105483. * @param pluginExtension the extension used to determine the plugin
  105484. * @returns The loaded plugin
  105485. */
  105486. 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>;
  105487. /**
  105488. * Append a scene
  105489. * @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)
  105490. * @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)
  105491. * @param scene is the instance of BABYLON.Scene to append to
  105492. * @param onProgress a callback with a progress event for each file being loaded
  105493. * @param pluginExtension the extension used to determine the plugin
  105494. * @returns The given scene
  105495. */
  105496. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105497. /**
  105498. * Load a scene into an asset container
  105499. * @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)
  105500. * @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)
  105501. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105502. * @param onSuccess a callback with the scene when import succeeds
  105503. * @param onProgress a callback with a progress event for each file being loaded
  105504. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105505. * @param pluginExtension the extension used to determine the plugin
  105506. * @returns The loaded plugin
  105507. */
  105508. 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>;
  105509. /**
  105510. * Load a scene into an asset container
  105511. * @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)
  105512. * @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)
  105513. * @param scene is the instance of Scene to append to
  105514. * @param onProgress a callback with a progress event for each file being loaded
  105515. * @param pluginExtension the extension used to determine the plugin
  105516. * @returns The loaded asset container
  105517. */
  105518. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105519. }
  105520. }
  105521. declare module BABYLON {
  105522. /**
  105523. * Google Daydream controller
  105524. */
  105525. export class DaydreamController extends WebVRController {
  105526. /**
  105527. * Base Url for the controller model.
  105528. */
  105529. static MODEL_BASE_URL: string;
  105530. /**
  105531. * File name for the controller model.
  105532. */
  105533. static MODEL_FILENAME: string;
  105534. /**
  105535. * Gamepad Id prefix used to identify Daydream Controller.
  105536. */
  105537. static readonly GAMEPAD_ID_PREFIX: string;
  105538. /**
  105539. * Creates a new DaydreamController from a gamepad
  105540. * @param vrGamepad the gamepad that the controller should be created from
  105541. */
  105542. constructor(vrGamepad: any);
  105543. /**
  105544. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105545. * @param scene scene in which to add meshes
  105546. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105547. */
  105548. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105549. /**
  105550. * Called once for each button that changed state since the last frame
  105551. * @param buttonIdx Which button index changed
  105552. * @param state New state of the button
  105553. * @param changes Which properties on the state changed since last frame
  105554. */
  105555. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105556. }
  105557. }
  105558. declare module BABYLON {
  105559. /**
  105560. * Gear VR Controller
  105561. */
  105562. export class GearVRController extends WebVRController {
  105563. /**
  105564. * Base Url for the controller model.
  105565. */
  105566. static MODEL_BASE_URL: string;
  105567. /**
  105568. * File name for the controller model.
  105569. */
  105570. static MODEL_FILENAME: string;
  105571. /**
  105572. * Gamepad Id prefix used to identify this controller.
  105573. */
  105574. static readonly GAMEPAD_ID_PREFIX: string;
  105575. private readonly _buttonIndexToObservableNameMap;
  105576. /**
  105577. * Creates a new GearVRController from a gamepad
  105578. * @param vrGamepad the gamepad that the controller should be created from
  105579. */
  105580. constructor(vrGamepad: any);
  105581. /**
  105582. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105583. * @param scene scene in which to add meshes
  105584. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105585. */
  105586. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105587. /**
  105588. * Called once for each button that changed state since the last frame
  105589. * @param buttonIdx Which button index changed
  105590. * @param state New state of the button
  105591. * @param changes Which properties on the state changed since last frame
  105592. */
  105593. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105594. }
  105595. }
  105596. declare module BABYLON {
  105597. /**
  105598. * Generic Controller
  105599. */
  105600. export class GenericController extends WebVRController {
  105601. /**
  105602. * Base Url for the controller model.
  105603. */
  105604. static readonly MODEL_BASE_URL: string;
  105605. /**
  105606. * File name for the controller model.
  105607. */
  105608. static readonly MODEL_FILENAME: string;
  105609. /**
  105610. * Creates a new GenericController from a gamepad
  105611. * @param vrGamepad the gamepad that the controller should be created from
  105612. */
  105613. constructor(vrGamepad: any);
  105614. /**
  105615. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105616. * @param scene scene in which to add meshes
  105617. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105618. */
  105619. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105620. /**
  105621. * Called once for each button that changed state since the last frame
  105622. * @param buttonIdx Which button index changed
  105623. * @param state New state of the button
  105624. * @param changes Which properties on the state changed since last frame
  105625. */
  105626. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105627. }
  105628. }
  105629. declare module BABYLON {
  105630. /**
  105631. * Oculus Touch Controller
  105632. */
  105633. export class OculusTouchController extends WebVRController {
  105634. /**
  105635. * Base Url for the controller model.
  105636. */
  105637. static MODEL_BASE_URL: string;
  105638. /**
  105639. * File name for the left controller model.
  105640. */
  105641. static MODEL_LEFT_FILENAME: string;
  105642. /**
  105643. * File name for the right controller model.
  105644. */
  105645. static MODEL_RIGHT_FILENAME: string;
  105646. /**
  105647. * Base Url for the Quest controller model.
  105648. */
  105649. static QUEST_MODEL_BASE_URL: string;
  105650. /**
  105651. * @hidden
  105652. * If the controllers are running on a device that needs the updated Quest controller models
  105653. */
  105654. static _IsQuest: boolean;
  105655. /**
  105656. * Fired when the secondary trigger on this controller is modified
  105657. */
  105658. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105659. /**
  105660. * Fired when the thumb rest on this controller is modified
  105661. */
  105662. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105663. /**
  105664. * Creates a new OculusTouchController from a gamepad
  105665. * @param vrGamepad the gamepad that the controller should be created from
  105666. */
  105667. constructor(vrGamepad: any);
  105668. /**
  105669. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105670. * @param scene scene in which to add meshes
  105671. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105672. */
  105673. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105674. /**
  105675. * Fired when the A button on this controller is modified
  105676. */
  105677. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105678. /**
  105679. * Fired when the B button on this controller is modified
  105680. */
  105681. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105682. /**
  105683. * Fired when the X button on this controller is modified
  105684. */
  105685. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105686. /**
  105687. * Fired when the Y button on this controller is modified
  105688. */
  105689. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105690. /**
  105691. * Called once for each button that changed state since the last frame
  105692. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105693. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105694. * 2) secondary trigger (same)
  105695. * 3) A (right) X (left), touch, pressed = value
  105696. * 4) B / Y
  105697. * 5) thumb rest
  105698. * @param buttonIdx Which button index changed
  105699. * @param state New state of the button
  105700. * @param changes Which properties on the state changed since last frame
  105701. */
  105702. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105703. }
  105704. }
  105705. declare module BABYLON {
  105706. /**
  105707. * Vive Controller
  105708. */
  105709. export class ViveController extends WebVRController {
  105710. /**
  105711. * Base Url for the controller model.
  105712. */
  105713. static MODEL_BASE_URL: string;
  105714. /**
  105715. * File name for the controller model.
  105716. */
  105717. static MODEL_FILENAME: string;
  105718. /**
  105719. * Creates a new ViveController from a gamepad
  105720. * @param vrGamepad the gamepad that the controller should be created from
  105721. */
  105722. constructor(vrGamepad: any);
  105723. /**
  105724. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105725. * @param scene scene in which to add meshes
  105726. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105727. */
  105728. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105729. /**
  105730. * Fired when the left button on this controller is modified
  105731. */
  105732. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105733. /**
  105734. * Fired when the right button on this controller is modified
  105735. */
  105736. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105737. /**
  105738. * Fired when the menu button on this controller is modified
  105739. */
  105740. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105741. /**
  105742. * Called once for each button that changed state since the last frame
  105743. * Vive mapping:
  105744. * 0: touchpad
  105745. * 1: trigger
  105746. * 2: left AND right buttons
  105747. * 3: menu button
  105748. * @param buttonIdx Which button index changed
  105749. * @param state New state of the button
  105750. * @param changes Which properties on the state changed since last frame
  105751. */
  105752. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105753. }
  105754. }
  105755. declare module BABYLON {
  105756. /**
  105757. * Defines the WindowsMotionController object that the state of the windows motion controller
  105758. */
  105759. export class WindowsMotionController extends WebVRController {
  105760. /**
  105761. * The base url used to load the left and right controller models
  105762. */
  105763. static MODEL_BASE_URL: string;
  105764. /**
  105765. * The name of the left controller model file
  105766. */
  105767. static MODEL_LEFT_FILENAME: string;
  105768. /**
  105769. * The name of the right controller model file
  105770. */
  105771. static MODEL_RIGHT_FILENAME: string;
  105772. /**
  105773. * The controller name prefix for this controller type
  105774. */
  105775. static readonly GAMEPAD_ID_PREFIX: string;
  105776. /**
  105777. * The controller id pattern for this controller type
  105778. */
  105779. private static readonly GAMEPAD_ID_PATTERN;
  105780. private _loadedMeshInfo;
  105781. private readonly _mapping;
  105782. /**
  105783. * Fired when the trackpad on this controller is clicked
  105784. */
  105785. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105786. /**
  105787. * Fired when the trackpad on this controller is modified
  105788. */
  105789. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105790. /**
  105791. * The current x and y values of this controller's trackpad
  105792. */
  105793. trackpad: StickValues;
  105794. /**
  105795. * Creates a new WindowsMotionController from a gamepad
  105796. * @param vrGamepad the gamepad that the controller should be created from
  105797. */
  105798. constructor(vrGamepad: any);
  105799. /**
  105800. * Fired when the trigger on this controller is modified
  105801. */
  105802. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105803. /**
  105804. * Fired when the menu button on this controller is modified
  105805. */
  105806. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105807. /**
  105808. * Fired when the grip button on this controller is modified
  105809. */
  105810. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105811. /**
  105812. * Fired when the thumbstick button on this controller is modified
  105813. */
  105814. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105815. /**
  105816. * Fired when the touchpad button on this controller is modified
  105817. */
  105818. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105819. /**
  105820. * Fired when the touchpad values on this controller are modified
  105821. */
  105822. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105823. private _updateTrackpad;
  105824. /**
  105825. * Called once per frame by the engine.
  105826. */
  105827. update(): void;
  105828. /**
  105829. * Called once for each button that changed state since the last frame
  105830. * @param buttonIdx Which button index changed
  105831. * @param state New state of the button
  105832. * @param changes Which properties on the state changed since last frame
  105833. */
  105834. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105835. /**
  105836. * Moves the buttons on the controller mesh based on their current state
  105837. * @param buttonName the name of the button to move
  105838. * @param buttonValue the value of the button which determines the buttons new position
  105839. */
  105840. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105841. /**
  105842. * Moves the axis on the controller mesh based on its current state
  105843. * @param axis the index of the axis
  105844. * @param axisValue the value of the axis which determines the meshes new position
  105845. * @hidden
  105846. */
  105847. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105848. /**
  105849. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105850. * @param scene scene in which to add meshes
  105851. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105852. */
  105853. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105854. /**
  105855. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105856. * can be transformed by button presses and axes values, based on this._mapping.
  105857. *
  105858. * @param scene scene in which the meshes exist
  105859. * @param meshes list of meshes that make up the controller model to process
  105860. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105861. */
  105862. private processModel;
  105863. private createMeshInfo;
  105864. /**
  105865. * Gets the ray of the controller in the direction the controller is pointing
  105866. * @param length the length the resulting ray should be
  105867. * @returns a ray in the direction the controller is pointing
  105868. */
  105869. getForwardRay(length?: number): Ray;
  105870. /**
  105871. * Disposes of the controller
  105872. */
  105873. dispose(): void;
  105874. }
  105875. }
  105876. declare module BABYLON {
  105877. /**
  105878. * Class containing static functions to help procedurally build meshes
  105879. */
  105880. export class PolyhedronBuilder {
  105881. /**
  105882. * Creates a polyhedron mesh
  105883. * * 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
  105884. * * The parameter `size` (positive float, default 1) sets the polygon size
  105885. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105886. * * 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`
  105887. * * 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
  105888. * * 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)`)
  105889. * * 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
  105890. * * 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
  105891. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105892. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105894. * @param name defines the name of the mesh
  105895. * @param options defines the options used to create the mesh
  105896. * @param scene defines the hosting scene
  105897. * @returns the polyhedron mesh
  105898. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  105899. */
  105900. static CreatePolyhedron(name: string, options: {
  105901. type?: number;
  105902. size?: number;
  105903. sizeX?: number;
  105904. sizeY?: number;
  105905. sizeZ?: number;
  105906. custom?: any;
  105907. faceUV?: Vector4[];
  105908. faceColors?: Color4[];
  105909. flat?: boolean;
  105910. updatable?: boolean;
  105911. sideOrientation?: number;
  105912. frontUVs?: Vector4;
  105913. backUVs?: Vector4;
  105914. }, scene?: Nullable<Scene>): Mesh;
  105915. }
  105916. }
  105917. declare module BABYLON {
  105918. /**
  105919. * Gizmo that enables scaling a mesh along 3 axis
  105920. */
  105921. export class ScaleGizmo extends Gizmo {
  105922. /**
  105923. * Internal gizmo used for interactions on the x axis
  105924. */
  105925. xGizmo: AxisScaleGizmo;
  105926. /**
  105927. * Internal gizmo used for interactions on the y axis
  105928. */
  105929. yGizmo: AxisScaleGizmo;
  105930. /**
  105931. * Internal gizmo used for interactions on the z axis
  105932. */
  105933. zGizmo: AxisScaleGizmo;
  105934. /**
  105935. * Internal gizmo used to scale all axis equally
  105936. */
  105937. uniformScaleGizmo: AxisScaleGizmo;
  105938. private _meshAttached;
  105939. private _updateGizmoRotationToMatchAttachedMesh;
  105940. private _snapDistance;
  105941. private _scaleRatio;
  105942. private _uniformScalingMesh;
  105943. private _octahedron;
  105944. /** Fires an event when any of it's sub gizmos are dragged */
  105945. onDragStartObservable: Observable<unknown>;
  105946. /** Fires an event when any of it's sub gizmos are released from dragging */
  105947. onDragEndObservable: Observable<unknown>;
  105948. attachedMesh: Nullable<AbstractMesh>;
  105949. /**
  105950. * Creates a ScaleGizmo
  105951. * @param gizmoLayer The utility layer the gizmo will be added to
  105952. */
  105953. constructor(gizmoLayer?: UtilityLayerRenderer);
  105954. updateGizmoRotationToMatchAttachedMesh: boolean;
  105955. /**
  105956. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105957. */
  105958. snapDistance: number;
  105959. /**
  105960. * Ratio for the scale of the gizmo (Default: 1)
  105961. */
  105962. scaleRatio: number;
  105963. /**
  105964. * Disposes of the gizmo
  105965. */
  105966. dispose(): void;
  105967. }
  105968. }
  105969. declare module BABYLON {
  105970. /**
  105971. * Single axis scale gizmo
  105972. */
  105973. export class AxisScaleGizmo extends Gizmo {
  105974. /**
  105975. * Drag behavior responsible for the gizmos dragging interactions
  105976. */
  105977. dragBehavior: PointerDragBehavior;
  105978. private _pointerObserver;
  105979. /**
  105980. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105981. */
  105982. snapDistance: number;
  105983. /**
  105984. * Event that fires each time the gizmo snaps to a new location.
  105985. * * snapDistance is the the change in distance
  105986. */
  105987. onSnapObservable: Observable<{
  105988. snapDistance: number;
  105989. }>;
  105990. /**
  105991. * If the scaling operation should be done on all axis (default: false)
  105992. */
  105993. uniformScaling: boolean;
  105994. private _isEnabled;
  105995. private _parent;
  105996. private _arrow;
  105997. private _coloredMaterial;
  105998. private _hoverMaterial;
  105999. /**
  106000. * Creates an AxisScaleGizmo
  106001. * @param gizmoLayer The utility layer the gizmo will be added to
  106002. * @param dragAxis The axis which the gizmo will be able to scale on
  106003. * @param color The color of the gizmo
  106004. */
  106005. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  106006. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106007. /**
  106008. * If the gizmo is enabled
  106009. */
  106010. isEnabled: boolean;
  106011. /**
  106012. * Disposes of the gizmo
  106013. */
  106014. dispose(): void;
  106015. /**
  106016. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  106017. * @param mesh The mesh to replace the default mesh of the gizmo
  106018. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  106019. */
  106020. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  106021. }
  106022. }
  106023. declare module BABYLON {
  106024. /**
  106025. * Bounding box gizmo
  106026. */
  106027. export class BoundingBoxGizmo extends Gizmo {
  106028. private _lineBoundingBox;
  106029. private _rotateSpheresParent;
  106030. private _scaleBoxesParent;
  106031. private _boundingDimensions;
  106032. private _renderObserver;
  106033. private _pointerObserver;
  106034. private _scaleDragSpeed;
  106035. private _tmpQuaternion;
  106036. private _tmpVector;
  106037. private _tmpRotationMatrix;
  106038. /**
  106039. * 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)
  106040. */
  106041. ignoreChildren: boolean;
  106042. /**
  106043. * 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)
  106044. */
  106045. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  106046. /**
  106047. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  106048. */
  106049. rotationSphereSize: number;
  106050. /**
  106051. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  106052. */
  106053. scaleBoxSize: number;
  106054. /**
  106055. * 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)
  106056. */
  106057. fixedDragMeshScreenSize: boolean;
  106058. /**
  106059. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  106060. */
  106061. fixedDragMeshScreenSizeDistanceFactor: number;
  106062. /**
  106063. * Fired when a rotation sphere or scale box is dragged
  106064. */
  106065. onDragStartObservable: Observable<{}>;
  106066. /**
  106067. * Fired when a scale box is dragged
  106068. */
  106069. onScaleBoxDragObservable: Observable<{}>;
  106070. /**
  106071. * Fired when a scale box drag is ended
  106072. */
  106073. onScaleBoxDragEndObservable: Observable<{}>;
  106074. /**
  106075. * Fired when a rotation sphere is dragged
  106076. */
  106077. onRotationSphereDragObservable: Observable<{}>;
  106078. /**
  106079. * Fired when a rotation sphere drag is ended
  106080. */
  106081. onRotationSphereDragEndObservable: Observable<{}>;
  106082. /**
  106083. * 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)
  106084. */
  106085. scalePivot: Nullable<Vector3>;
  106086. /**
  106087. * Mesh used as a pivot to rotate the attached mesh
  106088. */
  106089. private _anchorMesh;
  106090. private _existingMeshScale;
  106091. private _dragMesh;
  106092. private pointerDragBehavior;
  106093. private coloredMaterial;
  106094. private hoverColoredMaterial;
  106095. /**
  106096. * Sets the color of the bounding box gizmo
  106097. * @param color the color to set
  106098. */
  106099. setColor(color: Color3): void;
  106100. /**
  106101. * Creates an BoundingBoxGizmo
  106102. * @param gizmoLayer The utility layer the gizmo will be added to
  106103. * @param color The color of the gizmo
  106104. */
  106105. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  106106. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106107. private _selectNode;
  106108. /**
  106109. * Updates the bounding box information for the Gizmo
  106110. */
  106111. updateBoundingBox(): void;
  106112. private _updateRotationSpheres;
  106113. private _updateScaleBoxes;
  106114. /**
  106115. * Enables rotation on the specified axis and disables rotation on the others
  106116. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  106117. */
  106118. setEnabledRotationAxis(axis: string): void;
  106119. /**
  106120. * Enables/disables scaling
  106121. * @param enable if scaling should be enabled
  106122. */
  106123. setEnabledScaling(enable: boolean): void;
  106124. private _updateDummy;
  106125. /**
  106126. * Enables a pointer drag behavior on the bounding box of the gizmo
  106127. */
  106128. enableDragBehavior(): void;
  106129. /**
  106130. * Disposes of the gizmo
  106131. */
  106132. dispose(): void;
  106133. /**
  106134. * 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)
  106135. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  106136. * @returns the bounding box mesh with the passed in mesh as a child
  106137. */
  106138. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  106139. /**
  106140. * CustomMeshes are not supported by this gizmo
  106141. * @param mesh The mesh to replace the default mesh of the gizmo
  106142. */
  106143. setCustomMesh(mesh: Mesh): void;
  106144. }
  106145. }
  106146. declare module BABYLON {
  106147. /**
  106148. * Single plane rotation gizmo
  106149. */
  106150. export class PlaneRotationGizmo extends Gizmo {
  106151. /**
  106152. * Drag behavior responsible for the gizmos dragging interactions
  106153. */
  106154. dragBehavior: PointerDragBehavior;
  106155. private _pointerObserver;
  106156. /**
  106157. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  106158. */
  106159. snapDistance: number;
  106160. /**
  106161. * Event that fires each time the gizmo snaps to a new location.
  106162. * * snapDistance is the the change in distance
  106163. */
  106164. onSnapObservable: Observable<{
  106165. snapDistance: number;
  106166. }>;
  106167. private _isEnabled;
  106168. private _parent;
  106169. /**
  106170. * Creates a PlaneRotationGizmo
  106171. * @param gizmoLayer The utility layer the gizmo will be added to
  106172. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  106173. * @param color The color of the gizmo
  106174. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106175. */
  106176. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  106177. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106178. /**
  106179. * If the gizmo is enabled
  106180. */
  106181. isEnabled: boolean;
  106182. /**
  106183. * Disposes of the gizmo
  106184. */
  106185. dispose(): void;
  106186. }
  106187. }
  106188. declare module BABYLON {
  106189. /**
  106190. * Gizmo that enables rotating a mesh along 3 axis
  106191. */
  106192. export class RotationGizmo extends Gizmo {
  106193. /**
  106194. * Internal gizmo used for interactions on the x axis
  106195. */
  106196. xGizmo: PlaneRotationGizmo;
  106197. /**
  106198. * Internal gizmo used for interactions on the y axis
  106199. */
  106200. yGizmo: PlaneRotationGizmo;
  106201. /**
  106202. * Internal gizmo used for interactions on the z axis
  106203. */
  106204. zGizmo: PlaneRotationGizmo;
  106205. /** Fires an event when any of it's sub gizmos are dragged */
  106206. onDragStartObservable: Observable<unknown>;
  106207. /** Fires an event when any of it's sub gizmos are released from dragging */
  106208. onDragEndObservable: Observable<unknown>;
  106209. private _meshAttached;
  106210. attachedMesh: Nullable<AbstractMesh>;
  106211. /**
  106212. * Creates a RotationGizmo
  106213. * @param gizmoLayer The utility layer the gizmo will be added to
  106214. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106215. */
  106216. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  106217. updateGizmoRotationToMatchAttachedMesh: boolean;
  106218. /**
  106219. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106220. */
  106221. snapDistance: number;
  106222. /**
  106223. * Ratio for the scale of the gizmo (Default: 1)
  106224. */
  106225. scaleRatio: number;
  106226. /**
  106227. * Disposes of the gizmo
  106228. */
  106229. dispose(): void;
  106230. /**
  106231. * CustomMeshes are not supported by this gizmo
  106232. * @param mesh The mesh to replace the default mesh of the gizmo
  106233. */
  106234. setCustomMesh(mesh: Mesh): void;
  106235. }
  106236. }
  106237. declare module BABYLON {
  106238. /**
  106239. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  106240. */
  106241. export class GizmoManager implements IDisposable {
  106242. private scene;
  106243. /**
  106244. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  106245. */
  106246. gizmos: {
  106247. positionGizmo: Nullable<PositionGizmo>;
  106248. rotationGizmo: Nullable<RotationGizmo>;
  106249. scaleGizmo: Nullable<ScaleGizmo>;
  106250. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  106251. };
  106252. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  106253. clearGizmoOnEmptyPointerEvent: boolean;
  106254. /** Fires an event when the manager is attached to a mesh */
  106255. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  106256. private _gizmosEnabled;
  106257. private _pointerObserver;
  106258. private _attachedMesh;
  106259. private _boundingBoxColor;
  106260. private _defaultUtilityLayer;
  106261. private _defaultKeepDepthUtilityLayer;
  106262. /**
  106263. * When bounding box gizmo is enabled, this can be used to track drag/end events
  106264. */
  106265. boundingBoxDragBehavior: SixDofDragBehavior;
  106266. /**
  106267. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  106268. */
  106269. attachableMeshes: Nullable<Array<AbstractMesh>>;
  106270. /**
  106271. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  106272. */
  106273. usePointerToAttachGizmos: boolean;
  106274. /**
  106275. * Utility layer that the bounding box gizmo belongs to
  106276. */
  106277. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  106278. /**
  106279. * Utility layer that all gizmos besides bounding box belong to
  106280. */
  106281. readonly utilityLayer: UtilityLayerRenderer;
  106282. /**
  106283. * Instatiates a gizmo manager
  106284. * @param scene the scene to overlay the gizmos on top of
  106285. */
  106286. constructor(scene: Scene);
  106287. /**
  106288. * Attaches a set of gizmos to the specified mesh
  106289. * @param mesh The mesh the gizmo's should be attached to
  106290. */
  106291. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  106292. /**
  106293. * If the position gizmo is enabled
  106294. */
  106295. positionGizmoEnabled: boolean;
  106296. /**
  106297. * If the rotation gizmo is enabled
  106298. */
  106299. rotationGizmoEnabled: boolean;
  106300. /**
  106301. * If the scale gizmo is enabled
  106302. */
  106303. scaleGizmoEnabled: boolean;
  106304. /**
  106305. * If the boundingBox gizmo is enabled
  106306. */
  106307. boundingBoxGizmoEnabled: boolean;
  106308. /**
  106309. * Disposes of the gizmo manager
  106310. */
  106311. dispose(): void;
  106312. }
  106313. }
  106314. declare module BABYLON {
  106315. /**
  106316. * A directional light is defined by a direction (what a surprise!).
  106317. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  106318. * 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.
  106319. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106320. */
  106321. export class DirectionalLight extends ShadowLight {
  106322. private _shadowFrustumSize;
  106323. /**
  106324. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  106325. */
  106326. /**
  106327. * Specifies a fix frustum size for the shadow generation.
  106328. */
  106329. shadowFrustumSize: number;
  106330. private _shadowOrthoScale;
  106331. /**
  106332. * Gets the shadow projection scale against the optimal computed one.
  106333. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106334. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106335. */
  106336. /**
  106337. * Sets the shadow projection scale against the optimal computed one.
  106338. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106339. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106340. */
  106341. shadowOrthoScale: number;
  106342. /**
  106343. * Automatically compute the projection matrix to best fit (including all the casters)
  106344. * on each frame.
  106345. */
  106346. autoUpdateExtends: boolean;
  106347. private _orthoLeft;
  106348. private _orthoRight;
  106349. private _orthoTop;
  106350. private _orthoBottom;
  106351. /**
  106352. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  106353. * The directional light is emitted from everywhere in the given direction.
  106354. * It can cast shadows.
  106355. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106356. * @param name The friendly name of the light
  106357. * @param direction The direction of the light
  106358. * @param scene The scene the light belongs to
  106359. */
  106360. constructor(name: string, direction: Vector3, scene: Scene);
  106361. /**
  106362. * Returns the string "DirectionalLight".
  106363. * @return The class name
  106364. */
  106365. getClassName(): string;
  106366. /**
  106367. * Returns the integer 1.
  106368. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106369. */
  106370. getTypeID(): number;
  106371. /**
  106372. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  106373. * Returns the DirectionalLight Shadow projection matrix.
  106374. */
  106375. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106376. /**
  106377. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  106378. * Returns the DirectionalLight Shadow projection matrix.
  106379. */
  106380. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  106381. /**
  106382. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  106383. * Returns the DirectionalLight Shadow projection matrix.
  106384. */
  106385. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106386. protected _buildUniformLayout(): void;
  106387. /**
  106388. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  106389. * @param effect The effect to update
  106390. * @param lightIndex The index of the light in the effect to update
  106391. * @returns The directional light
  106392. */
  106393. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  106394. /**
  106395. * Gets the minZ used for shadow according to both the scene and the light.
  106396. *
  106397. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106398. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106399. * @param activeCamera The camera we are returning the min for
  106400. * @returns the depth min z
  106401. */
  106402. getDepthMinZ(activeCamera: Camera): number;
  106403. /**
  106404. * Gets the maxZ used for shadow according to both the scene and the light.
  106405. *
  106406. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106407. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106408. * @param activeCamera The camera we are returning the max for
  106409. * @returns the depth max z
  106410. */
  106411. getDepthMaxZ(activeCamera: Camera): number;
  106412. /**
  106413. * Prepares the list of defines specific to the light type.
  106414. * @param defines the list of defines
  106415. * @param lightIndex defines the index of the light for the effect
  106416. */
  106417. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106418. }
  106419. }
  106420. declare module BABYLON {
  106421. /**
  106422. * Class containing static functions to help procedurally build meshes
  106423. */
  106424. export class HemisphereBuilder {
  106425. /**
  106426. * Creates a hemisphere mesh
  106427. * @param name defines the name of the mesh
  106428. * @param options defines the options used to create the mesh
  106429. * @param scene defines the hosting scene
  106430. * @returns the hemisphere mesh
  106431. */
  106432. static CreateHemisphere(name: string, options: {
  106433. segments?: number;
  106434. diameter?: number;
  106435. sideOrientation?: number;
  106436. }, scene: any): Mesh;
  106437. }
  106438. }
  106439. declare module BABYLON {
  106440. /**
  106441. * A spot light is defined by a position, a direction, an angle, and an exponent.
  106442. * These values define a cone of light starting from the position, emitting toward the direction.
  106443. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  106444. * and the exponent defines the speed of the decay of the light with distance (reach).
  106445. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106446. */
  106447. export class SpotLight extends ShadowLight {
  106448. private _angle;
  106449. private _innerAngle;
  106450. private _cosHalfAngle;
  106451. private _lightAngleScale;
  106452. private _lightAngleOffset;
  106453. /**
  106454. * Gets the cone angle of the spot light in Radians.
  106455. */
  106456. /**
  106457. * Sets the cone angle of the spot light in Radians.
  106458. */
  106459. angle: number;
  106460. /**
  106461. * Only used in gltf falloff mode, this defines the angle where
  106462. * the directional falloff will start before cutting at angle which could be seen
  106463. * as outer angle.
  106464. */
  106465. /**
  106466. * Only used in gltf falloff mode, this defines the angle where
  106467. * the directional falloff will start before cutting at angle which could be seen
  106468. * as outer angle.
  106469. */
  106470. innerAngle: number;
  106471. private _shadowAngleScale;
  106472. /**
  106473. * Allows scaling the angle of the light for shadow generation only.
  106474. */
  106475. /**
  106476. * Allows scaling the angle of the light for shadow generation only.
  106477. */
  106478. shadowAngleScale: number;
  106479. /**
  106480. * The light decay speed with the distance from the emission spot.
  106481. */
  106482. exponent: number;
  106483. private _projectionTextureMatrix;
  106484. /**
  106485. * Allows reading the projecton texture
  106486. */
  106487. readonly projectionTextureMatrix: Matrix;
  106488. protected _projectionTextureLightNear: number;
  106489. /**
  106490. * Gets the near clip of the Spotlight for texture projection.
  106491. */
  106492. /**
  106493. * Sets the near clip of the Spotlight for texture projection.
  106494. */
  106495. projectionTextureLightNear: number;
  106496. protected _projectionTextureLightFar: number;
  106497. /**
  106498. * Gets the far clip of the Spotlight for texture projection.
  106499. */
  106500. /**
  106501. * Sets the far clip of the Spotlight for texture projection.
  106502. */
  106503. projectionTextureLightFar: number;
  106504. protected _projectionTextureUpDirection: Vector3;
  106505. /**
  106506. * Gets the Up vector of the Spotlight for texture projection.
  106507. */
  106508. /**
  106509. * Sets the Up vector of the Spotlight for texture projection.
  106510. */
  106511. projectionTextureUpDirection: Vector3;
  106512. private _projectionTexture;
  106513. /**
  106514. * Gets the projection texture of the light.
  106515. */
  106516. /**
  106517. * Sets the projection texture of the light.
  106518. */
  106519. projectionTexture: Nullable<BaseTexture>;
  106520. private _projectionTextureViewLightDirty;
  106521. private _projectionTextureProjectionLightDirty;
  106522. private _projectionTextureDirty;
  106523. private _projectionTextureViewTargetVector;
  106524. private _projectionTextureViewLightMatrix;
  106525. private _projectionTextureProjectionLightMatrix;
  106526. private _projectionTextureScalingMatrix;
  106527. /**
  106528. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  106529. * It can cast shadows.
  106530. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106531. * @param name The light friendly name
  106532. * @param position The position of the spot light in the scene
  106533. * @param direction The direction of the light in the scene
  106534. * @param angle The cone angle of the light in Radians
  106535. * @param exponent The light decay speed with the distance from the emission spot
  106536. * @param scene The scene the lights belongs to
  106537. */
  106538. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  106539. /**
  106540. * Returns the string "SpotLight".
  106541. * @returns the class name
  106542. */
  106543. getClassName(): string;
  106544. /**
  106545. * Returns the integer 2.
  106546. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106547. */
  106548. getTypeID(): number;
  106549. /**
  106550. * Overrides the direction setter to recompute the projection texture view light Matrix.
  106551. */
  106552. protected _setDirection(value: Vector3): void;
  106553. /**
  106554. * Overrides the position setter to recompute the projection texture view light Matrix.
  106555. */
  106556. protected _setPosition(value: Vector3): void;
  106557. /**
  106558. * 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.
  106559. * Returns the SpotLight.
  106560. */
  106561. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106562. protected _computeProjectionTextureViewLightMatrix(): void;
  106563. protected _computeProjectionTextureProjectionLightMatrix(): void;
  106564. /**
  106565. * Main function for light texture projection matrix computing.
  106566. */
  106567. protected _computeProjectionTextureMatrix(): void;
  106568. protected _buildUniformLayout(): void;
  106569. private _computeAngleValues;
  106570. /**
  106571. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  106572. * @param effect The effect to update
  106573. * @param lightIndex The index of the light in the effect to update
  106574. * @returns The spot light
  106575. */
  106576. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  106577. /**
  106578. * Disposes the light and the associated resources.
  106579. */
  106580. dispose(): void;
  106581. /**
  106582. * Prepares the list of defines specific to the light type.
  106583. * @param defines the list of defines
  106584. * @param lightIndex defines the index of the light for the effect
  106585. */
  106586. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106587. }
  106588. }
  106589. declare module BABYLON {
  106590. /**
  106591. * Gizmo that enables viewing a light
  106592. */
  106593. export class LightGizmo extends Gizmo {
  106594. private _lightMesh;
  106595. private _material;
  106596. private cachedPosition;
  106597. private cachedForward;
  106598. /**
  106599. * Creates a LightGizmo
  106600. * @param gizmoLayer The utility layer the gizmo will be added to
  106601. */
  106602. constructor(gizmoLayer?: UtilityLayerRenderer);
  106603. private _light;
  106604. /**
  106605. * The light that the gizmo is attached to
  106606. */
  106607. light: Nullable<Light>;
  106608. /**
  106609. * @hidden
  106610. * Updates the gizmo to match the attached mesh's position/rotation
  106611. */
  106612. protected _update(): void;
  106613. private static _Scale;
  106614. /**
  106615. * Creates the lines for a light mesh
  106616. */
  106617. private static _createLightLines;
  106618. /**
  106619. * Disposes of the light gizmo
  106620. */
  106621. dispose(): void;
  106622. private static _CreateHemisphericLightMesh;
  106623. private static _CreatePointLightMesh;
  106624. private static _CreateSpotLightMesh;
  106625. private static _CreateDirectionalLightMesh;
  106626. }
  106627. }
  106628. declare module BABYLON {
  106629. /** @hidden */
  106630. export var backgroundFragmentDeclaration: {
  106631. name: string;
  106632. shader: string;
  106633. };
  106634. }
  106635. declare module BABYLON {
  106636. /** @hidden */
  106637. export var backgroundUboDeclaration: {
  106638. name: string;
  106639. shader: string;
  106640. };
  106641. }
  106642. declare module BABYLON {
  106643. /** @hidden */
  106644. export var backgroundPixelShader: {
  106645. name: string;
  106646. shader: string;
  106647. };
  106648. }
  106649. declare module BABYLON {
  106650. /** @hidden */
  106651. export var backgroundVertexDeclaration: {
  106652. name: string;
  106653. shader: string;
  106654. };
  106655. }
  106656. declare module BABYLON {
  106657. /** @hidden */
  106658. export var backgroundVertexShader: {
  106659. name: string;
  106660. shader: string;
  106661. };
  106662. }
  106663. declare module BABYLON {
  106664. /**
  106665. * Background material used to create an efficient environement around your scene.
  106666. */
  106667. export class BackgroundMaterial extends PushMaterial {
  106668. /**
  106669. * Standard reflectance value at parallel view angle.
  106670. */
  106671. static StandardReflectance0: number;
  106672. /**
  106673. * Standard reflectance value at grazing angle.
  106674. */
  106675. static StandardReflectance90: number;
  106676. protected _primaryColor: Color3;
  106677. /**
  106678. * Key light Color (multiply against the environement texture)
  106679. */
  106680. primaryColor: Color3;
  106681. protected __perceptualColor: Nullable<Color3>;
  106682. /**
  106683. * Experimental Internal Use Only.
  106684. *
  106685. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106686. * This acts as a helper to set the primary color to a more "human friendly" value.
  106687. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106688. * output color as close as possible from the chosen value.
  106689. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106690. * part of lighting setup.)
  106691. */
  106692. _perceptualColor: Nullable<Color3>;
  106693. protected _primaryColorShadowLevel: float;
  106694. /**
  106695. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106696. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106697. */
  106698. primaryColorShadowLevel: float;
  106699. protected _primaryColorHighlightLevel: float;
  106700. /**
  106701. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106702. * The primary color is used at the level chosen to define what the white area would look.
  106703. */
  106704. primaryColorHighlightLevel: float;
  106705. protected _reflectionTexture: Nullable<BaseTexture>;
  106706. /**
  106707. * Reflection Texture used in the material.
  106708. * Should be author in a specific way for the best result (refer to the documentation).
  106709. */
  106710. reflectionTexture: Nullable<BaseTexture>;
  106711. protected _reflectionBlur: float;
  106712. /**
  106713. * Reflection Texture level of blur.
  106714. *
  106715. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106716. * texture twice.
  106717. */
  106718. reflectionBlur: float;
  106719. protected _diffuseTexture: Nullable<BaseTexture>;
  106720. /**
  106721. * Diffuse Texture used in the material.
  106722. * Should be author in a specific way for the best result (refer to the documentation).
  106723. */
  106724. diffuseTexture: Nullable<BaseTexture>;
  106725. protected _shadowLights: Nullable<IShadowLight[]>;
  106726. /**
  106727. * Specify the list of lights casting shadow on the material.
  106728. * All scene shadow lights will be included if null.
  106729. */
  106730. shadowLights: Nullable<IShadowLight[]>;
  106731. protected _shadowLevel: float;
  106732. /**
  106733. * Helps adjusting the shadow to a softer level if required.
  106734. * 0 means black shadows and 1 means no shadows.
  106735. */
  106736. shadowLevel: float;
  106737. protected _sceneCenter: Vector3;
  106738. /**
  106739. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106740. * It is usually zero but might be interesting to modify according to your setup.
  106741. */
  106742. sceneCenter: Vector3;
  106743. protected _opacityFresnel: boolean;
  106744. /**
  106745. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106746. * This helps ensuring a nice transition when the camera goes under the ground.
  106747. */
  106748. opacityFresnel: boolean;
  106749. protected _reflectionFresnel: boolean;
  106750. /**
  106751. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  106752. * This helps adding a mirror texture on the ground.
  106753. */
  106754. reflectionFresnel: boolean;
  106755. protected _reflectionFalloffDistance: number;
  106756. /**
  106757. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  106758. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  106759. */
  106760. reflectionFalloffDistance: number;
  106761. protected _reflectionAmount: number;
  106762. /**
  106763. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  106764. */
  106765. reflectionAmount: number;
  106766. protected _reflectionReflectance0: number;
  106767. /**
  106768. * This specifies the weight of the reflection at grazing angle.
  106769. */
  106770. reflectionReflectance0: number;
  106771. protected _reflectionReflectance90: number;
  106772. /**
  106773. * This specifies the weight of the reflection at a perpendicular point of view.
  106774. */
  106775. reflectionReflectance90: number;
  106776. /**
  106777. * Sets the reflection reflectance fresnel values according to the default standard
  106778. * empirically know to work well :-)
  106779. */
  106780. reflectionStandardFresnelWeight: number;
  106781. protected _useRGBColor: boolean;
  106782. /**
  106783. * Helps to directly use the maps channels instead of their level.
  106784. */
  106785. useRGBColor: boolean;
  106786. protected _enableNoise: boolean;
  106787. /**
  106788. * This helps reducing the banding effect that could occur on the background.
  106789. */
  106790. enableNoise: boolean;
  106791. /**
  106792. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106793. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  106794. * Recommended to be keep at 1.0 except for special cases.
  106795. */
  106796. fovMultiplier: number;
  106797. private _fovMultiplier;
  106798. /**
  106799. * Enable the FOV adjustment feature controlled by fovMultiplier.
  106800. */
  106801. useEquirectangularFOV: boolean;
  106802. private _maxSimultaneousLights;
  106803. /**
  106804. * Number of Simultaneous lights allowed on the material.
  106805. */
  106806. maxSimultaneousLights: int;
  106807. /**
  106808. * Default configuration related to image processing available in the Background Material.
  106809. */
  106810. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106811. /**
  106812. * Keep track of the image processing observer to allow dispose and replace.
  106813. */
  106814. private _imageProcessingObserver;
  106815. /**
  106816. * Attaches a new image processing configuration to the PBR Material.
  106817. * @param configuration (if null the scene configuration will be use)
  106818. */
  106819. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106820. /**
  106821. * Gets the image processing configuration used either in this material.
  106822. */
  106823. /**
  106824. * Sets the Default image processing configuration used either in the this material.
  106825. *
  106826. * If sets to null, the scene one is in use.
  106827. */
  106828. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  106829. /**
  106830. * Gets wether the color curves effect is enabled.
  106831. */
  106832. /**
  106833. * Sets wether the color curves effect is enabled.
  106834. */
  106835. cameraColorCurvesEnabled: boolean;
  106836. /**
  106837. * Gets wether the color grading effect is enabled.
  106838. */
  106839. /**
  106840. * Gets wether the color grading effect is enabled.
  106841. */
  106842. cameraColorGradingEnabled: boolean;
  106843. /**
  106844. * Gets wether tonemapping is enabled or not.
  106845. */
  106846. /**
  106847. * Sets wether tonemapping is enabled or not
  106848. */
  106849. cameraToneMappingEnabled: boolean;
  106850. /**
  106851. * The camera exposure used on this material.
  106852. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106853. * This corresponds to a photographic exposure.
  106854. */
  106855. /**
  106856. * The camera exposure used on this material.
  106857. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106858. * This corresponds to a photographic exposure.
  106859. */
  106860. cameraExposure: float;
  106861. /**
  106862. * Gets The camera contrast used on this material.
  106863. */
  106864. /**
  106865. * Sets The camera contrast used on this material.
  106866. */
  106867. cameraContrast: float;
  106868. /**
  106869. * Gets the Color Grading 2D Lookup Texture.
  106870. */
  106871. /**
  106872. * Sets the Color Grading 2D Lookup Texture.
  106873. */
  106874. cameraColorGradingTexture: Nullable<BaseTexture>;
  106875. /**
  106876. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106877. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106878. * 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;
  106879. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106880. */
  106881. /**
  106882. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106883. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106884. * 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;
  106885. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106886. */
  106887. cameraColorCurves: Nullable<ColorCurves>;
  106888. /**
  106889. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  106890. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  106891. */
  106892. switchToBGR: boolean;
  106893. private _renderTargets;
  106894. private _reflectionControls;
  106895. private _white;
  106896. private _primaryShadowColor;
  106897. private _primaryHighlightColor;
  106898. /**
  106899. * Instantiates a Background Material in the given scene
  106900. * @param name The friendly name of the material
  106901. * @param scene The scene to add the material to
  106902. */
  106903. constructor(name: string, scene: Scene);
  106904. /**
  106905. * Gets a boolean indicating that current material needs to register RTT
  106906. */
  106907. readonly hasRenderTargetTextures: boolean;
  106908. /**
  106909. * The entire material has been created in order to prevent overdraw.
  106910. * @returns false
  106911. */
  106912. needAlphaTesting(): boolean;
  106913. /**
  106914. * The entire material has been created in order to prevent overdraw.
  106915. * @returns true if blending is enable
  106916. */
  106917. needAlphaBlending(): boolean;
  106918. /**
  106919. * Checks wether the material is ready to be rendered for a given mesh.
  106920. * @param mesh The mesh to render
  106921. * @param subMesh The submesh to check against
  106922. * @param useInstances Specify wether or not the material is used with instances
  106923. * @returns true if all the dependencies are ready (Textures, Effects...)
  106924. */
  106925. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106926. /**
  106927. * Compute the primary color according to the chosen perceptual color.
  106928. */
  106929. private _computePrimaryColorFromPerceptualColor;
  106930. /**
  106931. * Compute the highlights and shadow colors according to their chosen levels.
  106932. */
  106933. private _computePrimaryColors;
  106934. /**
  106935. * Build the uniform buffer used in the material.
  106936. */
  106937. buildUniformLayout(): void;
  106938. /**
  106939. * Unbind the material.
  106940. */
  106941. unbind(): void;
  106942. /**
  106943. * Bind only the world matrix to the material.
  106944. * @param world The world matrix to bind.
  106945. */
  106946. bindOnlyWorldMatrix(world: Matrix): void;
  106947. /**
  106948. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  106949. * @param world The world matrix to bind.
  106950. * @param subMesh The submesh to bind for.
  106951. */
  106952. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106953. /**
  106954. * Dispose the material.
  106955. * @param forceDisposeEffect Force disposal of the associated effect.
  106956. * @param forceDisposeTextures Force disposal of the associated textures.
  106957. */
  106958. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106959. /**
  106960. * Clones the material.
  106961. * @param name The cloned name.
  106962. * @returns The cloned material.
  106963. */
  106964. clone(name: string): BackgroundMaterial;
  106965. /**
  106966. * Serializes the current material to its JSON representation.
  106967. * @returns The JSON representation.
  106968. */
  106969. serialize(): any;
  106970. /**
  106971. * Gets the class name of the material
  106972. * @returns "BackgroundMaterial"
  106973. */
  106974. getClassName(): string;
  106975. /**
  106976. * Parse a JSON input to create back a background material.
  106977. * @param source The JSON data to parse
  106978. * @param scene The scene to create the parsed material in
  106979. * @param rootUrl The root url of the assets the material depends upon
  106980. * @returns the instantiated BackgroundMaterial.
  106981. */
  106982. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  106983. }
  106984. }
  106985. declare module BABYLON {
  106986. /**
  106987. * Represents the different options available during the creation of
  106988. * a Environment helper.
  106989. *
  106990. * This can control the default ground, skybox and image processing setup of your scene.
  106991. */
  106992. export interface IEnvironmentHelperOptions {
  106993. /**
  106994. * Specifies wether or not to create a ground.
  106995. * True by default.
  106996. */
  106997. createGround: boolean;
  106998. /**
  106999. * Specifies the ground size.
  107000. * 15 by default.
  107001. */
  107002. groundSize: number;
  107003. /**
  107004. * The texture used on the ground for the main color.
  107005. * Comes from the BabylonJS CDN by default.
  107006. *
  107007. * Remarks: Can be either a texture or a url.
  107008. */
  107009. groundTexture: string | BaseTexture;
  107010. /**
  107011. * The color mixed in the ground texture by default.
  107012. * BabylonJS clearColor by default.
  107013. */
  107014. groundColor: Color3;
  107015. /**
  107016. * Specifies the ground opacity.
  107017. * 1 by default.
  107018. */
  107019. groundOpacity: number;
  107020. /**
  107021. * Enables the ground to receive shadows.
  107022. * True by default.
  107023. */
  107024. enableGroundShadow: boolean;
  107025. /**
  107026. * Helps preventing the shadow to be fully black on the ground.
  107027. * 0.5 by default.
  107028. */
  107029. groundShadowLevel: number;
  107030. /**
  107031. * Creates a mirror texture attach to the ground.
  107032. * false by default.
  107033. */
  107034. enableGroundMirror: boolean;
  107035. /**
  107036. * Specifies the ground mirror size ratio.
  107037. * 0.3 by default as the default kernel is 64.
  107038. */
  107039. groundMirrorSizeRatio: number;
  107040. /**
  107041. * Specifies the ground mirror blur kernel size.
  107042. * 64 by default.
  107043. */
  107044. groundMirrorBlurKernel: number;
  107045. /**
  107046. * Specifies the ground mirror visibility amount.
  107047. * 1 by default
  107048. */
  107049. groundMirrorAmount: number;
  107050. /**
  107051. * Specifies the ground mirror reflectance weight.
  107052. * This uses the standard weight of the background material to setup the fresnel effect
  107053. * of the mirror.
  107054. * 1 by default.
  107055. */
  107056. groundMirrorFresnelWeight: number;
  107057. /**
  107058. * Specifies the ground mirror Falloff distance.
  107059. * This can helps reducing the size of the reflection.
  107060. * 0 by Default.
  107061. */
  107062. groundMirrorFallOffDistance: number;
  107063. /**
  107064. * Specifies the ground mirror texture type.
  107065. * Unsigned Int by Default.
  107066. */
  107067. groundMirrorTextureType: number;
  107068. /**
  107069. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  107070. * the shown objects.
  107071. */
  107072. groundYBias: number;
  107073. /**
  107074. * Specifies wether or not to create a skybox.
  107075. * True by default.
  107076. */
  107077. createSkybox: boolean;
  107078. /**
  107079. * Specifies the skybox size.
  107080. * 20 by default.
  107081. */
  107082. skyboxSize: number;
  107083. /**
  107084. * The texture used on the skybox for the main color.
  107085. * Comes from the BabylonJS CDN by default.
  107086. *
  107087. * Remarks: Can be either a texture or a url.
  107088. */
  107089. skyboxTexture: string | BaseTexture;
  107090. /**
  107091. * The color mixed in the skybox texture by default.
  107092. * BabylonJS clearColor by default.
  107093. */
  107094. skyboxColor: Color3;
  107095. /**
  107096. * The background rotation around the Y axis of the scene.
  107097. * This helps aligning the key lights of your scene with the background.
  107098. * 0 by default.
  107099. */
  107100. backgroundYRotation: number;
  107101. /**
  107102. * Compute automatically the size of the elements to best fit with the scene.
  107103. */
  107104. sizeAuto: boolean;
  107105. /**
  107106. * Default position of the rootMesh if autoSize is not true.
  107107. */
  107108. rootPosition: Vector3;
  107109. /**
  107110. * Sets up the image processing in the scene.
  107111. * true by default.
  107112. */
  107113. setupImageProcessing: boolean;
  107114. /**
  107115. * The texture used as your environment texture in the scene.
  107116. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  107117. *
  107118. * Remarks: Can be either a texture or a url.
  107119. */
  107120. environmentTexture: string | BaseTexture;
  107121. /**
  107122. * The value of the exposure to apply to the scene.
  107123. * 0.6 by default if setupImageProcessing is true.
  107124. */
  107125. cameraExposure: number;
  107126. /**
  107127. * The value of the contrast to apply to the scene.
  107128. * 1.6 by default if setupImageProcessing is true.
  107129. */
  107130. cameraContrast: number;
  107131. /**
  107132. * Specifies wether or not tonemapping should be enabled in the scene.
  107133. * true by default if setupImageProcessing is true.
  107134. */
  107135. toneMappingEnabled: boolean;
  107136. }
  107137. /**
  107138. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  107139. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  107140. * It also helps with the default setup of your imageProcessing configuration.
  107141. */
  107142. export class EnvironmentHelper {
  107143. /**
  107144. * Default ground texture URL.
  107145. */
  107146. private static _groundTextureCDNUrl;
  107147. /**
  107148. * Default skybox texture URL.
  107149. */
  107150. private static _skyboxTextureCDNUrl;
  107151. /**
  107152. * Default environment texture URL.
  107153. */
  107154. private static _environmentTextureCDNUrl;
  107155. /**
  107156. * Creates the default options for the helper.
  107157. */
  107158. private static _getDefaultOptions;
  107159. private _rootMesh;
  107160. /**
  107161. * Gets the root mesh created by the helper.
  107162. */
  107163. readonly rootMesh: Mesh;
  107164. private _skybox;
  107165. /**
  107166. * Gets the skybox created by the helper.
  107167. */
  107168. readonly skybox: Nullable<Mesh>;
  107169. private _skyboxTexture;
  107170. /**
  107171. * Gets the skybox texture created by the helper.
  107172. */
  107173. readonly skyboxTexture: Nullable<BaseTexture>;
  107174. private _skyboxMaterial;
  107175. /**
  107176. * Gets the skybox material created by the helper.
  107177. */
  107178. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  107179. private _ground;
  107180. /**
  107181. * Gets the ground mesh created by the helper.
  107182. */
  107183. readonly ground: Nullable<Mesh>;
  107184. private _groundTexture;
  107185. /**
  107186. * Gets the ground texture created by the helper.
  107187. */
  107188. readonly groundTexture: Nullable<BaseTexture>;
  107189. private _groundMirror;
  107190. /**
  107191. * Gets the ground mirror created by the helper.
  107192. */
  107193. readonly groundMirror: Nullable<MirrorTexture>;
  107194. /**
  107195. * Gets the ground mirror render list to helps pushing the meshes
  107196. * you wish in the ground reflection.
  107197. */
  107198. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  107199. private _groundMaterial;
  107200. /**
  107201. * Gets the ground material created by the helper.
  107202. */
  107203. readonly groundMaterial: Nullable<BackgroundMaterial>;
  107204. /**
  107205. * Stores the creation options.
  107206. */
  107207. private readonly _scene;
  107208. private _options;
  107209. /**
  107210. * This observable will be notified with any error during the creation of the environment,
  107211. * mainly texture creation errors.
  107212. */
  107213. onErrorObservable: Observable<{
  107214. message?: string;
  107215. exception?: any;
  107216. }>;
  107217. /**
  107218. * constructor
  107219. * @param options Defines the options we want to customize the helper
  107220. * @param scene The scene to add the material to
  107221. */
  107222. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  107223. /**
  107224. * Updates the background according to the new options
  107225. * @param options
  107226. */
  107227. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  107228. /**
  107229. * Sets the primary color of all the available elements.
  107230. * @param color the main color to affect to the ground and the background
  107231. */
  107232. setMainColor(color: Color3): void;
  107233. /**
  107234. * Setup the image processing according to the specified options.
  107235. */
  107236. private _setupImageProcessing;
  107237. /**
  107238. * Setup the environment texture according to the specified options.
  107239. */
  107240. private _setupEnvironmentTexture;
  107241. /**
  107242. * Setup the background according to the specified options.
  107243. */
  107244. private _setupBackground;
  107245. /**
  107246. * Get the scene sizes according to the setup.
  107247. */
  107248. private _getSceneSize;
  107249. /**
  107250. * Setup the ground according to the specified options.
  107251. */
  107252. private _setupGround;
  107253. /**
  107254. * Setup the ground material according to the specified options.
  107255. */
  107256. private _setupGroundMaterial;
  107257. /**
  107258. * Setup the ground diffuse texture according to the specified options.
  107259. */
  107260. private _setupGroundDiffuseTexture;
  107261. /**
  107262. * Setup the ground mirror texture according to the specified options.
  107263. */
  107264. private _setupGroundMirrorTexture;
  107265. /**
  107266. * Setup the ground to receive the mirror texture.
  107267. */
  107268. private _setupMirrorInGroundMaterial;
  107269. /**
  107270. * Setup the skybox according to the specified options.
  107271. */
  107272. private _setupSkybox;
  107273. /**
  107274. * Setup the skybox material according to the specified options.
  107275. */
  107276. private _setupSkyboxMaterial;
  107277. /**
  107278. * Setup the skybox reflection texture according to the specified options.
  107279. */
  107280. private _setupSkyboxReflectionTexture;
  107281. private _errorHandler;
  107282. /**
  107283. * Dispose all the elements created by the Helper.
  107284. */
  107285. dispose(): void;
  107286. }
  107287. }
  107288. declare module BABYLON {
  107289. /**
  107290. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  107291. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  107292. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  107293. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  107294. */
  107295. export class PhotoDome extends TransformNode {
  107296. /**
  107297. * Define the image as a Monoscopic panoramic 360 image.
  107298. */
  107299. static readonly MODE_MONOSCOPIC: number;
  107300. /**
  107301. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107302. */
  107303. static readonly MODE_TOPBOTTOM: number;
  107304. /**
  107305. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107306. */
  107307. static readonly MODE_SIDEBYSIDE: number;
  107308. private _useDirectMapping;
  107309. /**
  107310. * The texture being displayed on the sphere
  107311. */
  107312. protected _photoTexture: Texture;
  107313. /**
  107314. * Gets or sets the texture being displayed on the sphere
  107315. */
  107316. photoTexture: Texture;
  107317. /**
  107318. * Observable raised when an error occured while loading the 360 image
  107319. */
  107320. onLoadErrorObservable: Observable<string>;
  107321. /**
  107322. * The skybox material
  107323. */
  107324. protected _material: BackgroundMaterial;
  107325. /**
  107326. * The surface used for the skybox
  107327. */
  107328. protected _mesh: Mesh;
  107329. /**
  107330. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  107331. * Also see the options.resolution property.
  107332. */
  107333. fovMultiplier: number;
  107334. private _imageMode;
  107335. /**
  107336. * Gets or set the current video mode for the video. It can be:
  107337. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  107338. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107339. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107340. */
  107341. imageMode: number;
  107342. /**
  107343. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  107344. * @param name Element's name, child elements will append suffixes for their own names.
  107345. * @param urlsOfPhoto defines the url of the photo to display
  107346. * @param options defines an object containing optional or exposed sub element properties
  107347. * @param onError defines a callback called when an error occured while loading the texture
  107348. */
  107349. constructor(name: string, urlOfPhoto: string, options: {
  107350. resolution?: number;
  107351. size?: number;
  107352. useDirectMapping?: boolean;
  107353. faceForward?: boolean;
  107354. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  107355. private _onBeforeCameraRenderObserver;
  107356. private _changeImageMode;
  107357. /**
  107358. * Releases resources associated with this node.
  107359. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107360. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107361. */
  107362. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107363. }
  107364. }
  107365. declare module BABYLON {
  107366. /** @hidden */
  107367. export var rgbdDecodePixelShader: {
  107368. name: string;
  107369. shader: string;
  107370. };
  107371. }
  107372. declare module BABYLON {
  107373. /**
  107374. * Class used to host texture specific utilities
  107375. */
  107376. export class BRDFTextureTools {
  107377. /**
  107378. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  107379. * @param texture the texture to expand.
  107380. */
  107381. private static _ExpandDefaultBRDFTexture;
  107382. /**
  107383. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  107384. * @param scene defines the hosting scene
  107385. * @returns the environment BRDF texture
  107386. */
  107387. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  107388. private static _environmentBRDFBase64Texture;
  107389. }
  107390. }
  107391. declare module BABYLON {
  107392. /**
  107393. * @hidden
  107394. */
  107395. export interface IMaterialClearCoatDefines {
  107396. CLEARCOAT: boolean;
  107397. CLEARCOAT_DEFAULTIOR: boolean;
  107398. CLEARCOAT_TEXTURE: boolean;
  107399. CLEARCOAT_TEXTUREDIRECTUV: number;
  107400. CLEARCOAT_BUMP: boolean;
  107401. CLEARCOAT_BUMPDIRECTUV: number;
  107402. CLEARCOAT_TINT: boolean;
  107403. CLEARCOAT_TINT_TEXTURE: boolean;
  107404. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107405. /** @hidden */
  107406. _areTexturesDirty: boolean;
  107407. }
  107408. /**
  107409. * Define the code related to the clear coat parameters of the pbr material.
  107410. */
  107411. export class PBRClearCoatConfiguration {
  107412. /**
  107413. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107414. * The default fits with a polyurethane material.
  107415. */
  107416. private static readonly _DefaultIndexOfRefraction;
  107417. private _isEnabled;
  107418. /**
  107419. * Defines if the clear coat is enabled in the material.
  107420. */
  107421. isEnabled: boolean;
  107422. /**
  107423. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  107424. */
  107425. intensity: number;
  107426. /**
  107427. * Defines the clear coat layer roughness.
  107428. */
  107429. roughness: number;
  107430. private _indexOfRefraction;
  107431. /**
  107432. * Defines the index of refraction of the clear coat.
  107433. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107434. * The default fits with a polyurethane material.
  107435. * Changing the default value is more performance intensive.
  107436. */
  107437. indexOfRefraction: number;
  107438. private _texture;
  107439. /**
  107440. * Stores the clear coat values in a texture.
  107441. */
  107442. texture: Nullable<BaseTexture>;
  107443. private _bumpTexture;
  107444. /**
  107445. * Define the clear coat specific bump texture.
  107446. */
  107447. bumpTexture: Nullable<BaseTexture>;
  107448. private _isTintEnabled;
  107449. /**
  107450. * Defines if the clear coat tint is enabled in the material.
  107451. */
  107452. isTintEnabled: boolean;
  107453. /**
  107454. * Defines the clear coat tint of the material.
  107455. * This is only use if tint is enabled
  107456. */
  107457. tintColor: Color3;
  107458. /**
  107459. * Defines the distance at which the tint color should be found in the
  107460. * clear coat media.
  107461. * This is only use if tint is enabled
  107462. */
  107463. tintColorAtDistance: number;
  107464. /**
  107465. * Defines the clear coat layer thickness.
  107466. * This is only use if tint is enabled
  107467. */
  107468. tintThickness: number;
  107469. private _tintTexture;
  107470. /**
  107471. * Stores the clear tint values in a texture.
  107472. * rgb is tint
  107473. * a is a thickness factor
  107474. */
  107475. tintTexture: Nullable<BaseTexture>;
  107476. /** @hidden */
  107477. private _internalMarkAllSubMeshesAsTexturesDirty;
  107478. /** @hidden */
  107479. _markAllSubMeshesAsTexturesDirty(): void;
  107480. /**
  107481. * Instantiate a new istance of clear coat configuration.
  107482. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107483. */
  107484. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107485. /**
  107486. * Gets wehter the submesh is ready to be used or not.
  107487. * @param defines the list of "defines" to update.
  107488. * @param scene defines the scene the material belongs to.
  107489. * @param engine defines the engine the material belongs to.
  107490. * @param disableBumpMap defines wether the material disables bump or not.
  107491. * @returns - boolean indicating that the submesh is ready or not.
  107492. */
  107493. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  107494. /**
  107495. * Checks to see if a texture is used in the material.
  107496. * @param defines the list of "defines" to update.
  107497. * @param scene defines the scene to the material belongs to.
  107498. */
  107499. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  107500. /**
  107501. * Binds the material data.
  107502. * @param uniformBuffer defines the Uniform buffer to fill in.
  107503. * @param scene defines the scene the material belongs to.
  107504. * @param engine defines the engine the material belongs to.
  107505. * @param disableBumpMap defines wether the material disables bump or not.
  107506. * @param isFrozen defines wether the material is frozen or not.
  107507. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107508. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107509. */
  107510. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  107511. /**
  107512. * Checks to see if a texture is used in the material.
  107513. * @param texture - Base texture to use.
  107514. * @returns - Boolean specifying if a texture is used in the material.
  107515. */
  107516. hasTexture(texture: BaseTexture): boolean;
  107517. /**
  107518. * Returns an array of the actively used textures.
  107519. * @param activeTextures Array of BaseTextures
  107520. */
  107521. getActiveTextures(activeTextures: BaseTexture[]): void;
  107522. /**
  107523. * Returns the animatable textures.
  107524. * @param animatables Array of animatable textures.
  107525. */
  107526. getAnimatables(animatables: IAnimatable[]): void;
  107527. /**
  107528. * Disposes the resources of the material.
  107529. * @param forceDisposeTextures - Forces the disposal of all textures.
  107530. */
  107531. dispose(forceDisposeTextures?: boolean): void;
  107532. /**
  107533. * Get the current class name of the texture useful for serialization or dynamic coding.
  107534. * @returns "PBRClearCoatConfiguration"
  107535. */
  107536. getClassName(): string;
  107537. /**
  107538. * Add fallbacks to the effect fallbacks list.
  107539. * @param defines defines the Base texture to use.
  107540. * @param fallbacks defines the current fallback list.
  107541. * @param currentRank defines the current fallback rank.
  107542. * @returns the new fallback rank.
  107543. */
  107544. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107545. /**
  107546. * Add the required uniforms to the current list.
  107547. * @param uniforms defines the current uniform list.
  107548. */
  107549. static AddUniforms(uniforms: string[]): void;
  107550. /**
  107551. * Add the required samplers to the current list.
  107552. * @param samplers defines the current sampler list.
  107553. */
  107554. static AddSamplers(samplers: string[]): void;
  107555. /**
  107556. * Add the required uniforms to the current buffer.
  107557. * @param uniformBuffer defines the current uniform buffer.
  107558. */
  107559. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107560. /**
  107561. * Makes a duplicate of the current configuration into another one.
  107562. * @param clearCoatConfiguration define the config where to copy the info
  107563. */
  107564. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  107565. /**
  107566. * Serializes this clear coat configuration.
  107567. * @returns - An object with the serialized config.
  107568. */
  107569. serialize(): any;
  107570. /**
  107571. * Parses a anisotropy Configuration from a serialized object.
  107572. * @param source - Serialized object.
  107573. * @param scene Defines the scene we are parsing for
  107574. * @param rootUrl Defines the rootUrl to load from
  107575. */
  107576. parse(source: any, scene: Scene, rootUrl: string): void;
  107577. }
  107578. }
  107579. declare module BABYLON {
  107580. /**
  107581. * @hidden
  107582. */
  107583. export interface IMaterialAnisotropicDefines {
  107584. ANISOTROPIC: boolean;
  107585. ANISOTROPIC_TEXTURE: boolean;
  107586. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107587. MAINUV1: boolean;
  107588. _areTexturesDirty: boolean;
  107589. _needUVs: boolean;
  107590. }
  107591. /**
  107592. * Define the code related to the anisotropic parameters of the pbr material.
  107593. */
  107594. export class PBRAnisotropicConfiguration {
  107595. private _isEnabled;
  107596. /**
  107597. * Defines if the anisotropy is enabled in the material.
  107598. */
  107599. isEnabled: boolean;
  107600. /**
  107601. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  107602. */
  107603. intensity: number;
  107604. /**
  107605. * Defines if the effect is along the tangents, bitangents or in between.
  107606. * By default, the effect is "strectching" the highlights along the tangents.
  107607. */
  107608. direction: Vector2;
  107609. private _texture;
  107610. /**
  107611. * Stores the anisotropy values in a texture.
  107612. * rg is direction (like normal from -1 to 1)
  107613. * b is a intensity
  107614. */
  107615. texture: Nullable<BaseTexture>;
  107616. /** @hidden */
  107617. private _internalMarkAllSubMeshesAsTexturesDirty;
  107618. /** @hidden */
  107619. _markAllSubMeshesAsTexturesDirty(): void;
  107620. /**
  107621. * Instantiate a new istance of anisotropy configuration.
  107622. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107623. */
  107624. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107625. /**
  107626. * Specifies that the submesh is ready to be used.
  107627. * @param defines the list of "defines" to update.
  107628. * @param scene defines the scene the material belongs to.
  107629. * @returns - boolean indicating that the submesh is ready or not.
  107630. */
  107631. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  107632. /**
  107633. * Checks to see if a texture is used in the material.
  107634. * @param defines the list of "defines" to update.
  107635. * @param mesh the mesh we are preparing the defines for.
  107636. * @param scene defines the scene the material belongs to.
  107637. */
  107638. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  107639. /**
  107640. * Binds the material data.
  107641. * @param uniformBuffer defines the Uniform buffer to fill in.
  107642. * @param scene defines the scene the material belongs to.
  107643. * @param isFrozen defines wether the material is frozen or not.
  107644. */
  107645. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107646. /**
  107647. * Checks to see if a texture is used in the material.
  107648. * @param texture - Base texture to use.
  107649. * @returns - Boolean specifying if a texture is used in the material.
  107650. */
  107651. hasTexture(texture: BaseTexture): boolean;
  107652. /**
  107653. * Returns an array of the actively used textures.
  107654. * @param activeTextures Array of BaseTextures
  107655. */
  107656. getActiveTextures(activeTextures: BaseTexture[]): void;
  107657. /**
  107658. * Returns the animatable textures.
  107659. * @param animatables Array of animatable textures.
  107660. */
  107661. getAnimatables(animatables: IAnimatable[]): void;
  107662. /**
  107663. * Disposes the resources of the material.
  107664. * @param forceDisposeTextures - Forces the disposal of all textures.
  107665. */
  107666. dispose(forceDisposeTextures?: boolean): void;
  107667. /**
  107668. * Get the current class name of the texture useful for serialization or dynamic coding.
  107669. * @returns "PBRAnisotropicConfiguration"
  107670. */
  107671. getClassName(): string;
  107672. /**
  107673. * Add fallbacks to the effect fallbacks list.
  107674. * @param defines defines the Base texture to use.
  107675. * @param fallbacks defines the current fallback list.
  107676. * @param currentRank defines the current fallback rank.
  107677. * @returns the new fallback rank.
  107678. */
  107679. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107680. /**
  107681. * Add the required uniforms to the current list.
  107682. * @param uniforms defines the current uniform list.
  107683. */
  107684. static AddUniforms(uniforms: string[]): void;
  107685. /**
  107686. * Add the required uniforms to the current buffer.
  107687. * @param uniformBuffer defines the current uniform buffer.
  107688. */
  107689. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107690. /**
  107691. * Add the required samplers to the current list.
  107692. * @param samplers defines the current sampler list.
  107693. */
  107694. static AddSamplers(samplers: string[]): void;
  107695. /**
  107696. * Makes a duplicate of the current configuration into another one.
  107697. * @param anisotropicConfiguration define the config where to copy the info
  107698. */
  107699. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107700. /**
  107701. * Serializes this anisotropy configuration.
  107702. * @returns - An object with the serialized config.
  107703. */
  107704. serialize(): any;
  107705. /**
  107706. * Parses a anisotropy Configuration from a serialized object.
  107707. * @param source - Serialized object.
  107708. * @param scene Defines the scene we are parsing for
  107709. * @param rootUrl Defines the rootUrl to load from
  107710. */
  107711. parse(source: any, scene: Scene, rootUrl: string): void;
  107712. }
  107713. }
  107714. declare module BABYLON {
  107715. /**
  107716. * @hidden
  107717. */
  107718. export interface IMaterialBRDFDefines {
  107719. BRDF_V_HEIGHT_CORRELATED: boolean;
  107720. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107721. SPHERICAL_HARMONICS: boolean;
  107722. /** @hidden */
  107723. _areMiscDirty: boolean;
  107724. }
  107725. /**
  107726. * Define the code related to the BRDF parameters of the pbr material.
  107727. */
  107728. export class PBRBRDFConfiguration {
  107729. /**
  107730. * Default value used for the energy conservation.
  107731. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107732. */
  107733. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107734. /**
  107735. * Default value used for the Smith Visibility Height Correlated mode.
  107736. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107737. */
  107738. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107739. /**
  107740. * Default value used for the IBL diffuse part.
  107741. * This can help switching back to the polynomials mode globally which is a tiny bit
  107742. * less GPU intensive at the drawback of a lower quality.
  107743. */
  107744. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107745. private _useEnergyConservation;
  107746. /**
  107747. * Defines if the material uses energy conservation.
  107748. */
  107749. useEnergyConservation: boolean;
  107750. private _useSmithVisibilityHeightCorrelated;
  107751. /**
  107752. * LEGACY Mode set to false
  107753. * Defines if the material uses height smith correlated visibility term.
  107754. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  107755. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107756. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  107757. * Not relying on height correlated will also disable energy conservation.
  107758. */
  107759. useSmithVisibilityHeightCorrelated: boolean;
  107760. private _useSphericalHarmonics;
  107761. /**
  107762. * LEGACY Mode set to false
  107763. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  107764. * diffuse part of the IBL.
  107765. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  107766. * to the ground truth.
  107767. */
  107768. useSphericalHarmonics: boolean;
  107769. /** @hidden */
  107770. private _internalMarkAllSubMeshesAsMiscDirty;
  107771. /** @hidden */
  107772. _markAllSubMeshesAsMiscDirty(): void;
  107773. /**
  107774. * Instantiate a new istance of clear coat configuration.
  107775. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  107776. */
  107777. constructor(markAllSubMeshesAsMiscDirty: () => void);
  107778. /**
  107779. * Checks to see if a texture is used in the material.
  107780. * @param defines the list of "defines" to update.
  107781. */
  107782. prepareDefines(defines: IMaterialBRDFDefines): void;
  107783. /**
  107784. * Get the current class name of the texture useful for serialization or dynamic coding.
  107785. * @returns "PBRClearCoatConfiguration"
  107786. */
  107787. getClassName(): string;
  107788. /**
  107789. * Makes a duplicate of the current configuration into another one.
  107790. * @param brdfConfiguration define the config where to copy the info
  107791. */
  107792. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  107793. /**
  107794. * Serializes this BRDF configuration.
  107795. * @returns - An object with the serialized config.
  107796. */
  107797. serialize(): any;
  107798. /**
  107799. * Parses a anisotropy Configuration from a serialized object.
  107800. * @param source - Serialized object.
  107801. * @param scene Defines the scene we are parsing for
  107802. * @param rootUrl Defines the rootUrl to load from
  107803. */
  107804. parse(source: any, scene: Scene, rootUrl: string): void;
  107805. }
  107806. }
  107807. declare module BABYLON {
  107808. /**
  107809. * @hidden
  107810. */
  107811. export interface IMaterialSheenDefines {
  107812. SHEEN: boolean;
  107813. SHEEN_TEXTURE: boolean;
  107814. SHEEN_TEXTUREDIRECTUV: number;
  107815. SHEEN_LINKWITHALBEDO: boolean;
  107816. /** @hidden */
  107817. _areTexturesDirty: boolean;
  107818. }
  107819. /**
  107820. * Define the code related to the Sheen parameters of the pbr material.
  107821. */
  107822. export class PBRSheenConfiguration {
  107823. private _isEnabled;
  107824. /**
  107825. * Defines if the material uses sheen.
  107826. */
  107827. isEnabled: boolean;
  107828. private _linkSheenWithAlbedo;
  107829. /**
  107830. * Defines if the sheen is linked to the sheen color.
  107831. */
  107832. linkSheenWithAlbedo: boolean;
  107833. /**
  107834. * Defines the sheen intensity.
  107835. */
  107836. intensity: number;
  107837. /**
  107838. * Defines the sheen color.
  107839. */
  107840. color: Color3;
  107841. private _texture;
  107842. /**
  107843. * Stores the sheen tint values in a texture.
  107844. * rgb is tint
  107845. * a is a intensity
  107846. */
  107847. texture: Nullable<BaseTexture>;
  107848. /** @hidden */
  107849. private _internalMarkAllSubMeshesAsTexturesDirty;
  107850. /** @hidden */
  107851. _markAllSubMeshesAsTexturesDirty(): void;
  107852. /**
  107853. * Instantiate a new istance of clear coat configuration.
  107854. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107855. */
  107856. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107857. /**
  107858. * Specifies that the submesh is ready to be used.
  107859. * @param defines the list of "defines" to update.
  107860. * @param scene defines the scene the material belongs to.
  107861. * @returns - boolean indicating that the submesh is ready or not.
  107862. */
  107863. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  107864. /**
  107865. * Checks to see if a texture is used in the material.
  107866. * @param defines the list of "defines" to update.
  107867. * @param scene defines the scene the material belongs to.
  107868. */
  107869. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  107870. /**
  107871. * Binds the material data.
  107872. * @param uniformBuffer defines the Uniform buffer to fill in.
  107873. * @param scene defines the scene the material belongs to.
  107874. * @param isFrozen defines wether the material is frozen or not.
  107875. */
  107876. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107877. /**
  107878. * Checks to see if a texture is used in the material.
  107879. * @param texture - Base texture to use.
  107880. * @returns - Boolean specifying if a texture is used in the material.
  107881. */
  107882. hasTexture(texture: BaseTexture): boolean;
  107883. /**
  107884. * Returns an array of the actively used textures.
  107885. * @param activeTextures Array of BaseTextures
  107886. */
  107887. getActiveTextures(activeTextures: BaseTexture[]): void;
  107888. /**
  107889. * Returns the animatable textures.
  107890. * @param animatables Array of animatable textures.
  107891. */
  107892. getAnimatables(animatables: IAnimatable[]): void;
  107893. /**
  107894. * Disposes the resources of the material.
  107895. * @param forceDisposeTextures - Forces the disposal of all textures.
  107896. */
  107897. dispose(forceDisposeTextures?: boolean): void;
  107898. /**
  107899. * Get the current class name of the texture useful for serialization or dynamic coding.
  107900. * @returns "PBRSheenConfiguration"
  107901. */
  107902. getClassName(): string;
  107903. /**
  107904. * Add fallbacks to the effect fallbacks list.
  107905. * @param defines defines the Base texture to use.
  107906. * @param fallbacks defines the current fallback list.
  107907. * @param currentRank defines the current fallback rank.
  107908. * @returns the new fallback rank.
  107909. */
  107910. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107911. /**
  107912. * Add the required uniforms to the current list.
  107913. * @param uniforms defines the current uniform list.
  107914. */
  107915. static AddUniforms(uniforms: string[]): void;
  107916. /**
  107917. * Add the required uniforms to the current buffer.
  107918. * @param uniformBuffer defines the current uniform buffer.
  107919. */
  107920. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107921. /**
  107922. * Add the required samplers to the current list.
  107923. * @param samplers defines the current sampler list.
  107924. */
  107925. static AddSamplers(samplers: string[]): void;
  107926. /**
  107927. * Makes a duplicate of the current configuration into another one.
  107928. * @param sheenConfiguration define the config where to copy the info
  107929. */
  107930. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  107931. /**
  107932. * Serializes this BRDF configuration.
  107933. * @returns - An object with the serialized config.
  107934. */
  107935. serialize(): any;
  107936. /**
  107937. * Parses a anisotropy Configuration from a serialized object.
  107938. * @param source - Serialized object.
  107939. * @param scene Defines the scene we are parsing for
  107940. * @param rootUrl Defines the rootUrl to load from
  107941. */
  107942. parse(source: any, scene: Scene, rootUrl: string): void;
  107943. }
  107944. }
  107945. declare module BABYLON {
  107946. /**
  107947. * @hidden
  107948. */
  107949. export interface IMaterialSubSurfaceDefines {
  107950. SUBSURFACE: boolean;
  107951. SS_REFRACTION: boolean;
  107952. SS_TRANSLUCENCY: boolean;
  107953. SS_SCATERRING: boolean;
  107954. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107955. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107956. SS_REFRACTIONMAP_3D: boolean;
  107957. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107958. SS_LODINREFRACTIONALPHA: boolean;
  107959. SS_GAMMAREFRACTION: boolean;
  107960. SS_RGBDREFRACTION: boolean;
  107961. SS_LINEARSPECULARREFRACTION: boolean;
  107962. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107963. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107964. /** @hidden */
  107965. _areTexturesDirty: boolean;
  107966. }
  107967. /**
  107968. * Define the code related to the sub surface parameters of the pbr material.
  107969. */
  107970. export class PBRSubSurfaceConfiguration {
  107971. private _isRefractionEnabled;
  107972. /**
  107973. * Defines if the refraction is enabled in the material.
  107974. */
  107975. isRefractionEnabled: boolean;
  107976. private _isTranslucencyEnabled;
  107977. /**
  107978. * Defines if the translucency is enabled in the material.
  107979. */
  107980. isTranslucencyEnabled: boolean;
  107981. private _isScatteringEnabled;
  107982. /**
  107983. * Defines the refraction intensity of the material.
  107984. * The refraction when enabled replaces the Diffuse part of the material.
  107985. * The intensity helps transitionning between diffuse and refraction.
  107986. */
  107987. refractionIntensity: number;
  107988. /**
  107989. * Defines the translucency intensity of the material.
  107990. * When translucency has been enabled, this defines how much of the "translucency"
  107991. * is addded to the diffuse part of the material.
  107992. */
  107993. translucencyIntensity: number;
  107994. /**
  107995. * Defines the scattering intensity of the material.
  107996. * When scattering has been enabled, this defines how much of the "scattered light"
  107997. * is addded to the diffuse part of the material.
  107998. */
  107999. scatteringIntensity: number;
  108000. private _thicknessTexture;
  108001. /**
  108002. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  108003. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  108004. * 0 would mean minimumThickness
  108005. * 1 would mean maximumThickness
  108006. * The other channels might be use as a mask to vary the different effects intensity.
  108007. */
  108008. thicknessTexture: Nullable<BaseTexture>;
  108009. private _refractionTexture;
  108010. /**
  108011. * Defines the texture to use for refraction.
  108012. */
  108013. refractionTexture: Nullable<BaseTexture>;
  108014. private _indexOfRefraction;
  108015. /**
  108016. * Defines the index of refraction used in the material.
  108017. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  108018. */
  108019. indexOfRefraction: number;
  108020. private _invertRefractionY;
  108021. /**
  108022. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108023. */
  108024. invertRefractionY: boolean;
  108025. private _linkRefractionWithTransparency;
  108026. /**
  108027. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108028. * Materials half opaque for instance using refraction could benefit from this control.
  108029. */
  108030. linkRefractionWithTransparency: boolean;
  108031. /**
  108032. * Defines the minimum thickness stored in the thickness map.
  108033. * If no thickness map is defined, this value will be used to simulate thickness.
  108034. */
  108035. minimumThickness: number;
  108036. /**
  108037. * Defines the maximum thickness stored in the thickness map.
  108038. */
  108039. maximumThickness: number;
  108040. /**
  108041. * Defines the volume tint of the material.
  108042. * This is used for both translucency and scattering.
  108043. */
  108044. tintColor: Color3;
  108045. /**
  108046. * Defines the distance at which the tint color should be found in the media.
  108047. * This is used for refraction only.
  108048. */
  108049. tintColorAtDistance: number;
  108050. /**
  108051. * Defines how far each channel transmit through the media.
  108052. * It is defined as a color to simplify it selection.
  108053. */
  108054. diffusionDistance: Color3;
  108055. private _useMaskFromThicknessTexture;
  108056. /**
  108057. * Stores the intensity of the different subsurface effects in the thickness texture.
  108058. * * the green channel is the translucency intensity.
  108059. * * the blue channel is the scattering intensity.
  108060. * * the alpha channel is the refraction intensity.
  108061. */
  108062. useMaskFromThicknessTexture: boolean;
  108063. /** @hidden */
  108064. private _internalMarkAllSubMeshesAsTexturesDirty;
  108065. /** @hidden */
  108066. _markAllSubMeshesAsTexturesDirty(): void;
  108067. /**
  108068. * Instantiate a new istance of sub surface configuration.
  108069. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108070. */
  108071. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108072. /**
  108073. * Gets wehter the submesh is ready to be used or not.
  108074. * @param defines the list of "defines" to update.
  108075. * @param scene defines the scene the material belongs to.
  108076. * @returns - boolean indicating that the submesh is ready or not.
  108077. */
  108078. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  108079. /**
  108080. * Checks to see if a texture is used in the material.
  108081. * @param defines the list of "defines" to update.
  108082. * @param scene defines the scene to the material belongs to.
  108083. */
  108084. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  108085. /**
  108086. * Binds the material data.
  108087. * @param uniformBuffer defines the Uniform buffer to fill in.
  108088. * @param scene defines the scene the material belongs to.
  108089. * @param engine defines the engine the material belongs to.
  108090. * @param isFrozen defines wether the material is frozen or not.
  108091. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  108092. */
  108093. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  108094. /**
  108095. * Unbinds the material from the mesh.
  108096. * @param activeEffect defines the effect that should be unbound from.
  108097. * @returns true if unbound, otherwise false
  108098. */
  108099. unbind(activeEffect: Effect): boolean;
  108100. /**
  108101. * Returns the texture used for refraction or null if none is used.
  108102. * @param scene defines the scene the material belongs to.
  108103. * @returns - Refraction texture if present. If no refraction texture and refraction
  108104. * is linked with transparency, returns environment texture. Otherwise, returns null.
  108105. */
  108106. private _getRefractionTexture;
  108107. /**
  108108. * Returns true if alpha blending should be disabled.
  108109. */
  108110. readonly disableAlphaBlending: boolean;
  108111. /**
  108112. * Fills the list of render target textures.
  108113. * @param renderTargets the list of render targets to update
  108114. */
  108115. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  108116. /**
  108117. * Checks to see if a texture is used in the material.
  108118. * @param texture - Base texture to use.
  108119. * @returns - Boolean specifying if a texture is used in the material.
  108120. */
  108121. hasTexture(texture: BaseTexture): boolean;
  108122. /**
  108123. * Gets a boolean indicating that current material needs to register RTT
  108124. * @returns true if this uses a render target otherwise false.
  108125. */
  108126. hasRenderTargetTextures(): boolean;
  108127. /**
  108128. * Returns an array of the actively used textures.
  108129. * @param activeTextures Array of BaseTextures
  108130. */
  108131. getActiveTextures(activeTextures: BaseTexture[]): void;
  108132. /**
  108133. * Returns the animatable textures.
  108134. * @param animatables Array of animatable textures.
  108135. */
  108136. getAnimatables(animatables: IAnimatable[]): void;
  108137. /**
  108138. * Disposes the resources of the material.
  108139. * @param forceDisposeTextures - Forces the disposal of all textures.
  108140. */
  108141. dispose(forceDisposeTextures?: boolean): void;
  108142. /**
  108143. * Get the current class name of the texture useful for serialization or dynamic coding.
  108144. * @returns "PBRSubSurfaceConfiguration"
  108145. */
  108146. getClassName(): string;
  108147. /**
  108148. * Add fallbacks to the effect fallbacks list.
  108149. * @param defines defines the Base texture to use.
  108150. * @param fallbacks defines the current fallback list.
  108151. * @param currentRank defines the current fallback rank.
  108152. * @returns the new fallback rank.
  108153. */
  108154. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108155. /**
  108156. * Add the required uniforms to the current list.
  108157. * @param uniforms defines the current uniform list.
  108158. */
  108159. static AddUniforms(uniforms: string[]): void;
  108160. /**
  108161. * Add the required samplers to the current list.
  108162. * @param samplers defines the current sampler list.
  108163. */
  108164. static AddSamplers(samplers: string[]): void;
  108165. /**
  108166. * Add the required uniforms to the current buffer.
  108167. * @param uniformBuffer defines the current uniform buffer.
  108168. */
  108169. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108170. /**
  108171. * Makes a duplicate of the current configuration into another one.
  108172. * @param configuration define the config where to copy the info
  108173. */
  108174. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  108175. /**
  108176. * Serializes this Sub Surface configuration.
  108177. * @returns - An object with the serialized config.
  108178. */
  108179. serialize(): any;
  108180. /**
  108181. * Parses a anisotropy Configuration from a serialized object.
  108182. * @param source - Serialized object.
  108183. * @param scene Defines the scene we are parsing for
  108184. * @param rootUrl Defines the rootUrl to load from
  108185. */
  108186. parse(source: any, scene: Scene, rootUrl: string): void;
  108187. }
  108188. }
  108189. declare module BABYLON {
  108190. /** @hidden */
  108191. export var pbrFragmentDeclaration: {
  108192. name: string;
  108193. shader: string;
  108194. };
  108195. }
  108196. declare module BABYLON {
  108197. /** @hidden */
  108198. export var pbrUboDeclaration: {
  108199. name: string;
  108200. shader: string;
  108201. };
  108202. }
  108203. declare module BABYLON {
  108204. /** @hidden */
  108205. export var pbrFragmentExtraDeclaration: {
  108206. name: string;
  108207. shader: string;
  108208. };
  108209. }
  108210. declare module BABYLON {
  108211. /** @hidden */
  108212. export var pbrFragmentSamplersDeclaration: {
  108213. name: string;
  108214. shader: string;
  108215. };
  108216. }
  108217. declare module BABYLON {
  108218. /** @hidden */
  108219. export var pbrHelperFunctions: {
  108220. name: string;
  108221. shader: string;
  108222. };
  108223. }
  108224. declare module BABYLON {
  108225. /** @hidden */
  108226. export var harmonicsFunctions: {
  108227. name: string;
  108228. shader: string;
  108229. };
  108230. }
  108231. declare module BABYLON {
  108232. /** @hidden */
  108233. export var pbrDirectLightingSetupFunctions: {
  108234. name: string;
  108235. shader: string;
  108236. };
  108237. }
  108238. declare module BABYLON {
  108239. /** @hidden */
  108240. export var pbrDirectLightingFalloffFunctions: {
  108241. name: string;
  108242. shader: string;
  108243. };
  108244. }
  108245. declare module BABYLON {
  108246. /** @hidden */
  108247. export var pbrBRDFFunctions: {
  108248. name: string;
  108249. shader: string;
  108250. };
  108251. }
  108252. declare module BABYLON {
  108253. /** @hidden */
  108254. export var pbrDirectLightingFunctions: {
  108255. name: string;
  108256. shader: string;
  108257. };
  108258. }
  108259. declare module BABYLON {
  108260. /** @hidden */
  108261. export var pbrIBLFunctions: {
  108262. name: string;
  108263. shader: string;
  108264. };
  108265. }
  108266. declare module BABYLON {
  108267. /** @hidden */
  108268. export var pbrDebug: {
  108269. name: string;
  108270. shader: string;
  108271. };
  108272. }
  108273. declare module BABYLON {
  108274. /** @hidden */
  108275. export var pbrPixelShader: {
  108276. name: string;
  108277. shader: string;
  108278. };
  108279. }
  108280. declare module BABYLON {
  108281. /** @hidden */
  108282. export var pbrVertexDeclaration: {
  108283. name: string;
  108284. shader: string;
  108285. };
  108286. }
  108287. declare module BABYLON {
  108288. /** @hidden */
  108289. export var pbrVertexShader: {
  108290. name: string;
  108291. shader: string;
  108292. };
  108293. }
  108294. declare module BABYLON {
  108295. /**
  108296. * Manages the defines for the PBR Material.
  108297. * @hidden
  108298. */
  108299. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  108300. PBR: boolean;
  108301. MAINUV1: boolean;
  108302. MAINUV2: boolean;
  108303. UV1: boolean;
  108304. UV2: boolean;
  108305. ALBEDO: boolean;
  108306. ALBEDODIRECTUV: number;
  108307. VERTEXCOLOR: boolean;
  108308. AMBIENT: boolean;
  108309. AMBIENTDIRECTUV: number;
  108310. AMBIENTINGRAYSCALE: boolean;
  108311. OPACITY: boolean;
  108312. VERTEXALPHA: boolean;
  108313. OPACITYDIRECTUV: number;
  108314. OPACITYRGB: boolean;
  108315. ALPHATEST: boolean;
  108316. DEPTHPREPASS: boolean;
  108317. ALPHABLEND: boolean;
  108318. ALPHAFROMALBEDO: boolean;
  108319. ALPHATESTVALUE: string;
  108320. SPECULAROVERALPHA: boolean;
  108321. RADIANCEOVERALPHA: boolean;
  108322. ALPHAFRESNEL: boolean;
  108323. LINEARALPHAFRESNEL: boolean;
  108324. PREMULTIPLYALPHA: boolean;
  108325. EMISSIVE: boolean;
  108326. EMISSIVEDIRECTUV: number;
  108327. REFLECTIVITY: boolean;
  108328. REFLECTIVITYDIRECTUV: number;
  108329. SPECULARTERM: boolean;
  108330. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  108331. MICROSURFACEAUTOMATIC: boolean;
  108332. LODBASEDMICROSFURACE: boolean;
  108333. MICROSURFACEMAP: boolean;
  108334. MICROSURFACEMAPDIRECTUV: number;
  108335. METALLICWORKFLOW: boolean;
  108336. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  108337. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  108338. METALLNESSSTOREINMETALMAPBLUE: boolean;
  108339. AOSTOREINMETALMAPRED: boolean;
  108340. ENVIRONMENTBRDF: boolean;
  108341. ENVIRONMENTBRDF_RGBD: boolean;
  108342. NORMAL: boolean;
  108343. TANGENT: boolean;
  108344. BUMP: boolean;
  108345. BUMPDIRECTUV: number;
  108346. OBJECTSPACE_NORMALMAP: boolean;
  108347. PARALLAX: boolean;
  108348. PARALLAXOCCLUSION: boolean;
  108349. NORMALXYSCALE: boolean;
  108350. LIGHTMAP: boolean;
  108351. LIGHTMAPDIRECTUV: number;
  108352. USELIGHTMAPASSHADOWMAP: boolean;
  108353. GAMMALIGHTMAP: boolean;
  108354. REFLECTION: boolean;
  108355. REFLECTIONMAP_3D: boolean;
  108356. REFLECTIONMAP_SPHERICAL: boolean;
  108357. REFLECTIONMAP_PLANAR: boolean;
  108358. REFLECTIONMAP_CUBIC: boolean;
  108359. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108360. REFLECTIONMAP_PROJECTION: boolean;
  108361. REFLECTIONMAP_SKYBOX: boolean;
  108362. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108363. REFLECTIONMAP_EXPLICIT: boolean;
  108364. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108365. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108366. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108367. INVERTCUBICMAP: boolean;
  108368. USESPHERICALFROMREFLECTIONMAP: boolean;
  108369. USEIRRADIANCEMAP: boolean;
  108370. SPHERICAL_HARMONICS: boolean;
  108371. USESPHERICALINVERTEX: boolean;
  108372. REFLECTIONMAP_OPPOSITEZ: boolean;
  108373. LODINREFLECTIONALPHA: boolean;
  108374. GAMMAREFLECTION: boolean;
  108375. RGBDREFLECTION: boolean;
  108376. LINEARSPECULARREFLECTION: boolean;
  108377. RADIANCEOCCLUSION: boolean;
  108378. HORIZONOCCLUSION: boolean;
  108379. INSTANCES: boolean;
  108380. NUM_BONE_INFLUENCERS: number;
  108381. BonesPerMesh: number;
  108382. BONETEXTURE: boolean;
  108383. NONUNIFORMSCALING: boolean;
  108384. MORPHTARGETS: boolean;
  108385. MORPHTARGETS_NORMAL: boolean;
  108386. MORPHTARGETS_TANGENT: boolean;
  108387. MORPHTARGETS_UV: boolean;
  108388. NUM_MORPH_INFLUENCERS: number;
  108389. IMAGEPROCESSING: boolean;
  108390. VIGNETTE: boolean;
  108391. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108392. VIGNETTEBLENDMODEOPAQUE: boolean;
  108393. TONEMAPPING: boolean;
  108394. TONEMAPPING_ACES: boolean;
  108395. CONTRAST: boolean;
  108396. COLORCURVES: boolean;
  108397. COLORGRADING: boolean;
  108398. COLORGRADING3D: boolean;
  108399. SAMPLER3DGREENDEPTH: boolean;
  108400. SAMPLER3DBGRMAP: boolean;
  108401. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108402. EXPOSURE: boolean;
  108403. MULTIVIEW: boolean;
  108404. USEPHYSICALLIGHTFALLOFF: boolean;
  108405. USEGLTFLIGHTFALLOFF: boolean;
  108406. TWOSIDEDLIGHTING: boolean;
  108407. SHADOWFLOAT: boolean;
  108408. CLIPPLANE: boolean;
  108409. CLIPPLANE2: boolean;
  108410. CLIPPLANE3: boolean;
  108411. CLIPPLANE4: boolean;
  108412. POINTSIZE: boolean;
  108413. FOG: boolean;
  108414. LOGARITHMICDEPTH: boolean;
  108415. FORCENORMALFORWARD: boolean;
  108416. SPECULARAA: boolean;
  108417. CLEARCOAT: boolean;
  108418. CLEARCOAT_DEFAULTIOR: boolean;
  108419. CLEARCOAT_TEXTURE: boolean;
  108420. CLEARCOAT_TEXTUREDIRECTUV: number;
  108421. CLEARCOAT_BUMP: boolean;
  108422. CLEARCOAT_BUMPDIRECTUV: number;
  108423. CLEARCOAT_TINT: boolean;
  108424. CLEARCOAT_TINT_TEXTURE: boolean;
  108425. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108426. ANISOTROPIC: boolean;
  108427. ANISOTROPIC_TEXTURE: boolean;
  108428. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108429. BRDF_V_HEIGHT_CORRELATED: boolean;
  108430. MS_BRDF_ENERGY_CONSERVATION: boolean;
  108431. SHEEN: boolean;
  108432. SHEEN_TEXTURE: boolean;
  108433. SHEEN_TEXTUREDIRECTUV: number;
  108434. SHEEN_LINKWITHALBEDO: boolean;
  108435. SUBSURFACE: boolean;
  108436. SS_REFRACTION: boolean;
  108437. SS_TRANSLUCENCY: boolean;
  108438. SS_SCATERRING: boolean;
  108439. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108440. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108441. SS_REFRACTIONMAP_3D: boolean;
  108442. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108443. SS_LODINREFRACTIONALPHA: boolean;
  108444. SS_GAMMAREFRACTION: boolean;
  108445. SS_RGBDREFRACTION: boolean;
  108446. SS_LINEARSPECULARREFRACTION: boolean;
  108447. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108448. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108449. UNLIT: boolean;
  108450. DEBUGMODE: number;
  108451. /**
  108452. * Initializes the PBR Material defines.
  108453. */
  108454. constructor();
  108455. /**
  108456. * Resets the PBR Material defines.
  108457. */
  108458. reset(): void;
  108459. }
  108460. /**
  108461. * The Physically based material base class of BJS.
  108462. *
  108463. * This offers the main features of a standard PBR material.
  108464. * For more information, please refer to the documentation :
  108465. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108466. */
  108467. export abstract class PBRBaseMaterial extends PushMaterial {
  108468. /**
  108469. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108470. */
  108471. static readonly PBRMATERIAL_OPAQUE: number;
  108472. /**
  108473. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108474. */
  108475. static readonly PBRMATERIAL_ALPHATEST: number;
  108476. /**
  108477. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108478. */
  108479. static readonly PBRMATERIAL_ALPHABLEND: number;
  108480. /**
  108481. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108482. * They are also discarded below the alpha cutoff threshold to improve performances.
  108483. */
  108484. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108485. /**
  108486. * Defines the default value of how much AO map is occluding the analytical lights
  108487. * (point spot...).
  108488. */
  108489. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108490. /**
  108491. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  108492. */
  108493. static readonly LIGHTFALLOFF_PHYSICAL: number;
  108494. /**
  108495. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  108496. * to enhance interoperability with other engines.
  108497. */
  108498. static readonly LIGHTFALLOFF_GLTF: number;
  108499. /**
  108500. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  108501. * to enhance interoperability with other materials.
  108502. */
  108503. static readonly LIGHTFALLOFF_STANDARD: number;
  108504. /**
  108505. * Intensity of the direct lights e.g. the four lights available in your scene.
  108506. * This impacts both the direct diffuse and specular highlights.
  108507. */
  108508. protected _directIntensity: number;
  108509. /**
  108510. * Intensity of the emissive part of the material.
  108511. * This helps controlling the emissive effect without modifying the emissive color.
  108512. */
  108513. protected _emissiveIntensity: number;
  108514. /**
  108515. * Intensity of the environment e.g. how much the environment will light the object
  108516. * either through harmonics for rough material or through the refelction for shiny ones.
  108517. */
  108518. protected _environmentIntensity: number;
  108519. /**
  108520. * This is a special control allowing the reduction of the specular highlights coming from the
  108521. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108522. */
  108523. protected _specularIntensity: number;
  108524. /**
  108525. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  108526. */
  108527. private _lightingInfos;
  108528. /**
  108529. * Debug Control allowing disabling the bump map on this material.
  108530. */
  108531. protected _disableBumpMap: boolean;
  108532. /**
  108533. * AKA Diffuse Texture in standard nomenclature.
  108534. */
  108535. protected _albedoTexture: Nullable<BaseTexture>;
  108536. /**
  108537. * AKA Occlusion Texture in other nomenclature.
  108538. */
  108539. protected _ambientTexture: Nullable<BaseTexture>;
  108540. /**
  108541. * AKA Occlusion Texture Intensity in other nomenclature.
  108542. */
  108543. protected _ambientTextureStrength: number;
  108544. /**
  108545. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108546. * 1 means it completely occludes it
  108547. * 0 mean it has no impact
  108548. */
  108549. protected _ambientTextureImpactOnAnalyticalLights: number;
  108550. /**
  108551. * Stores the alpha values in a texture.
  108552. */
  108553. protected _opacityTexture: Nullable<BaseTexture>;
  108554. /**
  108555. * Stores the reflection values in a texture.
  108556. */
  108557. protected _reflectionTexture: Nullable<BaseTexture>;
  108558. /**
  108559. * Stores the emissive values in a texture.
  108560. */
  108561. protected _emissiveTexture: Nullable<BaseTexture>;
  108562. /**
  108563. * AKA Specular texture in other nomenclature.
  108564. */
  108565. protected _reflectivityTexture: Nullable<BaseTexture>;
  108566. /**
  108567. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108568. */
  108569. protected _metallicTexture: Nullable<BaseTexture>;
  108570. /**
  108571. * Specifies the metallic scalar of the metallic/roughness workflow.
  108572. * Can also be used to scale the metalness values of the metallic texture.
  108573. */
  108574. protected _metallic: Nullable<number>;
  108575. /**
  108576. * Specifies the roughness scalar of the metallic/roughness workflow.
  108577. * Can also be used to scale the roughness values of the metallic texture.
  108578. */
  108579. protected _roughness: Nullable<number>;
  108580. /**
  108581. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108582. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108583. */
  108584. protected _microSurfaceTexture: Nullable<BaseTexture>;
  108585. /**
  108586. * Stores surface normal data used to displace a mesh in a texture.
  108587. */
  108588. protected _bumpTexture: Nullable<BaseTexture>;
  108589. /**
  108590. * Stores the pre-calculated light information of a mesh in a texture.
  108591. */
  108592. protected _lightmapTexture: Nullable<BaseTexture>;
  108593. /**
  108594. * The color of a material in ambient lighting.
  108595. */
  108596. protected _ambientColor: Color3;
  108597. /**
  108598. * AKA Diffuse Color in other nomenclature.
  108599. */
  108600. protected _albedoColor: Color3;
  108601. /**
  108602. * AKA Specular Color in other nomenclature.
  108603. */
  108604. protected _reflectivityColor: Color3;
  108605. /**
  108606. * The color applied when light is reflected from a material.
  108607. */
  108608. protected _reflectionColor: Color3;
  108609. /**
  108610. * The color applied when light is emitted from a material.
  108611. */
  108612. protected _emissiveColor: Color3;
  108613. /**
  108614. * AKA Glossiness in other nomenclature.
  108615. */
  108616. protected _microSurface: number;
  108617. /**
  108618. * Specifies that the material will use the light map as a show map.
  108619. */
  108620. protected _useLightmapAsShadowmap: boolean;
  108621. /**
  108622. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108623. * makes the reflect vector face the model (under horizon).
  108624. */
  108625. protected _useHorizonOcclusion: boolean;
  108626. /**
  108627. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108628. * too much the area relying on ambient texture to define their ambient occlusion.
  108629. */
  108630. protected _useRadianceOcclusion: boolean;
  108631. /**
  108632. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108633. */
  108634. protected _useAlphaFromAlbedoTexture: boolean;
  108635. /**
  108636. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  108637. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108638. */
  108639. protected _useSpecularOverAlpha: boolean;
  108640. /**
  108641. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108642. */
  108643. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108644. /**
  108645. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108646. */
  108647. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  108648. /**
  108649. * Specifies if the metallic texture contains the roughness information in its green channel.
  108650. */
  108651. protected _useRoughnessFromMetallicTextureGreen: boolean;
  108652. /**
  108653. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108654. */
  108655. protected _useMetallnessFromMetallicTextureBlue: boolean;
  108656. /**
  108657. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108658. */
  108659. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  108660. /**
  108661. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108662. */
  108663. protected _useAmbientInGrayScale: boolean;
  108664. /**
  108665. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108666. * The material will try to infer what glossiness each pixel should be.
  108667. */
  108668. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  108669. /**
  108670. * Defines the falloff type used in this material.
  108671. * It by default is Physical.
  108672. */
  108673. protected _lightFalloff: number;
  108674. /**
  108675. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108676. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108677. */
  108678. protected _useRadianceOverAlpha: boolean;
  108679. /**
  108680. * Allows using an object space normal map (instead of tangent space).
  108681. */
  108682. protected _useObjectSpaceNormalMap: boolean;
  108683. /**
  108684. * Allows using the bump map in parallax mode.
  108685. */
  108686. protected _useParallax: boolean;
  108687. /**
  108688. * Allows using the bump map in parallax occlusion mode.
  108689. */
  108690. protected _useParallaxOcclusion: boolean;
  108691. /**
  108692. * Controls the scale bias of the parallax mode.
  108693. */
  108694. protected _parallaxScaleBias: number;
  108695. /**
  108696. * If sets to true, disables all the lights affecting the material.
  108697. */
  108698. protected _disableLighting: boolean;
  108699. /**
  108700. * Number of Simultaneous lights allowed on the material.
  108701. */
  108702. protected _maxSimultaneousLights: number;
  108703. /**
  108704. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108705. */
  108706. protected _invertNormalMapX: boolean;
  108707. /**
  108708. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108709. */
  108710. protected _invertNormalMapY: boolean;
  108711. /**
  108712. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108713. */
  108714. protected _twoSidedLighting: boolean;
  108715. /**
  108716. * Defines the alpha limits in alpha test mode.
  108717. */
  108718. protected _alphaCutOff: number;
  108719. /**
  108720. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108721. */
  108722. protected _forceAlphaTest: boolean;
  108723. /**
  108724. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108725. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108726. */
  108727. protected _useAlphaFresnel: boolean;
  108728. /**
  108729. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108730. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108731. */
  108732. protected _useLinearAlphaFresnel: boolean;
  108733. /**
  108734. * The transparency mode of the material.
  108735. */
  108736. protected _transparencyMode: Nullable<number>;
  108737. /**
  108738. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108739. * from cos thetav and roughness:
  108740. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108741. */
  108742. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108743. /**
  108744. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108745. */
  108746. protected _forceIrradianceInFragment: boolean;
  108747. /**
  108748. * Force normal to face away from face.
  108749. */
  108750. protected _forceNormalForward: boolean;
  108751. /**
  108752. * Enables specular anti aliasing in the PBR shader.
  108753. * It will both interacts on the Geometry for analytical and IBL lighting.
  108754. * It also prefilter the roughness map based on the bump values.
  108755. */
  108756. protected _enableSpecularAntiAliasing: boolean;
  108757. /**
  108758. * Default configuration related to image processing available in the PBR Material.
  108759. */
  108760. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108761. /**
  108762. * Keep track of the image processing observer to allow dispose and replace.
  108763. */
  108764. private _imageProcessingObserver;
  108765. /**
  108766. * Attaches a new image processing configuration to the PBR Material.
  108767. * @param configuration
  108768. */
  108769. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108770. /**
  108771. * Stores the available render targets.
  108772. */
  108773. private _renderTargets;
  108774. /**
  108775. * Sets the global ambient color for the material used in lighting calculations.
  108776. */
  108777. private _globalAmbientColor;
  108778. /**
  108779. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  108780. */
  108781. private _useLogarithmicDepth;
  108782. /**
  108783. * If set to true, no lighting calculations will be applied.
  108784. */
  108785. private _unlit;
  108786. private _debugMode;
  108787. /**
  108788. * @hidden
  108789. * This is reserved for the inspector.
  108790. * Defines the material debug mode.
  108791. * It helps seeing only some components of the material while troubleshooting.
  108792. */
  108793. debugMode: number;
  108794. /**
  108795. * @hidden
  108796. * This is reserved for the inspector.
  108797. * Specify from where on screen the debug mode should start.
  108798. * The value goes from -1 (full screen) to 1 (not visible)
  108799. * It helps with side by side comparison against the final render
  108800. * This defaults to -1
  108801. */
  108802. private debugLimit;
  108803. /**
  108804. * @hidden
  108805. * This is reserved for the inspector.
  108806. * As the default viewing range might not be enough (if the ambient is really small for instance)
  108807. * You can use the factor to better multiply the final value.
  108808. */
  108809. private debugFactor;
  108810. /**
  108811. * Defines the clear coat layer parameters for the material.
  108812. */
  108813. readonly clearCoat: PBRClearCoatConfiguration;
  108814. /**
  108815. * Defines the anisotropic parameters for the material.
  108816. */
  108817. readonly anisotropy: PBRAnisotropicConfiguration;
  108818. /**
  108819. * Defines the BRDF parameters for the material.
  108820. */
  108821. readonly brdf: PBRBRDFConfiguration;
  108822. /**
  108823. * Defines the Sheen parameters for the material.
  108824. */
  108825. readonly sheen: PBRSheenConfiguration;
  108826. /**
  108827. * Defines the SubSurface parameters for the material.
  108828. */
  108829. readonly subSurface: PBRSubSurfaceConfiguration;
  108830. /**
  108831. * Custom callback helping to override the default shader used in the material.
  108832. */
  108833. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  108834. /**
  108835. * Instantiates a new PBRMaterial instance.
  108836. *
  108837. * @param name The material name
  108838. * @param scene The scene the material will be use in.
  108839. */
  108840. constructor(name: string, scene: Scene);
  108841. /**
  108842. * Gets a boolean indicating that current material needs to register RTT
  108843. */
  108844. readonly hasRenderTargetTextures: boolean;
  108845. /**
  108846. * Gets the name of the material class.
  108847. */
  108848. getClassName(): string;
  108849. /**
  108850. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108851. */
  108852. /**
  108853. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108854. */
  108855. useLogarithmicDepth: boolean;
  108856. /**
  108857. * Gets the current transparency mode.
  108858. */
  108859. /**
  108860. * Sets the transparency mode of the material.
  108861. *
  108862. * | Value | Type | Description |
  108863. * | ----- | ----------------------------------- | ----------- |
  108864. * | 0 | OPAQUE | |
  108865. * | 1 | ALPHATEST | |
  108866. * | 2 | ALPHABLEND | |
  108867. * | 3 | ALPHATESTANDBLEND | |
  108868. *
  108869. */
  108870. transparencyMode: Nullable<number>;
  108871. /**
  108872. * Returns true if alpha blending should be disabled.
  108873. */
  108874. private readonly _disableAlphaBlending;
  108875. /**
  108876. * Specifies whether or not this material should be rendered in alpha blend mode.
  108877. */
  108878. needAlphaBlending(): boolean;
  108879. /**
  108880. * Specifies if the mesh will require alpha blending.
  108881. * @param mesh - BJS mesh.
  108882. */
  108883. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  108884. /**
  108885. * Specifies whether or not this material should be rendered in alpha test mode.
  108886. */
  108887. needAlphaTesting(): boolean;
  108888. /**
  108889. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  108890. */
  108891. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  108892. /**
  108893. * Gets the texture used for the alpha test.
  108894. */
  108895. getAlphaTestTexture(): Nullable<BaseTexture>;
  108896. /**
  108897. * Specifies that the submesh is ready to be used.
  108898. * @param mesh - BJS mesh.
  108899. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  108900. * @param useInstances - Specifies that instances should be used.
  108901. * @returns - boolean indicating that the submesh is ready or not.
  108902. */
  108903. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108904. /**
  108905. * Specifies if the material uses metallic roughness workflow.
  108906. * @returns boolean specifiying if the material uses metallic roughness workflow.
  108907. */
  108908. isMetallicWorkflow(): boolean;
  108909. private _prepareEffect;
  108910. private _prepareDefines;
  108911. /**
  108912. * Force shader compilation
  108913. */
  108914. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  108915. clipPlane: boolean;
  108916. }>): void;
  108917. /**
  108918. * Initializes the uniform buffer layout for the shader.
  108919. */
  108920. buildUniformLayout(): void;
  108921. /**
  108922. * Unbinds the material from the mesh
  108923. */
  108924. unbind(): void;
  108925. /**
  108926. * Binds the submesh data.
  108927. * @param world - The world matrix.
  108928. * @param mesh - The BJS mesh.
  108929. * @param subMesh - A submesh of the BJS mesh.
  108930. */
  108931. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108932. /**
  108933. * Returns the animatable textures.
  108934. * @returns - Array of animatable textures.
  108935. */
  108936. getAnimatables(): IAnimatable[];
  108937. /**
  108938. * Returns the texture used for reflections.
  108939. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  108940. */
  108941. private _getReflectionTexture;
  108942. /**
  108943. * Returns an array of the actively used textures.
  108944. * @returns - Array of BaseTextures
  108945. */
  108946. getActiveTextures(): BaseTexture[];
  108947. /**
  108948. * Checks to see if a texture is used in the material.
  108949. * @param texture - Base texture to use.
  108950. * @returns - Boolean specifying if a texture is used in the material.
  108951. */
  108952. hasTexture(texture: BaseTexture): boolean;
  108953. /**
  108954. * Disposes the resources of the material.
  108955. * @param forceDisposeEffect - Forces the disposal of effects.
  108956. * @param forceDisposeTextures - Forces the disposal of all textures.
  108957. */
  108958. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108959. }
  108960. }
  108961. declare module BABYLON {
  108962. /**
  108963. * The Physically based material of BJS.
  108964. *
  108965. * This offers the main features of a standard PBR material.
  108966. * For more information, please refer to the documentation :
  108967. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108968. */
  108969. export class PBRMaterial extends PBRBaseMaterial {
  108970. /**
  108971. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108972. */
  108973. static readonly PBRMATERIAL_OPAQUE: number;
  108974. /**
  108975. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108976. */
  108977. static readonly PBRMATERIAL_ALPHATEST: number;
  108978. /**
  108979. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108980. */
  108981. static readonly PBRMATERIAL_ALPHABLEND: number;
  108982. /**
  108983. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108984. * They are also discarded below the alpha cutoff threshold to improve performances.
  108985. */
  108986. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108987. /**
  108988. * Defines the default value of how much AO map is occluding the analytical lights
  108989. * (point spot...).
  108990. */
  108991. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108992. /**
  108993. * Intensity of the direct lights e.g. the four lights available in your scene.
  108994. * This impacts both the direct diffuse and specular highlights.
  108995. */
  108996. directIntensity: number;
  108997. /**
  108998. * Intensity of the emissive part of the material.
  108999. * This helps controlling the emissive effect without modifying the emissive color.
  109000. */
  109001. emissiveIntensity: number;
  109002. /**
  109003. * Intensity of the environment e.g. how much the environment will light the object
  109004. * either through harmonics for rough material or through the refelction for shiny ones.
  109005. */
  109006. environmentIntensity: number;
  109007. /**
  109008. * This is a special control allowing the reduction of the specular highlights coming from the
  109009. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  109010. */
  109011. specularIntensity: number;
  109012. /**
  109013. * Debug Control allowing disabling the bump map on this material.
  109014. */
  109015. disableBumpMap: boolean;
  109016. /**
  109017. * AKA Diffuse Texture in standard nomenclature.
  109018. */
  109019. albedoTexture: BaseTexture;
  109020. /**
  109021. * AKA Occlusion Texture in other nomenclature.
  109022. */
  109023. ambientTexture: BaseTexture;
  109024. /**
  109025. * AKA Occlusion Texture Intensity in other nomenclature.
  109026. */
  109027. ambientTextureStrength: number;
  109028. /**
  109029. * Defines how much the AO map is occluding the analytical lights (point spot...).
  109030. * 1 means it completely occludes it
  109031. * 0 mean it has no impact
  109032. */
  109033. ambientTextureImpactOnAnalyticalLights: number;
  109034. /**
  109035. * Stores the alpha values in a texture.
  109036. */
  109037. opacityTexture: BaseTexture;
  109038. /**
  109039. * Stores the reflection values in a texture.
  109040. */
  109041. reflectionTexture: Nullable<BaseTexture>;
  109042. /**
  109043. * Stores the emissive values in a texture.
  109044. */
  109045. emissiveTexture: BaseTexture;
  109046. /**
  109047. * AKA Specular texture in other nomenclature.
  109048. */
  109049. reflectivityTexture: BaseTexture;
  109050. /**
  109051. * Used to switch from specular/glossiness to metallic/roughness workflow.
  109052. */
  109053. metallicTexture: BaseTexture;
  109054. /**
  109055. * Specifies the metallic scalar of the metallic/roughness workflow.
  109056. * Can also be used to scale the metalness values of the metallic texture.
  109057. */
  109058. metallic: Nullable<number>;
  109059. /**
  109060. * Specifies the roughness scalar of the metallic/roughness workflow.
  109061. * Can also be used to scale the roughness values of the metallic texture.
  109062. */
  109063. roughness: Nullable<number>;
  109064. /**
  109065. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  109066. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  109067. */
  109068. microSurfaceTexture: BaseTexture;
  109069. /**
  109070. * Stores surface normal data used to displace a mesh in a texture.
  109071. */
  109072. bumpTexture: BaseTexture;
  109073. /**
  109074. * Stores the pre-calculated light information of a mesh in a texture.
  109075. */
  109076. lightmapTexture: BaseTexture;
  109077. /**
  109078. * Stores the refracted light information in a texture.
  109079. */
  109080. refractionTexture: Nullable<BaseTexture>;
  109081. /**
  109082. * The color of a material in ambient lighting.
  109083. */
  109084. ambientColor: Color3;
  109085. /**
  109086. * AKA Diffuse Color in other nomenclature.
  109087. */
  109088. albedoColor: Color3;
  109089. /**
  109090. * AKA Specular Color in other nomenclature.
  109091. */
  109092. reflectivityColor: Color3;
  109093. /**
  109094. * The color reflected from the material.
  109095. */
  109096. reflectionColor: Color3;
  109097. /**
  109098. * The color emitted from the material.
  109099. */
  109100. emissiveColor: Color3;
  109101. /**
  109102. * AKA Glossiness in other nomenclature.
  109103. */
  109104. microSurface: number;
  109105. /**
  109106. * source material index of refraction (IOR)' / 'destination material IOR.
  109107. */
  109108. indexOfRefraction: number;
  109109. /**
  109110. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  109111. */
  109112. invertRefractionY: boolean;
  109113. /**
  109114. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  109115. * Materials half opaque for instance using refraction could benefit from this control.
  109116. */
  109117. linkRefractionWithTransparency: boolean;
  109118. /**
  109119. * If true, the light map contains occlusion information instead of lighting info.
  109120. */
  109121. useLightmapAsShadowmap: boolean;
  109122. /**
  109123. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  109124. */
  109125. useAlphaFromAlbedoTexture: boolean;
  109126. /**
  109127. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109128. */
  109129. forceAlphaTest: boolean;
  109130. /**
  109131. * Defines the alpha limits in alpha test mode.
  109132. */
  109133. alphaCutOff: number;
  109134. /**
  109135. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109136. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109137. */
  109138. useSpecularOverAlpha: boolean;
  109139. /**
  109140. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  109141. */
  109142. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  109143. /**
  109144. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  109145. */
  109146. useRoughnessFromMetallicTextureAlpha: boolean;
  109147. /**
  109148. * Specifies if the metallic texture contains the roughness information in its green channel.
  109149. */
  109150. useRoughnessFromMetallicTextureGreen: boolean;
  109151. /**
  109152. * Specifies if the metallic texture contains the metallness information in its blue channel.
  109153. */
  109154. useMetallnessFromMetallicTextureBlue: boolean;
  109155. /**
  109156. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  109157. */
  109158. useAmbientOcclusionFromMetallicTextureRed: boolean;
  109159. /**
  109160. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  109161. */
  109162. useAmbientInGrayScale: boolean;
  109163. /**
  109164. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  109165. * The material will try to infer what glossiness each pixel should be.
  109166. */
  109167. useAutoMicroSurfaceFromReflectivityMap: boolean;
  109168. /**
  109169. * BJS is using an harcoded light falloff based on a manually sets up range.
  109170. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109171. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109172. */
  109173. /**
  109174. * BJS is using an harcoded light falloff based on a manually sets up range.
  109175. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109176. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109177. */
  109178. usePhysicalLightFalloff: boolean;
  109179. /**
  109180. * In order to support the falloff compatibility with gltf, a special mode has been added
  109181. * to reproduce the gltf light falloff.
  109182. */
  109183. /**
  109184. * In order to support the falloff compatibility with gltf, a special mode has been added
  109185. * to reproduce the gltf light falloff.
  109186. */
  109187. useGLTFLightFalloff: boolean;
  109188. /**
  109189. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109190. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109191. */
  109192. useRadianceOverAlpha: boolean;
  109193. /**
  109194. * Allows using an object space normal map (instead of tangent space).
  109195. */
  109196. useObjectSpaceNormalMap: boolean;
  109197. /**
  109198. * Allows using the bump map in parallax mode.
  109199. */
  109200. useParallax: boolean;
  109201. /**
  109202. * Allows using the bump map in parallax occlusion mode.
  109203. */
  109204. useParallaxOcclusion: boolean;
  109205. /**
  109206. * Controls the scale bias of the parallax mode.
  109207. */
  109208. parallaxScaleBias: number;
  109209. /**
  109210. * If sets to true, disables all the lights affecting the material.
  109211. */
  109212. disableLighting: boolean;
  109213. /**
  109214. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  109215. */
  109216. forceIrradianceInFragment: boolean;
  109217. /**
  109218. * Number of Simultaneous lights allowed on the material.
  109219. */
  109220. maxSimultaneousLights: number;
  109221. /**
  109222. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109223. */
  109224. invertNormalMapX: boolean;
  109225. /**
  109226. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109227. */
  109228. invertNormalMapY: boolean;
  109229. /**
  109230. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109231. */
  109232. twoSidedLighting: boolean;
  109233. /**
  109234. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109235. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  109236. */
  109237. useAlphaFresnel: boolean;
  109238. /**
  109239. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109240. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  109241. */
  109242. useLinearAlphaFresnel: boolean;
  109243. /**
  109244. * Let user defines the brdf lookup texture used for IBL.
  109245. * A default 8bit version is embedded but you could point at :
  109246. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  109247. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109248. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  109249. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109250. */
  109251. environmentBRDFTexture: Nullable<BaseTexture>;
  109252. /**
  109253. * Force normal to face away from face.
  109254. */
  109255. forceNormalForward: boolean;
  109256. /**
  109257. * Enables specular anti aliasing in the PBR shader.
  109258. * It will both interacts on the Geometry for analytical and IBL lighting.
  109259. * It also prefilter the roughness map based on the bump values.
  109260. */
  109261. enableSpecularAntiAliasing: boolean;
  109262. /**
  109263. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  109264. * makes the reflect vector face the model (under horizon).
  109265. */
  109266. useHorizonOcclusion: boolean;
  109267. /**
  109268. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  109269. * too much the area relying on ambient texture to define their ambient occlusion.
  109270. */
  109271. useRadianceOcclusion: boolean;
  109272. /**
  109273. * If set to true, no lighting calculations will be applied.
  109274. */
  109275. unlit: boolean;
  109276. /**
  109277. * Gets the image processing configuration used either in this material.
  109278. */
  109279. /**
  109280. * Sets the Default image processing configuration used either in the this material.
  109281. *
  109282. * If sets to null, the scene one is in use.
  109283. */
  109284. imageProcessingConfiguration: ImageProcessingConfiguration;
  109285. /**
  109286. * Gets wether the color curves effect is enabled.
  109287. */
  109288. /**
  109289. * Sets wether the color curves effect is enabled.
  109290. */
  109291. cameraColorCurvesEnabled: boolean;
  109292. /**
  109293. * Gets wether the color grading effect is enabled.
  109294. */
  109295. /**
  109296. * Gets wether the color grading effect is enabled.
  109297. */
  109298. cameraColorGradingEnabled: boolean;
  109299. /**
  109300. * Gets wether tonemapping is enabled or not.
  109301. */
  109302. /**
  109303. * Sets wether tonemapping is enabled or not
  109304. */
  109305. cameraToneMappingEnabled: boolean;
  109306. /**
  109307. * The camera exposure used on this material.
  109308. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109309. * This corresponds to a photographic exposure.
  109310. */
  109311. /**
  109312. * The camera exposure used on this material.
  109313. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109314. * This corresponds to a photographic exposure.
  109315. */
  109316. cameraExposure: number;
  109317. /**
  109318. * Gets The camera contrast used on this material.
  109319. */
  109320. /**
  109321. * Sets The camera contrast used on this material.
  109322. */
  109323. cameraContrast: number;
  109324. /**
  109325. * Gets the Color Grading 2D Lookup Texture.
  109326. */
  109327. /**
  109328. * Sets the Color Grading 2D Lookup Texture.
  109329. */
  109330. cameraColorGradingTexture: Nullable<BaseTexture>;
  109331. /**
  109332. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109333. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109334. * 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;
  109335. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109336. */
  109337. /**
  109338. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109339. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109340. * 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;
  109341. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109342. */
  109343. cameraColorCurves: Nullable<ColorCurves>;
  109344. /**
  109345. * Instantiates a new PBRMaterial instance.
  109346. *
  109347. * @param name The material name
  109348. * @param scene The scene the material will be use in.
  109349. */
  109350. constructor(name: string, scene: Scene);
  109351. /**
  109352. * Returns the name of this material class.
  109353. */
  109354. getClassName(): string;
  109355. /**
  109356. * Makes a duplicate of the current material.
  109357. * @param name - name to use for the new material.
  109358. */
  109359. clone(name: string): PBRMaterial;
  109360. /**
  109361. * Serializes this PBR Material.
  109362. * @returns - An object with the serialized material.
  109363. */
  109364. serialize(): any;
  109365. /**
  109366. * Parses a PBR Material from a serialized object.
  109367. * @param source - Serialized object.
  109368. * @param scene - BJS scene instance.
  109369. * @param rootUrl - url for the scene object
  109370. * @returns - PBRMaterial
  109371. */
  109372. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  109373. }
  109374. }
  109375. declare module BABYLON {
  109376. /**
  109377. * Direct draw surface info
  109378. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  109379. */
  109380. export interface DDSInfo {
  109381. /**
  109382. * Width of the texture
  109383. */
  109384. width: number;
  109385. /**
  109386. * Width of the texture
  109387. */
  109388. height: number;
  109389. /**
  109390. * Number of Mipmaps for the texture
  109391. * @see https://en.wikipedia.org/wiki/Mipmap
  109392. */
  109393. mipmapCount: number;
  109394. /**
  109395. * If the textures format is a known fourCC format
  109396. * @see https://www.fourcc.org/
  109397. */
  109398. isFourCC: boolean;
  109399. /**
  109400. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  109401. */
  109402. isRGB: boolean;
  109403. /**
  109404. * If the texture is a lumincance format
  109405. */
  109406. isLuminance: boolean;
  109407. /**
  109408. * If this is a cube texture
  109409. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  109410. */
  109411. isCube: boolean;
  109412. /**
  109413. * If the texture is a compressed format eg. FOURCC_DXT1
  109414. */
  109415. isCompressed: boolean;
  109416. /**
  109417. * The dxgiFormat of the texture
  109418. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  109419. */
  109420. dxgiFormat: number;
  109421. /**
  109422. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  109423. */
  109424. textureType: number;
  109425. /**
  109426. * Sphericle polynomial created for the dds texture
  109427. */
  109428. sphericalPolynomial?: SphericalPolynomial;
  109429. }
  109430. /**
  109431. * Class used to provide DDS decompression tools
  109432. */
  109433. export class DDSTools {
  109434. /**
  109435. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  109436. */
  109437. static StoreLODInAlphaChannel: boolean;
  109438. /**
  109439. * Gets DDS information from an array buffer
  109440. * @param arrayBuffer defines the array buffer to read data from
  109441. * @returns the DDS information
  109442. */
  109443. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  109444. private static _FloatView;
  109445. private static _Int32View;
  109446. private static _ToHalfFloat;
  109447. private static _FromHalfFloat;
  109448. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  109449. private static _GetHalfFloatRGBAArrayBuffer;
  109450. private static _GetFloatRGBAArrayBuffer;
  109451. private static _GetFloatAsUIntRGBAArrayBuffer;
  109452. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  109453. private static _GetRGBAArrayBuffer;
  109454. private static _ExtractLongWordOrder;
  109455. private static _GetRGBArrayBuffer;
  109456. private static _GetLuminanceArrayBuffer;
  109457. /**
  109458. * Uploads DDS Levels to a Babylon Texture
  109459. * @hidden
  109460. */
  109461. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  109462. }
  109463. interface Engine {
  109464. /**
  109465. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  109466. * @param rootUrl defines the url where the file to load is located
  109467. * @param scene defines the current scene
  109468. * @param lodScale defines scale to apply to the mip map selection
  109469. * @param lodOffset defines offset to apply to the mip map selection
  109470. * @param onLoad defines an optional callback raised when the texture is loaded
  109471. * @param onError defines an optional callback raised if there is an issue to load the texture
  109472. * @param format defines the format of the data
  109473. * @param forcedExtension defines the extension to use to pick the right loader
  109474. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  109475. * @returns the cube texture as an InternalTexture
  109476. */
  109477. 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;
  109478. }
  109479. }
  109480. declare module BABYLON {
  109481. /**
  109482. * Implementation of the DDS Texture Loader.
  109483. * @hidden
  109484. */
  109485. export class _DDSTextureLoader implements IInternalTextureLoader {
  109486. /**
  109487. * Defines wether the loader supports cascade loading the different faces.
  109488. */
  109489. readonly supportCascades: boolean;
  109490. /**
  109491. * This returns if the loader support the current file information.
  109492. * @param extension defines the file extension of the file being loaded
  109493. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109494. * @param fallback defines the fallback internal texture if any
  109495. * @param isBase64 defines whether the texture is encoded as a base64
  109496. * @param isBuffer defines whether the texture data are stored as a buffer
  109497. * @returns true if the loader can load the specified file
  109498. */
  109499. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109500. /**
  109501. * Transform the url before loading if required.
  109502. * @param rootUrl the url of the texture
  109503. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109504. * @returns the transformed texture
  109505. */
  109506. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109507. /**
  109508. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109509. * @param rootUrl the url of the texture
  109510. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109511. * @returns the fallback texture
  109512. */
  109513. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109514. /**
  109515. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109516. * @param data contains the texture data
  109517. * @param texture defines the BabylonJS internal texture
  109518. * @param createPolynomials will be true if polynomials have been requested
  109519. * @param onLoad defines the callback to trigger once the texture is ready
  109520. * @param onError defines the callback to trigger in case of error
  109521. */
  109522. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109523. /**
  109524. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109525. * @param data contains the texture data
  109526. * @param texture defines the BabylonJS internal texture
  109527. * @param callback defines the method to call once ready to upload
  109528. */
  109529. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109530. }
  109531. }
  109532. declare module BABYLON {
  109533. /** @hidden */
  109534. export var rgbdEncodePixelShader: {
  109535. name: string;
  109536. shader: string;
  109537. };
  109538. }
  109539. declare module BABYLON {
  109540. /**
  109541. * Raw texture data and descriptor sufficient for WebGL texture upload
  109542. */
  109543. export interface EnvironmentTextureInfo {
  109544. /**
  109545. * Version of the environment map
  109546. */
  109547. version: number;
  109548. /**
  109549. * Width of image
  109550. */
  109551. width: number;
  109552. /**
  109553. * Irradiance information stored in the file.
  109554. */
  109555. irradiance: any;
  109556. /**
  109557. * Specular information stored in the file.
  109558. */
  109559. specular: any;
  109560. }
  109561. /**
  109562. * Sets of helpers addressing the serialization and deserialization of environment texture
  109563. * stored in a BabylonJS env file.
  109564. * Those files are usually stored as .env files.
  109565. */
  109566. export class EnvironmentTextureTools {
  109567. /**
  109568. * Magic number identifying the env file.
  109569. */
  109570. private static _MagicBytes;
  109571. /**
  109572. * Gets the environment info from an env file.
  109573. * @param data The array buffer containing the .env bytes.
  109574. * @returns the environment file info (the json header) if successfully parsed.
  109575. */
  109576. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109577. /**
  109578. * Creates an environment texture from a loaded cube texture.
  109579. * @param texture defines the cube texture to convert in env file
  109580. * @return a promise containing the environment data if succesfull.
  109581. */
  109582. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109583. /**
  109584. * Creates a JSON representation of the spherical data.
  109585. * @param texture defines the texture containing the polynomials
  109586. * @return the JSON representation of the spherical info
  109587. */
  109588. private static _CreateEnvTextureIrradiance;
  109589. /**
  109590. * Uploads the texture info contained in the env file to the GPU.
  109591. * @param texture defines the internal texture to upload to
  109592. * @param arrayBuffer defines the buffer cotaining the data to load
  109593. * @param info defines the texture info retrieved through the GetEnvInfo method
  109594. * @returns a promise
  109595. */
  109596. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109597. /**
  109598. * Uploads the levels of image data to the GPU.
  109599. * @param texture defines the internal texture to upload to
  109600. * @param imageData defines the array buffer views of image data [mipmap][face]
  109601. * @returns a promise
  109602. */
  109603. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109604. /**
  109605. * Uploads spherical polynomials information to the texture.
  109606. * @param texture defines the texture we are trying to upload the information to
  109607. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109608. */
  109609. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109610. /** @hidden */
  109611. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109612. }
  109613. }
  109614. declare module BABYLON {
  109615. /**
  109616. * Implementation of the ENV Texture Loader.
  109617. * @hidden
  109618. */
  109619. export class _ENVTextureLoader implements IInternalTextureLoader {
  109620. /**
  109621. * Defines wether the loader supports cascade loading the different faces.
  109622. */
  109623. readonly supportCascades: boolean;
  109624. /**
  109625. * This returns if the loader support the current file information.
  109626. * @param extension defines the file extension of the file being loaded
  109627. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109628. * @param fallback defines the fallback internal texture if any
  109629. * @param isBase64 defines whether the texture is encoded as a base64
  109630. * @param isBuffer defines whether the texture data are stored as a buffer
  109631. * @returns true if the loader can load the specified file
  109632. */
  109633. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109634. /**
  109635. * Transform the url before loading if required.
  109636. * @param rootUrl the url of the texture
  109637. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109638. * @returns the transformed texture
  109639. */
  109640. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109641. /**
  109642. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109643. * @param rootUrl the url of the texture
  109644. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109645. * @returns the fallback texture
  109646. */
  109647. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109648. /**
  109649. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109650. * @param data contains the texture data
  109651. * @param texture defines the BabylonJS internal texture
  109652. * @param createPolynomials will be true if polynomials have been requested
  109653. * @param onLoad defines the callback to trigger once the texture is ready
  109654. * @param onError defines the callback to trigger in case of error
  109655. */
  109656. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109657. /**
  109658. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109659. * @param data contains the texture data
  109660. * @param texture defines the BabylonJS internal texture
  109661. * @param callback defines the method to call once ready to upload
  109662. */
  109663. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109664. }
  109665. }
  109666. declare module BABYLON {
  109667. /**
  109668. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  109669. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  109670. */
  109671. export class KhronosTextureContainer {
  109672. /** contents of the KTX container file */
  109673. arrayBuffer: any;
  109674. private static HEADER_LEN;
  109675. private static COMPRESSED_2D;
  109676. private static COMPRESSED_3D;
  109677. private static TEX_2D;
  109678. private static TEX_3D;
  109679. /**
  109680. * Gets the openGL type
  109681. */
  109682. glType: number;
  109683. /**
  109684. * Gets the openGL type size
  109685. */
  109686. glTypeSize: number;
  109687. /**
  109688. * Gets the openGL format
  109689. */
  109690. glFormat: number;
  109691. /**
  109692. * Gets the openGL internal format
  109693. */
  109694. glInternalFormat: number;
  109695. /**
  109696. * Gets the base internal format
  109697. */
  109698. glBaseInternalFormat: number;
  109699. /**
  109700. * Gets image width in pixel
  109701. */
  109702. pixelWidth: number;
  109703. /**
  109704. * Gets image height in pixel
  109705. */
  109706. pixelHeight: number;
  109707. /**
  109708. * Gets image depth in pixels
  109709. */
  109710. pixelDepth: number;
  109711. /**
  109712. * Gets the number of array elements
  109713. */
  109714. numberOfArrayElements: number;
  109715. /**
  109716. * Gets the number of faces
  109717. */
  109718. numberOfFaces: number;
  109719. /**
  109720. * Gets the number of mipmap levels
  109721. */
  109722. numberOfMipmapLevels: number;
  109723. /**
  109724. * Gets the bytes of key value data
  109725. */
  109726. bytesOfKeyValueData: number;
  109727. /**
  109728. * Gets the load type
  109729. */
  109730. loadType: number;
  109731. /**
  109732. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109733. */
  109734. isInvalid: boolean;
  109735. /**
  109736. * Creates a new KhronosTextureContainer
  109737. * @param arrayBuffer contents of the KTX container file
  109738. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109739. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109740. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109741. */
  109742. constructor(
  109743. /** contents of the KTX container file */
  109744. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109745. /**
  109746. * Uploads KTX content to a Babylon Texture.
  109747. * It is assumed that the texture has already been created & is currently bound
  109748. * @hidden
  109749. */
  109750. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  109751. private _upload2DCompressedLevels;
  109752. }
  109753. }
  109754. declare module BABYLON {
  109755. /**
  109756. * Implementation of the KTX Texture Loader.
  109757. * @hidden
  109758. */
  109759. export class _KTXTextureLoader implements IInternalTextureLoader {
  109760. /**
  109761. * Defines wether the loader supports cascade loading the different faces.
  109762. */
  109763. readonly supportCascades: boolean;
  109764. /**
  109765. * This returns if the loader support the current file information.
  109766. * @param extension defines the file extension of the file being loaded
  109767. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109768. * @param fallback defines the fallback internal texture if any
  109769. * @param isBase64 defines whether the texture is encoded as a base64
  109770. * @param isBuffer defines whether the texture data are stored as a buffer
  109771. * @returns true if the loader can load the specified file
  109772. */
  109773. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109774. /**
  109775. * Transform the url before loading if required.
  109776. * @param rootUrl the url of the texture
  109777. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109778. * @returns the transformed texture
  109779. */
  109780. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109781. /**
  109782. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109783. * @param rootUrl the url of the texture
  109784. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109785. * @returns the fallback texture
  109786. */
  109787. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109788. /**
  109789. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109790. * @param data contains the texture data
  109791. * @param texture defines the BabylonJS internal texture
  109792. * @param createPolynomials will be true if polynomials have been requested
  109793. * @param onLoad defines the callback to trigger once the texture is ready
  109794. * @param onError defines the callback to trigger in case of error
  109795. */
  109796. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109797. /**
  109798. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109799. * @param data contains the texture data
  109800. * @param texture defines the BabylonJS internal texture
  109801. * @param callback defines the method to call once ready to upload
  109802. */
  109803. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  109804. }
  109805. }
  109806. declare module BABYLON {
  109807. /** @hidden */
  109808. export var _forceSceneHelpersToBundle: boolean;
  109809. interface Scene {
  109810. /**
  109811. * Creates a default light for the scene.
  109812. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  109813. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  109814. */
  109815. createDefaultLight(replace?: boolean): void;
  109816. /**
  109817. * Creates a default camera for the scene.
  109818. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  109819. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109820. * @param replace has default false, when true replaces the active camera in the scene
  109821. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  109822. */
  109823. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109824. /**
  109825. * Creates a default camera and a default light.
  109826. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  109827. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109828. * @param replace has the default false, when true replaces the active camera/light in the scene
  109829. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  109830. */
  109831. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109832. /**
  109833. * Creates a new sky box
  109834. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  109835. * @param environmentTexture defines the texture to use as environment texture
  109836. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  109837. * @param scale defines the overall scale of the skybox
  109838. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  109839. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  109840. * @returns a new mesh holding the sky box
  109841. */
  109842. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  109843. /**
  109844. * Creates a new environment
  109845. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  109846. * @param options defines the options you can use to configure the environment
  109847. * @returns the new EnvironmentHelper
  109848. */
  109849. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  109850. /**
  109851. * Creates a new VREXperienceHelper
  109852. * @see http://doc.babylonjs.com/how_to/webvr_helper
  109853. * @param webVROptions defines the options used to create the new VREXperienceHelper
  109854. * @returns a new VREXperienceHelper
  109855. */
  109856. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  109857. /**
  109858. * Creates a new XREXperienceHelper
  109859. * @see http://doc.babylonjs.com/how_to/webxr
  109860. * @returns a promise for a new XREXperienceHelper
  109861. */
  109862. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  109863. }
  109864. }
  109865. declare module BABYLON {
  109866. /**
  109867. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  109868. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  109869. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  109870. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109871. */
  109872. export class VideoDome extends TransformNode {
  109873. /**
  109874. * Define the video source as a Monoscopic panoramic 360 video.
  109875. */
  109876. static readonly MODE_MONOSCOPIC: number;
  109877. /**
  109878. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109879. */
  109880. static readonly MODE_TOPBOTTOM: number;
  109881. /**
  109882. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109883. */
  109884. static readonly MODE_SIDEBYSIDE: number;
  109885. private _useDirectMapping;
  109886. /**
  109887. * The video texture being displayed on the sphere
  109888. */
  109889. protected _videoTexture: VideoTexture;
  109890. /**
  109891. * Gets the video texture being displayed on the sphere
  109892. */
  109893. readonly videoTexture: VideoTexture;
  109894. /**
  109895. * The skybox material
  109896. */
  109897. protected _material: BackgroundMaterial;
  109898. /**
  109899. * The surface used for the skybox
  109900. */
  109901. protected _mesh: Mesh;
  109902. /**
  109903. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109904. * Also see the options.resolution property.
  109905. */
  109906. fovMultiplier: number;
  109907. private _videoMode;
  109908. /**
  109909. * Gets or set the current video mode for the video. It can be:
  109910. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  109911. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109912. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109913. */
  109914. videoMode: number;
  109915. /**
  109916. * Oberserver used in Stereoscopic VR Mode.
  109917. */
  109918. private _onBeforeCameraRenderObserver;
  109919. /**
  109920. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  109921. * @param name Element's name, child elements will append suffixes for their own names.
  109922. * @param urlsOrVideo defines the url(s) or the video element to use
  109923. * @param options An object containing optional or exposed sub element properties
  109924. */
  109925. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  109926. resolution?: number;
  109927. clickToPlay?: boolean;
  109928. autoPlay?: boolean;
  109929. loop?: boolean;
  109930. size?: number;
  109931. poster?: string;
  109932. faceForward?: boolean;
  109933. useDirectMapping?: boolean;
  109934. }, scene: Scene);
  109935. private _changeVideoMode;
  109936. /**
  109937. * Releases resources associated with this node.
  109938. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109939. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109940. */
  109941. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109942. }
  109943. }
  109944. declare module BABYLON {
  109945. /**
  109946. * This class can be used to get instrumentation data from a Babylon engine
  109947. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109948. */
  109949. export class EngineInstrumentation implements IDisposable {
  109950. /**
  109951. * Define the instrumented engine.
  109952. */
  109953. engine: Engine;
  109954. private _captureGPUFrameTime;
  109955. private _gpuFrameTimeToken;
  109956. private _gpuFrameTime;
  109957. private _captureShaderCompilationTime;
  109958. private _shaderCompilationTime;
  109959. private _onBeginFrameObserver;
  109960. private _onEndFrameObserver;
  109961. private _onBeforeShaderCompilationObserver;
  109962. private _onAfterShaderCompilationObserver;
  109963. /**
  109964. * Gets the perf counter used for GPU frame time
  109965. */
  109966. readonly gpuFrameTimeCounter: PerfCounter;
  109967. /**
  109968. * Gets the GPU frame time capture status
  109969. */
  109970. /**
  109971. * Enable or disable the GPU frame time capture
  109972. */
  109973. captureGPUFrameTime: boolean;
  109974. /**
  109975. * Gets the perf counter used for shader compilation time
  109976. */
  109977. readonly shaderCompilationTimeCounter: PerfCounter;
  109978. /**
  109979. * Gets the shader compilation time capture status
  109980. */
  109981. /**
  109982. * Enable or disable the shader compilation time capture
  109983. */
  109984. captureShaderCompilationTime: boolean;
  109985. /**
  109986. * Instantiates a new engine instrumentation.
  109987. * This class can be used to get instrumentation data from a Babylon engine
  109988. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109989. * @param engine Defines the engine to instrument
  109990. */
  109991. constructor(
  109992. /**
  109993. * Define the instrumented engine.
  109994. */
  109995. engine: Engine);
  109996. /**
  109997. * Dispose and release associated resources.
  109998. */
  109999. dispose(): void;
  110000. }
  110001. }
  110002. declare module BABYLON {
  110003. /**
  110004. * This class can be used to get instrumentation data from a Babylon engine
  110005. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110006. */
  110007. export class SceneInstrumentation implements IDisposable {
  110008. /**
  110009. * Defines the scene to instrument
  110010. */
  110011. scene: Scene;
  110012. private _captureActiveMeshesEvaluationTime;
  110013. private _activeMeshesEvaluationTime;
  110014. private _captureRenderTargetsRenderTime;
  110015. private _renderTargetsRenderTime;
  110016. private _captureFrameTime;
  110017. private _frameTime;
  110018. private _captureRenderTime;
  110019. private _renderTime;
  110020. private _captureInterFrameTime;
  110021. private _interFrameTime;
  110022. private _captureParticlesRenderTime;
  110023. private _particlesRenderTime;
  110024. private _captureSpritesRenderTime;
  110025. private _spritesRenderTime;
  110026. private _capturePhysicsTime;
  110027. private _physicsTime;
  110028. private _captureAnimationsTime;
  110029. private _animationsTime;
  110030. private _captureCameraRenderTime;
  110031. private _cameraRenderTime;
  110032. private _onBeforeActiveMeshesEvaluationObserver;
  110033. private _onAfterActiveMeshesEvaluationObserver;
  110034. private _onBeforeRenderTargetsRenderObserver;
  110035. private _onAfterRenderTargetsRenderObserver;
  110036. private _onAfterRenderObserver;
  110037. private _onBeforeDrawPhaseObserver;
  110038. private _onAfterDrawPhaseObserver;
  110039. private _onBeforeAnimationsObserver;
  110040. private _onBeforeParticlesRenderingObserver;
  110041. private _onAfterParticlesRenderingObserver;
  110042. private _onBeforeSpritesRenderingObserver;
  110043. private _onAfterSpritesRenderingObserver;
  110044. private _onBeforePhysicsObserver;
  110045. private _onAfterPhysicsObserver;
  110046. private _onAfterAnimationsObserver;
  110047. private _onBeforeCameraRenderObserver;
  110048. private _onAfterCameraRenderObserver;
  110049. /**
  110050. * Gets the perf counter used for active meshes evaluation time
  110051. */
  110052. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  110053. /**
  110054. * Gets the active meshes evaluation time capture status
  110055. */
  110056. /**
  110057. * Enable or disable the active meshes evaluation time capture
  110058. */
  110059. captureActiveMeshesEvaluationTime: boolean;
  110060. /**
  110061. * Gets the perf counter used for render targets render time
  110062. */
  110063. readonly renderTargetsRenderTimeCounter: PerfCounter;
  110064. /**
  110065. * Gets the render targets render time capture status
  110066. */
  110067. /**
  110068. * Enable or disable the render targets render time capture
  110069. */
  110070. captureRenderTargetsRenderTime: boolean;
  110071. /**
  110072. * Gets the perf counter used for particles render time
  110073. */
  110074. readonly particlesRenderTimeCounter: PerfCounter;
  110075. /**
  110076. * Gets the particles render time capture status
  110077. */
  110078. /**
  110079. * Enable or disable the particles render time capture
  110080. */
  110081. captureParticlesRenderTime: boolean;
  110082. /**
  110083. * Gets the perf counter used for sprites render time
  110084. */
  110085. readonly spritesRenderTimeCounter: PerfCounter;
  110086. /**
  110087. * Gets the sprites render time capture status
  110088. */
  110089. /**
  110090. * Enable or disable the sprites render time capture
  110091. */
  110092. captureSpritesRenderTime: boolean;
  110093. /**
  110094. * Gets the perf counter used for physics time
  110095. */
  110096. readonly physicsTimeCounter: PerfCounter;
  110097. /**
  110098. * Gets the physics time capture status
  110099. */
  110100. /**
  110101. * Enable or disable the physics time capture
  110102. */
  110103. capturePhysicsTime: boolean;
  110104. /**
  110105. * Gets the perf counter used for animations time
  110106. */
  110107. readonly animationsTimeCounter: PerfCounter;
  110108. /**
  110109. * Gets the animations time capture status
  110110. */
  110111. /**
  110112. * Enable or disable the animations time capture
  110113. */
  110114. captureAnimationsTime: boolean;
  110115. /**
  110116. * Gets the perf counter used for frame time capture
  110117. */
  110118. readonly frameTimeCounter: PerfCounter;
  110119. /**
  110120. * Gets the frame time capture status
  110121. */
  110122. /**
  110123. * Enable or disable the frame time capture
  110124. */
  110125. captureFrameTime: boolean;
  110126. /**
  110127. * Gets the perf counter used for inter-frames time capture
  110128. */
  110129. readonly interFrameTimeCounter: PerfCounter;
  110130. /**
  110131. * Gets the inter-frames time capture status
  110132. */
  110133. /**
  110134. * Enable or disable the inter-frames time capture
  110135. */
  110136. captureInterFrameTime: boolean;
  110137. /**
  110138. * Gets the perf counter used for render time capture
  110139. */
  110140. readonly renderTimeCounter: PerfCounter;
  110141. /**
  110142. * Gets the render time capture status
  110143. */
  110144. /**
  110145. * Enable or disable the render time capture
  110146. */
  110147. captureRenderTime: boolean;
  110148. /**
  110149. * Gets the perf counter used for camera render time capture
  110150. */
  110151. readonly cameraRenderTimeCounter: PerfCounter;
  110152. /**
  110153. * Gets the camera render time capture status
  110154. */
  110155. /**
  110156. * Enable or disable the camera render time capture
  110157. */
  110158. captureCameraRenderTime: boolean;
  110159. /**
  110160. * Gets the perf counter used for draw calls
  110161. */
  110162. readonly drawCallsCounter: PerfCounter;
  110163. /**
  110164. * Instantiates a new scene instrumentation.
  110165. * This class can be used to get instrumentation data from a Babylon engine
  110166. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110167. * @param scene Defines the scene to instrument
  110168. */
  110169. constructor(
  110170. /**
  110171. * Defines the scene to instrument
  110172. */
  110173. scene: Scene);
  110174. /**
  110175. * Dispose and release associated resources.
  110176. */
  110177. dispose(): void;
  110178. }
  110179. }
  110180. declare module BABYLON {
  110181. /** @hidden */
  110182. export var glowMapGenerationPixelShader: {
  110183. name: string;
  110184. shader: string;
  110185. };
  110186. }
  110187. declare module BABYLON {
  110188. /** @hidden */
  110189. export var glowMapGenerationVertexShader: {
  110190. name: string;
  110191. shader: string;
  110192. };
  110193. }
  110194. declare module BABYLON {
  110195. /**
  110196. * Effect layer options. This helps customizing the behaviour
  110197. * of the effect layer.
  110198. */
  110199. export interface IEffectLayerOptions {
  110200. /**
  110201. * Multiplication factor apply to the canvas size to compute the render target size
  110202. * used to generated the objects (the smaller the faster).
  110203. */
  110204. mainTextureRatio: number;
  110205. /**
  110206. * Enforces a fixed size texture to ensure effect stability across devices.
  110207. */
  110208. mainTextureFixedSize?: number;
  110209. /**
  110210. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  110211. */
  110212. alphaBlendingMode: number;
  110213. /**
  110214. * The camera attached to the layer.
  110215. */
  110216. camera: Nullable<Camera>;
  110217. /**
  110218. * The rendering group to draw the layer in.
  110219. */
  110220. renderingGroupId: number;
  110221. }
  110222. /**
  110223. * The effect layer Helps adding post process effect blended with the main pass.
  110224. *
  110225. * This can be for instance use to generate glow or higlight effects on the scene.
  110226. *
  110227. * The effect layer class can not be used directly and is intented to inherited from to be
  110228. * customized per effects.
  110229. */
  110230. export abstract class EffectLayer {
  110231. private _vertexBuffers;
  110232. private _indexBuffer;
  110233. private _cachedDefines;
  110234. private _effectLayerMapGenerationEffect;
  110235. private _effectLayerOptions;
  110236. private _mergeEffect;
  110237. protected _scene: Scene;
  110238. protected _engine: Engine;
  110239. protected _maxSize: number;
  110240. protected _mainTextureDesiredSize: ISize;
  110241. protected _mainTexture: RenderTargetTexture;
  110242. protected _shouldRender: boolean;
  110243. protected _postProcesses: PostProcess[];
  110244. protected _textures: BaseTexture[];
  110245. protected _emissiveTextureAndColor: {
  110246. texture: Nullable<BaseTexture>;
  110247. color: Color4;
  110248. };
  110249. /**
  110250. * The name of the layer
  110251. */
  110252. name: string;
  110253. /**
  110254. * The clear color of the texture used to generate the glow map.
  110255. */
  110256. neutralColor: Color4;
  110257. /**
  110258. * Specifies wether the highlight layer is enabled or not.
  110259. */
  110260. isEnabled: boolean;
  110261. /**
  110262. * Gets the camera attached to the layer.
  110263. */
  110264. readonly camera: Nullable<Camera>;
  110265. /**
  110266. * Gets the rendering group id the layer should render in.
  110267. */
  110268. renderingGroupId: number;
  110269. /**
  110270. * An event triggered when the effect layer has been disposed.
  110271. */
  110272. onDisposeObservable: Observable<EffectLayer>;
  110273. /**
  110274. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  110275. */
  110276. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  110277. /**
  110278. * An event triggered when the generated texture is being merged in the scene.
  110279. */
  110280. onBeforeComposeObservable: Observable<EffectLayer>;
  110281. /**
  110282. * An event triggered when the generated texture has been merged in the scene.
  110283. */
  110284. onAfterComposeObservable: Observable<EffectLayer>;
  110285. /**
  110286. * An event triggered when the efffect layer changes its size.
  110287. */
  110288. onSizeChangedObservable: Observable<EffectLayer>;
  110289. /** @hidden */
  110290. static _SceneComponentInitialization: (scene: Scene) => void;
  110291. /**
  110292. * Instantiates a new effect Layer and references it in the scene.
  110293. * @param name The name of the layer
  110294. * @param scene The scene to use the layer in
  110295. */
  110296. constructor(
  110297. /** The Friendly of the effect in the scene */
  110298. name: string, scene: Scene);
  110299. /**
  110300. * Get the effect name of the layer.
  110301. * @return The effect name
  110302. */
  110303. abstract getEffectName(): string;
  110304. /**
  110305. * Checks for the readiness of the element composing the layer.
  110306. * @param subMesh the mesh to check for
  110307. * @param useInstances specify wether or not to use instances to render the mesh
  110308. * @return true if ready otherwise, false
  110309. */
  110310. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110311. /**
  110312. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110313. * @returns true if the effect requires stencil during the main canvas render pass.
  110314. */
  110315. abstract needStencil(): boolean;
  110316. /**
  110317. * Create the merge effect. This is the shader use to blit the information back
  110318. * to the main canvas at the end of the scene rendering.
  110319. * @returns The effect containing the shader used to merge the effect on the main canvas
  110320. */
  110321. protected abstract _createMergeEffect(): Effect;
  110322. /**
  110323. * Creates the render target textures and post processes used in the effect layer.
  110324. */
  110325. protected abstract _createTextureAndPostProcesses(): void;
  110326. /**
  110327. * Implementation specific of rendering the generating effect on the main canvas.
  110328. * @param effect The effect used to render through
  110329. */
  110330. protected abstract _internalRender(effect: Effect): void;
  110331. /**
  110332. * Sets the required values for both the emissive texture and and the main color.
  110333. */
  110334. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110335. /**
  110336. * Free any resources and references associated to a mesh.
  110337. * Internal use
  110338. * @param mesh The mesh to free.
  110339. */
  110340. abstract _disposeMesh(mesh: Mesh): void;
  110341. /**
  110342. * Serializes this layer (Glow or Highlight for example)
  110343. * @returns a serialized layer object
  110344. */
  110345. abstract serialize?(): any;
  110346. /**
  110347. * Initializes the effect layer with the required options.
  110348. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  110349. */
  110350. protected _init(options: Partial<IEffectLayerOptions>): void;
  110351. /**
  110352. * Generates the index buffer of the full screen quad blending to the main canvas.
  110353. */
  110354. private _generateIndexBuffer;
  110355. /**
  110356. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  110357. */
  110358. private _generateVertexBuffer;
  110359. /**
  110360. * Sets the main texture desired size which is the closest power of two
  110361. * of the engine canvas size.
  110362. */
  110363. private _setMainTextureSize;
  110364. /**
  110365. * Creates the main texture for the effect layer.
  110366. */
  110367. protected _createMainTexture(): void;
  110368. /**
  110369. * Adds specific effects defines.
  110370. * @param defines The defines to add specifics to.
  110371. */
  110372. protected _addCustomEffectDefines(defines: string[]): void;
  110373. /**
  110374. * Checks for the readiness of the element composing the layer.
  110375. * @param subMesh the mesh to check for
  110376. * @param useInstances specify wether or not to use instances to render the mesh
  110377. * @param emissiveTexture the associated emissive texture used to generate the glow
  110378. * @return true if ready otherwise, false
  110379. */
  110380. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  110381. /**
  110382. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  110383. */
  110384. render(): void;
  110385. /**
  110386. * Determine if a given mesh will be used in the current effect.
  110387. * @param mesh mesh to test
  110388. * @returns true if the mesh will be used
  110389. */
  110390. hasMesh(mesh: AbstractMesh): boolean;
  110391. /**
  110392. * Returns true if the layer contains information to display, otherwise false.
  110393. * @returns true if the glow layer should be rendered
  110394. */
  110395. shouldRender(): boolean;
  110396. /**
  110397. * Returns true if the mesh should render, otherwise false.
  110398. * @param mesh The mesh to render
  110399. * @returns true if it should render otherwise false
  110400. */
  110401. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  110402. /**
  110403. * Returns true if the mesh can be rendered, otherwise false.
  110404. * @param mesh The mesh to render
  110405. * @param material The material used on the mesh
  110406. * @returns true if it can be rendered otherwise false
  110407. */
  110408. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110409. /**
  110410. * Returns true if the mesh should render, otherwise false.
  110411. * @param mesh The mesh to render
  110412. * @returns true if it should render otherwise false
  110413. */
  110414. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  110415. /**
  110416. * Renders the submesh passed in parameter to the generation map.
  110417. */
  110418. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  110419. /**
  110420. * Rebuild the required buffers.
  110421. * @hidden Internal use only.
  110422. */
  110423. _rebuild(): void;
  110424. /**
  110425. * Dispose only the render target textures and post process.
  110426. */
  110427. private _disposeTextureAndPostProcesses;
  110428. /**
  110429. * Dispose the highlight layer and free resources.
  110430. */
  110431. dispose(): void;
  110432. /**
  110433. * Gets the class name of the effect layer
  110434. * @returns the string with the class name of the effect layer
  110435. */
  110436. getClassName(): string;
  110437. /**
  110438. * Creates an effect layer from parsed effect layer data
  110439. * @param parsedEffectLayer defines effect layer data
  110440. * @param scene defines the current scene
  110441. * @param rootUrl defines the root URL containing the effect layer information
  110442. * @returns a parsed effect Layer
  110443. */
  110444. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  110445. }
  110446. }
  110447. declare module BABYLON {
  110448. interface AbstractScene {
  110449. /**
  110450. * The list of effect layers (highlights/glow) added to the scene
  110451. * @see http://doc.babylonjs.com/how_to/highlight_layer
  110452. * @see http://doc.babylonjs.com/how_to/glow_layer
  110453. */
  110454. effectLayers: Array<EffectLayer>;
  110455. /**
  110456. * Removes the given effect layer from this scene.
  110457. * @param toRemove defines the effect layer to remove
  110458. * @returns the index of the removed effect layer
  110459. */
  110460. removeEffectLayer(toRemove: EffectLayer): number;
  110461. /**
  110462. * Adds the given effect layer to this scene
  110463. * @param newEffectLayer defines the effect layer to add
  110464. */
  110465. addEffectLayer(newEffectLayer: EffectLayer): void;
  110466. }
  110467. /**
  110468. * Defines the layer scene component responsible to manage any effect layers
  110469. * in a given scene.
  110470. */
  110471. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  110472. /**
  110473. * The component name helpfull to identify the component in the list of scene components.
  110474. */
  110475. readonly name: string;
  110476. /**
  110477. * The scene the component belongs to.
  110478. */
  110479. scene: Scene;
  110480. private _engine;
  110481. private _renderEffects;
  110482. private _needStencil;
  110483. private _previousStencilState;
  110484. /**
  110485. * Creates a new instance of the component for the given scene
  110486. * @param scene Defines the scene to register the component in
  110487. */
  110488. constructor(scene: Scene);
  110489. /**
  110490. * Registers the component in a given scene
  110491. */
  110492. register(): void;
  110493. /**
  110494. * Rebuilds the elements related to this component in case of
  110495. * context lost for instance.
  110496. */
  110497. rebuild(): void;
  110498. /**
  110499. * Serializes the component data to the specified json object
  110500. * @param serializationObject The object to serialize to
  110501. */
  110502. serialize(serializationObject: any): void;
  110503. /**
  110504. * Adds all the elements from the container to the scene
  110505. * @param container the container holding the elements
  110506. */
  110507. addFromContainer(container: AbstractScene): void;
  110508. /**
  110509. * Removes all the elements in the container from the scene
  110510. * @param container contains the elements to remove
  110511. * @param dispose if the removed element should be disposed (default: false)
  110512. */
  110513. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110514. /**
  110515. * Disposes the component and the associated ressources.
  110516. */
  110517. dispose(): void;
  110518. private _isReadyForMesh;
  110519. private _renderMainTexture;
  110520. private _setStencil;
  110521. private _setStencilBack;
  110522. private _draw;
  110523. private _drawCamera;
  110524. private _drawRenderingGroup;
  110525. }
  110526. }
  110527. declare module BABYLON {
  110528. /** @hidden */
  110529. export var glowMapMergePixelShader: {
  110530. name: string;
  110531. shader: string;
  110532. };
  110533. }
  110534. declare module BABYLON {
  110535. /** @hidden */
  110536. export var glowMapMergeVertexShader: {
  110537. name: string;
  110538. shader: string;
  110539. };
  110540. }
  110541. declare module BABYLON {
  110542. interface AbstractScene {
  110543. /**
  110544. * Return a the first highlight layer of the scene with a given name.
  110545. * @param name The name of the highlight layer to look for.
  110546. * @return The highlight layer if found otherwise null.
  110547. */
  110548. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  110549. }
  110550. /**
  110551. * Glow layer options. This helps customizing the behaviour
  110552. * of the glow layer.
  110553. */
  110554. export interface IGlowLayerOptions {
  110555. /**
  110556. * Multiplication factor apply to the canvas size to compute the render target size
  110557. * used to generated the glowing objects (the smaller the faster).
  110558. */
  110559. mainTextureRatio: number;
  110560. /**
  110561. * Enforces a fixed size texture to ensure resize independant blur.
  110562. */
  110563. mainTextureFixedSize?: number;
  110564. /**
  110565. * How big is the kernel of the blur texture.
  110566. */
  110567. blurKernelSize: number;
  110568. /**
  110569. * The camera attached to the layer.
  110570. */
  110571. camera: Nullable<Camera>;
  110572. /**
  110573. * Enable MSAA by chosing the number of samples.
  110574. */
  110575. mainTextureSamples?: number;
  110576. /**
  110577. * The rendering group to draw the layer in.
  110578. */
  110579. renderingGroupId: number;
  110580. }
  110581. /**
  110582. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  110583. *
  110584. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110585. * glowy meshes to your scene.
  110586. *
  110587. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  110588. */
  110589. export class GlowLayer extends EffectLayer {
  110590. /**
  110591. * Effect Name of the layer.
  110592. */
  110593. static readonly EffectName: string;
  110594. /**
  110595. * The default blur kernel size used for the glow.
  110596. */
  110597. static DefaultBlurKernelSize: number;
  110598. /**
  110599. * The default texture size ratio used for the glow.
  110600. */
  110601. static DefaultTextureRatio: number;
  110602. /**
  110603. * Sets the kernel size of the blur.
  110604. */
  110605. /**
  110606. * Gets the kernel size of the blur.
  110607. */
  110608. blurKernelSize: number;
  110609. /**
  110610. * Sets the glow intensity.
  110611. */
  110612. /**
  110613. * Gets the glow intensity.
  110614. */
  110615. intensity: number;
  110616. private _options;
  110617. private _intensity;
  110618. private _horizontalBlurPostprocess1;
  110619. private _verticalBlurPostprocess1;
  110620. private _horizontalBlurPostprocess2;
  110621. private _verticalBlurPostprocess2;
  110622. private _blurTexture1;
  110623. private _blurTexture2;
  110624. private _postProcesses1;
  110625. private _postProcesses2;
  110626. private _includedOnlyMeshes;
  110627. private _excludedMeshes;
  110628. /**
  110629. * Callback used to let the user override the color selection on a per mesh basis
  110630. */
  110631. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  110632. /**
  110633. * Callback used to let the user override the texture selection on a per mesh basis
  110634. */
  110635. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  110636. /**
  110637. * Instantiates a new glow Layer and references it to the scene.
  110638. * @param name The name of the layer
  110639. * @param scene The scene to use the layer in
  110640. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  110641. */
  110642. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  110643. /**
  110644. * Get the effect name of the layer.
  110645. * @return The effect name
  110646. */
  110647. getEffectName(): string;
  110648. /**
  110649. * Create the merge effect. This is the shader use to blit the information back
  110650. * to the main canvas at the end of the scene rendering.
  110651. */
  110652. protected _createMergeEffect(): Effect;
  110653. /**
  110654. * Creates the render target textures and post processes used in the glow layer.
  110655. */
  110656. protected _createTextureAndPostProcesses(): void;
  110657. /**
  110658. * Checks for the readiness of the element composing the layer.
  110659. * @param subMesh the mesh to check for
  110660. * @param useInstances specify wether or not to use instances to render the mesh
  110661. * @param emissiveTexture the associated emissive texture used to generate the glow
  110662. * @return true if ready otherwise, false
  110663. */
  110664. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110665. /**
  110666. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110667. */
  110668. needStencil(): boolean;
  110669. /**
  110670. * Returns true if the mesh can be rendered, otherwise false.
  110671. * @param mesh The mesh to render
  110672. * @param material The material used on the mesh
  110673. * @returns true if it can be rendered otherwise false
  110674. */
  110675. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110676. /**
  110677. * Implementation specific of rendering the generating effect on the main canvas.
  110678. * @param effect The effect used to render through
  110679. */
  110680. protected _internalRender(effect: Effect): void;
  110681. /**
  110682. * Sets the required values for both the emissive texture and and the main color.
  110683. */
  110684. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110685. /**
  110686. * Returns true if the mesh should render, otherwise false.
  110687. * @param mesh The mesh to render
  110688. * @returns true if it should render otherwise false
  110689. */
  110690. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110691. /**
  110692. * Adds specific effects defines.
  110693. * @param defines The defines to add specifics to.
  110694. */
  110695. protected _addCustomEffectDefines(defines: string[]): void;
  110696. /**
  110697. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110698. * @param mesh The mesh to exclude from the glow layer
  110699. */
  110700. addExcludedMesh(mesh: Mesh): void;
  110701. /**
  110702. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110703. * @param mesh The mesh to remove
  110704. */
  110705. removeExcludedMesh(mesh: Mesh): void;
  110706. /**
  110707. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110708. * @param mesh The mesh to include in the glow layer
  110709. */
  110710. addIncludedOnlyMesh(mesh: Mesh): void;
  110711. /**
  110712. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110713. * @param mesh The mesh to remove
  110714. */
  110715. removeIncludedOnlyMesh(mesh: Mesh): void;
  110716. /**
  110717. * Determine if a given mesh will be used in the glow layer
  110718. * @param mesh The mesh to test
  110719. * @returns true if the mesh will be highlighted by the current glow layer
  110720. */
  110721. hasMesh(mesh: AbstractMesh): boolean;
  110722. /**
  110723. * Free any resources and references associated to a mesh.
  110724. * Internal use
  110725. * @param mesh The mesh to free.
  110726. * @hidden
  110727. */
  110728. _disposeMesh(mesh: Mesh): void;
  110729. /**
  110730. * Gets the class name of the effect layer
  110731. * @returns the string with the class name of the effect layer
  110732. */
  110733. getClassName(): string;
  110734. /**
  110735. * Serializes this glow layer
  110736. * @returns a serialized glow layer object
  110737. */
  110738. serialize(): any;
  110739. /**
  110740. * Creates a Glow Layer from parsed glow layer data
  110741. * @param parsedGlowLayer defines glow layer data
  110742. * @param scene defines the current scene
  110743. * @param rootUrl defines the root URL containing the glow layer information
  110744. * @returns a parsed Glow Layer
  110745. */
  110746. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  110747. }
  110748. }
  110749. declare module BABYLON {
  110750. /** @hidden */
  110751. export var glowBlurPostProcessPixelShader: {
  110752. name: string;
  110753. shader: string;
  110754. };
  110755. }
  110756. declare module BABYLON {
  110757. interface AbstractScene {
  110758. /**
  110759. * Return a the first highlight layer of the scene with a given name.
  110760. * @param name The name of the highlight layer to look for.
  110761. * @return The highlight layer if found otherwise null.
  110762. */
  110763. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  110764. }
  110765. /**
  110766. * Highlight layer options. This helps customizing the behaviour
  110767. * of the highlight layer.
  110768. */
  110769. export interface IHighlightLayerOptions {
  110770. /**
  110771. * Multiplication factor apply to the canvas size to compute the render target size
  110772. * used to generated the glowing objects (the smaller the faster).
  110773. */
  110774. mainTextureRatio: number;
  110775. /**
  110776. * Enforces a fixed size texture to ensure resize independant blur.
  110777. */
  110778. mainTextureFixedSize?: number;
  110779. /**
  110780. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  110781. * of the picture to blur (the smaller the faster).
  110782. */
  110783. blurTextureSizeRatio: number;
  110784. /**
  110785. * How big in texel of the blur texture is the vertical blur.
  110786. */
  110787. blurVerticalSize: number;
  110788. /**
  110789. * How big in texel of the blur texture is the horizontal blur.
  110790. */
  110791. blurHorizontalSize: number;
  110792. /**
  110793. * Alpha blending mode used to apply the blur. Default is combine.
  110794. */
  110795. alphaBlendingMode: number;
  110796. /**
  110797. * The camera attached to the layer.
  110798. */
  110799. camera: Nullable<Camera>;
  110800. /**
  110801. * Should we display highlight as a solid stroke?
  110802. */
  110803. isStroke?: boolean;
  110804. /**
  110805. * The rendering group to draw the layer in.
  110806. */
  110807. renderingGroupId: number;
  110808. }
  110809. /**
  110810. * The highlight layer Helps adding a glow effect around a mesh.
  110811. *
  110812. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110813. * glowy meshes to your scene.
  110814. *
  110815. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  110816. */
  110817. export class HighlightLayer extends EffectLayer {
  110818. name: string;
  110819. /**
  110820. * Effect Name of the highlight layer.
  110821. */
  110822. static readonly EffectName: string;
  110823. /**
  110824. * The neutral color used during the preparation of the glow effect.
  110825. * This is black by default as the blend operation is a blend operation.
  110826. */
  110827. static NeutralColor: Color4;
  110828. /**
  110829. * Stencil value used for glowing meshes.
  110830. */
  110831. static GlowingMeshStencilReference: number;
  110832. /**
  110833. * Stencil value used for the other meshes in the scene.
  110834. */
  110835. static NormalMeshStencilReference: number;
  110836. /**
  110837. * Specifies whether or not the inner glow is ACTIVE in the layer.
  110838. */
  110839. innerGlow: boolean;
  110840. /**
  110841. * Specifies whether or not the outer glow is ACTIVE in the layer.
  110842. */
  110843. outerGlow: boolean;
  110844. /**
  110845. * Specifies the horizontal size of the blur.
  110846. */
  110847. /**
  110848. * Gets the horizontal size of the blur.
  110849. */
  110850. blurHorizontalSize: number;
  110851. /**
  110852. * Specifies the vertical size of the blur.
  110853. */
  110854. /**
  110855. * Gets the vertical size of the blur.
  110856. */
  110857. blurVerticalSize: number;
  110858. /**
  110859. * An event triggered when the highlight layer is being blurred.
  110860. */
  110861. onBeforeBlurObservable: Observable<HighlightLayer>;
  110862. /**
  110863. * An event triggered when the highlight layer has been blurred.
  110864. */
  110865. onAfterBlurObservable: Observable<HighlightLayer>;
  110866. private _instanceGlowingMeshStencilReference;
  110867. private _options;
  110868. private _downSamplePostprocess;
  110869. private _horizontalBlurPostprocess;
  110870. private _verticalBlurPostprocess;
  110871. private _blurTexture;
  110872. private _meshes;
  110873. private _excludedMeshes;
  110874. /**
  110875. * Instantiates a new highlight Layer and references it to the scene..
  110876. * @param name The name of the layer
  110877. * @param scene The scene to use the layer in
  110878. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  110879. */
  110880. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  110881. /**
  110882. * Get the effect name of the layer.
  110883. * @return The effect name
  110884. */
  110885. getEffectName(): string;
  110886. /**
  110887. * Create the merge effect. This is the shader use to blit the information back
  110888. * to the main canvas at the end of the scene rendering.
  110889. */
  110890. protected _createMergeEffect(): Effect;
  110891. /**
  110892. * Creates the render target textures and post processes used in the highlight layer.
  110893. */
  110894. protected _createTextureAndPostProcesses(): void;
  110895. /**
  110896. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110897. */
  110898. needStencil(): boolean;
  110899. /**
  110900. * Checks for the readiness of the element composing the layer.
  110901. * @param subMesh the mesh to check for
  110902. * @param useInstances specify wether or not to use instances to render the mesh
  110903. * @param emissiveTexture the associated emissive texture used to generate the glow
  110904. * @return true if ready otherwise, false
  110905. */
  110906. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110907. /**
  110908. * Implementation specific of rendering the generating effect on the main canvas.
  110909. * @param effect The effect used to render through
  110910. */
  110911. protected _internalRender(effect: Effect): void;
  110912. /**
  110913. * Returns true if the layer contains information to display, otherwise false.
  110914. */
  110915. shouldRender(): boolean;
  110916. /**
  110917. * Returns true if the mesh should render, otherwise false.
  110918. * @param mesh The mesh to render
  110919. * @returns true if it should render otherwise false
  110920. */
  110921. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110922. /**
  110923. * Sets the required values for both the emissive texture and and the main color.
  110924. */
  110925. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110926. /**
  110927. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  110928. * @param mesh The mesh to exclude from the highlight layer
  110929. */
  110930. addExcludedMesh(mesh: Mesh): void;
  110931. /**
  110932. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  110933. * @param mesh The mesh to highlight
  110934. */
  110935. removeExcludedMesh(mesh: Mesh): void;
  110936. /**
  110937. * Determine if a given mesh will be highlighted by the current HighlightLayer
  110938. * @param mesh mesh to test
  110939. * @returns true if the mesh will be highlighted by the current HighlightLayer
  110940. */
  110941. hasMesh(mesh: AbstractMesh): boolean;
  110942. /**
  110943. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  110944. * @param mesh The mesh to highlight
  110945. * @param color The color of the highlight
  110946. * @param glowEmissiveOnly Extract the glow from the emissive texture
  110947. */
  110948. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  110949. /**
  110950. * Remove a mesh from the highlight layer in order to make it stop glowing.
  110951. * @param mesh The mesh to highlight
  110952. */
  110953. removeMesh(mesh: Mesh): void;
  110954. /**
  110955. * Force the stencil to the normal expected value for none glowing parts
  110956. */
  110957. private _defaultStencilReference;
  110958. /**
  110959. * Free any resources and references associated to a mesh.
  110960. * Internal use
  110961. * @param mesh The mesh to free.
  110962. * @hidden
  110963. */
  110964. _disposeMesh(mesh: Mesh): void;
  110965. /**
  110966. * Dispose the highlight layer and free resources.
  110967. */
  110968. dispose(): void;
  110969. /**
  110970. * Gets the class name of the effect layer
  110971. * @returns the string with the class name of the effect layer
  110972. */
  110973. getClassName(): string;
  110974. /**
  110975. * Serializes this Highlight layer
  110976. * @returns a serialized Highlight layer object
  110977. */
  110978. serialize(): any;
  110979. /**
  110980. * Creates a Highlight layer from parsed Highlight layer data
  110981. * @param parsedHightlightLayer defines the Highlight layer data
  110982. * @param scene defines the current scene
  110983. * @param rootUrl defines the root URL containing the Highlight layer information
  110984. * @returns a parsed Highlight layer
  110985. */
  110986. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  110987. }
  110988. }
  110989. declare module BABYLON {
  110990. interface AbstractScene {
  110991. /**
  110992. * The list of layers (background and foreground) of the scene
  110993. */
  110994. layers: Array<Layer>;
  110995. }
  110996. /**
  110997. * Defines the layer scene component responsible to manage any layers
  110998. * in a given scene.
  110999. */
  111000. export class LayerSceneComponent implements ISceneComponent {
  111001. /**
  111002. * The component name helpfull to identify the component in the list of scene components.
  111003. */
  111004. readonly name: string;
  111005. /**
  111006. * The scene the component belongs to.
  111007. */
  111008. scene: Scene;
  111009. private _engine;
  111010. /**
  111011. * Creates a new instance of the component for the given scene
  111012. * @param scene Defines the scene to register the component in
  111013. */
  111014. constructor(scene: Scene);
  111015. /**
  111016. * Registers the component in a given scene
  111017. */
  111018. register(): void;
  111019. /**
  111020. * Rebuilds the elements related to this component in case of
  111021. * context lost for instance.
  111022. */
  111023. rebuild(): void;
  111024. /**
  111025. * Disposes the component and the associated ressources.
  111026. */
  111027. dispose(): void;
  111028. private _draw;
  111029. private _drawCameraPredicate;
  111030. private _drawCameraBackground;
  111031. private _drawCameraForeground;
  111032. private _drawRenderTargetPredicate;
  111033. private _drawRenderTargetBackground;
  111034. private _drawRenderTargetForeground;
  111035. /**
  111036. * Adds all the elements from the container to the scene
  111037. * @param container the container holding the elements
  111038. */
  111039. addFromContainer(container: AbstractScene): void;
  111040. /**
  111041. * Removes all the elements in the container from the scene
  111042. * @param container contains the elements to remove
  111043. * @param dispose if the removed element should be disposed (default: false)
  111044. */
  111045. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111046. }
  111047. }
  111048. declare module BABYLON {
  111049. /** @hidden */
  111050. export var layerPixelShader: {
  111051. name: string;
  111052. shader: string;
  111053. };
  111054. }
  111055. declare module BABYLON {
  111056. /** @hidden */
  111057. export var layerVertexShader: {
  111058. name: string;
  111059. shader: string;
  111060. };
  111061. }
  111062. declare module BABYLON {
  111063. /**
  111064. * This represents a full screen 2d layer.
  111065. * This can be useful to display a picture in the background of your scene for instance.
  111066. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111067. */
  111068. export class Layer {
  111069. /**
  111070. * Define the name of the layer.
  111071. */
  111072. name: string;
  111073. /**
  111074. * Define the texture the layer should display.
  111075. */
  111076. texture: Nullable<Texture>;
  111077. /**
  111078. * Is the layer in background or foreground.
  111079. */
  111080. isBackground: boolean;
  111081. /**
  111082. * Define the color of the layer (instead of texture).
  111083. */
  111084. color: Color4;
  111085. /**
  111086. * Define the scale of the layer in order to zoom in out of the texture.
  111087. */
  111088. scale: Vector2;
  111089. /**
  111090. * Define an offset for the layer in order to shift the texture.
  111091. */
  111092. offset: Vector2;
  111093. /**
  111094. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  111095. */
  111096. alphaBlendingMode: number;
  111097. /**
  111098. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  111099. * Alpha test will not mix with the background color in case of transparency.
  111100. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  111101. */
  111102. alphaTest: boolean;
  111103. /**
  111104. * Define a mask to restrict the layer to only some of the scene cameras.
  111105. */
  111106. layerMask: number;
  111107. /**
  111108. * Define the list of render target the layer is visible into.
  111109. */
  111110. renderTargetTextures: RenderTargetTexture[];
  111111. /**
  111112. * Define if the layer is only used in renderTarget or if it also
  111113. * renders in the main frame buffer of the canvas.
  111114. */
  111115. renderOnlyInRenderTargetTextures: boolean;
  111116. private _scene;
  111117. private _vertexBuffers;
  111118. private _indexBuffer;
  111119. private _effect;
  111120. private _alphaTestEffect;
  111121. /**
  111122. * An event triggered when the layer is disposed.
  111123. */
  111124. onDisposeObservable: Observable<Layer>;
  111125. private _onDisposeObserver;
  111126. /**
  111127. * Back compatibility with callback before the onDisposeObservable existed.
  111128. * The set callback will be triggered when the layer has been disposed.
  111129. */
  111130. onDispose: () => void;
  111131. /**
  111132. * An event triggered before rendering the scene
  111133. */
  111134. onBeforeRenderObservable: Observable<Layer>;
  111135. private _onBeforeRenderObserver;
  111136. /**
  111137. * Back compatibility with callback before the onBeforeRenderObservable existed.
  111138. * The set callback will be triggered just before rendering the layer.
  111139. */
  111140. onBeforeRender: () => void;
  111141. /**
  111142. * An event triggered after rendering the scene
  111143. */
  111144. onAfterRenderObservable: Observable<Layer>;
  111145. private _onAfterRenderObserver;
  111146. /**
  111147. * Back compatibility with callback before the onAfterRenderObservable existed.
  111148. * The set callback will be triggered just after rendering the layer.
  111149. */
  111150. onAfterRender: () => void;
  111151. /**
  111152. * Instantiates a new layer.
  111153. * This represents a full screen 2d layer.
  111154. * This can be useful to display a picture in the background of your scene for instance.
  111155. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111156. * @param name Define the name of the layer in the scene
  111157. * @param imgUrl Define the url of the texture to display in the layer
  111158. * @param scene Define the scene the layer belongs to
  111159. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  111160. * @param color Defines a color for the layer
  111161. */
  111162. constructor(
  111163. /**
  111164. * Define the name of the layer.
  111165. */
  111166. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  111167. private _createIndexBuffer;
  111168. /** @hidden */
  111169. _rebuild(): void;
  111170. /**
  111171. * Renders the layer in the scene.
  111172. */
  111173. render(): void;
  111174. /**
  111175. * Disposes and releases the associated ressources.
  111176. */
  111177. dispose(): void;
  111178. }
  111179. }
  111180. declare module BABYLON {
  111181. /** @hidden */
  111182. export var lensFlarePixelShader: {
  111183. name: string;
  111184. shader: string;
  111185. };
  111186. }
  111187. declare module BABYLON {
  111188. /** @hidden */
  111189. export var lensFlareVertexShader: {
  111190. name: string;
  111191. shader: string;
  111192. };
  111193. }
  111194. declare module BABYLON {
  111195. /**
  111196. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111197. * It is usually composed of several `lensFlare`.
  111198. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111199. */
  111200. export class LensFlareSystem {
  111201. /**
  111202. * Define the name of the lens flare system
  111203. */
  111204. name: string;
  111205. /**
  111206. * List of lens flares used in this system.
  111207. */
  111208. lensFlares: LensFlare[];
  111209. /**
  111210. * Define a limit from the border the lens flare can be visible.
  111211. */
  111212. borderLimit: number;
  111213. /**
  111214. * Define a viewport border we do not want to see the lens flare in.
  111215. */
  111216. viewportBorder: number;
  111217. /**
  111218. * Define a predicate which could limit the list of meshes able to occlude the effect.
  111219. */
  111220. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  111221. /**
  111222. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  111223. */
  111224. layerMask: number;
  111225. /**
  111226. * Define the id of the lens flare system in the scene.
  111227. * (equal to name by default)
  111228. */
  111229. id: string;
  111230. private _scene;
  111231. private _emitter;
  111232. private _vertexBuffers;
  111233. private _indexBuffer;
  111234. private _effect;
  111235. private _positionX;
  111236. private _positionY;
  111237. private _isEnabled;
  111238. /** @hidden */
  111239. static _SceneComponentInitialization: (scene: Scene) => void;
  111240. /**
  111241. * Instantiates a lens flare system.
  111242. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111243. * It is usually composed of several `lensFlare`.
  111244. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111245. * @param name Define the name of the lens flare system in the scene
  111246. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  111247. * @param scene Define the scene the lens flare system belongs to
  111248. */
  111249. constructor(
  111250. /**
  111251. * Define the name of the lens flare system
  111252. */
  111253. name: string, emitter: any, scene: Scene);
  111254. /**
  111255. * Define if the lens flare system is enabled.
  111256. */
  111257. isEnabled: boolean;
  111258. /**
  111259. * Get the scene the effects belongs to.
  111260. * @returns the scene holding the lens flare system
  111261. */
  111262. getScene(): Scene;
  111263. /**
  111264. * Get the emitter of the lens flare system.
  111265. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111266. * @returns the emitter of the lens flare system
  111267. */
  111268. getEmitter(): any;
  111269. /**
  111270. * Set the emitter of the lens flare system.
  111271. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111272. * @param newEmitter Define the new emitter of the system
  111273. */
  111274. setEmitter(newEmitter: any): void;
  111275. /**
  111276. * Get the lens flare system emitter position.
  111277. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  111278. * @returns the position
  111279. */
  111280. getEmitterPosition(): Vector3;
  111281. /**
  111282. * @hidden
  111283. */
  111284. computeEffectivePosition(globalViewport: Viewport): boolean;
  111285. /** @hidden */
  111286. _isVisible(): boolean;
  111287. /**
  111288. * @hidden
  111289. */
  111290. render(): boolean;
  111291. /**
  111292. * Dispose and release the lens flare with its associated resources.
  111293. */
  111294. dispose(): void;
  111295. /**
  111296. * Parse a lens flare system from a JSON repressentation
  111297. * @param parsedLensFlareSystem Define the JSON to parse
  111298. * @param scene Define the scene the parsed system should be instantiated in
  111299. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  111300. * @returns the parsed system
  111301. */
  111302. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  111303. /**
  111304. * Serialize the current Lens Flare System into a JSON representation.
  111305. * @returns the serialized JSON
  111306. */
  111307. serialize(): any;
  111308. }
  111309. }
  111310. declare module BABYLON {
  111311. /**
  111312. * This represents one of the lens effect in a `lensFlareSystem`.
  111313. * It controls one of the indiviual texture used in the effect.
  111314. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111315. */
  111316. export class LensFlare {
  111317. /**
  111318. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111319. */
  111320. size: number;
  111321. /**
  111322. * 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.
  111323. */
  111324. position: number;
  111325. /**
  111326. * Define the lens color.
  111327. */
  111328. color: Color3;
  111329. /**
  111330. * Define the lens texture.
  111331. */
  111332. texture: Nullable<Texture>;
  111333. /**
  111334. * Define the alpha mode to render this particular lens.
  111335. */
  111336. alphaMode: number;
  111337. private _system;
  111338. /**
  111339. * Creates a new Lens Flare.
  111340. * This represents one of the lens effect in a `lensFlareSystem`.
  111341. * It controls one of the indiviual texture used in the effect.
  111342. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111343. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  111344. * @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.
  111345. * @param color Define the lens color
  111346. * @param imgUrl Define the lens texture url
  111347. * @param system Define the `lensFlareSystem` this flare is part of
  111348. * @returns The newly created Lens Flare
  111349. */
  111350. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  111351. /**
  111352. * Instantiates a new Lens Flare.
  111353. * This represents one of the lens effect in a `lensFlareSystem`.
  111354. * It controls one of the indiviual texture used in the effect.
  111355. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111356. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  111357. * @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.
  111358. * @param color Define the lens color
  111359. * @param imgUrl Define the lens texture url
  111360. * @param system Define the `lensFlareSystem` this flare is part of
  111361. */
  111362. constructor(
  111363. /**
  111364. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111365. */
  111366. size: number,
  111367. /**
  111368. * 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.
  111369. */
  111370. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  111371. /**
  111372. * Dispose and release the lens flare with its associated resources.
  111373. */
  111374. dispose(): void;
  111375. }
  111376. }
  111377. declare module BABYLON {
  111378. interface AbstractScene {
  111379. /**
  111380. * The list of lens flare system added to the scene
  111381. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111382. */
  111383. lensFlareSystems: Array<LensFlareSystem>;
  111384. /**
  111385. * Removes the given lens flare system from this scene.
  111386. * @param toRemove The lens flare system to remove
  111387. * @returns The index of the removed lens flare system
  111388. */
  111389. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  111390. /**
  111391. * Adds the given lens flare system to this scene
  111392. * @param newLensFlareSystem The lens flare system to add
  111393. */
  111394. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  111395. /**
  111396. * Gets a lens flare system using its name
  111397. * @param name defines the name to look for
  111398. * @returns the lens flare system or null if not found
  111399. */
  111400. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  111401. /**
  111402. * Gets a lens flare system using its id
  111403. * @param id defines the id to look for
  111404. * @returns the lens flare system or null if not found
  111405. */
  111406. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  111407. }
  111408. /**
  111409. * Defines the lens flare scene component responsible to manage any lens flares
  111410. * in a given scene.
  111411. */
  111412. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  111413. /**
  111414. * The component name helpfull to identify the component in the list of scene components.
  111415. */
  111416. readonly name: string;
  111417. /**
  111418. * The scene the component belongs to.
  111419. */
  111420. scene: Scene;
  111421. /**
  111422. * Creates a new instance of the component for the given scene
  111423. * @param scene Defines the scene to register the component in
  111424. */
  111425. constructor(scene: Scene);
  111426. /**
  111427. * Registers the component in a given scene
  111428. */
  111429. register(): void;
  111430. /**
  111431. * Rebuilds the elements related to this component in case of
  111432. * context lost for instance.
  111433. */
  111434. rebuild(): void;
  111435. /**
  111436. * Adds all the elements from the container to the scene
  111437. * @param container the container holding the elements
  111438. */
  111439. addFromContainer(container: AbstractScene): void;
  111440. /**
  111441. * Removes all the elements in the container from the scene
  111442. * @param container contains the elements to remove
  111443. * @param dispose if the removed element should be disposed (default: false)
  111444. */
  111445. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111446. /**
  111447. * Serializes the component data to the specified json object
  111448. * @param serializationObject The object to serialize to
  111449. */
  111450. serialize(serializationObject: any): void;
  111451. /**
  111452. * Disposes the component and the associated ressources.
  111453. */
  111454. dispose(): void;
  111455. private _draw;
  111456. }
  111457. }
  111458. declare module BABYLON {
  111459. /**
  111460. * Defines the shadow generator component responsible to manage any shadow generators
  111461. * in a given scene.
  111462. */
  111463. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  111464. /**
  111465. * The component name helpfull to identify the component in the list of scene components.
  111466. */
  111467. readonly name: string;
  111468. /**
  111469. * The scene the component belongs to.
  111470. */
  111471. scene: Scene;
  111472. /**
  111473. * Creates a new instance of the component for the given scene
  111474. * @param scene Defines the scene to register the component in
  111475. */
  111476. constructor(scene: Scene);
  111477. /**
  111478. * Registers the component in a given scene
  111479. */
  111480. register(): void;
  111481. /**
  111482. * Rebuilds the elements related to this component in case of
  111483. * context lost for instance.
  111484. */
  111485. rebuild(): void;
  111486. /**
  111487. * Serializes the component data to the specified json object
  111488. * @param serializationObject The object to serialize to
  111489. */
  111490. serialize(serializationObject: any): void;
  111491. /**
  111492. * Adds all the elements from the container to the scene
  111493. * @param container the container holding the elements
  111494. */
  111495. addFromContainer(container: AbstractScene): void;
  111496. /**
  111497. * Removes all the elements in the container from the scene
  111498. * @param container contains the elements to remove
  111499. * @param dispose if the removed element should be disposed (default: false)
  111500. */
  111501. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111502. /**
  111503. * Rebuilds the elements related to this component in case of
  111504. * context lost for instance.
  111505. */
  111506. dispose(): void;
  111507. private _gatherRenderTargets;
  111508. }
  111509. }
  111510. declare module BABYLON {
  111511. /**
  111512. * A point light is a light defined by an unique point in world space.
  111513. * The light is emitted in every direction from this point.
  111514. * A good example of a point light is a standard light bulb.
  111515. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111516. */
  111517. export class PointLight extends ShadowLight {
  111518. private _shadowAngle;
  111519. /**
  111520. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111521. * This specifies what angle the shadow will use to be created.
  111522. *
  111523. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111524. */
  111525. /**
  111526. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111527. * This specifies what angle the shadow will use to be created.
  111528. *
  111529. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111530. */
  111531. shadowAngle: number;
  111532. /**
  111533. * Gets the direction if it has been set.
  111534. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111535. */
  111536. /**
  111537. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111538. */
  111539. direction: Vector3;
  111540. /**
  111541. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  111542. * A PointLight emits the light in every direction.
  111543. * It can cast shadows.
  111544. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  111545. * ```javascript
  111546. * var pointLight = new PointLight("pl", camera.position, scene);
  111547. * ```
  111548. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111549. * @param name The light friendly name
  111550. * @param position The position of the point light in the scene
  111551. * @param scene The scene the lights belongs to
  111552. */
  111553. constructor(name: string, position: Vector3, scene: Scene);
  111554. /**
  111555. * Returns the string "PointLight"
  111556. * @returns the class name
  111557. */
  111558. getClassName(): string;
  111559. /**
  111560. * Returns the integer 0.
  111561. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111562. */
  111563. getTypeID(): number;
  111564. /**
  111565. * Specifies wether or not the shadowmap should be a cube texture.
  111566. * @returns true if the shadowmap needs to be a cube texture.
  111567. */
  111568. needCube(): boolean;
  111569. /**
  111570. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  111571. * @param faceIndex The index of the face we are computed the direction to generate shadow
  111572. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  111573. */
  111574. getShadowDirection(faceIndex?: number): Vector3;
  111575. /**
  111576. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  111577. * - fov = PI / 2
  111578. * - aspect ratio : 1.0
  111579. * - z-near and far equal to the active camera minZ and maxZ.
  111580. * Returns the PointLight.
  111581. */
  111582. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111583. protected _buildUniformLayout(): void;
  111584. /**
  111585. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  111586. * @param effect The effect to update
  111587. * @param lightIndex The index of the light in the effect to update
  111588. * @returns The point light
  111589. */
  111590. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  111591. /**
  111592. * Prepares the list of defines specific to the light type.
  111593. * @param defines the list of defines
  111594. * @param lightIndex defines the index of the light for the effect
  111595. */
  111596. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111597. }
  111598. }
  111599. declare module BABYLON {
  111600. /**
  111601. * Header information of HDR texture files.
  111602. */
  111603. export interface HDRInfo {
  111604. /**
  111605. * The height of the texture in pixels.
  111606. */
  111607. height: number;
  111608. /**
  111609. * The width of the texture in pixels.
  111610. */
  111611. width: number;
  111612. /**
  111613. * The index of the beginning of the data in the binary file.
  111614. */
  111615. dataPosition: number;
  111616. }
  111617. /**
  111618. * This groups tools to convert HDR texture to native colors array.
  111619. */
  111620. export class HDRTools {
  111621. private static Ldexp;
  111622. private static Rgbe2float;
  111623. private static readStringLine;
  111624. /**
  111625. * Reads header information from an RGBE texture stored in a native array.
  111626. * More information on this format are available here:
  111627. * https://en.wikipedia.org/wiki/RGBE_image_format
  111628. *
  111629. * @param uint8array The binary file stored in native array.
  111630. * @return The header information.
  111631. */
  111632. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  111633. /**
  111634. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  111635. * This RGBE texture needs to store the information as a panorama.
  111636. *
  111637. * More information on this format are available here:
  111638. * https://en.wikipedia.org/wiki/RGBE_image_format
  111639. *
  111640. * @param buffer The binary file stored in an array buffer.
  111641. * @param size The expected size of the extracted cubemap.
  111642. * @return The Cube Map information.
  111643. */
  111644. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  111645. /**
  111646. * Returns the pixels data extracted from an RGBE texture.
  111647. * This pixels will be stored left to right up to down in the R G B order in one array.
  111648. *
  111649. * More information on this format are available here:
  111650. * https://en.wikipedia.org/wiki/RGBE_image_format
  111651. *
  111652. * @param uint8array The binary file stored in an array buffer.
  111653. * @param hdrInfo The header information of the file.
  111654. * @return The pixels data in RGB right to left up to down order.
  111655. */
  111656. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  111657. private static RGBE_ReadPixels_RLE;
  111658. }
  111659. }
  111660. declare module BABYLON {
  111661. /**
  111662. * This represents a texture coming from an HDR input.
  111663. *
  111664. * The only supported format is currently panorama picture stored in RGBE format.
  111665. * Example of such files can be found on HDRLib: http://hdrlib.com/
  111666. */
  111667. export class HDRCubeTexture extends BaseTexture {
  111668. private static _facesMapping;
  111669. private _generateHarmonics;
  111670. private _noMipmap;
  111671. private _textureMatrix;
  111672. private _size;
  111673. private _onLoad;
  111674. private _onError;
  111675. /**
  111676. * The texture URL.
  111677. */
  111678. url: string;
  111679. /**
  111680. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  111681. */
  111682. coordinatesMode: number;
  111683. protected _isBlocking: boolean;
  111684. /**
  111685. * Sets wether or not the texture is blocking during loading.
  111686. */
  111687. /**
  111688. * Gets wether or not the texture is blocking during loading.
  111689. */
  111690. isBlocking: boolean;
  111691. protected _rotationY: number;
  111692. /**
  111693. * Sets texture matrix rotation angle around Y axis in radians.
  111694. */
  111695. /**
  111696. * Gets texture matrix rotation angle around Y axis radians.
  111697. */
  111698. rotationY: number;
  111699. /**
  111700. * Gets or sets the center of the bounding box associated with the cube texture
  111701. * It must define where the camera used to render the texture was set
  111702. */
  111703. boundingBoxPosition: Vector3;
  111704. private _boundingBoxSize;
  111705. /**
  111706. * Gets or sets the size of the bounding box associated with the cube texture
  111707. * When defined, the cubemap will switch to local mode
  111708. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111709. * @example https://www.babylonjs-playground.com/#RNASML
  111710. */
  111711. boundingBoxSize: Vector3;
  111712. /**
  111713. * Instantiates an HDRTexture from the following parameters.
  111714. *
  111715. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  111716. * @param scene The scene the texture will be used in
  111717. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111718. * @param noMipmap Forces to not generate the mipmap if true
  111719. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  111720. * @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)
  111721. * @param reserved Reserved flag for internal use.
  111722. */
  111723. 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>);
  111724. /**
  111725. * Get the current class name of the texture useful for serialization or dynamic coding.
  111726. * @returns "HDRCubeTexture"
  111727. */
  111728. getClassName(): string;
  111729. /**
  111730. * Occurs when the file is raw .hdr file.
  111731. */
  111732. private loadTexture;
  111733. clone(): HDRCubeTexture;
  111734. delayLoad(): void;
  111735. /**
  111736. * Get the texture reflection matrix used to rotate/transform the reflection.
  111737. * @returns the reflection matrix
  111738. */
  111739. getReflectionTextureMatrix(): Matrix;
  111740. /**
  111741. * Set the texture reflection matrix used to rotate/transform the reflection.
  111742. * @param value Define the reflection matrix to set
  111743. */
  111744. setReflectionTextureMatrix(value: Matrix): void;
  111745. /**
  111746. * Parses a JSON representation of an HDR Texture in order to create the texture
  111747. * @param parsedTexture Define the JSON representation
  111748. * @param scene Define the scene the texture should be created in
  111749. * @param rootUrl Define the root url in case we need to load relative dependencies
  111750. * @returns the newly created texture after parsing
  111751. */
  111752. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  111753. serialize(): any;
  111754. }
  111755. }
  111756. declare module BABYLON {
  111757. /**
  111758. * Class used to control physics engine
  111759. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111760. */
  111761. export class PhysicsEngine implements IPhysicsEngine {
  111762. private _physicsPlugin;
  111763. /**
  111764. * Global value used to control the smallest number supported by the simulation
  111765. */
  111766. static Epsilon: number;
  111767. private _impostors;
  111768. private _joints;
  111769. /**
  111770. * Gets the gravity vector used by the simulation
  111771. */
  111772. gravity: Vector3;
  111773. /**
  111774. * Factory used to create the default physics plugin.
  111775. * @returns The default physics plugin
  111776. */
  111777. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  111778. /**
  111779. * Creates a new Physics Engine
  111780. * @param gravity defines the gravity vector used by the simulation
  111781. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  111782. */
  111783. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  111784. /**
  111785. * Sets the gravity vector used by the simulation
  111786. * @param gravity defines the gravity vector to use
  111787. */
  111788. setGravity(gravity: Vector3): void;
  111789. /**
  111790. * Set the time step of the physics engine.
  111791. * Default is 1/60.
  111792. * To slow it down, enter 1/600 for example.
  111793. * To speed it up, 1/30
  111794. * @param newTimeStep defines the new timestep to apply to this world.
  111795. */
  111796. setTimeStep(newTimeStep?: number): void;
  111797. /**
  111798. * Get the time step of the physics engine.
  111799. * @returns the current time step
  111800. */
  111801. getTimeStep(): number;
  111802. /**
  111803. * Release all resources
  111804. */
  111805. dispose(): void;
  111806. /**
  111807. * Gets the name of the current physics plugin
  111808. * @returns the name of the plugin
  111809. */
  111810. getPhysicsPluginName(): string;
  111811. /**
  111812. * Adding a new impostor for the impostor tracking.
  111813. * This will be done by the impostor itself.
  111814. * @param impostor the impostor to add
  111815. */
  111816. addImpostor(impostor: PhysicsImpostor): void;
  111817. /**
  111818. * Remove an impostor from the engine.
  111819. * This impostor and its mesh will not longer be updated by the physics engine.
  111820. * @param impostor the impostor to remove
  111821. */
  111822. removeImpostor(impostor: PhysicsImpostor): void;
  111823. /**
  111824. * Add a joint to the physics engine
  111825. * @param mainImpostor defines the main impostor to which the joint is added.
  111826. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111827. * @param joint defines the joint that will connect both impostors.
  111828. */
  111829. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111830. /**
  111831. * Removes a joint from the simulation
  111832. * @param mainImpostor defines the impostor used with the joint
  111833. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111834. * @param joint defines the joint to remove
  111835. */
  111836. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111837. /**
  111838. * Called by the scene. No need to call it.
  111839. * @param delta defines the timespam between frames
  111840. */
  111841. _step(delta: number): void;
  111842. /**
  111843. * Gets the current plugin used to run the simulation
  111844. * @returns current plugin
  111845. */
  111846. getPhysicsPlugin(): IPhysicsEnginePlugin;
  111847. /**
  111848. * Gets the list of physic impostors
  111849. * @returns an array of PhysicsImpostor
  111850. */
  111851. getImpostors(): Array<PhysicsImpostor>;
  111852. /**
  111853. * Gets the impostor for a physics enabled object
  111854. * @param object defines the object impersonated by the impostor
  111855. * @returns the PhysicsImpostor or null if not found
  111856. */
  111857. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  111858. /**
  111859. * Gets the impostor for a physics body object
  111860. * @param body defines physics body used by the impostor
  111861. * @returns the PhysicsImpostor or null if not found
  111862. */
  111863. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  111864. /**
  111865. * Does a raycast in the physics world
  111866. * @param from when should the ray start?
  111867. * @param to when should the ray end?
  111868. * @returns PhysicsRaycastResult
  111869. */
  111870. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111871. }
  111872. }
  111873. declare module BABYLON {
  111874. /** @hidden */
  111875. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  111876. private _useDeltaForWorldStep;
  111877. world: any;
  111878. name: string;
  111879. private _physicsMaterials;
  111880. private _fixedTimeStep;
  111881. private _cannonRaycastResult;
  111882. private _raycastResult;
  111883. private _physicsBodysToRemoveAfterStep;
  111884. BJSCANNON: any;
  111885. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  111886. setGravity(gravity: Vector3): void;
  111887. setTimeStep(timeStep: number): void;
  111888. getTimeStep(): number;
  111889. executeStep(delta: number): void;
  111890. private _removeMarkedPhysicsBodiesFromWorld;
  111891. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111892. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111893. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111894. private _processChildMeshes;
  111895. removePhysicsBody(impostor: PhysicsImpostor): void;
  111896. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111897. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111898. private _addMaterial;
  111899. private _checkWithEpsilon;
  111900. private _createShape;
  111901. private _createHeightmap;
  111902. private _minus90X;
  111903. private _plus90X;
  111904. private _tmpPosition;
  111905. private _tmpDeltaPosition;
  111906. private _tmpUnityRotation;
  111907. private _updatePhysicsBodyTransformation;
  111908. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111909. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111910. isSupported(): boolean;
  111911. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111912. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111913. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111914. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111915. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111916. getBodyMass(impostor: PhysicsImpostor): number;
  111917. getBodyFriction(impostor: PhysicsImpostor): number;
  111918. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111919. getBodyRestitution(impostor: PhysicsImpostor): number;
  111920. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111921. sleepBody(impostor: PhysicsImpostor): void;
  111922. wakeUpBody(impostor: PhysicsImpostor): void;
  111923. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  111924. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  111925. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  111926. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111927. getRadius(impostor: PhysicsImpostor): number;
  111928. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111929. dispose(): void;
  111930. private _extendNamespace;
  111931. /**
  111932. * Does a raycast in the physics world
  111933. * @param from when should the ray start?
  111934. * @param to when should the ray end?
  111935. * @returns PhysicsRaycastResult
  111936. */
  111937. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111938. }
  111939. }
  111940. declare module BABYLON {
  111941. /** @hidden */
  111942. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  111943. world: any;
  111944. name: string;
  111945. BJSOIMO: any;
  111946. private _raycastResult;
  111947. constructor(iterations?: number, oimoInjection?: any);
  111948. setGravity(gravity: Vector3): void;
  111949. setTimeStep(timeStep: number): void;
  111950. getTimeStep(): number;
  111951. private _tmpImpostorsArray;
  111952. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111953. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111954. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111955. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111956. private _tmpPositionVector;
  111957. removePhysicsBody(impostor: PhysicsImpostor): void;
  111958. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111959. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111960. isSupported(): boolean;
  111961. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111962. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111963. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111964. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111965. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111966. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111967. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111968. getBodyMass(impostor: PhysicsImpostor): number;
  111969. getBodyFriction(impostor: PhysicsImpostor): number;
  111970. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111971. getBodyRestitution(impostor: PhysicsImpostor): number;
  111972. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111973. sleepBody(impostor: PhysicsImpostor): void;
  111974. wakeUpBody(impostor: PhysicsImpostor): void;
  111975. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  111976. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  111977. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  111978. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111979. getRadius(impostor: PhysicsImpostor): number;
  111980. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111981. dispose(): void;
  111982. /**
  111983. * Does a raycast in the physics world
  111984. * @param from when should the ray start?
  111985. * @param to when should the ray end?
  111986. * @returns PhysicsRaycastResult
  111987. */
  111988. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111989. }
  111990. }
  111991. declare module BABYLON {
  111992. /**
  111993. * Class containing static functions to help procedurally build meshes
  111994. */
  111995. export class RibbonBuilder {
  111996. /**
  111997. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  111998. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  111999. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  112000. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  112001. * * 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
  112002. * * 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
  112003. * * 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
  112004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112006. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112007. * * 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
  112008. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  112009. * * 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
  112010. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  112011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112012. * @param name defines the name of the mesh
  112013. * @param options defines the options used to create the mesh
  112014. * @param scene defines the hosting scene
  112015. * @returns the ribbon mesh
  112016. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  112017. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112018. */
  112019. static CreateRibbon(name: string, options: {
  112020. pathArray: Vector3[][];
  112021. closeArray?: boolean;
  112022. closePath?: boolean;
  112023. offset?: number;
  112024. updatable?: boolean;
  112025. sideOrientation?: number;
  112026. frontUVs?: Vector4;
  112027. backUVs?: Vector4;
  112028. instance?: Mesh;
  112029. invertUV?: boolean;
  112030. uvs?: Vector2[];
  112031. colors?: Color4[];
  112032. }, scene?: Nullable<Scene>): Mesh;
  112033. }
  112034. }
  112035. declare module BABYLON {
  112036. /**
  112037. * Class containing static functions to help procedurally build meshes
  112038. */
  112039. export class ShapeBuilder {
  112040. /**
  112041. * 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.
  112042. * * 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.
  112043. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112044. * * 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.
  112045. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  112046. * * 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
  112047. * * 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
  112048. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  112049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112050. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112051. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  112052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112053. * @param name defines the name of the mesh
  112054. * @param options defines the options used to create the mesh
  112055. * @param scene defines the hosting scene
  112056. * @returns the extruded shape mesh
  112057. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112059. */
  112060. static ExtrudeShape(name: string, options: {
  112061. shape: Vector3[];
  112062. path: Vector3[];
  112063. scale?: number;
  112064. rotation?: number;
  112065. cap?: number;
  112066. updatable?: boolean;
  112067. sideOrientation?: number;
  112068. frontUVs?: Vector4;
  112069. backUVs?: Vector4;
  112070. instance?: Mesh;
  112071. invertUV?: boolean;
  112072. }, scene?: Nullable<Scene>): Mesh;
  112073. /**
  112074. * Creates an custom extruded shape mesh.
  112075. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  112076. * * 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.
  112077. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112078. * * 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
  112079. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  112080. * * 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
  112081. * * It must returns a float value that will be the scale value applied to the shape on each path point
  112082. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  112083. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  112084. * * 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
  112085. * * 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
  112086. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  112087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112089. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112091. * @param name defines the name of the mesh
  112092. * @param options defines the options used to create the mesh
  112093. * @param scene defines the hosting scene
  112094. * @returns the custom extruded shape mesh
  112095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  112096. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112098. */
  112099. static ExtrudeShapeCustom(name: string, options: {
  112100. shape: Vector3[];
  112101. path: Vector3[];
  112102. scaleFunction?: any;
  112103. rotationFunction?: any;
  112104. ribbonCloseArray?: boolean;
  112105. ribbonClosePath?: boolean;
  112106. cap?: number;
  112107. updatable?: boolean;
  112108. sideOrientation?: number;
  112109. frontUVs?: Vector4;
  112110. backUVs?: Vector4;
  112111. instance?: Mesh;
  112112. invertUV?: boolean;
  112113. }, scene?: Nullable<Scene>): Mesh;
  112114. private static _ExtrudeShapeGeneric;
  112115. }
  112116. }
  112117. declare module BABYLON {
  112118. /**
  112119. * AmmoJS Physics plugin
  112120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112121. * @see https://github.com/kripken/ammo.js/
  112122. */
  112123. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  112124. private _useDeltaForWorldStep;
  112125. /**
  112126. * Reference to the Ammo library
  112127. */
  112128. bjsAMMO: any;
  112129. /**
  112130. * Created ammoJS world which physics bodies are added to
  112131. */
  112132. world: any;
  112133. /**
  112134. * Name of the plugin
  112135. */
  112136. name: string;
  112137. private _timeStep;
  112138. private _fixedTimeStep;
  112139. private _maxSteps;
  112140. private _tmpQuaternion;
  112141. private _tmpAmmoTransform;
  112142. private _tmpAmmoQuaternion;
  112143. private _tmpAmmoConcreteContactResultCallback;
  112144. private _collisionConfiguration;
  112145. private _dispatcher;
  112146. private _overlappingPairCache;
  112147. private _solver;
  112148. private _softBodySolver;
  112149. private _tmpAmmoVectorA;
  112150. private _tmpAmmoVectorB;
  112151. private _tmpAmmoVectorC;
  112152. private _tmpAmmoVectorD;
  112153. private _tmpContactCallbackResult;
  112154. private _tmpAmmoVectorRCA;
  112155. private _tmpAmmoVectorRCB;
  112156. private _raycastResult;
  112157. private static readonly DISABLE_COLLISION_FLAG;
  112158. private static readonly KINEMATIC_FLAG;
  112159. private static readonly DISABLE_DEACTIVATION_FLAG;
  112160. /**
  112161. * Initializes the ammoJS plugin
  112162. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  112163. * @param ammoInjection can be used to inject your own ammo reference
  112164. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  112165. */
  112166. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  112167. /**
  112168. * Sets the gravity of the physics world (m/(s^2))
  112169. * @param gravity Gravity to set
  112170. */
  112171. setGravity(gravity: Vector3): void;
  112172. /**
  112173. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  112174. * @param timeStep timestep to use in seconds
  112175. */
  112176. setTimeStep(timeStep: number): void;
  112177. /**
  112178. * 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)
  112179. * @param fixedTimeStep fixedTimeStep to use in seconds
  112180. */
  112181. setFixedTimeStep(fixedTimeStep: number): void;
  112182. /**
  112183. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  112184. * @param maxSteps the maximum number of steps by the physics engine per frame
  112185. */
  112186. setMaxSteps(maxSteps: number): void;
  112187. /**
  112188. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  112189. * @returns the current timestep in seconds
  112190. */
  112191. getTimeStep(): number;
  112192. private _isImpostorInContact;
  112193. private _isImpostorPairInContact;
  112194. private _stepSimulation;
  112195. /**
  112196. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  112197. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  112198. * After the step the babylon meshes are set to the position of the physics imposters
  112199. * @param delta amount of time to step forward
  112200. * @param impostors array of imposters to update before/after the step
  112201. */
  112202. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112203. /**
  112204. * Update babylon mesh to match physics world object
  112205. * @param impostor imposter to match
  112206. */
  112207. private _afterSoftStep;
  112208. /**
  112209. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112210. * @param impostor imposter to match
  112211. */
  112212. private _ropeStep;
  112213. /**
  112214. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112215. * @param impostor imposter to match
  112216. */
  112217. private _softbodyOrClothStep;
  112218. private _tmpVector;
  112219. private _tmpMatrix;
  112220. /**
  112221. * Applies an impulse on the imposter
  112222. * @param impostor imposter to apply impulse to
  112223. * @param force amount of force to be applied to the imposter
  112224. * @param contactPoint the location to apply the impulse on the imposter
  112225. */
  112226. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112227. /**
  112228. * Applies a force on the imposter
  112229. * @param impostor imposter to apply force
  112230. * @param force amount of force to be applied to the imposter
  112231. * @param contactPoint the location to apply the force on the imposter
  112232. */
  112233. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112234. /**
  112235. * Creates a physics body using the plugin
  112236. * @param impostor the imposter to create the physics body on
  112237. */
  112238. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112239. /**
  112240. * Removes the physics body from the imposter and disposes of the body's memory
  112241. * @param impostor imposter to remove the physics body from
  112242. */
  112243. removePhysicsBody(impostor: PhysicsImpostor): void;
  112244. /**
  112245. * Generates a joint
  112246. * @param impostorJoint the imposter joint to create the joint with
  112247. */
  112248. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112249. /**
  112250. * Removes a joint
  112251. * @param impostorJoint the imposter joint to remove the joint from
  112252. */
  112253. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112254. private _addMeshVerts;
  112255. /**
  112256. * Initialise the soft body vertices to match its object's (mesh) vertices
  112257. * Softbody vertices (nodes) are in world space and to match this
  112258. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  112259. * @param impostor to create the softbody for
  112260. */
  112261. private _softVertexData;
  112262. /**
  112263. * Create an impostor's soft body
  112264. * @param impostor to create the softbody for
  112265. */
  112266. private _createSoftbody;
  112267. /**
  112268. * Create cloth for an impostor
  112269. * @param impostor to create the softbody for
  112270. */
  112271. private _createCloth;
  112272. /**
  112273. * Create rope for an impostor
  112274. * @param impostor to create the softbody for
  112275. */
  112276. private _createRope;
  112277. private _addHullVerts;
  112278. private _createShape;
  112279. /**
  112280. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  112281. * @param impostor imposter containing the physics body and babylon object
  112282. */
  112283. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112284. /**
  112285. * Sets the babylon object's position/rotation from the physics body's position/rotation
  112286. * @param impostor imposter containing the physics body and babylon object
  112287. * @param newPosition new position
  112288. * @param newRotation new rotation
  112289. */
  112290. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112291. /**
  112292. * If this plugin is supported
  112293. * @returns true if its supported
  112294. */
  112295. isSupported(): boolean;
  112296. /**
  112297. * Sets the linear velocity of the physics body
  112298. * @param impostor imposter to set the velocity on
  112299. * @param velocity velocity to set
  112300. */
  112301. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112302. /**
  112303. * Sets the angular velocity of the physics body
  112304. * @param impostor imposter to set the velocity on
  112305. * @param velocity velocity to set
  112306. */
  112307. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112308. /**
  112309. * gets the linear velocity
  112310. * @param impostor imposter to get linear velocity from
  112311. * @returns linear velocity
  112312. */
  112313. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112314. /**
  112315. * gets the angular velocity
  112316. * @param impostor imposter to get angular velocity from
  112317. * @returns angular velocity
  112318. */
  112319. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112320. /**
  112321. * Sets the mass of physics body
  112322. * @param impostor imposter to set the mass on
  112323. * @param mass mass to set
  112324. */
  112325. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112326. /**
  112327. * Gets the mass of the physics body
  112328. * @param impostor imposter to get the mass from
  112329. * @returns mass
  112330. */
  112331. getBodyMass(impostor: PhysicsImpostor): number;
  112332. /**
  112333. * Gets friction of the impostor
  112334. * @param impostor impostor to get friction from
  112335. * @returns friction value
  112336. */
  112337. getBodyFriction(impostor: PhysicsImpostor): number;
  112338. /**
  112339. * Sets friction of the impostor
  112340. * @param impostor impostor to set friction on
  112341. * @param friction friction value
  112342. */
  112343. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112344. /**
  112345. * Gets restitution of the impostor
  112346. * @param impostor impostor to get restitution from
  112347. * @returns restitution value
  112348. */
  112349. getBodyRestitution(impostor: PhysicsImpostor): number;
  112350. /**
  112351. * Sets resitution of the impostor
  112352. * @param impostor impostor to set resitution on
  112353. * @param restitution resitution value
  112354. */
  112355. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112356. /**
  112357. * Gets pressure inside the impostor
  112358. * @param impostor impostor to get pressure from
  112359. * @returns pressure value
  112360. */
  112361. getBodyPressure(impostor: PhysicsImpostor): number;
  112362. /**
  112363. * Sets pressure inside a soft body impostor
  112364. * Cloth and rope must remain 0 pressure
  112365. * @param impostor impostor to set pressure on
  112366. * @param pressure pressure value
  112367. */
  112368. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  112369. /**
  112370. * Gets stiffness of the impostor
  112371. * @param impostor impostor to get stiffness from
  112372. * @returns pressure value
  112373. */
  112374. getBodyStiffness(impostor: PhysicsImpostor): number;
  112375. /**
  112376. * Sets stiffness of the impostor
  112377. * @param impostor impostor to set stiffness on
  112378. * @param stiffness stiffness value from 0 to 1
  112379. */
  112380. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  112381. /**
  112382. * Gets velocityIterations of the impostor
  112383. * @param impostor impostor to get velocity iterations from
  112384. * @returns velocityIterations value
  112385. */
  112386. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  112387. /**
  112388. * Sets velocityIterations of the impostor
  112389. * @param impostor impostor to set velocity iterations on
  112390. * @param velocityIterations velocityIterations value
  112391. */
  112392. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  112393. /**
  112394. * Gets positionIterations of the impostor
  112395. * @param impostor impostor to get position iterations from
  112396. * @returns positionIterations value
  112397. */
  112398. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  112399. /**
  112400. * Sets positionIterations of the impostor
  112401. * @param impostor impostor to set position on
  112402. * @param positionIterations positionIterations value
  112403. */
  112404. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  112405. /**
  112406. * Append an anchor to a cloth object
  112407. * @param impostor is the cloth impostor to add anchor to
  112408. * @param otherImpostor is the rigid impostor to anchor to
  112409. * @param width ratio across width from 0 to 1
  112410. * @param height ratio up height from 0 to 1
  112411. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112412. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112413. */
  112414. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112415. /**
  112416. * Append an hook to a rope object
  112417. * @param impostor is the rope impostor to add hook to
  112418. * @param otherImpostor is the rigid impostor to hook to
  112419. * @param length ratio along the rope from 0 to 1
  112420. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  112421. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112422. */
  112423. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112424. /**
  112425. * Sleeps the physics body and stops it from being active
  112426. * @param impostor impostor to sleep
  112427. */
  112428. sleepBody(impostor: PhysicsImpostor): void;
  112429. /**
  112430. * Activates the physics body
  112431. * @param impostor impostor to activate
  112432. */
  112433. wakeUpBody(impostor: PhysicsImpostor): void;
  112434. /**
  112435. * Updates the distance parameters of the joint
  112436. * @param joint joint to update
  112437. * @param maxDistance maximum distance of the joint
  112438. * @param minDistance minimum distance of the joint
  112439. */
  112440. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112441. /**
  112442. * Sets a motor on the joint
  112443. * @param joint joint to set motor on
  112444. * @param speed speed of the motor
  112445. * @param maxForce maximum force of the motor
  112446. * @param motorIndex index of the motor
  112447. */
  112448. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112449. /**
  112450. * Sets the motors limit
  112451. * @param joint joint to set limit on
  112452. * @param upperLimit upper limit
  112453. * @param lowerLimit lower limit
  112454. */
  112455. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112456. /**
  112457. * Syncs the position and rotation of a mesh with the impostor
  112458. * @param mesh mesh to sync
  112459. * @param impostor impostor to update the mesh with
  112460. */
  112461. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112462. /**
  112463. * Gets the radius of the impostor
  112464. * @param impostor impostor to get radius from
  112465. * @returns the radius
  112466. */
  112467. getRadius(impostor: PhysicsImpostor): number;
  112468. /**
  112469. * Gets the box size of the impostor
  112470. * @param impostor impostor to get box size from
  112471. * @param result the resulting box size
  112472. */
  112473. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112474. /**
  112475. * Disposes of the impostor
  112476. */
  112477. dispose(): void;
  112478. /**
  112479. * Does a raycast in the physics world
  112480. * @param from when should the ray start?
  112481. * @param to when should the ray end?
  112482. * @returns PhysicsRaycastResult
  112483. */
  112484. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112485. }
  112486. }
  112487. declare module BABYLON {
  112488. interface AbstractScene {
  112489. /**
  112490. * The list of reflection probes added to the scene
  112491. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112492. */
  112493. reflectionProbes: Array<ReflectionProbe>;
  112494. /**
  112495. * Removes the given reflection probe from this scene.
  112496. * @param toRemove The reflection probe to remove
  112497. * @returns The index of the removed reflection probe
  112498. */
  112499. removeReflectionProbe(toRemove: ReflectionProbe): number;
  112500. /**
  112501. * Adds the given reflection probe to this scene.
  112502. * @param newReflectionProbe The reflection probe to add
  112503. */
  112504. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  112505. }
  112506. /**
  112507. * Class used to generate realtime reflection / refraction cube textures
  112508. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112509. */
  112510. export class ReflectionProbe {
  112511. /** defines the name of the probe */
  112512. name: string;
  112513. private _scene;
  112514. private _renderTargetTexture;
  112515. private _projectionMatrix;
  112516. private _viewMatrix;
  112517. private _target;
  112518. private _add;
  112519. private _attachedMesh;
  112520. private _invertYAxis;
  112521. /** Gets or sets probe position (center of the cube map) */
  112522. position: Vector3;
  112523. /**
  112524. * Creates a new reflection probe
  112525. * @param name defines the name of the probe
  112526. * @param size defines the texture resolution (for each face)
  112527. * @param scene defines the hosting scene
  112528. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  112529. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  112530. */
  112531. constructor(
  112532. /** defines the name of the probe */
  112533. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  112534. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  112535. samples: number;
  112536. /** Gets or sets the refresh rate to use (on every frame by default) */
  112537. refreshRate: number;
  112538. /**
  112539. * Gets the hosting scene
  112540. * @returns a Scene
  112541. */
  112542. getScene(): Scene;
  112543. /** Gets the internal CubeTexture used to render to */
  112544. readonly cubeTexture: RenderTargetTexture;
  112545. /** Gets the list of meshes to render */
  112546. readonly renderList: Nullable<AbstractMesh[]>;
  112547. /**
  112548. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  112549. * @param mesh defines the mesh to attach to
  112550. */
  112551. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112552. /**
  112553. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  112554. * @param renderingGroupId The rendering group id corresponding to its index
  112555. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  112556. */
  112557. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  112558. /**
  112559. * Clean all associated resources
  112560. */
  112561. dispose(): void;
  112562. /**
  112563. * Converts the reflection probe information to a readable string for debug purpose.
  112564. * @param fullDetails Supports for multiple levels of logging within scene loading
  112565. * @returns the human readable reflection probe info
  112566. */
  112567. toString(fullDetails?: boolean): string;
  112568. /**
  112569. * Get the class name of the relfection probe.
  112570. * @returns "ReflectionProbe"
  112571. */
  112572. getClassName(): string;
  112573. /**
  112574. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  112575. * @returns The JSON representation of the texture
  112576. */
  112577. serialize(): any;
  112578. /**
  112579. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  112580. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  112581. * @param scene Define the scene the parsed reflection probe should be instantiated in
  112582. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  112583. * @returns The parsed reflection probe if successful
  112584. */
  112585. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  112586. }
  112587. }
  112588. declare module BABYLON {
  112589. /** @hidden */
  112590. export var _BabylonLoaderRegistered: boolean;
  112591. }
  112592. declare module BABYLON {
  112593. /**
  112594. * The Physically based simple base material of BJS.
  112595. *
  112596. * This enables better naming and convention enforcements on top of the pbrMaterial.
  112597. * It is used as the base class for both the specGloss and metalRough conventions.
  112598. */
  112599. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  112600. /**
  112601. * Number of Simultaneous lights allowed on the material.
  112602. */
  112603. maxSimultaneousLights: number;
  112604. /**
  112605. * If sets to true, disables all the lights affecting the material.
  112606. */
  112607. disableLighting: boolean;
  112608. /**
  112609. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  112610. */
  112611. environmentTexture: BaseTexture;
  112612. /**
  112613. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112614. */
  112615. invertNormalMapX: boolean;
  112616. /**
  112617. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112618. */
  112619. invertNormalMapY: boolean;
  112620. /**
  112621. * Normal map used in the model.
  112622. */
  112623. normalTexture: BaseTexture;
  112624. /**
  112625. * Emissivie color used to self-illuminate the model.
  112626. */
  112627. emissiveColor: Color3;
  112628. /**
  112629. * Emissivie texture used to self-illuminate the model.
  112630. */
  112631. emissiveTexture: BaseTexture;
  112632. /**
  112633. * Occlusion Channel Strenght.
  112634. */
  112635. occlusionStrength: number;
  112636. /**
  112637. * Occlusion Texture of the material (adding extra occlusion effects).
  112638. */
  112639. occlusionTexture: BaseTexture;
  112640. /**
  112641. * Defines the alpha limits in alpha test mode.
  112642. */
  112643. alphaCutOff: number;
  112644. /**
  112645. * Gets the current double sided mode.
  112646. */
  112647. /**
  112648. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112649. */
  112650. doubleSided: boolean;
  112651. /**
  112652. * Stores the pre-calculated light information of a mesh in a texture.
  112653. */
  112654. lightmapTexture: BaseTexture;
  112655. /**
  112656. * If true, the light map contains occlusion information instead of lighting info.
  112657. */
  112658. useLightmapAsShadowmap: boolean;
  112659. /**
  112660. * Instantiates a new PBRMaterial instance.
  112661. *
  112662. * @param name The material name
  112663. * @param scene The scene the material will be use in.
  112664. */
  112665. constructor(name: string, scene: Scene);
  112666. getClassName(): string;
  112667. }
  112668. }
  112669. declare module BABYLON {
  112670. /**
  112671. * The PBR material of BJS following the metal roughness convention.
  112672. *
  112673. * This fits to the PBR convention in the GLTF definition:
  112674. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  112675. */
  112676. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  112677. /**
  112678. * The base color has two different interpretations depending on the value of metalness.
  112679. * When the material is a metal, the base color is the specific measured reflectance value
  112680. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  112681. * of the material.
  112682. */
  112683. baseColor: Color3;
  112684. /**
  112685. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  112686. * well as opacity information in the alpha channel.
  112687. */
  112688. baseTexture: BaseTexture;
  112689. /**
  112690. * Specifies the metallic scalar value of the material.
  112691. * Can also be used to scale the metalness values of the metallic texture.
  112692. */
  112693. metallic: number;
  112694. /**
  112695. * Specifies the roughness scalar value of the material.
  112696. * Can also be used to scale the roughness values of the metallic texture.
  112697. */
  112698. roughness: number;
  112699. /**
  112700. * Texture containing both the metallic value in the B channel and the
  112701. * roughness value in the G channel to keep better precision.
  112702. */
  112703. metallicRoughnessTexture: BaseTexture;
  112704. /**
  112705. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112706. *
  112707. * @param name The material name
  112708. * @param scene The scene the material will be use in.
  112709. */
  112710. constructor(name: string, scene: Scene);
  112711. /**
  112712. * Return the currrent class name of the material.
  112713. */
  112714. getClassName(): string;
  112715. /**
  112716. * Makes a duplicate of the current material.
  112717. * @param name - name to use for the new material.
  112718. */
  112719. clone(name: string): PBRMetallicRoughnessMaterial;
  112720. /**
  112721. * Serialize the material to a parsable JSON object.
  112722. */
  112723. serialize(): any;
  112724. /**
  112725. * Parses a JSON object correponding to the serialize function.
  112726. */
  112727. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  112728. }
  112729. }
  112730. declare module BABYLON {
  112731. /**
  112732. * The PBR material of BJS following the specular glossiness convention.
  112733. *
  112734. * This fits to the PBR convention in the GLTF definition:
  112735. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  112736. */
  112737. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  112738. /**
  112739. * Specifies the diffuse color of the material.
  112740. */
  112741. diffuseColor: Color3;
  112742. /**
  112743. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  112744. * channel.
  112745. */
  112746. diffuseTexture: BaseTexture;
  112747. /**
  112748. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  112749. */
  112750. specularColor: Color3;
  112751. /**
  112752. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  112753. */
  112754. glossiness: number;
  112755. /**
  112756. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  112757. */
  112758. specularGlossinessTexture: BaseTexture;
  112759. /**
  112760. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  112761. *
  112762. * @param name The material name
  112763. * @param scene The scene the material will be use in.
  112764. */
  112765. constructor(name: string, scene: Scene);
  112766. /**
  112767. * Return the currrent class name of the material.
  112768. */
  112769. getClassName(): string;
  112770. /**
  112771. * Makes a duplicate of the current material.
  112772. * @param name - name to use for the new material.
  112773. */
  112774. clone(name: string): PBRSpecularGlossinessMaterial;
  112775. /**
  112776. * Serialize the material to a parsable JSON object.
  112777. */
  112778. serialize(): any;
  112779. /**
  112780. * Parses a JSON object correponding to the serialize function.
  112781. */
  112782. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  112783. }
  112784. }
  112785. declare module BABYLON {
  112786. /**
  112787. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  112788. * It can help converting any input color in a desired output one. This can then be used to create effects
  112789. * from sepia, black and white to sixties or futuristic rendering...
  112790. *
  112791. * The only supported format is currently 3dl.
  112792. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  112793. */
  112794. export class ColorGradingTexture extends BaseTexture {
  112795. /**
  112796. * The current texture matrix. (will always be identity in color grading texture)
  112797. */
  112798. private _textureMatrix;
  112799. /**
  112800. * The texture URL.
  112801. */
  112802. url: string;
  112803. /**
  112804. * Empty line regex stored for GC.
  112805. */
  112806. private static _noneEmptyLineRegex;
  112807. private _engine;
  112808. /**
  112809. * Instantiates a ColorGradingTexture from the following parameters.
  112810. *
  112811. * @param url The location of the color gradind data (currently only supporting 3dl)
  112812. * @param scene The scene the texture will be used in
  112813. */
  112814. constructor(url: string, scene: Scene);
  112815. /**
  112816. * Returns the texture matrix used in most of the material.
  112817. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  112818. */
  112819. getTextureMatrix(): Matrix;
  112820. /**
  112821. * Occurs when the file being loaded is a .3dl LUT file.
  112822. */
  112823. private load3dlTexture;
  112824. /**
  112825. * Starts the loading process of the texture.
  112826. */
  112827. private loadTexture;
  112828. /**
  112829. * Clones the color gradind texture.
  112830. */
  112831. clone(): ColorGradingTexture;
  112832. /**
  112833. * Called during delayed load for textures.
  112834. */
  112835. delayLoad(): void;
  112836. /**
  112837. * Parses a color grading texture serialized by Babylon.
  112838. * @param parsedTexture The texture information being parsedTexture
  112839. * @param scene The scene to load the texture in
  112840. * @param rootUrl The root url of the data assets to load
  112841. * @return A color gradind texture
  112842. */
  112843. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  112844. /**
  112845. * Serializes the LUT texture to json format.
  112846. */
  112847. serialize(): any;
  112848. }
  112849. }
  112850. declare module BABYLON {
  112851. /**
  112852. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  112853. */
  112854. export class EquiRectangularCubeTexture extends BaseTexture {
  112855. /** The six faces of the cube. */
  112856. private static _FacesMapping;
  112857. private _noMipmap;
  112858. private _onLoad;
  112859. private _onError;
  112860. /** The size of the cubemap. */
  112861. private _size;
  112862. /** The buffer of the image. */
  112863. private _buffer;
  112864. /** The width of the input image. */
  112865. private _width;
  112866. /** The height of the input image. */
  112867. private _height;
  112868. /** The URL to the image. */
  112869. url: string;
  112870. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  112871. coordinatesMode: number;
  112872. /**
  112873. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  112874. * @param url The location of the image
  112875. * @param scene The scene the texture will be used in
  112876. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  112877. * @param noMipmap Forces to not generate the mipmap if true
  112878. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  112879. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  112880. * @param onLoad — defines a callback called when texture is loaded
  112881. * @param onError — defines a callback called if there is an error
  112882. */
  112883. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  112884. /**
  112885. * Load the image data, by putting the image on a canvas and extracting its buffer.
  112886. */
  112887. private loadImage;
  112888. /**
  112889. * Convert the image buffer into a cubemap and create a CubeTexture.
  112890. */
  112891. private loadTexture;
  112892. /**
  112893. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  112894. * @param buffer The ArrayBuffer that should be converted.
  112895. * @returns The buffer as Float32Array.
  112896. */
  112897. private getFloat32ArrayFromArrayBuffer;
  112898. /**
  112899. * Get the current class name of the texture useful for serialization or dynamic coding.
  112900. * @returns "EquiRectangularCubeTexture"
  112901. */
  112902. getClassName(): string;
  112903. /**
  112904. * Create a clone of the current EquiRectangularCubeTexture and return it.
  112905. * @returns A clone of the current EquiRectangularCubeTexture.
  112906. */
  112907. clone(): EquiRectangularCubeTexture;
  112908. }
  112909. }
  112910. declare module BABYLON {
  112911. /**
  112912. * Based on jsTGALoader - Javascript loader for TGA file
  112913. * By Vincent Thibault
  112914. * @see http://blog.robrowser.com/javascript-tga-loader.html
  112915. */
  112916. export class TGATools {
  112917. private static _TYPE_INDEXED;
  112918. private static _TYPE_RGB;
  112919. private static _TYPE_GREY;
  112920. private static _TYPE_RLE_INDEXED;
  112921. private static _TYPE_RLE_RGB;
  112922. private static _TYPE_RLE_GREY;
  112923. private static _ORIGIN_MASK;
  112924. private static _ORIGIN_SHIFT;
  112925. private static _ORIGIN_BL;
  112926. private static _ORIGIN_BR;
  112927. private static _ORIGIN_UL;
  112928. private static _ORIGIN_UR;
  112929. /**
  112930. * Gets the header of a TGA file
  112931. * @param data defines the TGA data
  112932. * @returns the header
  112933. */
  112934. static GetTGAHeader(data: Uint8Array): any;
  112935. /**
  112936. * Uploads TGA content to a Babylon Texture
  112937. * @hidden
  112938. */
  112939. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  112940. /** @hidden */
  112941. 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;
  112942. /** @hidden */
  112943. 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;
  112944. /** @hidden */
  112945. 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;
  112946. /** @hidden */
  112947. 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;
  112948. /** @hidden */
  112949. 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;
  112950. /** @hidden */
  112951. 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;
  112952. }
  112953. }
  112954. declare module BABYLON {
  112955. /**
  112956. * Implementation of the TGA Texture Loader.
  112957. * @hidden
  112958. */
  112959. export class _TGATextureLoader implements IInternalTextureLoader {
  112960. /**
  112961. * Defines wether the loader supports cascade loading the different faces.
  112962. */
  112963. readonly supportCascades: boolean;
  112964. /**
  112965. * This returns if the loader support the current file information.
  112966. * @param extension defines the file extension of the file being loaded
  112967. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112968. * @param fallback defines the fallback internal texture if any
  112969. * @param isBase64 defines whether the texture is encoded as a base64
  112970. * @param isBuffer defines whether the texture data are stored as a buffer
  112971. * @returns true if the loader can load the specified file
  112972. */
  112973. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112974. /**
  112975. * Transform the url before loading if required.
  112976. * @param rootUrl the url of the texture
  112977. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112978. * @returns the transformed texture
  112979. */
  112980. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112981. /**
  112982. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112983. * @param rootUrl the url of the texture
  112984. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112985. * @returns the fallback texture
  112986. */
  112987. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112988. /**
  112989. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112990. * @param data contains the texture data
  112991. * @param texture defines the BabylonJS internal texture
  112992. * @param createPolynomials will be true if polynomials have been requested
  112993. * @param onLoad defines the callback to trigger once the texture is ready
  112994. * @param onError defines the callback to trigger in case of error
  112995. */
  112996. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112997. /**
  112998. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112999. * @param data contains the texture data
  113000. * @param texture defines the BabylonJS internal texture
  113001. * @param callback defines the method to call once ready to upload
  113002. */
  113003. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113004. }
  113005. }
  113006. declare module BABYLON {
  113007. /**
  113008. * Info about the .basis files
  113009. */
  113010. class BasisFileInfo {
  113011. /**
  113012. * If the file has alpha
  113013. */
  113014. hasAlpha: boolean;
  113015. /**
  113016. * Info about each image of the basis file
  113017. */
  113018. images: Array<{
  113019. levels: Array<{
  113020. width: number;
  113021. height: number;
  113022. transcodedPixels: ArrayBufferView;
  113023. }>;
  113024. }>;
  113025. }
  113026. /**
  113027. * Result of transcoding a basis file
  113028. */
  113029. class TranscodeResult {
  113030. /**
  113031. * Info about the .basis file
  113032. */
  113033. fileInfo: BasisFileInfo;
  113034. /**
  113035. * Format to use when loading the file
  113036. */
  113037. format: number;
  113038. }
  113039. /**
  113040. * Configuration options for the Basis transcoder
  113041. */
  113042. export class BasisTranscodeConfiguration {
  113043. /**
  113044. * Supported compression formats used to determine the supported output format of the transcoder
  113045. */
  113046. supportedCompressionFormats?: {
  113047. /**
  113048. * etc1 compression format
  113049. */
  113050. etc1?: boolean;
  113051. /**
  113052. * s3tc compression format
  113053. */
  113054. s3tc?: boolean;
  113055. /**
  113056. * pvrtc compression format
  113057. */
  113058. pvrtc?: boolean;
  113059. /**
  113060. * etc2 compression format
  113061. */
  113062. etc2?: boolean;
  113063. };
  113064. /**
  113065. * If mipmap levels should be loaded for transcoded images (Default: true)
  113066. */
  113067. loadMipmapLevels?: boolean;
  113068. /**
  113069. * Index of a single image to load (Default: all images)
  113070. */
  113071. loadSingleImage?: number;
  113072. }
  113073. /**
  113074. * Used to load .Basis files
  113075. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  113076. */
  113077. export class BasisTools {
  113078. private static _IgnoreSupportedFormats;
  113079. /**
  113080. * URL to use when loading the basis transcoder
  113081. */
  113082. static JSModuleURL: string;
  113083. /**
  113084. * URL to use when loading the wasm module for the transcoder
  113085. */
  113086. static WasmModuleURL: string;
  113087. /**
  113088. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  113089. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  113090. * @returns internal format corresponding to the Basis format
  113091. */
  113092. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  113093. private static _WorkerPromise;
  113094. private static _Worker;
  113095. private static _actionId;
  113096. private static _CreateWorkerAsync;
  113097. /**
  113098. * Transcodes a loaded image file to compressed pixel data
  113099. * @param imageData image data to transcode
  113100. * @param config configuration options for the transcoding
  113101. * @returns a promise resulting in the transcoded image
  113102. */
  113103. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  113104. /**
  113105. * Loads a texture from the transcode result
  113106. * @param texture texture load to
  113107. * @param transcodeResult the result of transcoding the basis file to load from
  113108. */
  113109. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  113110. }
  113111. }
  113112. declare module BABYLON {
  113113. /**
  113114. * Loader for .basis file format
  113115. */
  113116. export class _BasisTextureLoader implements IInternalTextureLoader {
  113117. /**
  113118. * Defines whether the loader supports cascade loading the different faces.
  113119. */
  113120. readonly supportCascades: boolean;
  113121. /**
  113122. * This returns if the loader support the current file information.
  113123. * @param extension defines the file extension of the file being loaded
  113124. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113125. * @param fallback defines the fallback internal texture if any
  113126. * @param isBase64 defines whether the texture is encoded as a base64
  113127. * @param isBuffer defines whether the texture data are stored as a buffer
  113128. * @returns true if the loader can load the specified file
  113129. */
  113130. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113131. /**
  113132. * Transform the url before loading if required.
  113133. * @param rootUrl the url of the texture
  113134. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113135. * @returns the transformed texture
  113136. */
  113137. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113138. /**
  113139. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113140. * @param rootUrl the url of the texture
  113141. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113142. * @returns the fallback texture
  113143. */
  113144. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113145. /**
  113146. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  113147. * @param data contains the texture data
  113148. * @param texture defines the BabylonJS internal texture
  113149. * @param createPolynomials will be true if polynomials have been requested
  113150. * @param onLoad defines the callback to trigger once the texture is ready
  113151. * @param onError defines the callback to trigger in case of error
  113152. */
  113153. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113154. /**
  113155. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113156. * @param data contains the texture data
  113157. * @param texture defines the BabylonJS internal texture
  113158. * @param callback defines the method to call once ready to upload
  113159. */
  113160. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113161. }
  113162. }
  113163. declare module BABYLON {
  113164. /**
  113165. * 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.
  113166. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113167. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113168. */
  113169. export class CustomProceduralTexture extends ProceduralTexture {
  113170. private _animate;
  113171. private _time;
  113172. private _config;
  113173. private _texturePath;
  113174. /**
  113175. * Instantiates a new Custom Procedural Texture.
  113176. * 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.
  113177. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113178. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113179. * @param name Define the name of the texture
  113180. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  113181. * @param size Define the size of the texture to create
  113182. * @param scene Define the scene the texture belongs to
  113183. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  113184. * @param generateMipMaps Define if the texture should creates mip maps or not
  113185. */
  113186. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113187. private _loadJson;
  113188. /**
  113189. * Is the texture ready to be used ? (rendered at least once)
  113190. * @returns true if ready, otherwise, false.
  113191. */
  113192. isReady(): boolean;
  113193. /**
  113194. * Render the texture to its associated render target.
  113195. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  113196. */
  113197. render(useCameraPostProcess?: boolean): void;
  113198. /**
  113199. * Update the list of dependant textures samplers in the shader.
  113200. */
  113201. updateTextures(): void;
  113202. /**
  113203. * Update the uniform values of the procedural texture in the shader.
  113204. */
  113205. updateShaderUniforms(): void;
  113206. /**
  113207. * Define if the texture animates or not.
  113208. */
  113209. animate: boolean;
  113210. }
  113211. }
  113212. declare module BABYLON {
  113213. /** @hidden */
  113214. export var noisePixelShader: {
  113215. name: string;
  113216. shader: string;
  113217. };
  113218. }
  113219. declare module BABYLON {
  113220. /**
  113221. * Class used to generate noise procedural textures
  113222. */
  113223. export class NoiseProceduralTexture extends ProceduralTexture {
  113224. private _time;
  113225. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  113226. brightness: number;
  113227. /** Defines the number of octaves to process */
  113228. octaves: number;
  113229. /** Defines the level of persistence (0.8 by default) */
  113230. persistence: number;
  113231. /** Gets or sets animation speed factor (default is 1) */
  113232. animationSpeedFactor: number;
  113233. /**
  113234. * Creates a new NoiseProceduralTexture
  113235. * @param name defines the name fo the texture
  113236. * @param size defines the size of the texture (default is 256)
  113237. * @param scene defines the hosting scene
  113238. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  113239. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  113240. */
  113241. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113242. private _updateShaderUniforms;
  113243. protected _getDefines(): string;
  113244. /** Generate the current state of the procedural texture */
  113245. render(useCameraPostProcess?: boolean): void;
  113246. /**
  113247. * Serializes this noise procedural texture
  113248. * @returns a serialized noise procedural texture object
  113249. */
  113250. serialize(): any;
  113251. /**
  113252. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  113253. * @param parsedTexture defines parsed texture data
  113254. * @param scene defines the current scene
  113255. * @param rootUrl defines the root URL containing noise procedural texture information
  113256. * @returns a parsed NoiseProceduralTexture
  113257. */
  113258. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  113259. }
  113260. }
  113261. declare module BABYLON {
  113262. /**
  113263. * Raw cube texture where the raw buffers are passed in
  113264. */
  113265. export class RawCubeTexture extends CubeTexture {
  113266. /**
  113267. * Creates a cube texture where the raw buffers are passed in.
  113268. * @param scene defines the scene the texture is attached to
  113269. * @param data defines the array of data to use to create each face
  113270. * @param size defines the size of the textures
  113271. * @param format defines the format of the data
  113272. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  113273. * @param generateMipMaps defines if the engine should generate the mip levels
  113274. * @param invertY defines if data must be stored with Y axis inverted
  113275. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  113276. * @param compression defines the compression used (null by default)
  113277. */
  113278. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  113279. /**
  113280. * Updates the raw cube texture.
  113281. * @param data defines the data to store
  113282. * @param format defines the data format
  113283. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113284. * @param invertY defines if data must be stored with Y axis inverted
  113285. * @param compression defines the compression used (null by default)
  113286. * @param level defines which level of the texture to update
  113287. */
  113288. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  113289. /**
  113290. * Updates a raw cube texture with RGBD encoded data.
  113291. * @param data defines the array of data [mipmap][face] to use to create each face
  113292. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  113293. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113294. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113295. * @returns a promsie that resolves when the operation is complete
  113296. */
  113297. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  113298. /**
  113299. * Clones the raw cube texture.
  113300. * @return a new cube texture
  113301. */
  113302. clone(): CubeTexture;
  113303. /** @hidden */
  113304. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113305. }
  113306. }
  113307. declare module BABYLON {
  113308. /**
  113309. * Class used to store 3D textures containing user data
  113310. */
  113311. export class RawTexture3D extends Texture {
  113312. /** Gets or sets the texture format to use */
  113313. format: number;
  113314. private _engine;
  113315. /**
  113316. * Create a new RawTexture3D
  113317. * @param data defines the data of the texture
  113318. * @param width defines the width of the texture
  113319. * @param height defines the height of the texture
  113320. * @param depth defines the depth of the texture
  113321. * @param format defines the texture format to use
  113322. * @param scene defines the hosting scene
  113323. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  113324. * @param invertY defines if texture must be stored with Y axis inverted
  113325. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  113326. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  113327. */
  113328. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  113329. /** Gets or sets the texture format to use */
  113330. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  113331. /**
  113332. * Update the texture with new data
  113333. * @param data defines the data to store in the texture
  113334. */
  113335. update(data: ArrayBufferView): void;
  113336. }
  113337. }
  113338. declare module BABYLON {
  113339. /**
  113340. * Creates a refraction texture used by refraction channel of the standard material.
  113341. * It is like a mirror but to see through a material.
  113342. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113343. */
  113344. export class RefractionTexture extends RenderTargetTexture {
  113345. /**
  113346. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  113347. * 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.
  113348. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113349. */
  113350. refractionPlane: Plane;
  113351. /**
  113352. * Define how deep under the surface we should see.
  113353. */
  113354. depth: number;
  113355. /**
  113356. * Creates a refraction texture used by refraction channel of the standard material.
  113357. * It is like a mirror but to see through a material.
  113358. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113359. * @param name Define the texture name
  113360. * @param size Define the size of the underlying texture
  113361. * @param scene Define the scene the refraction belongs to
  113362. * @param generateMipMaps Define if we need to generate mips level for the refraction
  113363. */
  113364. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  113365. /**
  113366. * Clone the refraction texture.
  113367. * @returns the cloned texture
  113368. */
  113369. clone(): RefractionTexture;
  113370. /**
  113371. * Serialize the texture to a JSON representation you could use in Parse later on
  113372. * @returns the serialized JSON representation
  113373. */
  113374. serialize(): any;
  113375. }
  113376. }
  113377. declare module BABYLON {
  113378. /**
  113379. * Defines the options related to the creation of an HtmlElementTexture
  113380. */
  113381. export interface IHtmlElementTextureOptions {
  113382. /**
  113383. * Defines wether mip maps should be created or not.
  113384. */
  113385. generateMipMaps?: boolean;
  113386. /**
  113387. * Defines the sampling mode of the texture.
  113388. */
  113389. samplingMode?: number;
  113390. /**
  113391. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  113392. */
  113393. engine: Nullable<Engine>;
  113394. /**
  113395. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  113396. */
  113397. scene: Nullable<Scene>;
  113398. }
  113399. /**
  113400. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  113401. * To be as efficient as possible depending on your constraints nothing aside the first upload
  113402. * is automatically managed.
  113403. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  113404. * in your application.
  113405. *
  113406. * As the update is not automatic, you need to call them manually.
  113407. */
  113408. export class HtmlElementTexture extends BaseTexture {
  113409. /**
  113410. * The texture URL.
  113411. */
  113412. element: HTMLVideoElement | HTMLCanvasElement;
  113413. private static readonly DefaultOptions;
  113414. private _textureMatrix;
  113415. private _engine;
  113416. private _isVideo;
  113417. private _generateMipMaps;
  113418. private _samplingMode;
  113419. /**
  113420. * Instantiates a HtmlElementTexture from the following parameters.
  113421. *
  113422. * @param name Defines the name of the texture
  113423. * @param element Defines the video or canvas the texture is filled with
  113424. * @param options Defines the other none mandatory texture creation options
  113425. */
  113426. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  113427. private _createInternalTexture;
  113428. /**
  113429. * Returns the texture matrix used in most of the material.
  113430. */
  113431. getTextureMatrix(): Matrix;
  113432. /**
  113433. * Updates the content of the texture.
  113434. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  113435. */
  113436. update(invertY?: Nullable<boolean>): void;
  113437. }
  113438. }
  113439. declare module BABYLON {
  113440. /**
  113441. * Enum used to define the target of a block
  113442. */
  113443. export enum NodeMaterialBlockTargets {
  113444. /** Vertex shader */
  113445. Vertex = 1,
  113446. /** Fragment shader */
  113447. Fragment = 2,
  113448. /** Vertex and Fragment */
  113449. VertexAndFragment = 3
  113450. }
  113451. }
  113452. declare module BABYLON {
  113453. /**
  113454. * Defines the kind of connection point for node based material
  113455. */
  113456. export enum NodeMaterialBlockConnectionPointTypes {
  113457. /** Float */
  113458. Float = 1,
  113459. /** Int */
  113460. Int = 2,
  113461. /** Vector2 */
  113462. Vector2 = 4,
  113463. /** Vector3 */
  113464. Vector3 = 8,
  113465. /** Vector4 */
  113466. Vector4 = 16,
  113467. /** Color3 */
  113468. Color3 = 32,
  113469. /** Color4 */
  113470. Color4 = 64,
  113471. /** Matrix */
  113472. Matrix = 128,
  113473. /** Vector3 or Color3 */
  113474. Vector3OrColor3 = 40,
  113475. /** Vector3 or Vector4 */
  113476. Vector3OrVector4 = 24,
  113477. /** Vector4 or Color4 */
  113478. Vector4OrColor4 = 80,
  113479. /** Color3 or Color4 */
  113480. Color3OrColor4 = 96,
  113481. /** Vector2 or Color3 or Color4 */
  113482. Vector2OrColor3OrColor4 = 100,
  113483. /** Vector3 or Color3 or Color4 or Vector4 */
  113484. Vector3OrColor3OrVector4OrColor4 = 120,
  113485. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  113486. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  113487. /** Detect type based on connection */
  113488. AutoDetect = 1024,
  113489. /** Output type that will be defined by input type */
  113490. BasedOnInput = 2048
  113491. }
  113492. }
  113493. declare module BABYLON {
  113494. /**
  113495. * Root class for all node material optimizers
  113496. */
  113497. export class NodeMaterialOptimizer {
  113498. /**
  113499. * Function used to optimize a NodeMaterial graph
  113500. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  113501. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  113502. */
  113503. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  113504. }
  113505. }
  113506. declare module BABYLON {
  113507. /**
  113508. * Block used to transform a vector4 with a matrix
  113509. */
  113510. export class Vector4TransformBlock extends NodeMaterialBlock {
  113511. /**
  113512. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113513. */
  113514. complementW: number;
  113515. /**
  113516. * Creates a new Vector4TransformBlock
  113517. * @param name defines the block name
  113518. */
  113519. constructor(name: string);
  113520. /**
  113521. * Gets the current class name
  113522. * @returns the class name
  113523. */
  113524. getClassName(): string;
  113525. /**
  113526. * Gets the vector input
  113527. */
  113528. readonly vector: NodeMaterialConnectionPoint;
  113529. /**
  113530. * Gets the output component
  113531. */
  113532. readonly output: NodeMaterialConnectionPoint;
  113533. /**
  113534. * Gets the matrix transform input
  113535. */
  113536. readonly transform: NodeMaterialConnectionPoint;
  113537. protected _buildBlock(state: NodeMaterialBuildState): this;
  113538. }
  113539. }
  113540. declare module BABYLON {
  113541. /**
  113542. * Block used to output the vertex position
  113543. */
  113544. export class VertexOutputBlock extends NodeMaterialBlock {
  113545. /**
  113546. * Creates a new VertexOutputBlock
  113547. * @param name defines the block name
  113548. */
  113549. constructor(name: string);
  113550. /**
  113551. * Gets the current class name
  113552. * @returns the class name
  113553. */
  113554. getClassName(): string;
  113555. /**
  113556. * Gets the vector input component
  113557. */
  113558. readonly vector: NodeMaterialConnectionPoint;
  113559. protected _buildBlock(state: NodeMaterialBuildState): this;
  113560. }
  113561. }
  113562. declare module BABYLON {
  113563. /**
  113564. * Block used to output the final color
  113565. */
  113566. export class FragmentOutputBlock extends NodeMaterialBlock {
  113567. /**
  113568. * Gets or sets a boolean indicating if this block will output an alpha value
  113569. */
  113570. alphaBlendingEnabled: boolean;
  113571. /**
  113572. * Create a new FragmentOutputBlock
  113573. * @param name defines the block name
  113574. */
  113575. constructor(name: string);
  113576. /**
  113577. * Gets the current class name
  113578. * @returns the class name
  113579. */
  113580. getClassName(): string;
  113581. /**
  113582. * Gets the color input component
  113583. */
  113584. readonly color: NodeMaterialConnectionPoint;
  113585. protected _buildBlock(state: NodeMaterialBuildState): this;
  113586. }
  113587. }
  113588. declare module BABYLON {
  113589. /**
  113590. * Interface used to configure the node material editor
  113591. */
  113592. export interface INodeMaterialEditorOptions {
  113593. /** Define the URl to load node editor script */
  113594. editorURL?: string;
  113595. }
  113596. /** @hidden */
  113597. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  113598. /** BONES */
  113599. NUM_BONE_INFLUENCERS: number;
  113600. BonesPerMesh: number;
  113601. BONETEXTURE: boolean;
  113602. /** MORPH TARGETS */
  113603. MORPHTARGETS: boolean;
  113604. MORPHTARGETS_NORMAL: boolean;
  113605. MORPHTARGETS_TANGENT: boolean;
  113606. MORPHTARGETS_UV: boolean;
  113607. NUM_MORPH_INFLUENCERS: number;
  113608. /** IMAGE PROCESSING */
  113609. IMAGEPROCESSING: boolean;
  113610. VIGNETTE: boolean;
  113611. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113612. VIGNETTEBLENDMODEOPAQUE: boolean;
  113613. TONEMAPPING: boolean;
  113614. TONEMAPPING_ACES: boolean;
  113615. CONTRAST: boolean;
  113616. EXPOSURE: boolean;
  113617. COLORCURVES: boolean;
  113618. COLORGRADING: boolean;
  113619. COLORGRADING3D: boolean;
  113620. SAMPLER3DGREENDEPTH: boolean;
  113621. SAMPLER3DBGRMAP: boolean;
  113622. IMAGEPROCESSINGPOSTPROCESS: boolean;
  113623. constructor();
  113624. setValue(name: string, value: boolean): void;
  113625. }
  113626. /**
  113627. * Class used to configure NodeMaterial
  113628. */
  113629. export interface INodeMaterialOptions {
  113630. /**
  113631. * Defines if blocks should emit comments
  113632. */
  113633. emitComments: boolean;
  113634. }
  113635. /**
  113636. * Class used to create a node based material built by assembling shader blocks
  113637. */
  113638. export class NodeMaterial extends PushMaterial {
  113639. private _options;
  113640. private _vertexCompilationState;
  113641. private _fragmentCompilationState;
  113642. private _sharedData;
  113643. private _buildId;
  113644. private _buildWasSuccessful;
  113645. private _cachedWorldViewMatrix;
  113646. private _cachedWorldViewProjectionMatrix;
  113647. private _optimizers;
  113648. /** Define the URl to load node editor script */
  113649. static EditorURL: string;
  113650. private BJSNODEMATERIALEDITOR;
  113651. /** Get the inspector from bundle or global */
  113652. private _getGlobalNodeMaterialEditor;
  113653. /**
  113654. * Defines the maximum number of lights that can be used in the material
  113655. */
  113656. maxSimultaneousLights: number;
  113657. /**
  113658. * Observable raised when the material is built
  113659. */
  113660. onBuildObservable: Observable<NodeMaterial>;
  113661. /**
  113662. * Gets or sets the root nodes of the material vertex shader
  113663. */
  113664. _vertexOutputNodes: NodeMaterialBlock[];
  113665. /**
  113666. * Gets or sets the root nodes of the material fragment (pixel) shader
  113667. */
  113668. _fragmentOutputNodes: NodeMaterialBlock[];
  113669. /** Gets or sets options to control the node material overall behavior */
  113670. options: INodeMaterialOptions;
  113671. /**
  113672. * Default configuration related to image processing available in the standard Material.
  113673. */
  113674. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113675. /**
  113676. * Gets the image processing configuration used either in this material.
  113677. */
  113678. /**
  113679. * Sets the Default image processing configuration used either in the this material.
  113680. *
  113681. * If sets to null, the scene one is in use.
  113682. */
  113683. imageProcessingConfiguration: ImageProcessingConfiguration;
  113684. /**
  113685. * Create a new node based material
  113686. * @param name defines the material name
  113687. * @param scene defines the hosting scene
  113688. * @param options defines creation option
  113689. */
  113690. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  113691. /**
  113692. * Gets the current class name of the material e.g. "NodeMaterial"
  113693. * @returns the class name
  113694. */
  113695. getClassName(): string;
  113696. /**
  113697. * Keep track of the image processing observer to allow dispose and replace.
  113698. */
  113699. private _imageProcessingObserver;
  113700. /**
  113701. * Attaches a new image processing configuration to the Standard Material.
  113702. * @param configuration
  113703. */
  113704. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113705. /**
  113706. * Adds a new optimizer to the list of optimizers
  113707. * @param optimizer defines the optimizers to add
  113708. * @returns the current material
  113709. */
  113710. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113711. /**
  113712. * Remove an optimizer from the list of optimizers
  113713. * @param optimizer defines the optimizers to remove
  113714. * @returns the current material
  113715. */
  113716. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113717. /**
  113718. * Add a new block to the list of output nodes
  113719. * @param node defines the node to add
  113720. * @returns the current material
  113721. */
  113722. addOutputNode(node: NodeMaterialBlock): this;
  113723. /**
  113724. * Remove a block from the list of root nodes
  113725. * @param node defines the node to remove
  113726. * @returns the current material
  113727. */
  113728. removeOutputNode(node: NodeMaterialBlock): this;
  113729. private _addVertexOutputNode;
  113730. private _removeVertexOutputNode;
  113731. private _addFragmentOutputNode;
  113732. private _removeFragmentOutputNode;
  113733. /**
  113734. * Specifies if the material will require alpha blending
  113735. * @returns a boolean specifying if alpha blending is needed
  113736. */
  113737. needAlphaBlending(): boolean;
  113738. /**
  113739. * Specifies if this material should be rendered in alpha test mode
  113740. * @returns a boolean specifying if an alpha test is needed.
  113741. */
  113742. needAlphaTesting(): boolean;
  113743. private _initializeBlock;
  113744. private _resetDualBlocks;
  113745. /**
  113746. * Build the material and generates the inner effect
  113747. * @param verbose defines if the build should log activity
  113748. */
  113749. build(verbose?: boolean): void;
  113750. /**
  113751. * Runs an otpimization phase to try to improve the shader code
  113752. */
  113753. optimize(): void;
  113754. private _prepareDefinesForAttributes;
  113755. /**
  113756. * Get if the submesh is ready to be used and all its information available.
  113757. * Child classes can use it to update shaders
  113758. * @param mesh defines the mesh to check
  113759. * @param subMesh defines which submesh to check
  113760. * @param useInstances specifies that instances should be used
  113761. * @returns a boolean indicating that the submesh is ready or not
  113762. */
  113763. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113764. /**
  113765. * Binds the world matrix to the material
  113766. * @param world defines the world transformation matrix
  113767. */
  113768. bindOnlyWorldMatrix(world: Matrix): void;
  113769. /**
  113770. * Binds the submesh to this material by preparing the effect and shader to draw
  113771. * @param world defines the world transformation matrix
  113772. * @param mesh defines the mesh containing the submesh
  113773. * @param subMesh defines the submesh to bind the material to
  113774. */
  113775. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113776. /**
  113777. * Gets the active textures from the material
  113778. * @returns an array of textures
  113779. */
  113780. getActiveTextures(): BaseTexture[];
  113781. /**
  113782. * Specifies if the material uses a texture
  113783. * @param texture defines the texture to check against the material
  113784. * @returns a boolean specifying if the material uses the texture
  113785. */
  113786. hasTexture(texture: BaseTexture): boolean;
  113787. /**
  113788. * Disposes the material
  113789. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  113790. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  113791. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  113792. */
  113793. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  113794. /** Creates the node editor window. */
  113795. private _createNodeEditor;
  113796. /**
  113797. * Launch the node material editor
  113798. * @param config Define the configuration of the editor
  113799. * @return a promise fulfilled when the node editor is visible
  113800. */
  113801. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  113802. /**
  113803. * Clear the current material
  113804. */
  113805. clear(): void;
  113806. /**
  113807. * Clear the current material and set it to a default state
  113808. */
  113809. setToDefault(): void;
  113810. }
  113811. }
  113812. declare module BABYLON {
  113813. /**
  113814. * Block used to read a texture from a sampler
  113815. */
  113816. export class TextureBlock extends NodeMaterialBlock {
  113817. private _defineName;
  113818. private _samplerName;
  113819. private _transformedUVName;
  113820. private _textureTransformName;
  113821. private _textureInfoName;
  113822. private _mainUVName;
  113823. private _mainUVDefineName;
  113824. /**
  113825. * Gets or sets the texture associated with the node
  113826. */
  113827. texture: Nullable<BaseTexture>;
  113828. /**
  113829. * Create a new TextureBlock
  113830. * @param name defines the block name
  113831. */
  113832. constructor(name: string);
  113833. /**
  113834. * Gets the current class name
  113835. * @returns the class name
  113836. */
  113837. getClassName(): string;
  113838. /**
  113839. * Gets the uv input component
  113840. */
  113841. readonly uv: NodeMaterialConnectionPoint;
  113842. /**
  113843. * Gets the output component
  113844. */
  113845. readonly output: NodeMaterialConnectionPoint;
  113846. autoConfigure(): void;
  113847. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  113848. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113849. isReady(): boolean;
  113850. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113851. private _injectVertexCode;
  113852. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  113853. }
  113854. }
  113855. declare module BABYLON {
  113856. /**
  113857. * Class used to store shared data between 2 NodeMaterialBuildState
  113858. */
  113859. export class NodeMaterialBuildStateSharedData {
  113860. /**
  113861. * Gets the list of emitted varyings
  113862. */
  113863. varyings: string[];
  113864. /**
  113865. * Gets the varying declaration string
  113866. */
  113867. varyingDeclaration: string;
  113868. /**
  113869. * Input blocks
  113870. */
  113871. inputBlocks: InputBlock[];
  113872. /**
  113873. * Input blocks
  113874. */
  113875. textureBlocks: TextureBlock[];
  113876. /**
  113877. * Bindable blocks (Blocks that need to set data to the effect)
  113878. */
  113879. bindableBlocks: NodeMaterialBlock[];
  113880. /**
  113881. * List of blocks that can provide a compilation fallback
  113882. */
  113883. blocksWithFallbacks: NodeMaterialBlock[];
  113884. /**
  113885. * List of blocks that can provide a define update
  113886. */
  113887. blocksWithDefines: NodeMaterialBlock[];
  113888. /**
  113889. * List of blocks that can provide a repeatable content
  113890. */
  113891. repeatableContentBlocks: NodeMaterialBlock[];
  113892. /**
  113893. * List of blocks that can provide a dynamic list of uniforms
  113894. */
  113895. dynamicUniformBlocks: NodeMaterialBlock[];
  113896. /**
  113897. * List of blocks that can block the isReady function for the material
  113898. */
  113899. blockingBlocks: NodeMaterialBlock[];
  113900. /**
  113901. * Build Id used to avoid multiple recompilations
  113902. */
  113903. buildId: number;
  113904. /** List of emitted variables */
  113905. variableNames: {
  113906. [key: string]: number;
  113907. };
  113908. /** List of emitted defines */
  113909. defineNames: {
  113910. [key: string]: number;
  113911. };
  113912. /** Should emit comments? */
  113913. emitComments: boolean;
  113914. /** Emit build activity */
  113915. verbose: boolean;
  113916. /**
  113917. * Gets the compilation hints emitted at compilation time
  113918. */
  113919. hints: {
  113920. needWorldViewMatrix: boolean;
  113921. needWorldViewProjectionMatrix: boolean;
  113922. needAlphaBlending: boolean;
  113923. needAlphaTesting: boolean;
  113924. };
  113925. /**
  113926. * List of compilation checks
  113927. */
  113928. checks: {
  113929. emitVertex: boolean;
  113930. emitFragment: boolean;
  113931. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  113932. };
  113933. /** Creates a new shared data */
  113934. constructor();
  113935. /**
  113936. * Emits console errors and exceptions if there is a failing check
  113937. */
  113938. emitErrors(): void;
  113939. }
  113940. }
  113941. declare module BABYLON {
  113942. /**
  113943. * Class used to store node based material build state
  113944. */
  113945. export class NodeMaterialBuildState {
  113946. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  113947. supportUniformBuffers: boolean;
  113948. /**
  113949. * Gets the list of emitted attributes
  113950. */
  113951. attributes: string[];
  113952. /**
  113953. * Gets the list of emitted uniforms
  113954. */
  113955. uniforms: string[];
  113956. /**
  113957. * Gets the list of emitted uniform buffers
  113958. */
  113959. uniformBuffers: string[];
  113960. /**
  113961. * Gets the list of emitted samplers
  113962. */
  113963. samplers: string[];
  113964. /**
  113965. * Gets the list of emitted functions
  113966. */
  113967. functions: {
  113968. [key: string]: string;
  113969. };
  113970. /**
  113971. * Gets the target of the compilation state
  113972. */
  113973. target: NodeMaterialBlockTargets;
  113974. /**
  113975. * Gets the list of emitted counters
  113976. */
  113977. counters: {
  113978. [key: string]: number;
  113979. };
  113980. /**
  113981. * Shared data between multiple NodeMaterialBuildState instances
  113982. */
  113983. sharedData: NodeMaterialBuildStateSharedData;
  113984. /** @hidden */
  113985. _vertexState: NodeMaterialBuildState;
  113986. /** @hidden */
  113987. _attributeDeclaration: string;
  113988. /** @hidden */
  113989. _uniformDeclaration: string;
  113990. /** @hidden */
  113991. _samplerDeclaration: string;
  113992. /** @hidden */
  113993. _varyingTransfer: string;
  113994. private _repeatableContentAnchorIndex;
  113995. /** @hidden */
  113996. _builtCompilationString: string;
  113997. /**
  113998. * Gets the emitted compilation strings
  113999. */
  114000. compilationString: string;
  114001. /**
  114002. * Finalize the compilation strings
  114003. * @param state defines the current compilation state
  114004. */
  114005. finalize(state: NodeMaterialBuildState): void;
  114006. /** @hidden */
  114007. readonly _repeatableContentAnchor: string;
  114008. /** @hidden */
  114009. _getFreeVariableName(prefix: string): string;
  114010. /** @hidden */
  114011. _getFreeDefineName(prefix: string): string;
  114012. /** @hidden */
  114013. _excludeVariableName(name: string): void;
  114014. /** @hidden */
  114015. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  114016. /** @hidden */
  114017. _emitFunction(name: string, code: string, comments: string): void;
  114018. /** @hidden */
  114019. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  114020. replaceStrings?: {
  114021. search: RegExp;
  114022. replace: string;
  114023. }[];
  114024. repeatKey?: string;
  114025. }): string;
  114026. /** @hidden */
  114027. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  114028. repeatKey?: string;
  114029. removeAttributes?: boolean;
  114030. removeUniforms?: boolean;
  114031. removeVaryings?: boolean;
  114032. removeIfDef?: boolean;
  114033. replaceStrings?: {
  114034. search: RegExp;
  114035. replace: string;
  114036. }[];
  114037. }, storeKey?: string): void;
  114038. /** @hidden */
  114039. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  114040. /** @hidden */
  114041. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  114042. }
  114043. }
  114044. declare module BABYLON {
  114045. /**
  114046. * Defines a block that can be used inside a node based material
  114047. */
  114048. export class NodeMaterialBlock {
  114049. private _buildId;
  114050. private _buildTarget;
  114051. private _target;
  114052. private _isFinalMerger;
  114053. private _isInput;
  114054. /** @hidden */
  114055. _inputs: NodeMaterialConnectionPoint[];
  114056. /** @hidden */
  114057. _outputs: NodeMaterialConnectionPoint[];
  114058. /**
  114059. * Gets or sets the name of the block
  114060. */
  114061. name: string;
  114062. /**
  114063. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  114064. */
  114065. readonly isFinalMerger: boolean;
  114066. /**
  114067. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  114068. */
  114069. readonly isInput: boolean;
  114070. /**
  114071. * Gets or sets the build Id
  114072. */
  114073. buildId: number;
  114074. /**
  114075. * Gets or sets the target of the block
  114076. */
  114077. target: NodeMaterialBlockTargets;
  114078. /**
  114079. * Gets the list of input points
  114080. */
  114081. readonly inputs: NodeMaterialConnectionPoint[];
  114082. /** Gets the list of output points */
  114083. readonly outputs: NodeMaterialConnectionPoint[];
  114084. /**
  114085. * Find an input by its name
  114086. * @param name defines the name of the input to look for
  114087. * @returns the input or null if not found
  114088. */
  114089. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114090. /**
  114091. * Find an output by its name
  114092. * @param name defines the name of the outputto look for
  114093. * @returns the output or null if not found
  114094. */
  114095. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114096. /**
  114097. * Creates a new NodeMaterialBlock
  114098. * @param name defines the block name
  114099. * @param target defines the target of that block (Vertex by default)
  114100. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  114101. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  114102. */
  114103. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  114104. /**
  114105. * Initialize the block and prepare the context for build
  114106. * @param state defines the state that will be used for the build
  114107. */
  114108. initialize(state: NodeMaterialBuildState): void;
  114109. /**
  114110. * Bind data to effect. Will only be called for blocks with isBindable === true
  114111. * @param effect defines the effect to bind data to
  114112. * @param nodeMaterial defines the hosting NodeMaterial
  114113. * @param mesh defines the mesh that will be rendered
  114114. */
  114115. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114116. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  114117. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  114118. protected _writeFloat(value: number): string;
  114119. /**
  114120. * Gets the current class name e.g. "NodeMaterialBlock"
  114121. * @returns the class name
  114122. */
  114123. getClassName(): string;
  114124. /**
  114125. * Register a new input. Must be called inside a block constructor
  114126. * @param name defines the connection point name
  114127. * @param type defines the connection point type
  114128. * @param isOptional defines a boolean indicating that this input can be omitted
  114129. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114130. * @returns the current block
  114131. */
  114132. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  114133. /**
  114134. * Register a new output. Must be called inside a block constructor
  114135. * @param name defines the connection point name
  114136. * @param type defines the connection point type
  114137. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114138. * @returns the current block
  114139. */
  114140. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  114141. /**
  114142. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  114143. * @param forOutput defines an optional connection point to check compatibility with
  114144. * @returns the first available input or null
  114145. */
  114146. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  114147. /**
  114148. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  114149. * @param forBlock defines an optional block to check compatibility with
  114150. * @returns the first available input or null
  114151. */
  114152. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  114153. /**
  114154. * Connect current block with another block
  114155. * @param other defines the block to connect with
  114156. * @param options define the various options to help pick the right connections
  114157. * @returns the current block
  114158. */
  114159. connectTo(other: NodeMaterialBlock, options?: {
  114160. input?: string;
  114161. output?: string;
  114162. outputSwizzle?: string;
  114163. }): this | undefined;
  114164. protected _buildBlock(state: NodeMaterialBuildState): void;
  114165. /**
  114166. * Add uniforms, samplers and uniform buffers at compilation time
  114167. * @param state defines the state to update
  114168. * @param nodeMaterial defines the node material requesting the update
  114169. * @param defines defines the material defines to update
  114170. */
  114171. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114172. /**
  114173. * Add potential fallbacks if shader compilation fails
  114174. * @param mesh defines the mesh to be rendered
  114175. * @param fallbacks defines the current prioritized list of fallbacks
  114176. */
  114177. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114178. /**
  114179. * Update defines for shader compilation
  114180. * @param mesh defines the mesh to be rendered
  114181. * @param nodeMaterial defines the node material requesting the update
  114182. * @param defines defines the material defines to update
  114183. * @param useInstances specifies that instances should be used
  114184. */
  114185. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114186. /**
  114187. * Initialize defines for shader compilation
  114188. * @param mesh defines the mesh to be rendered
  114189. * @param nodeMaterial defines the node material requesting the update
  114190. * @param defines defines the material defines to be prepared
  114191. * @param useInstances specifies that instances should be used
  114192. */
  114193. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114194. /**
  114195. * Lets the block try to connect some inputs automatically
  114196. */
  114197. autoConfigure(): void;
  114198. /**
  114199. * Function called when a block is declared as repeatable content generator
  114200. * @param vertexShaderState defines the current compilation state for the vertex shader
  114201. * @param fragmentShaderState defines the current compilation state for the fragment shader
  114202. * @param mesh defines the mesh to be rendered
  114203. * @param defines defines the material defines to update
  114204. */
  114205. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114206. /**
  114207. * Checks if the block is ready
  114208. * @param mesh defines the mesh to be rendered
  114209. * @param nodeMaterial defines the node material requesting the update
  114210. * @param defines defines the material defines to update
  114211. * @param useInstances specifies that instances should be used
  114212. * @returns true if the block is ready
  114213. */
  114214. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  114215. private _processBuild;
  114216. /**
  114217. * Compile the current node and generate the shader code
  114218. * @param state defines the current compilation state (uniforms, samplers, current string)
  114219. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  114220. * @returns true if already built
  114221. */
  114222. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  114223. }
  114224. }
  114225. declare module BABYLON {
  114226. /**
  114227. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  114228. */
  114229. export enum NodeMaterialBlockConnectionPointMode {
  114230. /** Value is an uniform */
  114231. Uniform = 0,
  114232. /** Value is a mesh attribute */
  114233. Attribute = 1,
  114234. /** Value is a varying between vertex and fragment shaders */
  114235. Varying = 2,
  114236. /** Mode is undefined */
  114237. Undefined = 3
  114238. }
  114239. }
  114240. declare module BABYLON {
  114241. /**
  114242. * Enum used to define well known values e.g. values automatically provided by the system
  114243. */
  114244. export enum NodeMaterialWellKnownValues {
  114245. /** World */
  114246. World = 1,
  114247. /** View */
  114248. View = 2,
  114249. /** Projection */
  114250. Projection = 3,
  114251. /** ViewProjection */
  114252. ViewProjection = 4,
  114253. /** WorldView */
  114254. WorldView = 5,
  114255. /** WorldViewProjection */
  114256. WorldViewProjection = 6,
  114257. /** CameraPosition */
  114258. CameraPosition = 7,
  114259. /** Fog Color */
  114260. FogColor = 8
  114261. }
  114262. }
  114263. declare module BABYLON {
  114264. /**
  114265. * Block used to expose an input value
  114266. */
  114267. export class InputBlock extends NodeMaterialBlock {
  114268. private _mode;
  114269. private _associatedVariableName;
  114270. private _storedValue;
  114271. private _valueCallback;
  114272. private _type;
  114273. /** @hidden */
  114274. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114275. /**
  114276. * Gets or sets the connection point type (default is float)
  114277. */
  114278. readonly type: NodeMaterialBlockConnectionPointTypes;
  114279. /**
  114280. * Creates a new InputBlock
  114281. * @param name defines the block name
  114282. * @param target defines the target of that block (Vertex by default)
  114283. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  114284. */
  114285. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  114286. /**
  114287. * Gets the output component
  114288. */
  114289. readonly output: NodeMaterialConnectionPoint;
  114290. /**
  114291. * Set the source of this connection point to a vertex attribute
  114292. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  114293. * @returns the current connection point
  114294. */
  114295. setAsAttribute(attributeName?: string): InputBlock;
  114296. /**
  114297. * Set the source of this connection point to a well known value
  114298. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  114299. * @returns the current connection point
  114300. */
  114301. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  114302. /**
  114303. * Gets or sets the value of that point.
  114304. * Please note that this value will be ignored if valueCallback is defined
  114305. */
  114306. value: any;
  114307. /**
  114308. * Gets or sets a callback used to get the value of that point.
  114309. * Please note that setting this value will force the connection point to ignore the value property
  114310. */
  114311. valueCallback: () => any;
  114312. /**
  114313. * Gets or sets the associated variable name in the shader
  114314. */
  114315. associatedVariableName: string;
  114316. /**
  114317. * Gets a boolean indicating that this connection point not defined yet
  114318. */
  114319. readonly isUndefined: boolean;
  114320. /**
  114321. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  114322. * In this case the connection point name must be the name of the uniform to use.
  114323. * Can only be set on inputs
  114324. */
  114325. isUniform: boolean;
  114326. /**
  114327. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  114328. * In this case the connection point name must be the name of the attribute to use
  114329. * Can only be set on inputs
  114330. */
  114331. isAttribute: boolean;
  114332. /**
  114333. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  114334. * Can only be set on exit points
  114335. */
  114336. isVarying: boolean;
  114337. /**
  114338. * Gets a boolean indicating that the current connection point is a well known value
  114339. */
  114340. readonly isWellKnownValue: boolean;
  114341. /**
  114342. * Gets or sets the current well known value or null if not defined as well know value
  114343. */
  114344. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114345. /**
  114346. * Gets the current class name
  114347. * @returns the class name
  114348. */
  114349. getClassName(): string;
  114350. private _emitDefine;
  114351. /**
  114352. * Set the input block to its default value (based on its type)
  114353. */
  114354. setDefaultValue(): void;
  114355. private _emit;
  114356. /** @hidden */
  114357. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  114358. /** @hidden */
  114359. _transmit(effect: Effect, scene: Scene): void;
  114360. protected _buildBlock(state: NodeMaterialBuildState): void;
  114361. }
  114362. }
  114363. declare module BABYLON {
  114364. /**
  114365. * Defines a connection point for a block
  114366. */
  114367. export class NodeMaterialConnectionPoint {
  114368. /** @hidden */
  114369. _ownerBlock: NodeMaterialBlock;
  114370. /** @hidden */
  114371. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114372. private _endpoints;
  114373. private _associatedVariableName;
  114374. /** @hidden */
  114375. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  114376. private _type;
  114377. /** @hidden */
  114378. _enforceAssociatedVariableName: boolean;
  114379. /**
  114380. * Gets or sets the associated variable name in the shader
  114381. */
  114382. associatedVariableName: string;
  114383. /**
  114384. * Gets or sets the connection point type (default is float)
  114385. */
  114386. type: NodeMaterialBlockConnectionPointTypes;
  114387. /**
  114388. * Gets or sets the connection point name
  114389. */
  114390. name: string;
  114391. /**
  114392. * Gets or sets the swizzle to apply to this connection point when reading or writing
  114393. */
  114394. swizzle: string;
  114395. /**
  114396. * Gets or sets a boolean indicating that this connection point can be omitted
  114397. */
  114398. isOptional: boolean;
  114399. /**
  114400. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  114401. */
  114402. define: string;
  114403. /** Gets or sets the target of that connection point */
  114404. target: NodeMaterialBlockTargets;
  114405. /**
  114406. * Gets a boolean indicating that the current point is connected
  114407. */
  114408. readonly isConnected: boolean;
  114409. /**
  114410. * Gets a boolean indicating that the current point is connected to an input block
  114411. */
  114412. readonly isConnectedToInput: boolean;
  114413. /**
  114414. * Gets a the connected input block (if any)
  114415. */
  114416. readonly connectInputBlock: Nullable<InputBlock>;
  114417. /** Get the other side of the connection (if any) */
  114418. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114419. /** Get the block that owns this connection point */
  114420. readonly ownerBlock: NodeMaterialBlock;
  114421. /** Get the block connected on the other side of this connection (if any) */
  114422. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  114423. /** Get the block connected on the endpoints of this connection (if any) */
  114424. readonly connectedBlocks: Array<NodeMaterialBlock>;
  114425. /** Gets the list of connected endpoints */
  114426. readonly endpoints: NodeMaterialConnectionPoint[];
  114427. /**
  114428. * Creates a new connection point
  114429. * @param name defines the connection point name
  114430. * @param ownerBlock defines the block hosting this connection point
  114431. */
  114432. constructor(name: string, ownerBlock: NodeMaterialBlock);
  114433. /**
  114434. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  114435. * @returns the class name
  114436. */
  114437. getClassName(): string;
  114438. private _getTypeLength;
  114439. /**
  114440. * Gets an boolean indicating if the current point can be connected to another point
  114441. * @param connectionPoint defines the other connection point
  114442. * @returns true if the connection is possible
  114443. */
  114444. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  114445. /**
  114446. * Connect this point to another connection point
  114447. * @param connectionPoint defines the other connection point
  114448. * @returns the current connection point
  114449. */
  114450. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114451. /**
  114452. * Disconnect this point from one of his endpoint
  114453. * @param endpoint defines the other connection point
  114454. * @returns the current connection point
  114455. */
  114456. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114457. }
  114458. }
  114459. declare module BABYLON {
  114460. /**
  114461. * Block used to add support for vertex skinning (bones)
  114462. */
  114463. export class BonesBlock extends NodeMaterialBlock {
  114464. /**
  114465. * Creates a new BonesBlock
  114466. * @param name defines the block name
  114467. */
  114468. constructor(name: string);
  114469. /**
  114470. * Initialize the block and prepare the context for build
  114471. * @param state defines the state that will be used for the build
  114472. */
  114473. initialize(state: NodeMaterialBuildState): void;
  114474. /**
  114475. * Gets the current class name
  114476. * @returns the class name
  114477. */
  114478. getClassName(): string;
  114479. /**
  114480. * Gets the matrix indices input component
  114481. */
  114482. readonly matricesIndices: NodeMaterialConnectionPoint;
  114483. /**
  114484. * Gets the matrix weights input component
  114485. */
  114486. readonly matricesWeights: NodeMaterialConnectionPoint;
  114487. /**
  114488. * Gets the extra matrix indices input component
  114489. */
  114490. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  114491. /**
  114492. * Gets the extra matrix weights input component
  114493. */
  114494. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  114495. /**
  114496. * Gets the world input component
  114497. */
  114498. readonly world: NodeMaterialConnectionPoint;
  114499. /**
  114500. * Gets the output component
  114501. */
  114502. readonly output: NodeMaterialConnectionPoint;
  114503. autoConfigure(): void;
  114504. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114505. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114506. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114507. protected _buildBlock(state: NodeMaterialBuildState): this;
  114508. }
  114509. }
  114510. declare module BABYLON {
  114511. /**
  114512. * Block used to add support for instances
  114513. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114514. */
  114515. export class InstancesBlock extends NodeMaterialBlock {
  114516. /**
  114517. * Creates a new InstancesBlock
  114518. * @param name defines the block name
  114519. */
  114520. constructor(name: string);
  114521. /**
  114522. * Gets the current class name
  114523. * @returns the class name
  114524. */
  114525. getClassName(): string;
  114526. /**
  114527. * Gets the first world row input component
  114528. */
  114529. readonly world0: NodeMaterialConnectionPoint;
  114530. /**
  114531. * Gets the second world row input component
  114532. */
  114533. readonly world1: NodeMaterialConnectionPoint;
  114534. /**
  114535. * Gets the third world row input component
  114536. */
  114537. readonly world2: NodeMaterialConnectionPoint;
  114538. /**
  114539. * Gets the forth world row input component
  114540. */
  114541. readonly world3: NodeMaterialConnectionPoint;
  114542. /**
  114543. * Gets the world input component
  114544. */
  114545. readonly world: NodeMaterialConnectionPoint;
  114546. /**
  114547. * Gets the output component
  114548. */
  114549. readonly output: NodeMaterialConnectionPoint;
  114550. autoConfigure(): void;
  114551. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114552. protected _buildBlock(state: NodeMaterialBuildState): this;
  114553. }
  114554. }
  114555. declare module BABYLON {
  114556. /**
  114557. * Block used to add morph targets support to vertex shader
  114558. */
  114559. export class MorphTargetsBlock extends NodeMaterialBlock {
  114560. private _repeatableContentAnchor;
  114561. private _repeatebleContentGenerated;
  114562. /**
  114563. * Create a new MorphTargetsBlock
  114564. * @param name defines the block name
  114565. */
  114566. constructor(name: string);
  114567. /**
  114568. * Gets the current class name
  114569. * @returns the class name
  114570. */
  114571. getClassName(): string;
  114572. /**
  114573. * Gets the position input component
  114574. */
  114575. readonly position: NodeMaterialConnectionPoint;
  114576. /**
  114577. * Gets the normal input component
  114578. */
  114579. readonly normal: NodeMaterialConnectionPoint;
  114580. /**
  114581. * Gets the tangent input component
  114582. */
  114583. readonly tangent: NodeMaterialConnectionPoint;
  114584. /**
  114585. * Gets the tangent input component
  114586. */
  114587. readonly uv: NodeMaterialConnectionPoint;
  114588. /**
  114589. * Gets the position output component
  114590. */
  114591. readonly positionOutput: NodeMaterialConnectionPoint;
  114592. /**
  114593. * Gets the normal output component
  114594. */
  114595. readonly normalOutput: NodeMaterialConnectionPoint;
  114596. /**
  114597. * Gets the tangent output component
  114598. */
  114599. readonly tangentOutput: NodeMaterialConnectionPoint;
  114600. /**
  114601. * Gets the tangent output component
  114602. */
  114603. readonly uvOutput: NodeMaterialConnectionPoint;
  114604. initialize(state: NodeMaterialBuildState): void;
  114605. autoConfigure(): void;
  114606. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114607. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114608. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114609. protected _buildBlock(state: NodeMaterialBuildState): this;
  114610. }
  114611. }
  114612. declare module BABYLON {
  114613. /**
  114614. * Block used to add an alpha test in the fragment shader
  114615. */
  114616. export class AlphaTestBlock extends NodeMaterialBlock {
  114617. /**
  114618. * Gets or sets the alpha value where alpha testing happens
  114619. */
  114620. alphaCutOff: number;
  114621. /**
  114622. * Create a new AlphaTestBlock
  114623. * @param name defines the block name
  114624. */
  114625. constructor(name: string);
  114626. /**
  114627. * Gets the current class name
  114628. * @returns the class name
  114629. */
  114630. getClassName(): string;
  114631. /**
  114632. * Gets the color input component
  114633. */
  114634. readonly color: NodeMaterialConnectionPoint;
  114635. protected _buildBlock(state: NodeMaterialBuildState): this;
  114636. }
  114637. }
  114638. declare module BABYLON {
  114639. /**
  114640. * Block used to create a Color4 out of 4 inputs (one for each component)
  114641. */
  114642. export class RGBAMergerBlock extends NodeMaterialBlock {
  114643. /**
  114644. * Create a new RGBAMergerBlock
  114645. * @param name defines the block name
  114646. */
  114647. constructor(name: string);
  114648. /**
  114649. * Gets the current class name
  114650. * @returns the class name
  114651. */
  114652. getClassName(): string;
  114653. /**
  114654. * Gets the R input component
  114655. */
  114656. readonly r: NodeMaterialConnectionPoint;
  114657. /**
  114658. * Gets the G input component
  114659. */
  114660. readonly g: NodeMaterialConnectionPoint;
  114661. /**
  114662. * Gets the B input component
  114663. */
  114664. readonly b: NodeMaterialConnectionPoint;
  114665. /**
  114666. * Gets the RGB input component
  114667. */
  114668. readonly rgb: NodeMaterialConnectionPoint;
  114669. /**
  114670. * Gets the R input component
  114671. */
  114672. readonly a: NodeMaterialConnectionPoint;
  114673. /**
  114674. * Gets the output component
  114675. */
  114676. readonly output: NodeMaterialConnectionPoint;
  114677. protected _buildBlock(state: NodeMaterialBuildState): this;
  114678. }
  114679. }
  114680. declare module BABYLON {
  114681. /**
  114682. * Block used to create a Color3 out of 3 inputs (one for each component)
  114683. */
  114684. export class RGBMergerBlock extends NodeMaterialBlock {
  114685. /**
  114686. * Create a new RGBMergerBlock
  114687. * @param name defines the block name
  114688. */
  114689. constructor(name: string);
  114690. /**
  114691. * Gets the current class name
  114692. * @returns the class name
  114693. */
  114694. getClassName(): string;
  114695. /**
  114696. * Gets the R component input
  114697. */
  114698. readonly r: NodeMaterialConnectionPoint;
  114699. /**
  114700. * Gets the G component input
  114701. */
  114702. readonly g: NodeMaterialConnectionPoint;
  114703. /**
  114704. * Gets the B component input
  114705. */
  114706. readonly b: NodeMaterialConnectionPoint;
  114707. /**
  114708. * Gets the output component
  114709. */
  114710. readonly output: NodeMaterialConnectionPoint;
  114711. protected _buildBlock(state: NodeMaterialBuildState): this;
  114712. }
  114713. }
  114714. declare module BABYLON {
  114715. /**
  114716. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  114717. */
  114718. export class RGBASplitterBlock extends NodeMaterialBlock {
  114719. /**
  114720. * Create a new RGBASplitterBlock
  114721. * @param name defines the block name
  114722. */
  114723. constructor(name: string);
  114724. /**
  114725. * Gets the current class name
  114726. * @returns the class name
  114727. */
  114728. getClassName(): string;
  114729. /**
  114730. * Gets the input component
  114731. */
  114732. readonly input: NodeMaterialConnectionPoint;
  114733. protected _buildBlock(state: NodeMaterialBuildState): this;
  114734. }
  114735. }
  114736. declare module BABYLON {
  114737. /**
  114738. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  114739. */
  114740. export class RGBSplitterBlock extends NodeMaterialBlock {
  114741. /**
  114742. * Create a new RGBSplitterBlock
  114743. * @param name defines the block name
  114744. */
  114745. constructor(name: string);
  114746. /**
  114747. * Gets the current class name
  114748. * @returns the class name
  114749. */
  114750. getClassName(): string;
  114751. /**
  114752. * Gets the input component
  114753. */
  114754. readonly input: NodeMaterialConnectionPoint;
  114755. protected _buildBlock(state: NodeMaterialBuildState): this;
  114756. }
  114757. }
  114758. declare module BABYLON {
  114759. /**
  114760. * Block used to add image processing support to fragment shader
  114761. */
  114762. export class ImageProcessingBlock extends NodeMaterialBlock {
  114763. /**
  114764. * Create a new ImageProcessingBlock
  114765. * @param name defines the block name
  114766. */
  114767. constructor(name: string);
  114768. /**
  114769. * Gets the current class name
  114770. * @returns the class name
  114771. */
  114772. getClassName(): string;
  114773. /**
  114774. * Gets the color input component
  114775. */
  114776. readonly color: NodeMaterialConnectionPoint;
  114777. /**
  114778. * Gets the output component
  114779. */
  114780. readonly output: NodeMaterialConnectionPoint;
  114781. /**
  114782. * Initialize the block and prepare the context for build
  114783. * @param state defines the state that will be used for the build
  114784. */
  114785. initialize(state: NodeMaterialBuildState): void;
  114786. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  114787. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114788. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114789. protected _buildBlock(state: NodeMaterialBuildState): this;
  114790. }
  114791. }
  114792. declare module BABYLON {
  114793. /**
  114794. * Block used to add support for scene fog
  114795. */
  114796. export class FogBlock extends NodeMaterialBlock {
  114797. private _fogDistanceName;
  114798. private _fogParameters;
  114799. /**
  114800. * Create a new FogBlock
  114801. * @param name defines the block name
  114802. */
  114803. constructor(name: string);
  114804. /**
  114805. * Gets the current class name
  114806. * @returns the class name
  114807. */
  114808. getClassName(): string;
  114809. /**
  114810. * Gets the world position input component
  114811. */
  114812. readonly worldPosition: NodeMaterialConnectionPoint;
  114813. /**
  114814. * Gets the view input component
  114815. */
  114816. readonly view: NodeMaterialConnectionPoint;
  114817. /**
  114818. * Gets the color input component
  114819. */
  114820. readonly color: NodeMaterialConnectionPoint;
  114821. /**
  114822. * Gets the fog color input component
  114823. */
  114824. readonly fogColor: NodeMaterialConnectionPoint;
  114825. /**
  114826. * Gets the output component
  114827. */
  114828. readonly output: NodeMaterialConnectionPoint;
  114829. autoConfigure(): void;
  114830. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114831. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114832. protected _buildBlock(state: NodeMaterialBuildState): this;
  114833. }
  114834. }
  114835. declare module BABYLON {
  114836. /**
  114837. * Block used to add light in the fragment shader
  114838. */
  114839. export class LightBlock extends NodeMaterialBlock {
  114840. private _lightId;
  114841. /**
  114842. * Gets or sets the light associated with this block
  114843. */
  114844. light: Nullable<Light>;
  114845. /**
  114846. * Create a new LightBlock
  114847. * @param name defines the block name
  114848. */
  114849. constructor(name: string);
  114850. /**
  114851. * Gets the current class name
  114852. * @returns the class name
  114853. */
  114854. getClassName(): string;
  114855. /**
  114856. * Gets the world position input component
  114857. */
  114858. readonly worldPosition: NodeMaterialConnectionPoint;
  114859. /**
  114860. * Gets the world normal input component
  114861. */
  114862. readonly worldNormal: NodeMaterialConnectionPoint;
  114863. /**
  114864. * Gets the camera (or eye) position component
  114865. */
  114866. readonly cameraPosition: NodeMaterialConnectionPoint;
  114867. /**
  114868. * Gets the diffuse output component
  114869. */
  114870. readonly diffuseOutput: NodeMaterialConnectionPoint;
  114871. /**
  114872. * Gets the specular output component
  114873. */
  114874. readonly specularOutput: NodeMaterialConnectionPoint;
  114875. autoConfigure(): void;
  114876. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114877. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114878. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114879. private _injectVertexCode;
  114880. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  114881. }
  114882. }
  114883. declare module BABYLON {
  114884. /**
  114885. * Block used to multiply 2 values
  114886. */
  114887. export class MultiplyBlock extends NodeMaterialBlock {
  114888. /**
  114889. * Creates a new MultiplyBlock
  114890. * @param name defines the block name
  114891. */
  114892. constructor(name: string);
  114893. /**
  114894. * Gets the current class name
  114895. * @returns the class name
  114896. */
  114897. getClassName(): string;
  114898. /**
  114899. * Gets the left operand input component
  114900. */
  114901. readonly left: NodeMaterialConnectionPoint;
  114902. /**
  114903. * Gets the right operand input component
  114904. */
  114905. readonly right: NodeMaterialConnectionPoint;
  114906. /**
  114907. * Gets the output component
  114908. */
  114909. readonly output: NodeMaterialConnectionPoint;
  114910. protected _buildBlock(state: NodeMaterialBuildState): this;
  114911. }
  114912. }
  114913. declare module BABYLON {
  114914. /**
  114915. * Block used to add 2 vector4
  114916. */
  114917. export class AddBlock extends NodeMaterialBlock {
  114918. /**
  114919. * Creates a new AddBlock
  114920. * @param name defines the block name
  114921. */
  114922. constructor(name: string);
  114923. /**
  114924. * Gets the current class name
  114925. * @returns the class name
  114926. */
  114927. getClassName(): string;
  114928. /**
  114929. * Gets the left operand input component
  114930. */
  114931. readonly left: NodeMaterialConnectionPoint;
  114932. /**
  114933. * Gets the right operand input component
  114934. */
  114935. readonly right: NodeMaterialConnectionPoint;
  114936. /**
  114937. * Gets the output component
  114938. */
  114939. readonly output: NodeMaterialConnectionPoint;
  114940. protected _buildBlock(state: NodeMaterialBuildState): this;
  114941. }
  114942. }
  114943. declare module BABYLON {
  114944. /**
  114945. * Block used to clamp a float
  114946. */
  114947. export class ClampBlock extends NodeMaterialBlock {
  114948. /** Gets or sets the minimum range */
  114949. minimum: number;
  114950. /** Gets or sets the maximum range */
  114951. maximum: number;
  114952. /**
  114953. * Creates a new ClampBlock
  114954. * @param name defines the block name
  114955. */
  114956. constructor(name: string);
  114957. /**
  114958. * Gets the current class name
  114959. * @returns the class name
  114960. */
  114961. getClassName(): string;
  114962. /**
  114963. * Gets the value input component
  114964. */
  114965. readonly value: NodeMaterialConnectionPoint;
  114966. /**
  114967. * Gets the output component
  114968. */
  114969. readonly output: NodeMaterialConnectionPoint;
  114970. protected _buildBlock(state: NodeMaterialBuildState): this;
  114971. }
  114972. }
  114973. declare module BABYLON {
  114974. /**
  114975. * Block used to transform a vector2 with a matrix
  114976. */
  114977. export class Vector2TransformBlock extends NodeMaterialBlock {
  114978. /**
  114979. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114980. */
  114981. complementZ: number;
  114982. /**
  114983. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114984. */
  114985. complementW: number;
  114986. /**
  114987. * Creates a new Vector2TransformBlock
  114988. * @param name defines the block name
  114989. */
  114990. constructor(name: string);
  114991. /**
  114992. * Gets the vector input
  114993. */
  114994. readonly vector: NodeMaterialConnectionPoint;
  114995. /**
  114996. * Gets the matrix transform input
  114997. */
  114998. readonly transform: NodeMaterialConnectionPoint;
  114999. /**
  115000. * Gets the output component
  115001. */
  115002. readonly output: NodeMaterialConnectionPoint;
  115003. /**
  115004. * Gets the current class name
  115005. * @returns the class name
  115006. */
  115007. getClassName(): string;
  115008. protected _buildBlock(state: NodeMaterialBuildState): this;
  115009. }
  115010. }
  115011. declare module BABYLON {
  115012. /**
  115013. * Block used to transform a vector3 with a matrix
  115014. */
  115015. export class Vector3TransformBlock extends NodeMaterialBlock {
  115016. /**
  115017. * Defines the value to use to complement Vector3 to transform it to a Vector4
  115018. */
  115019. complement: number;
  115020. /**
  115021. * Creates a new Vector3TransformBlock
  115022. * @param name defines the block name
  115023. */
  115024. constructor(name: string);
  115025. /**
  115026. * Gets the vector input
  115027. */
  115028. readonly vector: NodeMaterialConnectionPoint;
  115029. /**
  115030. * Gets the matrix transform input
  115031. */
  115032. readonly transform: NodeMaterialConnectionPoint;
  115033. /**
  115034. * Gets the output component
  115035. */
  115036. readonly output: NodeMaterialConnectionPoint;
  115037. /**
  115038. * Gets the current class name
  115039. * @returns the class name
  115040. */
  115041. getClassName(): string;
  115042. protected _buildBlock(state: NodeMaterialBuildState): this;
  115043. }
  115044. }
  115045. declare module BABYLON {
  115046. /**
  115047. * Helper class to render one or more effects
  115048. */
  115049. export class EffectRenderer {
  115050. private engine;
  115051. private static _Vertices;
  115052. private static _Indices;
  115053. private _vertexBuffers;
  115054. private _indexBuffer;
  115055. private _ringBufferIndex;
  115056. private _ringScreenBuffer;
  115057. private _getNextFrameBuffer;
  115058. /**
  115059. * Creates an effect renderer
  115060. * @param engine the engine to use for rendering
  115061. */
  115062. constructor(engine: Engine);
  115063. /**
  115064. * renders one or more effects to a specified texture
  115065. * @param effectWrappers list of effects to renderer
  115066. * @param outputTexture texture to draw to, if null it will render to the screen
  115067. */
  115068. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  115069. /**
  115070. * Disposes of the effect renderer
  115071. */
  115072. dispose(): void;
  115073. }
  115074. /**
  115075. * Options to create an EffectWrapper
  115076. */
  115077. interface EffectWrapperCreationOptions {
  115078. /**
  115079. * Engine to use to create the effect
  115080. */
  115081. engine: Engine;
  115082. /**
  115083. * Fragment shader for the effect
  115084. */
  115085. fragmentShader: string;
  115086. /**
  115087. * Attributes to use in the shader
  115088. */
  115089. attributeNames: Array<string>;
  115090. /**
  115091. * Uniforms to use in the shader
  115092. */
  115093. uniformNames: Array<string>;
  115094. /**
  115095. * Texture sampler names to use in the shader
  115096. */
  115097. samplerNames: Array<string>;
  115098. }
  115099. /**
  115100. * Wraps an effect to be used for rendering
  115101. */
  115102. export class EffectWrapper {
  115103. /**
  115104. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  115105. */
  115106. onApplyObservable: Observable<{}>;
  115107. /**
  115108. * The underlying effect
  115109. */
  115110. effect: Effect;
  115111. /**
  115112. * Creates an effect to be renderer
  115113. * @param creationOptions options to create the effect
  115114. */
  115115. constructor(creationOptions: EffectWrapperCreationOptions);
  115116. /**
  115117. * Disposes of the effect wrapper
  115118. */
  115119. dispose(): void;
  115120. }
  115121. }
  115122. declare module BABYLON {
  115123. /**
  115124. * Helper class to push actions to a pool of workers.
  115125. */
  115126. export class WorkerPool implements IDisposable {
  115127. private _workerInfos;
  115128. private _pendingActions;
  115129. /**
  115130. * Constructor
  115131. * @param workers Array of workers to use for actions
  115132. */
  115133. constructor(workers: Array<Worker>);
  115134. /**
  115135. * Terminates all workers and clears any pending actions.
  115136. */
  115137. dispose(): void;
  115138. /**
  115139. * Pushes an action to the worker pool. If all the workers are active, the action will be
  115140. * pended until a worker has completed its action.
  115141. * @param action The action to perform. Call onComplete when the action is complete.
  115142. */
  115143. push(action: (worker: Worker, onComplete: () => void) => void): void;
  115144. private _execute;
  115145. }
  115146. }
  115147. declare module BABYLON {
  115148. /**
  115149. * Configuration for Draco compression
  115150. */
  115151. export interface IDracoCompressionConfiguration {
  115152. /**
  115153. * Configuration for the decoder.
  115154. */
  115155. decoder: {
  115156. /**
  115157. * The url to the WebAssembly module.
  115158. */
  115159. wasmUrl?: string;
  115160. /**
  115161. * The url to the WebAssembly binary.
  115162. */
  115163. wasmBinaryUrl?: string;
  115164. /**
  115165. * The url to the fallback JavaScript module.
  115166. */
  115167. fallbackUrl?: string;
  115168. };
  115169. }
  115170. /**
  115171. * Draco compression (https://google.github.io/draco/)
  115172. *
  115173. * This class wraps the Draco module.
  115174. *
  115175. * **Encoder**
  115176. *
  115177. * The encoder is not currently implemented.
  115178. *
  115179. * **Decoder**
  115180. *
  115181. * 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.
  115182. *
  115183. * To update the configuration, use the following code:
  115184. * ```javascript
  115185. * DracoCompression.Configuration = {
  115186. * decoder: {
  115187. * wasmUrl: "<url to the WebAssembly library>",
  115188. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  115189. * fallbackUrl: "<url to the fallback JavaScript library>",
  115190. * }
  115191. * };
  115192. * ```
  115193. *
  115194. * 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.
  115195. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  115196. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  115197. *
  115198. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  115199. * ```javascript
  115200. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  115201. * ```
  115202. *
  115203. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  115204. */
  115205. export class DracoCompression implements IDisposable {
  115206. private _workerPoolPromise?;
  115207. private _decoderModulePromise?;
  115208. /**
  115209. * The configuration. Defaults to the following urls:
  115210. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  115211. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  115212. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  115213. */
  115214. static Configuration: IDracoCompressionConfiguration;
  115215. /**
  115216. * Returns true if the decoder configuration is available.
  115217. */
  115218. static readonly DecoderAvailable: boolean;
  115219. /**
  115220. * Default number of workers to create when creating the draco compression object.
  115221. */
  115222. static DefaultNumWorkers: number;
  115223. private static GetDefaultNumWorkers;
  115224. private static _Default;
  115225. /**
  115226. * Default instance for the draco compression object.
  115227. */
  115228. static readonly Default: DracoCompression;
  115229. /**
  115230. * Constructor
  115231. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  115232. */
  115233. constructor(numWorkers?: number);
  115234. /**
  115235. * Stop all async operations and release resources.
  115236. */
  115237. dispose(): void;
  115238. /**
  115239. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  115240. * @returns a promise that resolves when ready
  115241. */
  115242. whenReadyAsync(): Promise<void>;
  115243. /**
  115244. * Decode Draco compressed mesh data to vertex data.
  115245. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  115246. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  115247. * @returns A promise that resolves with the decoded vertex data
  115248. */
  115249. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  115250. [kind: string]: number;
  115251. }): Promise<VertexData>;
  115252. }
  115253. }
  115254. declare module BABYLON {
  115255. /**
  115256. * Class for building Constructive Solid Geometry
  115257. */
  115258. export class CSG {
  115259. private polygons;
  115260. /**
  115261. * The world matrix
  115262. */
  115263. matrix: Matrix;
  115264. /**
  115265. * Stores the position
  115266. */
  115267. position: Vector3;
  115268. /**
  115269. * Stores the rotation
  115270. */
  115271. rotation: Vector3;
  115272. /**
  115273. * Stores the rotation quaternion
  115274. */
  115275. rotationQuaternion: Nullable<Quaternion>;
  115276. /**
  115277. * Stores the scaling vector
  115278. */
  115279. scaling: Vector3;
  115280. /**
  115281. * Convert the Mesh to CSG
  115282. * @param mesh The Mesh to convert to CSG
  115283. * @returns A new CSG from the Mesh
  115284. */
  115285. static FromMesh(mesh: Mesh): CSG;
  115286. /**
  115287. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  115288. * @param polygons Polygons used to construct a CSG solid
  115289. */
  115290. private static FromPolygons;
  115291. /**
  115292. * Clones, or makes a deep copy, of the CSG
  115293. * @returns A new CSG
  115294. */
  115295. clone(): CSG;
  115296. /**
  115297. * Unions this CSG with another CSG
  115298. * @param csg The CSG to union against this CSG
  115299. * @returns The unioned CSG
  115300. */
  115301. union(csg: CSG): CSG;
  115302. /**
  115303. * Unions this CSG with another CSG in place
  115304. * @param csg The CSG to union against this CSG
  115305. */
  115306. unionInPlace(csg: CSG): void;
  115307. /**
  115308. * Subtracts this CSG with another CSG
  115309. * @param csg The CSG to subtract against this CSG
  115310. * @returns A new CSG
  115311. */
  115312. subtract(csg: CSG): CSG;
  115313. /**
  115314. * Subtracts this CSG with another CSG in place
  115315. * @param csg The CSG to subtact against this CSG
  115316. */
  115317. subtractInPlace(csg: CSG): void;
  115318. /**
  115319. * Intersect this CSG with another CSG
  115320. * @param csg The CSG to intersect against this CSG
  115321. * @returns A new CSG
  115322. */
  115323. intersect(csg: CSG): CSG;
  115324. /**
  115325. * Intersects this CSG with another CSG in place
  115326. * @param csg The CSG to intersect against this CSG
  115327. */
  115328. intersectInPlace(csg: CSG): void;
  115329. /**
  115330. * Return a new CSG solid with solid and empty space switched. This solid is
  115331. * not modified.
  115332. * @returns A new CSG solid with solid and empty space switched
  115333. */
  115334. inverse(): CSG;
  115335. /**
  115336. * Inverses the CSG in place
  115337. */
  115338. inverseInPlace(): void;
  115339. /**
  115340. * This is used to keep meshes transformations so they can be restored
  115341. * when we build back a Babylon Mesh
  115342. * NB : All CSG operations are performed in world coordinates
  115343. * @param csg The CSG to copy the transform attributes from
  115344. * @returns This CSG
  115345. */
  115346. copyTransformAttributes(csg: CSG): CSG;
  115347. /**
  115348. * Build Raw mesh from CSG
  115349. * Coordinates here are in world space
  115350. * @param name The name of the mesh geometry
  115351. * @param scene The Scene
  115352. * @param keepSubMeshes Specifies if the submeshes should be kept
  115353. * @returns A new Mesh
  115354. */
  115355. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  115356. /**
  115357. * Build Mesh from CSG taking material and transforms into account
  115358. * @param name The name of the Mesh
  115359. * @param material The material of the Mesh
  115360. * @param scene The Scene
  115361. * @param keepSubMeshes Specifies if submeshes should be kept
  115362. * @returns The new Mesh
  115363. */
  115364. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  115365. }
  115366. }
  115367. declare module BABYLON {
  115368. /**
  115369. * Class used to create a trail following a mesh
  115370. */
  115371. export class TrailMesh extends Mesh {
  115372. private _generator;
  115373. private _autoStart;
  115374. private _running;
  115375. private _diameter;
  115376. private _length;
  115377. private _sectionPolygonPointsCount;
  115378. private _sectionVectors;
  115379. private _sectionNormalVectors;
  115380. private _beforeRenderObserver;
  115381. /**
  115382. * @constructor
  115383. * @param name The value used by scene.getMeshByName() to do a lookup.
  115384. * @param generator The mesh to generate a trail.
  115385. * @param scene The scene to add this mesh to.
  115386. * @param diameter Diameter of trailing mesh. Default is 1.
  115387. * @param length Length of trailing mesh. Default is 60.
  115388. * @param autoStart Automatically start trailing mesh. Default true.
  115389. */
  115390. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  115391. /**
  115392. * "TrailMesh"
  115393. * @returns "TrailMesh"
  115394. */
  115395. getClassName(): string;
  115396. private _createMesh;
  115397. /**
  115398. * Start trailing mesh.
  115399. */
  115400. start(): void;
  115401. /**
  115402. * Stop trailing mesh.
  115403. */
  115404. stop(): void;
  115405. /**
  115406. * Update trailing mesh geometry.
  115407. */
  115408. update(): void;
  115409. /**
  115410. * Returns a new TrailMesh object.
  115411. * @param name is a string, the name given to the new mesh
  115412. * @param newGenerator use new generator object for cloned trail mesh
  115413. * @returns a new mesh
  115414. */
  115415. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  115416. /**
  115417. * Serializes this trail mesh
  115418. * @param serializationObject object to write serialization to
  115419. */
  115420. serialize(serializationObject: any): void;
  115421. /**
  115422. * Parses a serialized trail mesh
  115423. * @param parsedMesh the serialized mesh
  115424. * @param scene the scene to create the trail mesh in
  115425. * @returns the created trail mesh
  115426. */
  115427. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  115428. }
  115429. }
  115430. declare module BABYLON {
  115431. /**
  115432. * Class containing static functions to help procedurally build meshes
  115433. */
  115434. export class TiledBoxBuilder {
  115435. /**
  115436. * Creates a box mesh
  115437. * 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)
  115438. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115442. * @param name defines the name of the mesh
  115443. * @param options defines the options used to create the mesh
  115444. * @param scene defines the hosting scene
  115445. * @returns the box mesh
  115446. */
  115447. static CreateTiledBox(name: string, options: {
  115448. pattern?: number;
  115449. width?: number;
  115450. height?: number;
  115451. depth?: number;
  115452. tileSize?: number;
  115453. tileWidth?: number;
  115454. tileHeight?: number;
  115455. alignHorizontal?: number;
  115456. alignVertical?: number;
  115457. faceUV?: Vector4[];
  115458. faceColors?: Color4[];
  115459. sideOrientation?: number;
  115460. updatable?: boolean;
  115461. }, scene?: Nullable<Scene>): Mesh;
  115462. }
  115463. }
  115464. declare module BABYLON {
  115465. /**
  115466. * Class containing static functions to help procedurally build meshes
  115467. */
  115468. export class TorusKnotBuilder {
  115469. /**
  115470. * Creates a torus knot mesh
  115471. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115472. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115473. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115474. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115476. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115478. * @param name defines the name of the mesh
  115479. * @param options defines the options used to create the mesh
  115480. * @param scene defines the hosting scene
  115481. * @returns the torus knot mesh
  115482. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115483. */
  115484. static CreateTorusKnot(name: string, options: {
  115485. radius?: number;
  115486. tube?: number;
  115487. radialSegments?: number;
  115488. tubularSegments?: number;
  115489. p?: number;
  115490. q?: number;
  115491. updatable?: boolean;
  115492. sideOrientation?: number;
  115493. frontUVs?: Vector4;
  115494. backUVs?: Vector4;
  115495. }, scene: any): Mesh;
  115496. }
  115497. }
  115498. declare module BABYLON {
  115499. /**
  115500. * Polygon
  115501. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  115502. */
  115503. export class Polygon {
  115504. /**
  115505. * Creates a rectangle
  115506. * @param xmin bottom X coord
  115507. * @param ymin bottom Y coord
  115508. * @param xmax top X coord
  115509. * @param ymax top Y coord
  115510. * @returns points that make the resulting rectation
  115511. */
  115512. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  115513. /**
  115514. * Creates a circle
  115515. * @param radius radius of circle
  115516. * @param cx scale in x
  115517. * @param cy scale in y
  115518. * @param numberOfSides number of sides that make up the circle
  115519. * @returns points that make the resulting circle
  115520. */
  115521. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  115522. /**
  115523. * Creates a polygon from input string
  115524. * @param input Input polygon data
  115525. * @returns the parsed points
  115526. */
  115527. static Parse(input: string): Vector2[];
  115528. /**
  115529. * Starts building a polygon from x and y coordinates
  115530. * @param x x coordinate
  115531. * @param y y coordinate
  115532. * @returns the started path2
  115533. */
  115534. static StartingAt(x: number, y: number): Path2;
  115535. }
  115536. /**
  115537. * Builds a polygon
  115538. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  115539. */
  115540. export class PolygonMeshBuilder {
  115541. private _points;
  115542. private _outlinepoints;
  115543. private _holes;
  115544. private _name;
  115545. private _scene;
  115546. private _epoints;
  115547. private _eholes;
  115548. private _addToepoint;
  115549. /**
  115550. * Babylon reference to the earcut plugin.
  115551. */
  115552. bjsEarcut: any;
  115553. /**
  115554. * Creates a PolygonMeshBuilder
  115555. * @param name name of the builder
  115556. * @param contours Path of the polygon
  115557. * @param scene scene to add to when creating the mesh
  115558. * @param earcutInjection can be used to inject your own earcut reference
  115559. */
  115560. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  115561. /**
  115562. * Adds a whole within the polygon
  115563. * @param hole Array of points defining the hole
  115564. * @returns this
  115565. */
  115566. addHole(hole: Vector2[]): PolygonMeshBuilder;
  115567. /**
  115568. * Creates the polygon
  115569. * @param updatable If the mesh should be updatable
  115570. * @param depth The depth of the mesh created
  115571. * @returns the created mesh
  115572. */
  115573. build(updatable?: boolean, depth?: number): Mesh;
  115574. /**
  115575. * Creates the polygon
  115576. * @param depth The depth of the mesh created
  115577. * @returns the created VertexData
  115578. */
  115579. buildVertexData(depth?: number): VertexData;
  115580. /**
  115581. * Adds a side to the polygon
  115582. * @param positions points that make the polygon
  115583. * @param normals normals of the polygon
  115584. * @param uvs uvs of the polygon
  115585. * @param indices indices of the polygon
  115586. * @param bounds bounds of the polygon
  115587. * @param points points of the polygon
  115588. * @param depth depth of the polygon
  115589. * @param flip flip of the polygon
  115590. */
  115591. private addSide;
  115592. }
  115593. }
  115594. declare module BABYLON {
  115595. /**
  115596. * Class containing static functions to help procedurally build meshes
  115597. */
  115598. export class PolygonBuilder {
  115599. /**
  115600. * Creates a polygon mesh
  115601. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115602. * * 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
  115603. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115606. * * Remember you can only change the shape positions, not their number when updating a polygon
  115607. * @param name defines the name of the mesh
  115608. * @param options defines the options used to create the mesh
  115609. * @param scene defines the hosting scene
  115610. * @param earcutInjection can be used to inject your own earcut reference
  115611. * @returns the polygon mesh
  115612. */
  115613. static CreatePolygon(name: string, options: {
  115614. shape: Vector3[];
  115615. holes?: Vector3[][];
  115616. depth?: number;
  115617. faceUV?: Vector4[];
  115618. faceColors?: Color4[];
  115619. updatable?: boolean;
  115620. sideOrientation?: number;
  115621. frontUVs?: Vector4;
  115622. backUVs?: Vector4;
  115623. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115624. /**
  115625. * Creates an extruded polygon mesh, with depth in the Y direction.
  115626. * * 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)
  115627. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115628. * @param name defines the name of the mesh
  115629. * @param options defines the options used to create the mesh
  115630. * @param scene defines the hosting scene
  115631. * @param earcutInjection can be used to inject your own earcut reference
  115632. * @returns the polygon mesh
  115633. */
  115634. static ExtrudePolygon(name: string, options: {
  115635. shape: Vector3[];
  115636. holes?: Vector3[][];
  115637. depth?: number;
  115638. faceUV?: Vector4[];
  115639. faceColors?: Color4[];
  115640. updatable?: boolean;
  115641. sideOrientation?: number;
  115642. frontUVs?: Vector4;
  115643. backUVs?: Vector4;
  115644. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115645. }
  115646. }
  115647. declare module BABYLON {
  115648. /**
  115649. * Class containing static functions to help procedurally build meshes
  115650. */
  115651. export class LatheBuilder {
  115652. /**
  115653. * Creates lathe mesh.
  115654. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115655. * * 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
  115656. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115657. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115658. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115659. * * 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
  115660. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115661. * * 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
  115662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115663. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115664. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115666. * @param name defines the name of the mesh
  115667. * @param options defines the options used to create the mesh
  115668. * @param scene defines the hosting scene
  115669. * @returns the lathe mesh
  115670. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115671. */
  115672. static CreateLathe(name: string, options: {
  115673. shape: Vector3[];
  115674. radius?: number;
  115675. tessellation?: number;
  115676. clip?: number;
  115677. arc?: number;
  115678. closed?: boolean;
  115679. updatable?: boolean;
  115680. sideOrientation?: number;
  115681. frontUVs?: Vector4;
  115682. backUVs?: Vector4;
  115683. cap?: number;
  115684. invertUV?: boolean;
  115685. }, scene?: Nullable<Scene>): Mesh;
  115686. }
  115687. }
  115688. declare module BABYLON {
  115689. /**
  115690. * Class containing static functions to help procedurally build meshes
  115691. */
  115692. export class TiledPlaneBuilder {
  115693. /**
  115694. * Creates a tiled plane mesh
  115695. * * The parameter `pattern` will, depending on value, do nothing or
  115696. * * * flip (reflect about central vertical) alternate tiles across and up
  115697. * * * flip every tile on alternate rows
  115698. * * * rotate (180 degs) alternate tiles across and up
  115699. * * * rotate every tile on alternate rows
  115700. * * * flip and rotate alternate tiles across and up
  115701. * * * flip and rotate every tile on alternate rows
  115702. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  115703. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  115704. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115705. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115706. * * 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)
  115707. * * 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)
  115708. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115709. * @param name defines the name of the mesh
  115710. * @param options defines the options used to create the mesh
  115711. * @param scene defines the hosting scene
  115712. * @returns the box mesh
  115713. */
  115714. static CreateTiledPlane(name: string, options: {
  115715. pattern?: number;
  115716. tileSize?: number;
  115717. tileWidth?: number;
  115718. tileHeight?: number;
  115719. size?: number;
  115720. width?: number;
  115721. height?: number;
  115722. alignHorizontal?: number;
  115723. alignVertical?: number;
  115724. sideOrientation?: number;
  115725. frontUVs?: Vector4;
  115726. backUVs?: Vector4;
  115727. updatable?: boolean;
  115728. }, scene?: Nullable<Scene>): Mesh;
  115729. }
  115730. }
  115731. declare module BABYLON {
  115732. /**
  115733. * Class containing static functions to help procedurally build meshes
  115734. */
  115735. export class TubeBuilder {
  115736. /**
  115737. * Creates a tube mesh.
  115738. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115739. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115740. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115741. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115742. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115743. * * 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)
  115744. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115745. * * 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
  115746. * * 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
  115747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115748. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115749. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115751. * @param name defines the name of the mesh
  115752. * @param options defines the options used to create the mesh
  115753. * @param scene defines the hosting scene
  115754. * @returns the tube mesh
  115755. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115756. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115757. */
  115758. static CreateTube(name: string, options: {
  115759. path: Vector3[];
  115760. radius?: number;
  115761. tessellation?: number;
  115762. radiusFunction?: {
  115763. (i: number, distance: number): number;
  115764. };
  115765. cap?: number;
  115766. arc?: number;
  115767. updatable?: boolean;
  115768. sideOrientation?: number;
  115769. frontUVs?: Vector4;
  115770. backUVs?: Vector4;
  115771. instance?: Mesh;
  115772. invertUV?: boolean;
  115773. }, scene?: Nullable<Scene>): Mesh;
  115774. }
  115775. }
  115776. declare module BABYLON {
  115777. /**
  115778. * Class containing static functions to help procedurally build meshes
  115779. */
  115780. export class IcoSphereBuilder {
  115781. /**
  115782. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115783. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115784. * * 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`)
  115785. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115786. * * 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
  115787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115790. * @param name defines the name of the mesh
  115791. * @param options defines the options used to create the mesh
  115792. * @param scene defines the hosting scene
  115793. * @returns the icosahedron mesh
  115794. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115795. */
  115796. static CreateIcoSphere(name: string, options: {
  115797. radius?: number;
  115798. radiusX?: number;
  115799. radiusY?: number;
  115800. radiusZ?: number;
  115801. flat?: boolean;
  115802. subdivisions?: number;
  115803. sideOrientation?: number;
  115804. frontUVs?: Vector4;
  115805. backUVs?: Vector4;
  115806. updatable?: boolean;
  115807. }, scene?: Nullable<Scene>): Mesh;
  115808. }
  115809. }
  115810. declare module BABYLON {
  115811. /**
  115812. * Class containing static functions to help procedurally build meshes
  115813. */
  115814. export class DecalBuilder {
  115815. /**
  115816. * Creates a decal mesh.
  115817. * 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
  115818. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115819. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115820. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115821. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115822. * @param name defines the name of the mesh
  115823. * @param sourceMesh defines the mesh where the decal must be applied
  115824. * @param options defines the options used to create the mesh
  115825. * @param scene defines the hosting scene
  115826. * @returns the decal mesh
  115827. * @see https://doc.babylonjs.com/how_to/decals
  115828. */
  115829. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115830. position?: Vector3;
  115831. normal?: Vector3;
  115832. size?: Vector3;
  115833. angle?: number;
  115834. }): Mesh;
  115835. }
  115836. }
  115837. declare module BABYLON {
  115838. /**
  115839. * Class containing static functions to help procedurally build meshes
  115840. */
  115841. export class MeshBuilder {
  115842. /**
  115843. * Creates a box mesh
  115844. * * The parameter `size` sets the size (float) of each box side (default 1)
  115845. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  115846. * * 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)
  115847. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115849. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115851. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115852. * @param name defines the name of the mesh
  115853. * @param options defines the options used to create the mesh
  115854. * @param scene defines the hosting scene
  115855. * @returns the box mesh
  115856. */
  115857. static CreateBox(name: string, options: {
  115858. size?: number;
  115859. width?: number;
  115860. height?: number;
  115861. depth?: number;
  115862. faceUV?: Vector4[];
  115863. faceColors?: Color4[];
  115864. sideOrientation?: number;
  115865. frontUVs?: Vector4;
  115866. backUVs?: Vector4;
  115867. updatable?: boolean;
  115868. }, scene?: Nullable<Scene>): Mesh;
  115869. /**
  115870. * Creates a tiled box mesh
  115871. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115873. * @param name defines the name of the mesh
  115874. * @param options defines the options used to create the mesh
  115875. * @param scene defines the hosting scene
  115876. * @returns the tiled box mesh
  115877. */
  115878. static CreateTiledBox(name: string, options: {
  115879. pattern?: number;
  115880. size?: number;
  115881. width?: number;
  115882. height?: number;
  115883. depth: number;
  115884. tileSize?: number;
  115885. tileWidth?: number;
  115886. tileHeight?: number;
  115887. faceUV?: Vector4[];
  115888. faceColors?: Color4[];
  115889. alignHorizontal?: number;
  115890. alignVertical?: number;
  115891. sideOrientation?: number;
  115892. updatable?: boolean;
  115893. }, scene?: Nullable<Scene>): Mesh;
  115894. /**
  115895. * Creates a sphere mesh
  115896. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  115897. * * 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`)
  115898. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  115899. * * 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
  115900. * * 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)
  115901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115904. * @param name defines the name of the mesh
  115905. * @param options defines the options used to create the mesh
  115906. * @param scene defines the hosting scene
  115907. * @returns the sphere mesh
  115908. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  115909. */
  115910. static CreateSphere(name: string, options: {
  115911. segments?: number;
  115912. diameter?: number;
  115913. diameterX?: number;
  115914. diameterY?: number;
  115915. diameterZ?: number;
  115916. arc?: number;
  115917. slice?: number;
  115918. sideOrientation?: number;
  115919. frontUVs?: Vector4;
  115920. backUVs?: Vector4;
  115921. updatable?: boolean;
  115922. }, scene?: Nullable<Scene>): Mesh;
  115923. /**
  115924. * Creates a plane polygonal mesh. By default, this is a disc
  115925. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115926. * * 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
  115927. * * 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
  115928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115931. * @param name defines the name of the mesh
  115932. * @param options defines the options used to create the mesh
  115933. * @param scene defines the hosting scene
  115934. * @returns the plane polygonal mesh
  115935. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115936. */
  115937. static CreateDisc(name: string, options: {
  115938. radius?: number;
  115939. tessellation?: number;
  115940. arc?: number;
  115941. updatable?: boolean;
  115942. sideOrientation?: number;
  115943. frontUVs?: Vector4;
  115944. backUVs?: Vector4;
  115945. }, scene?: Nullable<Scene>): Mesh;
  115946. /**
  115947. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115948. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115949. * * 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`)
  115950. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115951. * * 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
  115952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115955. * @param name defines the name of the mesh
  115956. * @param options defines the options used to create the mesh
  115957. * @param scene defines the hosting scene
  115958. * @returns the icosahedron mesh
  115959. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115960. */
  115961. static CreateIcoSphere(name: string, options: {
  115962. radius?: number;
  115963. radiusX?: number;
  115964. radiusY?: number;
  115965. radiusZ?: number;
  115966. flat?: boolean;
  115967. subdivisions?: number;
  115968. sideOrientation?: number;
  115969. frontUVs?: Vector4;
  115970. backUVs?: Vector4;
  115971. updatable?: boolean;
  115972. }, scene?: Nullable<Scene>): Mesh;
  115973. /**
  115974. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115975. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  115976. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  115977. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  115978. * * 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
  115979. * * 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
  115980. * * 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
  115981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115982. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115983. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115984. * * 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
  115985. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  115986. * * 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
  115987. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  115988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115989. * @param name defines the name of the mesh
  115990. * @param options defines the options used to create the mesh
  115991. * @param scene defines the hosting scene
  115992. * @returns the ribbon mesh
  115993. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  115994. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115995. */
  115996. static CreateRibbon(name: string, options: {
  115997. pathArray: Vector3[][];
  115998. closeArray?: boolean;
  115999. closePath?: boolean;
  116000. offset?: number;
  116001. updatable?: boolean;
  116002. sideOrientation?: number;
  116003. frontUVs?: Vector4;
  116004. backUVs?: Vector4;
  116005. instance?: Mesh;
  116006. invertUV?: boolean;
  116007. uvs?: Vector2[];
  116008. colors?: Color4[];
  116009. }, scene?: Nullable<Scene>): Mesh;
  116010. /**
  116011. * Creates a cylinder or a cone mesh
  116012. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  116013. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  116014. * * 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.
  116015. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  116016. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  116017. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  116018. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  116019. * * 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).
  116020. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  116021. * * 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).
  116022. * * 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
  116023. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  116024. * * 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
  116025. * * 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.
  116026. * * If `enclose` is false, a ring surface is one element.
  116027. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  116028. * * 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
  116029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116030. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116032. * @param name defines the name of the mesh
  116033. * @param options defines the options used to create the mesh
  116034. * @param scene defines the hosting scene
  116035. * @returns the cylinder mesh
  116036. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  116037. */
  116038. static CreateCylinder(name: string, options: {
  116039. height?: number;
  116040. diameterTop?: number;
  116041. diameterBottom?: number;
  116042. diameter?: number;
  116043. tessellation?: number;
  116044. subdivisions?: number;
  116045. arc?: number;
  116046. faceColors?: Color4[];
  116047. faceUV?: Vector4[];
  116048. updatable?: boolean;
  116049. hasRings?: boolean;
  116050. enclose?: boolean;
  116051. cap?: number;
  116052. sideOrientation?: number;
  116053. frontUVs?: Vector4;
  116054. backUVs?: Vector4;
  116055. }, scene?: Nullable<Scene>): Mesh;
  116056. /**
  116057. * Creates a torus mesh
  116058. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  116059. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  116060. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  116061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116064. * @param name defines the name of the mesh
  116065. * @param options defines the options used to create the mesh
  116066. * @param scene defines the hosting scene
  116067. * @returns the torus mesh
  116068. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  116069. */
  116070. static CreateTorus(name: string, options: {
  116071. diameter?: number;
  116072. thickness?: number;
  116073. tessellation?: number;
  116074. updatable?: boolean;
  116075. sideOrientation?: number;
  116076. frontUVs?: Vector4;
  116077. backUVs?: Vector4;
  116078. }, scene?: Nullable<Scene>): Mesh;
  116079. /**
  116080. * Creates a torus knot mesh
  116081. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  116082. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  116083. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  116084. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  116085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116086. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116088. * @param name defines the name of the mesh
  116089. * @param options defines the options used to create the mesh
  116090. * @param scene defines the hosting scene
  116091. * @returns the torus knot mesh
  116092. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  116093. */
  116094. static CreateTorusKnot(name: string, options: {
  116095. radius?: number;
  116096. tube?: number;
  116097. radialSegments?: number;
  116098. tubularSegments?: number;
  116099. p?: number;
  116100. q?: number;
  116101. updatable?: boolean;
  116102. sideOrientation?: number;
  116103. frontUVs?: Vector4;
  116104. backUVs?: Vector4;
  116105. }, scene?: Nullable<Scene>): Mesh;
  116106. /**
  116107. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116108. * * 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
  116109. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116110. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116111. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116112. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116113. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116114. * * 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
  116115. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116117. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116118. * @param name defines the name of the new line system
  116119. * @param options defines the options used to create the line system
  116120. * @param scene defines the hosting scene
  116121. * @returns a new line system mesh
  116122. */
  116123. static CreateLineSystem(name: string, options: {
  116124. lines: Vector3[][];
  116125. updatable?: boolean;
  116126. instance?: Nullable<LinesMesh>;
  116127. colors?: Nullable<Color4[][]>;
  116128. useVertexAlpha?: boolean;
  116129. }, scene: Nullable<Scene>): LinesMesh;
  116130. /**
  116131. * Creates a line mesh
  116132. * 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
  116133. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116134. * * The parameter `points` is an array successive Vector3
  116135. * * 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
  116136. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116137. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116138. * * When updating an instance, remember that only point positions can change, not the number of points
  116139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116140. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116141. * @param name defines the name of the new line system
  116142. * @param options defines the options used to create the line system
  116143. * @param scene defines the hosting scene
  116144. * @returns a new line mesh
  116145. */
  116146. static CreateLines(name: string, options: {
  116147. points: Vector3[];
  116148. updatable?: boolean;
  116149. instance?: Nullable<LinesMesh>;
  116150. colors?: Color4[];
  116151. useVertexAlpha?: boolean;
  116152. }, scene?: Nullable<Scene>): LinesMesh;
  116153. /**
  116154. * Creates a dashed line mesh
  116155. * * 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
  116156. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116157. * * The parameter `points` is an array successive Vector3
  116158. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116159. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116160. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116161. * * 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
  116162. * * When updating an instance, remember that only point positions can change, not the number of points
  116163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116164. * @param name defines the name of the mesh
  116165. * @param options defines the options used to create the mesh
  116166. * @param scene defines the hosting scene
  116167. * @returns the dashed line mesh
  116168. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116169. */
  116170. static CreateDashedLines(name: string, options: {
  116171. points: Vector3[];
  116172. dashSize?: number;
  116173. gapSize?: number;
  116174. dashNb?: number;
  116175. updatable?: boolean;
  116176. instance?: LinesMesh;
  116177. }, scene?: Nullable<Scene>): LinesMesh;
  116178. /**
  116179. * 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.
  116180. * * 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.
  116181. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116182. * * 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.
  116183. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116184. * * 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
  116185. * * 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
  116186. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116189. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116191. * @param name defines the name of the mesh
  116192. * @param options defines the options used to create the mesh
  116193. * @param scene defines the hosting scene
  116194. * @returns the extruded shape mesh
  116195. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116196. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116197. */
  116198. static ExtrudeShape(name: string, options: {
  116199. shape: Vector3[];
  116200. path: Vector3[];
  116201. scale?: number;
  116202. rotation?: number;
  116203. cap?: number;
  116204. updatable?: boolean;
  116205. sideOrientation?: number;
  116206. frontUVs?: Vector4;
  116207. backUVs?: Vector4;
  116208. instance?: Mesh;
  116209. invertUV?: boolean;
  116210. }, scene?: Nullable<Scene>): Mesh;
  116211. /**
  116212. * Creates an custom extruded shape mesh.
  116213. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116214. * * 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.
  116215. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116216. * * 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
  116217. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116218. * * 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
  116219. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116220. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116221. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116222. * * 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
  116223. * * 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
  116224. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116227. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116229. * @param name defines the name of the mesh
  116230. * @param options defines the options used to create the mesh
  116231. * @param scene defines the hosting scene
  116232. * @returns the custom extruded shape mesh
  116233. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116234. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116235. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116236. */
  116237. static ExtrudeShapeCustom(name: string, options: {
  116238. shape: Vector3[];
  116239. path: Vector3[];
  116240. scaleFunction?: any;
  116241. rotationFunction?: any;
  116242. ribbonCloseArray?: boolean;
  116243. ribbonClosePath?: boolean;
  116244. cap?: number;
  116245. updatable?: boolean;
  116246. sideOrientation?: number;
  116247. frontUVs?: Vector4;
  116248. backUVs?: Vector4;
  116249. instance?: Mesh;
  116250. invertUV?: boolean;
  116251. }, scene?: Nullable<Scene>): Mesh;
  116252. /**
  116253. * Creates lathe mesh.
  116254. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  116255. * * 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
  116256. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  116257. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  116258. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  116259. * * 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
  116260. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  116261. * * 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
  116262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116264. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116266. * @param name defines the name of the mesh
  116267. * @param options defines the options used to create the mesh
  116268. * @param scene defines the hosting scene
  116269. * @returns the lathe mesh
  116270. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  116271. */
  116272. static CreateLathe(name: string, options: {
  116273. shape: Vector3[];
  116274. radius?: number;
  116275. tessellation?: number;
  116276. clip?: number;
  116277. arc?: number;
  116278. closed?: boolean;
  116279. updatable?: boolean;
  116280. sideOrientation?: number;
  116281. frontUVs?: Vector4;
  116282. backUVs?: Vector4;
  116283. cap?: number;
  116284. invertUV?: boolean;
  116285. }, scene?: Nullable<Scene>): Mesh;
  116286. /**
  116287. * Creates a tiled plane mesh
  116288. * * You can set a limited pattern arrangement with the tiles
  116289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116290. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116292. * @param name defines the name of the mesh
  116293. * @param options defines the options used to create the mesh
  116294. * @param scene defines the hosting scene
  116295. * @returns the plane mesh
  116296. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116297. */
  116298. static CreateTiledPlane(name: string, options: {
  116299. pattern?: number;
  116300. tileSize?: number;
  116301. tileWidth?: number;
  116302. tileHeight?: number;
  116303. size?: number;
  116304. width?: number;
  116305. height?: number;
  116306. alignHorizontal?: number;
  116307. alignVertical?: number;
  116308. sideOrientation?: number;
  116309. frontUVs?: Vector4;
  116310. backUVs?: Vector4;
  116311. updatable?: boolean;
  116312. }, scene?: Nullable<Scene>): Mesh;
  116313. /**
  116314. * Creates a plane mesh
  116315. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  116316. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  116317. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  116318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116319. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116321. * @param name defines the name of the mesh
  116322. * @param options defines the options used to create the mesh
  116323. * @param scene defines the hosting scene
  116324. * @returns the plane mesh
  116325. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116326. */
  116327. static CreatePlane(name: string, options: {
  116328. size?: number;
  116329. width?: number;
  116330. height?: number;
  116331. sideOrientation?: number;
  116332. frontUVs?: Vector4;
  116333. backUVs?: Vector4;
  116334. updatable?: boolean;
  116335. sourcePlane?: Plane;
  116336. }, scene?: Nullable<Scene>): Mesh;
  116337. /**
  116338. * Creates a ground mesh
  116339. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  116340. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  116341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116342. * @param name defines the name of the mesh
  116343. * @param options defines the options used to create the mesh
  116344. * @param scene defines the hosting scene
  116345. * @returns the ground mesh
  116346. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  116347. */
  116348. static CreateGround(name: string, options: {
  116349. width?: number;
  116350. height?: number;
  116351. subdivisions?: number;
  116352. subdivisionsX?: number;
  116353. subdivisionsY?: number;
  116354. updatable?: boolean;
  116355. }, scene?: Nullable<Scene>): Mesh;
  116356. /**
  116357. * Creates a tiled ground mesh
  116358. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  116359. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  116360. * * 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
  116361. * * 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
  116362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116363. * @param name defines the name of the mesh
  116364. * @param options defines the options used to create the mesh
  116365. * @param scene defines the hosting scene
  116366. * @returns the tiled ground mesh
  116367. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  116368. */
  116369. static CreateTiledGround(name: string, options: {
  116370. xmin: number;
  116371. zmin: number;
  116372. xmax: number;
  116373. zmax: number;
  116374. subdivisions?: {
  116375. w: number;
  116376. h: number;
  116377. };
  116378. precision?: {
  116379. w: number;
  116380. h: number;
  116381. };
  116382. updatable?: boolean;
  116383. }, scene?: Nullable<Scene>): Mesh;
  116384. /**
  116385. * Creates a ground mesh from a height map
  116386. * * The parameter `url` sets the URL of the height map image resource.
  116387. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  116388. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  116389. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  116390. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  116391. * * 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.
  116392. * * 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).
  116393. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  116394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116395. * @param name defines the name of the mesh
  116396. * @param url defines the url to the height map
  116397. * @param options defines the options used to create the mesh
  116398. * @param scene defines the hosting scene
  116399. * @returns the ground mesh
  116400. * @see https://doc.babylonjs.com/babylon101/height_map
  116401. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  116402. */
  116403. static CreateGroundFromHeightMap(name: string, url: string, options: {
  116404. width?: number;
  116405. height?: number;
  116406. subdivisions?: number;
  116407. minHeight?: number;
  116408. maxHeight?: number;
  116409. colorFilter?: Color3;
  116410. alphaFilter?: number;
  116411. updatable?: boolean;
  116412. onReady?: (mesh: GroundMesh) => void;
  116413. }, scene?: Nullable<Scene>): GroundMesh;
  116414. /**
  116415. * Creates a polygon mesh
  116416. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  116417. * * 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
  116418. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  116419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  116421. * * Remember you can only change the shape positions, not their number when updating a polygon
  116422. * @param name defines the name of the mesh
  116423. * @param options defines the options used to create the mesh
  116424. * @param scene defines the hosting scene
  116425. * @param earcutInjection can be used to inject your own earcut reference
  116426. * @returns the polygon mesh
  116427. */
  116428. static CreatePolygon(name: string, options: {
  116429. shape: Vector3[];
  116430. holes?: Vector3[][];
  116431. depth?: number;
  116432. faceUV?: Vector4[];
  116433. faceColors?: Color4[];
  116434. updatable?: boolean;
  116435. sideOrientation?: number;
  116436. frontUVs?: Vector4;
  116437. backUVs?: Vector4;
  116438. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116439. /**
  116440. * Creates an extruded polygon mesh, with depth in the Y direction.
  116441. * * 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)
  116442. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116443. * @param name defines the name of the mesh
  116444. * @param options defines the options used to create the mesh
  116445. * @param scene defines the hosting scene
  116446. * @param earcutInjection can be used to inject your own earcut reference
  116447. * @returns the polygon mesh
  116448. */
  116449. static ExtrudePolygon(name: string, options: {
  116450. shape: Vector3[];
  116451. holes?: Vector3[][];
  116452. depth?: number;
  116453. faceUV?: Vector4[];
  116454. faceColors?: Color4[];
  116455. updatable?: boolean;
  116456. sideOrientation?: number;
  116457. frontUVs?: Vector4;
  116458. backUVs?: Vector4;
  116459. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116460. /**
  116461. * Creates a tube mesh.
  116462. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116463. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  116464. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  116465. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  116466. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  116467. * * 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)
  116468. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  116469. * * 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
  116470. * * 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
  116471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116473. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116475. * @param name defines the name of the mesh
  116476. * @param options defines the options used to create the mesh
  116477. * @param scene defines the hosting scene
  116478. * @returns the tube mesh
  116479. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116480. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  116481. */
  116482. static CreateTube(name: string, options: {
  116483. path: Vector3[];
  116484. radius?: number;
  116485. tessellation?: number;
  116486. radiusFunction?: {
  116487. (i: number, distance: number): number;
  116488. };
  116489. cap?: number;
  116490. arc?: number;
  116491. updatable?: boolean;
  116492. sideOrientation?: number;
  116493. frontUVs?: Vector4;
  116494. backUVs?: Vector4;
  116495. instance?: Mesh;
  116496. invertUV?: boolean;
  116497. }, scene?: Nullable<Scene>): Mesh;
  116498. /**
  116499. * Creates a polyhedron mesh
  116500. * * 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
  116501. * * The parameter `size` (positive float, default 1) sets the polygon size
  116502. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  116503. * * 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`
  116504. * * 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
  116505. * * 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)`)
  116506. * * 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
  116507. * * 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
  116508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116509. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116511. * @param name defines the name of the mesh
  116512. * @param options defines the options used to create the mesh
  116513. * @param scene defines the hosting scene
  116514. * @returns the polyhedron mesh
  116515. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  116516. */
  116517. static CreatePolyhedron(name: string, options: {
  116518. type?: number;
  116519. size?: number;
  116520. sizeX?: number;
  116521. sizeY?: number;
  116522. sizeZ?: number;
  116523. custom?: any;
  116524. faceUV?: Vector4[];
  116525. faceColors?: Color4[];
  116526. flat?: boolean;
  116527. updatable?: boolean;
  116528. sideOrientation?: number;
  116529. frontUVs?: Vector4;
  116530. backUVs?: Vector4;
  116531. }, scene?: Nullable<Scene>): Mesh;
  116532. /**
  116533. * Creates a decal mesh.
  116534. * 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
  116535. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  116536. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  116537. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  116538. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  116539. * @param name defines the name of the mesh
  116540. * @param sourceMesh defines the mesh where the decal must be applied
  116541. * @param options defines the options used to create the mesh
  116542. * @param scene defines the hosting scene
  116543. * @returns the decal mesh
  116544. * @see https://doc.babylonjs.com/how_to/decals
  116545. */
  116546. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  116547. position?: Vector3;
  116548. normal?: Vector3;
  116549. size?: Vector3;
  116550. angle?: number;
  116551. }): Mesh;
  116552. }
  116553. }
  116554. declare module BABYLON {
  116555. /**
  116556. * A simplifier interface for future simplification implementations
  116557. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116558. */
  116559. export interface ISimplifier {
  116560. /**
  116561. * Simplification of a given mesh according to the given settings.
  116562. * Since this requires computation, it is assumed that the function runs async.
  116563. * @param settings The settings of the simplification, including quality and distance
  116564. * @param successCallback A callback that will be called after the mesh was simplified.
  116565. * @param errorCallback in case of an error, this callback will be called. optional.
  116566. */
  116567. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  116568. }
  116569. /**
  116570. * Expected simplification settings.
  116571. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  116572. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116573. */
  116574. export interface ISimplificationSettings {
  116575. /**
  116576. * Gets or sets the expected quality
  116577. */
  116578. quality: number;
  116579. /**
  116580. * Gets or sets the distance when this optimized version should be used
  116581. */
  116582. distance: number;
  116583. /**
  116584. * Gets an already optimized mesh
  116585. */
  116586. optimizeMesh?: boolean;
  116587. }
  116588. /**
  116589. * Class used to specify simplification options
  116590. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116591. */
  116592. export class SimplificationSettings implements ISimplificationSettings {
  116593. /** expected quality */
  116594. quality: number;
  116595. /** distance when this optimized version should be used */
  116596. distance: number;
  116597. /** already optimized mesh */
  116598. optimizeMesh?: boolean | undefined;
  116599. /**
  116600. * Creates a SimplificationSettings
  116601. * @param quality expected quality
  116602. * @param distance distance when this optimized version should be used
  116603. * @param optimizeMesh already optimized mesh
  116604. */
  116605. constructor(
  116606. /** expected quality */
  116607. quality: number,
  116608. /** distance when this optimized version should be used */
  116609. distance: number,
  116610. /** already optimized mesh */
  116611. optimizeMesh?: boolean | undefined);
  116612. }
  116613. /**
  116614. * Interface used to define a simplification task
  116615. */
  116616. export interface ISimplificationTask {
  116617. /**
  116618. * Array of settings
  116619. */
  116620. settings: Array<ISimplificationSettings>;
  116621. /**
  116622. * Simplification type
  116623. */
  116624. simplificationType: SimplificationType;
  116625. /**
  116626. * Mesh to simplify
  116627. */
  116628. mesh: Mesh;
  116629. /**
  116630. * Callback called on success
  116631. */
  116632. successCallback?: () => void;
  116633. /**
  116634. * Defines if parallel processing can be used
  116635. */
  116636. parallelProcessing: boolean;
  116637. }
  116638. /**
  116639. * Queue used to order the simplification tasks
  116640. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116641. */
  116642. export class SimplificationQueue {
  116643. private _simplificationArray;
  116644. /**
  116645. * Gets a boolean indicating that the process is still running
  116646. */
  116647. running: boolean;
  116648. /**
  116649. * Creates a new queue
  116650. */
  116651. constructor();
  116652. /**
  116653. * Adds a new simplification task
  116654. * @param task defines a task to add
  116655. */
  116656. addTask(task: ISimplificationTask): void;
  116657. /**
  116658. * Execute next task
  116659. */
  116660. executeNext(): void;
  116661. /**
  116662. * Execute a simplification task
  116663. * @param task defines the task to run
  116664. */
  116665. runSimplification(task: ISimplificationTask): void;
  116666. private getSimplifier;
  116667. }
  116668. /**
  116669. * The implemented types of simplification
  116670. * At the moment only Quadratic Error Decimation is implemented
  116671. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116672. */
  116673. export enum SimplificationType {
  116674. /** Quadratic error decimation */
  116675. QUADRATIC = 0
  116676. }
  116677. }
  116678. declare module BABYLON {
  116679. interface Scene {
  116680. /** @hidden (Backing field) */
  116681. _simplificationQueue: SimplificationQueue;
  116682. /**
  116683. * Gets or sets the simplification queue attached to the scene
  116684. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116685. */
  116686. simplificationQueue: SimplificationQueue;
  116687. }
  116688. interface Mesh {
  116689. /**
  116690. * Simplify the mesh according to the given array of settings.
  116691. * Function will return immediately and will simplify async
  116692. * @param settings a collection of simplification settings
  116693. * @param parallelProcessing should all levels calculate parallel or one after the other
  116694. * @param simplificationType the type of simplification to run
  116695. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  116696. * @returns the current mesh
  116697. */
  116698. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  116699. }
  116700. /**
  116701. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  116702. * created in a scene
  116703. */
  116704. export class SimplicationQueueSceneComponent implements ISceneComponent {
  116705. /**
  116706. * The component name helpfull to identify the component in the list of scene components.
  116707. */
  116708. readonly name: string;
  116709. /**
  116710. * The scene the component belongs to.
  116711. */
  116712. scene: Scene;
  116713. /**
  116714. * Creates a new instance of the component for the given scene
  116715. * @param scene Defines the scene to register the component in
  116716. */
  116717. constructor(scene: Scene);
  116718. /**
  116719. * Registers the component in a given scene
  116720. */
  116721. register(): void;
  116722. /**
  116723. * Rebuilds the elements related to this component in case of
  116724. * context lost for instance.
  116725. */
  116726. rebuild(): void;
  116727. /**
  116728. * Disposes the component and the associated ressources
  116729. */
  116730. dispose(): void;
  116731. private _beforeCameraUpdate;
  116732. }
  116733. }
  116734. declare module BABYLON {
  116735. /**
  116736. * Class used to enable access to IndexedDB
  116737. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116738. */
  116739. export class Database implements IOfflineProvider {
  116740. private _callbackManifestChecked;
  116741. private _currentSceneUrl;
  116742. private _db;
  116743. private _enableSceneOffline;
  116744. private _enableTexturesOffline;
  116745. private _manifestVersionFound;
  116746. private _mustUpdateRessources;
  116747. private _hasReachedQuota;
  116748. private _isSupported;
  116749. private _idbFactory;
  116750. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  116751. private static IsUASupportingBlobStorage;
  116752. /**
  116753. * Gets a boolean indicating if Database storate is enabled (off by default)
  116754. */
  116755. static IDBStorageEnabled: boolean;
  116756. /**
  116757. * Gets a boolean indicating if scene must be saved in the database
  116758. */
  116759. readonly enableSceneOffline: boolean;
  116760. /**
  116761. * Gets a boolean indicating if textures must be saved in the database
  116762. */
  116763. readonly enableTexturesOffline: boolean;
  116764. /**
  116765. * Creates a new Database
  116766. * @param urlToScene defines the url to load the scene
  116767. * @param callbackManifestChecked defines the callback to use when manifest is checked
  116768. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  116769. */
  116770. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  116771. private static _ParseURL;
  116772. private static _ReturnFullUrlLocation;
  116773. private _checkManifestFile;
  116774. /**
  116775. * Open the database and make it available
  116776. * @param successCallback defines the callback to call on success
  116777. * @param errorCallback defines the callback to call on error
  116778. */
  116779. open(successCallback: () => void, errorCallback: () => void): void;
  116780. /**
  116781. * Loads an image from the database
  116782. * @param url defines the url to load from
  116783. * @param image defines the target DOM image
  116784. */
  116785. loadImage(url: string, image: HTMLImageElement): void;
  116786. private _loadImageFromDBAsync;
  116787. private _saveImageIntoDBAsync;
  116788. private _checkVersionFromDB;
  116789. private _loadVersionFromDBAsync;
  116790. private _saveVersionIntoDBAsync;
  116791. /**
  116792. * Loads a file from database
  116793. * @param url defines the URL to load from
  116794. * @param sceneLoaded defines a callback to call on success
  116795. * @param progressCallBack defines a callback to call when progress changed
  116796. * @param errorCallback defines a callback to call on error
  116797. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  116798. */
  116799. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  116800. private _loadFileAsync;
  116801. private _saveFileAsync;
  116802. /**
  116803. * Validates if xhr data is correct
  116804. * @param xhr defines the request to validate
  116805. * @param dataType defines the expected data type
  116806. * @returns true if data is correct
  116807. */
  116808. private static _ValidateXHRData;
  116809. }
  116810. }
  116811. declare module BABYLON {
  116812. /** @hidden */
  116813. export var gpuUpdateParticlesPixelShader: {
  116814. name: string;
  116815. shader: string;
  116816. };
  116817. }
  116818. declare module BABYLON {
  116819. /** @hidden */
  116820. export var gpuUpdateParticlesVertexShader: {
  116821. name: string;
  116822. shader: string;
  116823. };
  116824. }
  116825. declare module BABYLON {
  116826. /** @hidden */
  116827. export var clipPlaneFragmentDeclaration2: {
  116828. name: string;
  116829. shader: string;
  116830. };
  116831. }
  116832. declare module BABYLON {
  116833. /** @hidden */
  116834. export var gpuRenderParticlesPixelShader: {
  116835. name: string;
  116836. shader: string;
  116837. };
  116838. }
  116839. declare module BABYLON {
  116840. /** @hidden */
  116841. export var clipPlaneVertexDeclaration2: {
  116842. name: string;
  116843. shader: string;
  116844. };
  116845. }
  116846. declare module BABYLON {
  116847. /** @hidden */
  116848. export var gpuRenderParticlesVertexShader: {
  116849. name: string;
  116850. shader: string;
  116851. };
  116852. }
  116853. declare module BABYLON {
  116854. /**
  116855. * This represents a GPU particle system in Babylon
  116856. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  116857. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  116858. */
  116859. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  116860. /**
  116861. * The layer mask we are rendering the particles through.
  116862. */
  116863. layerMask: number;
  116864. private _capacity;
  116865. private _activeCount;
  116866. private _currentActiveCount;
  116867. private _accumulatedCount;
  116868. private _renderEffect;
  116869. private _updateEffect;
  116870. private _buffer0;
  116871. private _buffer1;
  116872. private _spriteBuffer;
  116873. private _updateVAO;
  116874. private _renderVAO;
  116875. private _targetIndex;
  116876. private _sourceBuffer;
  116877. private _targetBuffer;
  116878. private _engine;
  116879. private _currentRenderId;
  116880. private _started;
  116881. private _stopped;
  116882. private _timeDelta;
  116883. private _randomTexture;
  116884. private _randomTexture2;
  116885. private _attributesStrideSize;
  116886. private _updateEffectOptions;
  116887. private _randomTextureSize;
  116888. private _actualFrame;
  116889. private readonly _rawTextureWidth;
  116890. /**
  116891. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  116892. */
  116893. static readonly IsSupported: boolean;
  116894. /**
  116895. * An event triggered when the system is disposed.
  116896. */
  116897. onDisposeObservable: Observable<GPUParticleSystem>;
  116898. /**
  116899. * Gets the maximum number of particles active at the same time.
  116900. * @returns The max number of active particles.
  116901. */
  116902. getCapacity(): number;
  116903. /**
  116904. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  116905. * to override the particles.
  116906. */
  116907. forceDepthWrite: boolean;
  116908. /**
  116909. * Gets or set the number of active particles
  116910. */
  116911. activeParticleCount: number;
  116912. private _preWarmDone;
  116913. /**
  116914. * Is this system ready to be used/rendered
  116915. * @return true if the system is ready
  116916. */
  116917. isReady(): boolean;
  116918. /**
  116919. * Gets if the system has been started. (Note: this will still be true after stop is called)
  116920. * @returns True if it has been started, otherwise false.
  116921. */
  116922. isStarted(): boolean;
  116923. /**
  116924. * Starts the particle system and begins to emit
  116925. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  116926. */
  116927. start(delay?: number): void;
  116928. /**
  116929. * Stops the particle system.
  116930. */
  116931. stop(): void;
  116932. /**
  116933. * Remove all active particles
  116934. */
  116935. reset(): void;
  116936. /**
  116937. * Returns the string "GPUParticleSystem"
  116938. * @returns a string containing the class name
  116939. */
  116940. getClassName(): string;
  116941. private _colorGradientsTexture;
  116942. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  116943. /**
  116944. * Adds a new color gradient
  116945. * @param gradient defines the gradient to use (between 0 and 1)
  116946. * @param color1 defines the color to affect to the specified gradient
  116947. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  116948. * @returns the current particle system
  116949. */
  116950. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  116951. /**
  116952. * Remove a specific color gradient
  116953. * @param gradient defines the gradient to remove
  116954. * @returns the current particle system
  116955. */
  116956. removeColorGradient(gradient: number): GPUParticleSystem;
  116957. private _angularSpeedGradientsTexture;
  116958. private _sizeGradientsTexture;
  116959. private _velocityGradientsTexture;
  116960. private _limitVelocityGradientsTexture;
  116961. private _dragGradientsTexture;
  116962. private _addFactorGradient;
  116963. /**
  116964. * Adds a new size gradient
  116965. * @param gradient defines the gradient to use (between 0 and 1)
  116966. * @param factor defines the size factor to affect to the specified gradient
  116967. * @returns the current particle system
  116968. */
  116969. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  116970. /**
  116971. * Remove a specific size gradient
  116972. * @param gradient defines the gradient to remove
  116973. * @returns the current particle system
  116974. */
  116975. removeSizeGradient(gradient: number): GPUParticleSystem;
  116976. /**
  116977. * Adds a new angular speed gradient
  116978. * @param gradient defines the gradient to use (between 0 and 1)
  116979. * @param factor defines the angular speed to affect to the specified gradient
  116980. * @returns the current particle system
  116981. */
  116982. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  116983. /**
  116984. * Remove a specific angular speed gradient
  116985. * @param gradient defines the gradient to remove
  116986. * @returns the current particle system
  116987. */
  116988. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  116989. /**
  116990. * Adds a new velocity gradient
  116991. * @param gradient defines the gradient to use (between 0 and 1)
  116992. * @param factor defines the velocity to affect to the specified gradient
  116993. * @returns the current particle system
  116994. */
  116995. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116996. /**
  116997. * Remove a specific velocity gradient
  116998. * @param gradient defines the gradient to remove
  116999. * @returns the current particle system
  117000. */
  117001. removeVelocityGradient(gradient: number): GPUParticleSystem;
  117002. /**
  117003. * Adds a new limit velocity gradient
  117004. * @param gradient defines the gradient to use (between 0 and 1)
  117005. * @param factor defines the limit velocity value to affect to the specified gradient
  117006. * @returns the current particle system
  117007. */
  117008. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  117009. /**
  117010. * Remove a specific limit velocity gradient
  117011. * @param gradient defines the gradient to remove
  117012. * @returns the current particle system
  117013. */
  117014. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  117015. /**
  117016. * Adds a new drag gradient
  117017. * @param gradient defines the gradient to use (between 0 and 1)
  117018. * @param factor defines the drag value to affect to the specified gradient
  117019. * @returns the current particle system
  117020. */
  117021. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  117022. /**
  117023. * Remove a specific drag gradient
  117024. * @param gradient defines the gradient to remove
  117025. * @returns the current particle system
  117026. */
  117027. removeDragGradient(gradient: number): GPUParticleSystem;
  117028. /**
  117029. * Not supported by GPUParticleSystem
  117030. * @param gradient defines the gradient to use (between 0 and 1)
  117031. * @param factor defines the emit rate value to affect to the specified gradient
  117032. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117033. * @returns the current particle system
  117034. */
  117035. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117036. /**
  117037. * Not supported by GPUParticleSystem
  117038. * @param gradient defines the gradient to remove
  117039. * @returns the current particle system
  117040. */
  117041. removeEmitRateGradient(gradient: number): IParticleSystem;
  117042. /**
  117043. * Not supported by GPUParticleSystem
  117044. * @param gradient defines the gradient to use (between 0 and 1)
  117045. * @param factor defines the start size value to affect to the specified gradient
  117046. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117047. * @returns the current particle system
  117048. */
  117049. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117050. /**
  117051. * Not supported by GPUParticleSystem
  117052. * @param gradient defines the gradient to remove
  117053. * @returns the current particle system
  117054. */
  117055. removeStartSizeGradient(gradient: number): IParticleSystem;
  117056. /**
  117057. * Not supported by GPUParticleSystem
  117058. * @param gradient defines the gradient to use (between 0 and 1)
  117059. * @param min defines the color remap minimal range
  117060. * @param max defines the color remap maximal range
  117061. * @returns the current particle system
  117062. */
  117063. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  117064. /**
  117065. * Not supported by GPUParticleSystem
  117066. * @param gradient defines the gradient to remove
  117067. * @returns the current particle system
  117068. */
  117069. removeColorRemapGradient(): IParticleSystem;
  117070. /**
  117071. * Not supported by GPUParticleSystem
  117072. * @param gradient defines the gradient to use (between 0 and 1)
  117073. * @param min defines the alpha remap minimal range
  117074. * @param max defines the alpha remap maximal range
  117075. * @returns the current particle system
  117076. */
  117077. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  117078. /**
  117079. * Not supported by GPUParticleSystem
  117080. * @param gradient defines the gradient to remove
  117081. * @returns the current particle system
  117082. */
  117083. removeAlphaRemapGradient(): IParticleSystem;
  117084. /**
  117085. * Not supported by GPUParticleSystem
  117086. * @param gradient defines the gradient to use (between 0 and 1)
  117087. * @param color defines the color to affect to the specified gradient
  117088. * @returns the current particle system
  117089. */
  117090. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  117091. /**
  117092. * Not supported by GPUParticleSystem
  117093. * @param gradient defines the gradient to remove
  117094. * @returns the current particle system
  117095. */
  117096. removeRampGradient(): IParticleSystem;
  117097. /**
  117098. * Not supported by GPUParticleSystem
  117099. * @returns the list of ramp gradients
  117100. */
  117101. getRampGradients(): Nullable<Array<Color3Gradient>>;
  117102. /**
  117103. * Not supported by GPUParticleSystem
  117104. * Gets or sets a boolean indicating that ramp gradients must be used
  117105. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  117106. */
  117107. useRampGradients: boolean;
  117108. /**
  117109. * Not supported by GPUParticleSystem
  117110. * @param gradient defines the gradient to use (between 0 and 1)
  117111. * @param factor defines the life time factor to affect to the specified gradient
  117112. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117113. * @returns the current particle system
  117114. */
  117115. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117116. /**
  117117. * Not supported by GPUParticleSystem
  117118. * @param gradient defines the gradient to remove
  117119. * @returns the current particle system
  117120. */
  117121. removeLifeTimeGradient(gradient: number): IParticleSystem;
  117122. /**
  117123. * Instantiates a GPU particle system.
  117124. * 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.
  117125. * @param name The name of the particle system
  117126. * @param options The options used to create the system
  117127. * @param scene The scene the particle system belongs to
  117128. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  117129. */
  117130. constructor(name: string, options: Partial<{
  117131. capacity: number;
  117132. randomTextureSize: number;
  117133. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  117134. protected _reset(): void;
  117135. private _createUpdateVAO;
  117136. private _createRenderVAO;
  117137. private _initialize;
  117138. /** @hidden */
  117139. _recreateUpdateEffect(): void;
  117140. /** @hidden */
  117141. _recreateRenderEffect(): void;
  117142. /**
  117143. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  117144. * @param preWarm defines if we are in the pre-warmimg phase
  117145. */
  117146. animate(preWarm?: boolean): void;
  117147. private _createFactorGradientTexture;
  117148. private _createSizeGradientTexture;
  117149. private _createAngularSpeedGradientTexture;
  117150. private _createVelocityGradientTexture;
  117151. private _createLimitVelocityGradientTexture;
  117152. private _createDragGradientTexture;
  117153. private _createColorGradientTexture;
  117154. /**
  117155. * Renders the particle system in its current state
  117156. * @param preWarm defines if the system should only update the particles but not render them
  117157. * @returns the current number of particles
  117158. */
  117159. render(preWarm?: boolean): number;
  117160. /**
  117161. * Rebuilds the particle system
  117162. */
  117163. rebuild(): void;
  117164. private _releaseBuffers;
  117165. private _releaseVAOs;
  117166. /**
  117167. * Disposes the particle system and free the associated resources
  117168. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  117169. */
  117170. dispose(disposeTexture?: boolean): void;
  117171. /**
  117172. * Clones the particle system.
  117173. * @param name The name of the cloned object
  117174. * @param newEmitter The new emitter to use
  117175. * @returns the cloned particle system
  117176. */
  117177. clone(name: string, newEmitter: any): GPUParticleSystem;
  117178. /**
  117179. * Serializes the particle system to a JSON object.
  117180. * @returns the JSON object
  117181. */
  117182. serialize(): any;
  117183. /**
  117184. * Parses a JSON object to create a GPU particle system.
  117185. * @param parsedParticleSystem The JSON object to parse
  117186. * @param scene The scene to create the particle system in
  117187. * @param rootUrl The root url to use to load external dependencies like texture
  117188. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  117189. * @returns the parsed GPU particle system
  117190. */
  117191. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  117192. }
  117193. }
  117194. declare module BABYLON {
  117195. /**
  117196. * Represents a set of particle systems working together to create a specific effect
  117197. */
  117198. export class ParticleSystemSet implements IDisposable {
  117199. private _emitterCreationOptions;
  117200. private _emitterNode;
  117201. /**
  117202. * Gets the particle system list
  117203. */
  117204. systems: IParticleSystem[];
  117205. /**
  117206. * Gets the emitter node used with this set
  117207. */
  117208. readonly emitterNode: Nullable<TransformNode>;
  117209. /**
  117210. * Creates a new emitter mesh as a sphere
  117211. * @param options defines the options used to create the sphere
  117212. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  117213. * @param scene defines the hosting scene
  117214. */
  117215. setEmitterAsSphere(options: {
  117216. diameter: number;
  117217. segments: number;
  117218. color: Color3;
  117219. }, renderingGroupId: number, scene: Scene): void;
  117220. /**
  117221. * Starts all particle systems of the set
  117222. * @param emitter defines an optional mesh to use as emitter for the particle systems
  117223. */
  117224. start(emitter?: AbstractMesh): void;
  117225. /**
  117226. * Release all associated resources
  117227. */
  117228. dispose(): void;
  117229. /**
  117230. * Serialize the set into a JSON compatible object
  117231. * @returns a JSON compatible representation of the set
  117232. */
  117233. serialize(): any;
  117234. /**
  117235. * Parse a new ParticleSystemSet from a serialized source
  117236. * @param data defines a JSON compatible representation of the set
  117237. * @param scene defines the hosting scene
  117238. * @param gpu defines if we want GPU particles or CPU particles
  117239. * @returns a new ParticleSystemSet
  117240. */
  117241. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  117242. }
  117243. }
  117244. declare module BABYLON {
  117245. /**
  117246. * This class is made for on one-liner static method to help creating particle system set.
  117247. */
  117248. export class ParticleHelper {
  117249. /**
  117250. * Gets or sets base Assets URL
  117251. */
  117252. static BaseAssetsUrl: string;
  117253. /**
  117254. * Create a default particle system that you can tweak
  117255. * @param emitter defines the emitter to use
  117256. * @param capacity defines the system capacity (default is 500 particles)
  117257. * @param scene defines the hosting scene
  117258. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  117259. * @returns the new Particle system
  117260. */
  117261. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  117262. /**
  117263. * This is the main static method (one-liner) of this helper to create different particle systems
  117264. * @param type This string represents the type to the particle system to create
  117265. * @param scene The scene where the particle system should live
  117266. * @param gpu If the system will use gpu
  117267. * @returns the ParticleSystemSet created
  117268. */
  117269. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  117270. /**
  117271. * Static function used to export a particle system to a ParticleSystemSet variable.
  117272. * Please note that the emitter shape is not exported
  117273. * @param systems defines the particle systems to export
  117274. * @returns the created particle system set
  117275. */
  117276. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  117277. }
  117278. }
  117279. declare module BABYLON {
  117280. interface Engine {
  117281. /**
  117282. * Create an effect to use with particle systems.
  117283. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  117284. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  117285. * @param uniformsNames defines a list of attribute names
  117286. * @param samplers defines an array of string used to represent textures
  117287. * @param defines defines the string containing the defines to use to compile the shaders
  117288. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  117289. * @param onCompiled defines a function to call when the effect creation is successful
  117290. * @param onError defines a function to call when the effect creation has failed
  117291. * @returns the new Effect
  117292. */
  117293. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  117294. }
  117295. interface Mesh {
  117296. /**
  117297. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  117298. * @returns an array of IParticleSystem
  117299. */
  117300. getEmittedParticleSystems(): IParticleSystem[];
  117301. /**
  117302. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  117303. * @returns an array of IParticleSystem
  117304. */
  117305. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  117306. }
  117307. /**
  117308. * @hidden
  117309. */
  117310. export var _IDoNeedToBeInTheBuild: number;
  117311. }
  117312. declare module BABYLON {
  117313. interface Scene {
  117314. /** @hidden (Backing field) */
  117315. _physicsEngine: Nullable<IPhysicsEngine>;
  117316. /**
  117317. * Gets the current physics engine
  117318. * @returns a IPhysicsEngine or null if none attached
  117319. */
  117320. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  117321. /**
  117322. * Enables physics to the current scene
  117323. * @param gravity defines the scene's gravity for the physics engine
  117324. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  117325. * @return a boolean indicating if the physics engine was initialized
  117326. */
  117327. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  117328. /**
  117329. * Disables and disposes the physics engine associated with the scene
  117330. */
  117331. disablePhysicsEngine(): void;
  117332. /**
  117333. * Gets a boolean indicating if there is an active physics engine
  117334. * @returns a boolean indicating if there is an active physics engine
  117335. */
  117336. isPhysicsEnabled(): boolean;
  117337. /**
  117338. * Deletes a physics compound impostor
  117339. * @param compound defines the compound to delete
  117340. */
  117341. deleteCompoundImpostor(compound: any): void;
  117342. /**
  117343. * An event triggered when physic simulation is about to be run
  117344. */
  117345. onBeforePhysicsObservable: Observable<Scene>;
  117346. /**
  117347. * An event triggered when physic simulation has been done
  117348. */
  117349. onAfterPhysicsObservable: Observable<Scene>;
  117350. }
  117351. interface AbstractMesh {
  117352. /** @hidden */
  117353. _physicsImpostor: Nullable<PhysicsImpostor>;
  117354. /**
  117355. * Gets or sets impostor used for physic simulation
  117356. * @see http://doc.babylonjs.com/features/physics_engine
  117357. */
  117358. physicsImpostor: Nullable<PhysicsImpostor>;
  117359. /**
  117360. * Gets the current physics impostor
  117361. * @see http://doc.babylonjs.com/features/physics_engine
  117362. * @returns a physics impostor or null
  117363. */
  117364. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  117365. /** Apply a physic impulse to the mesh
  117366. * @param force defines the force to apply
  117367. * @param contactPoint defines where to apply the force
  117368. * @returns the current mesh
  117369. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117370. */
  117371. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  117372. /**
  117373. * Creates a physic joint between two meshes
  117374. * @param otherMesh defines the other mesh to use
  117375. * @param pivot1 defines the pivot to use on this mesh
  117376. * @param pivot2 defines the pivot to use on the other mesh
  117377. * @param options defines additional options (can be plugin dependent)
  117378. * @returns the current mesh
  117379. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  117380. */
  117381. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  117382. /** @hidden */
  117383. _disposePhysicsObserver: Nullable<Observer<Node>>;
  117384. }
  117385. /**
  117386. * Defines the physics engine scene component responsible to manage a physics engine
  117387. */
  117388. export class PhysicsEngineSceneComponent implements ISceneComponent {
  117389. /**
  117390. * The component name helpful to identify the component in the list of scene components.
  117391. */
  117392. readonly name: string;
  117393. /**
  117394. * The scene the component belongs to.
  117395. */
  117396. scene: Scene;
  117397. /**
  117398. * Creates a new instance of the component for the given scene
  117399. * @param scene Defines the scene to register the component in
  117400. */
  117401. constructor(scene: Scene);
  117402. /**
  117403. * Registers the component in a given scene
  117404. */
  117405. register(): void;
  117406. /**
  117407. * Rebuilds the elements related to this component in case of
  117408. * context lost for instance.
  117409. */
  117410. rebuild(): void;
  117411. /**
  117412. * Disposes the component and the associated ressources
  117413. */
  117414. dispose(): void;
  117415. }
  117416. }
  117417. declare module BABYLON {
  117418. /**
  117419. * A helper for physics simulations
  117420. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117421. */
  117422. export class PhysicsHelper {
  117423. private _scene;
  117424. private _physicsEngine;
  117425. /**
  117426. * Initializes the Physics helper
  117427. * @param scene Babylon.js scene
  117428. */
  117429. constructor(scene: Scene);
  117430. /**
  117431. * Applies a radial explosion impulse
  117432. * @param origin the origin of the explosion
  117433. * @param radiusOrEventOptions the radius or the options of radial explosion
  117434. * @param strength the explosion strength
  117435. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117436. * @returns A physics radial explosion event, or null
  117437. */
  117438. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117439. /**
  117440. * Applies a radial explosion force
  117441. * @param origin the origin of the explosion
  117442. * @param radiusOrEventOptions the radius or the options of radial explosion
  117443. * @param strength the explosion strength
  117444. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117445. * @returns A physics radial explosion event, or null
  117446. */
  117447. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117448. /**
  117449. * Creates a gravitational field
  117450. * @param origin the origin of the explosion
  117451. * @param radiusOrEventOptions the radius or the options of radial explosion
  117452. * @param strength the explosion strength
  117453. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117454. * @returns A physics gravitational field event, or null
  117455. */
  117456. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  117457. /**
  117458. * Creates a physics updraft event
  117459. * @param origin the origin of the updraft
  117460. * @param radiusOrEventOptions the radius or the options of the updraft
  117461. * @param strength the strength of the updraft
  117462. * @param height the height of the updraft
  117463. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  117464. * @returns A physics updraft event, or null
  117465. */
  117466. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  117467. /**
  117468. * Creates a physics vortex event
  117469. * @param origin the of the vortex
  117470. * @param radiusOrEventOptions the radius or the options of the vortex
  117471. * @param strength the strength of the vortex
  117472. * @param height the height of the vortex
  117473. * @returns a Physics vortex event, or null
  117474. * A physics vortex event or null
  117475. */
  117476. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  117477. }
  117478. /**
  117479. * Represents a physics radial explosion event
  117480. */
  117481. class PhysicsRadialExplosionEvent {
  117482. private _scene;
  117483. private _options;
  117484. private _sphere;
  117485. private _dataFetched;
  117486. /**
  117487. * Initializes a radial explosioin event
  117488. * @param _scene BabylonJS scene
  117489. * @param _options The options for the vortex event
  117490. */
  117491. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  117492. /**
  117493. * Returns the data related to the radial explosion event (sphere).
  117494. * @returns The radial explosion event data
  117495. */
  117496. getData(): PhysicsRadialExplosionEventData;
  117497. /**
  117498. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  117499. * @param impostor A physics imposter
  117500. * @param origin the origin of the explosion
  117501. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  117502. */
  117503. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  117504. /**
  117505. * Triggers affecterd impostors callbacks
  117506. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  117507. */
  117508. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  117509. /**
  117510. * Disposes the sphere.
  117511. * @param force Specifies if the sphere should be disposed by force
  117512. */
  117513. dispose(force?: boolean): void;
  117514. /*** Helpers ***/
  117515. private _prepareSphere;
  117516. private _intersectsWithSphere;
  117517. }
  117518. /**
  117519. * Represents a gravitational field event
  117520. */
  117521. class PhysicsGravitationalFieldEvent {
  117522. private _physicsHelper;
  117523. private _scene;
  117524. private _origin;
  117525. private _options;
  117526. private _tickCallback;
  117527. private _sphere;
  117528. private _dataFetched;
  117529. /**
  117530. * Initializes the physics gravitational field event
  117531. * @param _physicsHelper A physics helper
  117532. * @param _scene BabylonJS scene
  117533. * @param _origin The origin position of the gravitational field event
  117534. * @param _options The options for the vortex event
  117535. */
  117536. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  117537. /**
  117538. * Returns the data related to the gravitational field event (sphere).
  117539. * @returns A gravitational field event
  117540. */
  117541. getData(): PhysicsGravitationalFieldEventData;
  117542. /**
  117543. * Enables the gravitational field.
  117544. */
  117545. enable(): void;
  117546. /**
  117547. * Disables the gravitational field.
  117548. */
  117549. disable(): void;
  117550. /**
  117551. * Disposes the sphere.
  117552. * @param force The force to dispose from the gravitational field event
  117553. */
  117554. dispose(force?: boolean): void;
  117555. private _tick;
  117556. }
  117557. /**
  117558. * Represents a physics updraft event
  117559. */
  117560. class PhysicsUpdraftEvent {
  117561. private _scene;
  117562. private _origin;
  117563. private _options;
  117564. private _physicsEngine;
  117565. private _originTop;
  117566. private _originDirection;
  117567. private _tickCallback;
  117568. private _cylinder;
  117569. private _cylinderPosition;
  117570. private _dataFetched;
  117571. /**
  117572. * Initializes the physics updraft event
  117573. * @param _scene BabylonJS scene
  117574. * @param _origin The origin position of the updraft
  117575. * @param _options The options for the updraft event
  117576. */
  117577. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  117578. /**
  117579. * Returns the data related to the updraft event (cylinder).
  117580. * @returns A physics updraft event
  117581. */
  117582. getData(): PhysicsUpdraftEventData;
  117583. /**
  117584. * Enables the updraft.
  117585. */
  117586. enable(): void;
  117587. /**
  117588. * Disables the updraft.
  117589. */
  117590. disable(): void;
  117591. /**
  117592. * Disposes the cylinder.
  117593. * @param force Specifies if the updraft should be disposed by force
  117594. */
  117595. dispose(force?: boolean): void;
  117596. private getImpostorHitData;
  117597. private _tick;
  117598. /*** Helpers ***/
  117599. private _prepareCylinder;
  117600. private _intersectsWithCylinder;
  117601. }
  117602. /**
  117603. * Represents a physics vortex event
  117604. */
  117605. class PhysicsVortexEvent {
  117606. private _scene;
  117607. private _origin;
  117608. private _options;
  117609. private _physicsEngine;
  117610. private _originTop;
  117611. private _tickCallback;
  117612. private _cylinder;
  117613. private _cylinderPosition;
  117614. private _dataFetched;
  117615. /**
  117616. * Initializes the physics vortex event
  117617. * @param _scene The BabylonJS scene
  117618. * @param _origin The origin position of the vortex
  117619. * @param _options The options for the vortex event
  117620. */
  117621. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  117622. /**
  117623. * Returns the data related to the vortex event (cylinder).
  117624. * @returns The physics vortex event data
  117625. */
  117626. getData(): PhysicsVortexEventData;
  117627. /**
  117628. * Enables the vortex.
  117629. */
  117630. enable(): void;
  117631. /**
  117632. * Disables the cortex.
  117633. */
  117634. disable(): void;
  117635. /**
  117636. * Disposes the sphere.
  117637. * @param force
  117638. */
  117639. dispose(force?: boolean): void;
  117640. private getImpostorHitData;
  117641. private _tick;
  117642. /*** Helpers ***/
  117643. private _prepareCylinder;
  117644. private _intersectsWithCylinder;
  117645. }
  117646. /**
  117647. * Options fot the radial explosion event
  117648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117649. */
  117650. export class PhysicsRadialExplosionEventOptions {
  117651. /**
  117652. * The radius of the sphere for the radial explosion.
  117653. */
  117654. radius: number;
  117655. /**
  117656. * The strenth of the explosion.
  117657. */
  117658. strength: number;
  117659. /**
  117660. * The strenght of the force in correspondence to the distance of the affected object
  117661. */
  117662. falloff: PhysicsRadialImpulseFalloff;
  117663. /**
  117664. * Sphere options for the radial explosion.
  117665. */
  117666. sphere: {
  117667. segments: number;
  117668. diameter: number;
  117669. };
  117670. /**
  117671. * Sphere options for the radial explosion.
  117672. */
  117673. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  117674. }
  117675. /**
  117676. * Options fot the updraft event
  117677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117678. */
  117679. export class PhysicsUpdraftEventOptions {
  117680. /**
  117681. * The radius of the cylinder for the vortex
  117682. */
  117683. radius: number;
  117684. /**
  117685. * The strenth of the updraft.
  117686. */
  117687. strength: number;
  117688. /**
  117689. * The height of the cylinder for the updraft.
  117690. */
  117691. height: number;
  117692. /**
  117693. * The mode for the the updraft.
  117694. */
  117695. updraftMode: PhysicsUpdraftMode;
  117696. }
  117697. /**
  117698. * Options fot the vortex event
  117699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117700. */
  117701. export class PhysicsVortexEventOptions {
  117702. /**
  117703. * The radius of the cylinder for the vortex
  117704. */
  117705. radius: number;
  117706. /**
  117707. * The strenth of the vortex.
  117708. */
  117709. strength: number;
  117710. /**
  117711. * The height of the cylinder for the vortex.
  117712. */
  117713. height: number;
  117714. /**
  117715. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  117716. */
  117717. centripetalForceThreshold: number;
  117718. /**
  117719. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  117720. */
  117721. centripetalForceMultiplier: number;
  117722. /**
  117723. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  117724. */
  117725. centrifugalForceMultiplier: number;
  117726. /**
  117727. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  117728. */
  117729. updraftForceMultiplier: number;
  117730. }
  117731. /**
  117732. * The strenght of the force in correspondence to the distance of the affected object
  117733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117734. */
  117735. export enum PhysicsRadialImpulseFalloff {
  117736. /** Defines that impulse is constant in strength across it's whole radius */
  117737. Constant = 0,
  117738. /** Defines that impulse gets weaker if it's further from the origin */
  117739. Linear = 1
  117740. }
  117741. /**
  117742. * The strength of the force in correspondence to the distance of the affected object
  117743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117744. */
  117745. export enum PhysicsUpdraftMode {
  117746. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  117747. Center = 0,
  117748. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  117749. Perpendicular = 1
  117750. }
  117751. /**
  117752. * Interface for a physics hit data
  117753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117754. */
  117755. export interface PhysicsHitData {
  117756. /**
  117757. * The force applied at the contact point
  117758. */
  117759. force: Vector3;
  117760. /**
  117761. * The contact point
  117762. */
  117763. contactPoint: Vector3;
  117764. /**
  117765. * The distance from the origin to the contact point
  117766. */
  117767. distanceFromOrigin: number;
  117768. }
  117769. /**
  117770. * Interface for radial explosion event data
  117771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117772. */
  117773. export interface PhysicsRadialExplosionEventData {
  117774. /**
  117775. * A sphere used for the radial explosion event
  117776. */
  117777. sphere: Mesh;
  117778. }
  117779. /**
  117780. * Interface for gravitational field event data
  117781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117782. */
  117783. export interface PhysicsGravitationalFieldEventData {
  117784. /**
  117785. * A sphere mesh used for the gravitational field event
  117786. */
  117787. sphere: Mesh;
  117788. }
  117789. /**
  117790. * Interface for updraft event data
  117791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117792. */
  117793. export interface PhysicsUpdraftEventData {
  117794. /**
  117795. * A cylinder used for the updraft event
  117796. */
  117797. cylinder: Mesh;
  117798. }
  117799. /**
  117800. * Interface for vortex event data
  117801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117802. */
  117803. export interface PhysicsVortexEventData {
  117804. /**
  117805. * A cylinder used for the vortex event
  117806. */
  117807. cylinder: Mesh;
  117808. }
  117809. /**
  117810. * Interface for an affected physics impostor
  117811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117812. */
  117813. export interface PhysicsAffectedImpostorWithData {
  117814. /**
  117815. * The impostor affected by the effect
  117816. */
  117817. impostor: PhysicsImpostor;
  117818. /**
  117819. * The data about the hit/horce from the explosion
  117820. */
  117821. hitData: PhysicsHitData;
  117822. }
  117823. }
  117824. declare module BABYLON {
  117825. /** @hidden */
  117826. export var blackAndWhitePixelShader: {
  117827. name: string;
  117828. shader: string;
  117829. };
  117830. }
  117831. declare module BABYLON {
  117832. /**
  117833. * Post process used to render in black and white
  117834. */
  117835. export class BlackAndWhitePostProcess extends PostProcess {
  117836. /**
  117837. * Linear about to convert he result to black and white (default: 1)
  117838. */
  117839. degree: number;
  117840. /**
  117841. * Creates a black and white post process
  117842. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  117843. * @param name The name of the effect.
  117844. * @param options The required width/height ratio to downsize to before computing the render pass.
  117845. * @param camera The camera to apply the render pass to.
  117846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117847. * @param engine The engine which the post process will be applied. (default: current engine)
  117848. * @param reusable If the post process can be reused on the same frame. (default: false)
  117849. */
  117850. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117851. }
  117852. }
  117853. declare module BABYLON {
  117854. /**
  117855. * This represents a set of one or more post processes in Babylon.
  117856. * A post process can be used to apply a shader to a texture after it is rendered.
  117857. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117858. */
  117859. export class PostProcessRenderEffect {
  117860. private _postProcesses;
  117861. private _getPostProcesses;
  117862. private _singleInstance;
  117863. private _cameras;
  117864. private _indicesForCamera;
  117865. /**
  117866. * Name of the effect
  117867. * @hidden
  117868. */
  117869. _name: string;
  117870. /**
  117871. * Instantiates a post process render effect.
  117872. * A post process can be used to apply a shader to a texture after it is rendered.
  117873. * @param engine The engine the effect is tied to
  117874. * @param name The name of the effect
  117875. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  117876. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  117877. */
  117878. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  117879. /**
  117880. * Checks if all the post processes in the effect are supported.
  117881. */
  117882. readonly isSupported: boolean;
  117883. /**
  117884. * Updates the current state of the effect
  117885. * @hidden
  117886. */
  117887. _update(): void;
  117888. /**
  117889. * Attaches the effect on cameras
  117890. * @param cameras The camera to attach to.
  117891. * @hidden
  117892. */
  117893. _attachCameras(cameras: Camera): void;
  117894. /**
  117895. * Attaches the effect on cameras
  117896. * @param cameras The camera to attach to.
  117897. * @hidden
  117898. */
  117899. _attachCameras(cameras: Camera[]): void;
  117900. /**
  117901. * Detaches the effect on cameras
  117902. * @param cameras The camera to detatch from.
  117903. * @hidden
  117904. */
  117905. _detachCameras(cameras: Camera): void;
  117906. /**
  117907. * Detatches the effect on cameras
  117908. * @param cameras The camera to detatch from.
  117909. * @hidden
  117910. */
  117911. _detachCameras(cameras: Camera[]): void;
  117912. /**
  117913. * Enables the effect on given cameras
  117914. * @param cameras The camera to enable.
  117915. * @hidden
  117916. */
  117917. _enable(cameras: Camera): void;
  117918. /**
  117919. * Enables the effect on given cameras
  117920. * @param cameras The camera to enable.
  117921. * @hidden
  117922. */
  117923. _enable(cameras: Nullable<Camera[]>): void;
  117924. /**
  117925. * Disables the effect on the given cameras
  117926. * @param cameras The camera to disable.
  117927. * @hidden
  117928. */
  117929. _disable(cameras: Camera): void;
  117930. /**
  117931. * Disables the effect on the given cameras
  117932. * @param cameras The camera to disable.
  117933. * @hidden
  117934. */
  117935. _disable(cameras: Nullable<Camera[]>): void;
  117936. /**
  117937. * Gets a list of the post processes contained in the effect.
  117938. * @param camera The camera to get the post processes on.
  117939. * @returns The list of the post processes in the effect.
  117940. */
  117941. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  117942. }
  117943. }
  117944. declare module BABYLON {
  117945. /** @hidden */
  117946. export var extractHighlightsPixelShader: {
  117947. name: string;
  117948. shader: string;
  117949. };
  117950. }
  117951. declare module BABYLON {
  117952. /**
  117953. * 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.
  117954. */
  117955. export class ExtractHighlightsPostProcess extends PostProcess {
  117956. /**
  117957. * The luminance threshold, pixels below this value will be set to black.
  117958. */
  117959. threshold: number;
  117960. /** @hidden */
  117961. _exposure: number;
  117962. /**
  117963. * Post process which has the input texture to be used when performing highlight extraction
  117964. * @hidden
  117965. */
  117966. _inputPostProcess: Nullable<PostProcess>;
  117967. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117968. }
  117969. }
  117970. declare module BABYLON {
  117971. /** @hidden */
  117972. export var bloomMergePixelShader: {
  117973. name: string;
  117974. shader: string;
  117975. };
  117976. }
  117977. declare module BABYLON {
  117978. /**
  117979. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117980. */
  117981. export class BloomMergePostProcess extends PostProcess {
  117982. /** Weight of the bloom to be added to the original input. */
  117983. weight: number;
  117984. /**
  117985. * Creates a new instance of @see BloomMergePostProcess
  117986. * @param name The name of the effect.
  117987. * @param originalFromInput Post process which's input will be used for the merge.
  117988. * @param blurred Blurred highlights post process which's output will be used.
  117989. * @param weight Weight of the bloom to be added to the original input.
  117990. * @param options The required width/height ratio to downsize to before computing the render pass.
  117991. * @param camera The camera to apply the render pass to.
  117992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117993. * @param engine The engine which the post process will be applied. (default: current engine)
  117994. * @param reusable If the post process can be reused on the same frame. (default: false)
  117995. * @param textureType Type of textures used when performing the post process. (default: 0)
  117996. * @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)
  117997. */
  117998. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  117999. /** Weight of the bloom to be added to the original input. */
  118000. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118001. }
  118002. }
  118003. declare module BABYLON {
  118004. /**
  118005. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  118006. */
  118007. export class BloomEffect extends PostProcessRenderEffect {
  118008. private bloomScale;
  118009. /**
  118010. * @hidden Internal
  118011. */
  118012. _effects: Array<PostProcess>;
  118013. /**
  118014. * @hidden Internal
  118015. */
  118016. _downscale: ExtractHighlightsPostProcess;
  118017. private _blurX;
  118018. private _blurY;
  118019. private _merge;
  118020. /**
  118021. * The luminance threshold to find bright areas of the image to bloom.
  118022. */
  118023. threshold: number;
  118024. /**
  118025. * The strength of the bloom.
  118026. */
  118027. weight: number;
  118028. /**
  118029. * Specifies the size of the bloom blur kernel, relative to the final output size
  118030. */
  118031. kernel: number;
  118032. /**
  118033. * Creates a new instance of @see BloomEffect
  118034. * @param scene The scene the effect belongs to.
  118035. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  118036. * @param bloomKernel The size of the kernel to be used when applying the blur.
  118037. * @param bloomWeight The the strength of bloom.
  118038. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118039. * @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)
  118040. */
  118041. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  118042. /**
  118043. * Disposes each of the internal effects for a given camera.
  118044. * @param camera The camera to dispose the effect on.
  118045. */
  118046. disposeEffects(camera: Camera): void;
  118047. /**
  118048. * @hidden Internal
  118049. */
  118050. _updateEffects(): void;
  118051. /**
  118052. * Internal
  118053. * @returns if all the contained post processes are ready.
  118054. * @hidden
  118055. */
  118056. _isReady(): boolean;
  118057. }
  118058. }
  118059. declare module BABYLON {
  118060. /** @hidden */
  118061. export var chromaticAberrationPixelShader: {
  118062. name: string;
  118063. shader: string;
  118064. };
  118065. }
  118066. declare module BABYLON {
  118067. /**
  118068. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  118069. */
  118070. export class ChromaticAberrationPostProcess extends PostProcess {
  118071. /**
  118072. * The amount of seperation of rgb channels (default: 30)
  118073. */
  118074. aberrationAmount: number;
  118075. /**
  118076. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  118077. */
  118078. radialIntensity: number;
  118079. /**
  118080. * 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))
  118081. */
  118082. direction: Vector2;
  118083. /**
  118084. * 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))
  118085. */
  118086. centerPosition: Vector2;
  118087. /**
  118088. * Creates a new instance ChromaticAberrationPostProcess
  118089. * @param name The name of the effect.
  118090. * @param screenWidth The width of the screen to apply the effect on.
  118091. * @param screenHeight The height of the screen to apply the effect on.
  118092. * @param options The required width/height ratio to downsize to before computing the render pass.
  118093. * @param camera The camera to apply the render pass to.
  118094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118095. * @param engine The engine which the post process will be applied. (default: current engine)
  118096. * @param reusable If the post process can be reused on the same frame. (default: false)
  118097. * @param textureType Type of textures used when performing the post process. (default: 0)
  118098. * @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)
  118099. */
  118100. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118101. }
  118102. }
  118103. declare module BABYLON {
  118104. /** @hidden */
  118105. export var circleOfConfusionPixelShader: {
  118106. name: string;
  118107. shader: string;
  118108. };
  118109. }
  118110. declare module BABYLON {
  118111. /**
  118112. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  118113. */
  118114. export class CircleOfConfusionPostProcess extends PostProcess {
  118115. /**
  118116. * 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.
  118117. */
  118118. lensSize: number;
  118119. /**
  118120. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118121. */
  118122. fStop: number;
  118123. /**
  118124. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118125. */
  118126. focusDistance: number;
  118127. /**
  118128. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  118129. */
  118130. focalLength: number;
  118131. private _depthTexture;
  118132. /**
  118133. * Creates a new instance CircleOfConfusionPostProcess
  118134. * @param name The name of the effect.
  118135. * @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.
  118136. * @param options The required width/height ratio to downsize to before computing the render pass.
  118137. * @param camera The camera to apply the render pass to.
  118138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118139. * @param engine The engine which the post process will be applied. (default: current engine)
  118140. * @param reusable If the post process can be reused on the same frame. (default: false)
  118141. * @param textureType Type of textures used when performing the post process. (default: 0)
  118142. * @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)
  118143. */
  118144. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118145. /**
  118146. * 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.
  118147. */
  118148. depthTexture: RenderTargetTexture;
  118149. }
  118150. }
  118151. declare module BABYLON {
  118152. /** @hidden */
  118153. export var colorCorrectionPixelShader: {
  118154. name: string;
  118155. shader: string;
  118156. };
  118157. }
  118158. declare module BABYLON {
  118159. /**
  118160. *
  118161. * This post-process allows the modification of rendered colors by using
  118162. * a 'look-up table' (LUT). This effect is also called Color Grading.
  118163. *
  118164. * The object needs to be provided an url to a texture containing the color
  118165. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  118166. * Use an image editing software to tweak the LUT to match your needs.
  118167. *
  118168. * For an example of a color LUT, see here:
  118169. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  118170. * For explanations on color grading, see here:
  118171. * @see http://udn.epicgames.com/Three/ColorGrading.html
  118172. *
  118173. */
  118174. export class ColorCorrectionPostProcess extends PostProcess {
  118175. private _colorTableTexture;
  118176. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118177. }
  118178. }
  118179. declare module BABYLON {
  118180. /** @hidden */
  118181. export var convolutionPixelShader: {
  118182. name: string;
  118183. shader: string;
  118184. };
  118185. }
  118186. declare module BABYLON {
  118187. /**
  118188. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  118189. * input texture to perform effects such as edge detection or sharpening
  118190. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118191. */
  118192. export class ConvolutionPostProcess extends PostProcess {
  118193. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118194. kernel: number[];
  118195. /**
  118196. * Creates a new instance ConvolutionPostProcess
  118197. * @param name The name of the effect.
  118198. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  118199. * @param options The required width/height ratio to downsize to before computing the render pass.
  118200. * @param camera The camera to apply the render pass to.
  118201. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118202. * @param engine The engine which the post process will be applied. (default: current engine)
  118203. * @param reusable If the post process can be reused on the same frame. (default: false)
  118204. * @param textureType Type of textures used when performing the post process. (default: 0)
  118205. */
  118206. constructor(name: string,
  118207. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118208. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118209. /**
  118210. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118211. */
  118212. static EdgeDetect0Kernel: number[];
  118213. /**
  118214. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118215. */
  118216. static EdgeDetect1Kernel: number[];
  118217. /**
  118218. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118219. */
  118220. static EdgeDetect2Kernel: number[];
  118221. /**
  118222. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118223. */
  118224. static SharpenKernel: number[];
  118225. /**
  118226. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118227. */
  118228. static EmbossKernel: number[];
  118229. /**
  118230. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118231. */
  118232. static GaussianKernel: number[];
  118233. }
  118234. }
  118235. declare module BABYLON {
  118236. /**
  118237. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  118238. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  118239. * based on samples that have a large difference in distance than the center pixel.
  118240. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  118241. */
  118242. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  118243. direction: Vector2;
  118244. /**
  118245. * Creates a new instance CircleOfConfusionPostProcess
  118246. * @param name The name of the effect.
  118247. * @param scene The scene the effect belongs to.
  118248. * @param direction The direction the blur should be applied.
  118249. * @param kernel The size of the kernel used to blur.
  118250. * @param options The required width/height ratio to downsize to before computing the render pass.
  118251. * @param camera The camera to apply the render pass to.
  118252. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  118253. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  118254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118255. * @param engine The engine which the post process will be applied. (default: current engine)
  118256. * @param reusable If the post process can be reused on the same frame. (default: false)
  118257. * @param textureType Type of textures used when performing the post process. (default: 0)
  118258. * @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)
  118259. */
  118260. 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);
  118261. }
  118262. }
  118263. declare module BABYLON {
  118264. /** @hidden */
  118265. export var depthOfFieldMergePixelShader: {
  118266. name: string;
  118267. shader: string;
  118268. };
  118269. }
  118270. declare module BABYLON {
  118271. /**
  118272. * Options to be set when merging outputs from the default pipeline.
  118273. */
  118274. export class DepthOfFieldMergePostProcessOptions {
  118275. /**
  118276. * The original image to merge on top of
  118277. */
  118278. originalFromInput: PostProcess;
  118279. /**
  118280. * Parameters to perform the merge of the depth of field effect
  118281. */
  118282. depthOfField?: {
  118283. circleOfConfusion: PostProcess;
  118284. blurSteps: Array<PostProcess>;
  118285. };
  118286. /**
  118287. * Parameters to perform the merge of bloom effect
  118288. */
  118289. bloom?: {
  118290. blurred: PostProcess;
  118291. weight: number;
  118292. };
  118293. }
  118294. /**
  118295. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118296. */
  118297. export class DepthOfFieldMergePostProcess extends PostProcess {
  118298. private blurSteps;
  118299. /**
  118300. * Creates a new instance of DepthOfFieldMergePostProcess
  118301. * @param name The name of the effect.
  118302. * @param originalFromInput Post process which's input will be used for the merge.
  118303. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  118304. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  118305. * @param options The required width/height ratio to downsize to before computing the render pass.
  118306. * @param camera The camera to apply the render pass to.
  118307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118308. * @param engine The engine which the post process will be applied. (default: current engine)
  118309. * @param reusable If the post process can be reused on the same frame. (default: false)
  118310. * @param textureType Type of textures used when performing the post process. (default: 0)
  118311. * @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)
  118312. */
  118313. 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);
  118314. /**
  118315. * Updates the effect with the current post process compile time values and recompiles the shader.
  118316. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118317. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118318. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118319. * @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
  118320. * @param onCompiled Called when the shader has been compiled.
  118321. * @param onError Called if there is an error when compiling a shader.
  118322. */
  118323. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  118324. }
  118325. }
  118326. declare module BABYLON {
  118327. /**
  118328. * Specifies the level of max blur that should be applied when using the depth of field effect
  118329. */
  118330. export enum DepthOfFieldEffectBlurLevel {
  118331. /**
  118332. * Subtle blur
  118333. */
  118334. Low = 0,
  118335. /**
  118336. * Medium blur
  118337. */
  118338. Medium = 1,
  118339. /**
  118340. * Large blur
  118341. */
  118342. High = 2
  118343. }
  118344. /**
  118345. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  118346. */
  118347. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  118348. private _circleOfConfusion;
  118349. /**
  118350. * @hidden Internal, blurs from high to low
  118351. */
  118352. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  118353. private _depthOfFieldBlurY;
  118354. private _dofMerge;
  118355. /**
  118356. * @hidden Internal post processes in depth of field effect
  118357. */
  118358. _effects: Array<PostProcess>;
  118359. /**
  118360. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  118361. */
  118362. focalLength: number;
  118363. /**
  118364. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118365. */
  118366. fStop: number;
  118367. /**
  118368. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118369. */
  118370. focusDistance: number;
  118371. /**
  118372. * 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.
  118373. */
  118374. lensSize: number;
  118375. /**
  118376. * Creates a new instance DepthOfFieldEffect
  118377. * @param scene The scene the effect belongs to.
  118378. * @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.
  118379. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118380. * @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)
  118381. */
  118382. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  118383. /**
  118384. * Get the current class name of the current effet
  118385. * @returns "DepthOfFieldEffect"
  118386. */
  118387. getClassName(): string;
  118388. /**
  118389. * 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.
  118390. */
  118391. depthTexture: RenderTargetTexture;
  118392. /**
  118393. * Disposes each of the internal effects for a given camera.
  118394. * @param camera The camera to dispose the effect on.
  118395. */
  118396. disposeEffects(camera: Camera): void;
  118397. /**
  118398. * @hidden Internal
  118399. */
  118400. _updateEffects(): void;
  118401. /**
  118402. * Internal
  118403. * @returns if all the contained post processes are ready.
  118404. * @hidden
  118405. */
  118406. _isReady(): boolean;
  118407. }
  118408. }
  118409. declare module BABYLON {
  118410. /** @hidden */
  118411. export var displayPassPixelShader: {
  118412. name: string;
  118413. shader: string;
  118414. };
  118415. }
  118416. declare module BABYLON {
  118417. /**
  118418. * DisplayPassPostProcess which produces an output the same as it's input
  118419. */
  118420. export class DisplayPassPostProcess extends PostProcess {
  118421. /**
  118422. * Creates the DisplayPassPostProcess
  118423. * @param name The name of the effect.
  118424. * @param options The required width/height ratio to downsize to before computing the render pass.
  118425. * @param camera The camera to apply the render pass to.
  118426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118427. * @param engine The engine which the post process will be applied. (default: current engine)
  118428. * @param reusable If the post process can be reused on the same frame. (default: false)
  118429. */
  118430. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118431. }
  118432. }
  118433. declare module BABYLON {
  118434. /** @hidden */
  118435. export var filterPixelShader: {
  118436. name: string;
  118437. shader: string;
  118438. };
  118439. }
  118440. declare module BABYLON {
  118441. /**
  118442. * Applies a kernel filter to the image
  118443. */
  118444. export class FilterPostProcess extends PostProcess {
  118445. /** The matrix to be applied to the image */
  118446. kernelMatrix: Matrix;
  118447. /**
  118448. *
  118449. * @param name The name of the effect.
  118450. * @param kernelMatrix The matrix to be applied to the image
  118451. * @param options The required width/height ratio to downsize to before computing the render pass.
  118452. * @param camera The camera to apply the render pass to.
  118453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118454. * @param engine The engine which the post process will be applied. (default: current engine)
  118455. * @param reusable If the post process can be reused on the same frame. (default: false)
  118456. */
  118457. constructor(name: string,
  118458. /** The matrix to be applied to the image */
  118459. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118460. }
  118461. }
  118462. declare module BABYLON {
  118463. /** @hidden */
  118464. export var fxaaPixelShader: {
  118465. name: string;
  118466. shader: string;
  118467. };
  118468. }
  118469. declare module BABYLON {
  118470. /** @hidden */
  118471. export var fxaaVertexShader: {
  118472. name: string;
  118473. shader: string;
  118474. };
  118475. }
  118476. declare module BABYLON {
  118477. /**
  118478. * Fxaa post process
  118479. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  118480. */
  118481. export class FxaaPostProcess extends PostProcess {
  118482. /** @hidden */
  118483. texelWidth: number;
  118484. /** @hidden */
  118485. texelHeight: number;
  118486. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118487. private _getDefines;
  118488. }
  118489. }
  118490. declare module BABYLON {
  118491. /** @hidden */
  118492. export var grainPixelShader: {
  118493. name: string;
  118494. shader: string;
  118495. };
  118496. }
  118497. declare module BABYLON {
  118498. /**
  118499. * The GrainPostProcess adds noise to the image at mid luminance levels
  118500. */
  118501. export class GrainPostProcess extends PostProcess {
  118502. /**
  118503. * The intensity of the grain added (default: 30)
  118504. */
  118505. intensity: number;
  118506. /**
  118507. * If the grain should be randomized on every frame
  118508. */
  118509. animated: boolean;
  118510. /**
  118511. * Creates a new instance of @see GrainPostProcess
  118512. * @param name The name of the effect.
  118513. * @param options The required width/height ratio to downsize to before computing the render pass.
  118514. * @param camera The camera to apply the render pass to.
  118515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118516. * @param engine The engine which the post process will be applied. (default: current engine)
  118517. * @param reusable If the post process can be reused on the same frame. (default: false)
  118518. * @param textureType Type of textures used when performing the post process. (default: 0)
  118519. * @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)
  118520. */
  118521. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118522. }
  118523. }
  118524. declare module BABYLON {
  118525. /** @hidden */
  118526. export var highlightsPixelShader: {
  118527. name: string;
  118528. shader: string;
  118529. };
  118530. }
  118531. declare module BABYLON {
  118532. /**
  118533. * Extracts highlights from the image
  118534. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118535. */
  118536. export class HighlightsPostProcess extends PostProcess {
  118537. /**
  118538. * Extracts highlights from the image
  118539. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118540. * @param name The name of the effect.
  118541. * @param options The required width/height ratio to downsize to before computing the render pass.
  118542. * @param camera The camera to apply the render pass to.
  118543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118544. * @param engine The engine which the post process will be applied. (default: current engine)
  118545. * @param reusable If the post process can be reused on the same frame. (default: false)
  118546. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  118547. */
  118548. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118549. }
  118550. }
  118551. declare module BABYLON {
  118552. /** @hidden */
  118553. export var mrtFragmentDeclaration: {
  118554. name: string;
  118555. shader: string;
  118556. };
  118557. }
  118558. declare module BABYLON {
  118559. /** @hidden */
  118560. export var geometryPixelShader: {
  118561. name: string;
  118562. shader: string;
  118563. };
  118564. }
  118565. declare module BABYLON {
  118566. /** @hidden */
  118567. export var geometryVertexShader: {
  118568. name: string;
  118569. shader: string;
  118570. };
  118571. }
  118572. declare module BABYLON {
  118573. /** @hidden */
  118574. interface ISavedTransformationMatrix {
  118575. world: Matrix;
  118576. viewProjection: Matrix;
  118577. }
  118578. /**
  118579. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  118580. */
  118581. export class GeometryBufferRenderer {
  118582. /**
  118583. * Constant used to retrieve the position texture index in the G-Buffer textures array
  118584. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  118585. */
  118586. static readonly POSITION_TEXTURE_TYPE: number;
  118587. /**
  118588. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  118589. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  118590. */
  118591. static readonly VELOCITY_TEXTURE_TYPE: number;
  118592. /**
  118593. * Dictionary used to store the previous transformation matrices of each rendered mesh
  118594. * in order to compute objects velocities when enableVelocity is set to "true"
  118595. * @hidden
  118596. */
  118597. _previousTransformationMatrices: {
  118598. [index: number]: ISavedTransformationMatrix;
  118599. };
  118600. /**
  118601. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  118602. * in order to compute objects velocities when enableVelocity is set to "true"
  118603. * @hidden
  118604. */
  118605. _previousBonesTransformationMatrices: {
  118606. [index: number]: Float32Array;
  118607. };
  118608. /**
  118609. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  118610. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  118611. */
  118612. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  118613. private _scene;
  118614. private _multiRenderTarget;
  118615. private _ratio;
  118616. private _enablePosition;
  118617. private _enableVelocity;
  118618. private _positionIndex;
  118619. private _velocityIndex;
  118620. protected _effect: Effect;
  118621. protected _cachedDefines: string;
  118622. /**
  118623. * Set the render list (meshes to be rendered) used in the G buffer.
  118624. */
  118625. renderList: Mesh[];
  118626. /**
  118627. * Gets wether or not G buffer are supported by the running hardware.
  118628. * This requires draw buffer supports
  118629. */
  118630. readonly isSupported: boolean;
  118631. /**
  118632. * Returns the index of the given texture type in the G-Buffer textures array
  118633. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  118634. * @returns the index of the given texture type in the G-Buffer textures array
  118635. */
  118636. getTextureIndex(textureType: number): number;
  118637. /**
  118638. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  118639. */
  118640. /**
  118641. * Sets whether or not objects positions are enabled for the G buffer.
  118642. */
  118643. enablePosition: boolean;
  118644. /**
  118645. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  118646. */
  118647. /**
  118648. * Sets wether or not objects velocities are enabled for the G buffer.
  118649. */
  118650. enableVelocity: boolean;
  118651. /**
  118652. * Gets the scene associated with the buffer.
  118653. */
  118654. readonly scene: Scene;
  118655. /**
  118656. * Gets the ratio used by the buffer during its creation.
  118657. * How big is the buffer related to the main canvas.
  118658. */
  118659. readonly ratio: number;
  118660. /** @hidden */
  118661. static _SceneComponentInitialization: (scene: Scene) => void;
  118662. /**
  118663. * Creates a new G Buffer for the scene
  118664. * @param scene The scene the buffer belongs to
  118665. * @param ratio How big is the buffer related to the main canvas.
  118666. */
  118667. constructor(scene: Scene, ratio?: number);
  118668. /**
  118669. * Checks wether everything is ready to render a submesh to the G buffer.
  118670. * @param subMesh the submesh to check readiness for
  118671. * @param useInstances is the mesh drawn using instance or not
  118672. * @returns true if ready otherwise false
  118673. */
  118674. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118675. /**
  118676. * Gets the current underlying G Buffer.
  118677. * @returns the buffer
  118678. */
  118679. getGBuffer(): MultiRenderTarget;
  118680. /**
  118681. * Gets the number of samples used to render the buffer (anti aliasing).
  118682. */
  118683. /**
  118684. * Sets the number of samples used to render the buffer (anti aliasing).
  118685. */
  118686. samples: number;
  118687. /**
  118688. * Disposes the renderer and frees up associated resources.
  118689. */
  118690. dispose(): void;
  118691. protected _createRenderTargets(): void;
  118692. private _copyBonesTransformationMatrices;
  118693. }
  118694. }
  118695. declare module BABYLON {
  118696. interface Scene {
  118697. /** @hidden (Backing field) */
  118698. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118699. /**
  118700. * Gets or Sets the current geometry buffer associated to the scene.
  118701. */
  118702. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118703. /**
  118704. * Enables a GeometryBufferRender and associates it with the scene
  118705. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  118706. * @returns the GeometryBufferRenderer
  118707. */
  118708. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  118709. /**
  118710. * Disables the GeometryBufferRender associated with the scene
  118711. */
  118712. disableGeometryBufferRenderer(): void;
  118713. }
  118714. /**
  118715. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  118716. * in several rendering techniques.
  118717. */
  118718. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  118719. /**
  118720. * The component name helpful to identify the component in the list of scene components.
  118721. */
  118722. readonly name: string;
  118723. /**
  118724. * The scene the component belongs to.
  118725. */
  118726. scene: Scene;
  118727. /**
  118728. * Creates a new instance of the component for the given scene
  118729. * @param scene Defines the scene to register the component in
  118730. */
  118731. constructor(scene: Scene);
  118732. /**
  118733. * Registers the component in a given scene
  118734. */
  118735. register(): void;
  118736. /**
  118737. * Rebuilds the elements related to this component in case of
  118738. * context lost for instance.
  118739. */
  118740. rebuild(): void;
  118741. /**
  118742. * Disposes the component and the associated ressources
  118743. */
  118744. dispose(): void;
  118745. private _gatherRenderTargets;
  118746. }
  118747. }
  118748. declare module BABYLON {
  118749. /** @hidden */
  118750. export var motionBlurPixelShader: {
  118751. name: string;
  118752. shader: string;
  118753. };
  118754. }
  118755. declare module BABYLON {
  118756. /**
  118757. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118758. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118759. * As an example, all you have to do is to create the post-process:
  118760. * var mb = new BABYLON.MotionBlurPostProcess(
  118761. * 'mb', // The name of the effect.
  118762. * scene, // The scene containing the objects to blur according to their velocity.
  118763. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118764. * camera // The camera to apply the render pass to.
  118765. * );
  118766. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118767. */
  118768. export class MotionBlurPostProcess extends PostProcess {
  118769. /**
  118770. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118771. */
  118772. motionStrength: number;
  118773. /**
  118774. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118775. */
  118776. /**
  118777. * Sets the number of iterations to be used for motion blur quality
  118778. */
  118779. motionBlurSamples: number;
  118780. private _motionBlurSamples;
  118781. private _geometryBufferRenderer;
  118782. /**
  118783. * Creates a new instance MotionBlurPostProcess
  118784. * @param name The name of the effect.
  118785. * @param scene The scene containing the objects to blur according to their velocity.
  118786. * @param options The required width/height ratio to downsize to before computing the render pass.
  118787. * @param camera The camera to apply the render pass to.
  118788. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118789. * @param engine The engine which the post process will be applied. (default: current engine)
  118790. * @param reusable If the post process can be reused on the same frame. (default: false)
  118791. * @param textureType Type of textures used when performing the post process. (default: 0)
  118792. * @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)
  118793. */
  118794. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118795. /**
  118796. * Excludes the given skinned mesh from computing bones velocities.
  118797. * 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.
  118798. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  118799. */
  118800. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118801. /**
  118802. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  118803. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  118804. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  118805. */
  118806. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118807. /**
  118808. * Disposes the post process.
  118809. * @param camera The camera to dispose the post process on.
  118810. */
  118811. dispose(camera?: Camera): void;
  118812. }
  118813. }
  118814. declare module BABYLON {
  118815. /** @hidden */
  118816. export var refractionPixelShader: {
  118817. name: string;
  118818. shader: string;
  118819. };
  118820. }
  118821. declare module BABYLON {
  118822. /**
  118823. * Post process which applies a refractin texture
  118824. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118825. */
  118826. export class RefractionPostProcess extends PostProcess {
  118827. /** the base color of the refraction (used to taint the rendering) */
  118828. color: Color3;
  118829. /** simulated refraction depth */
  118830. depth: number;
  118831. /** the coefficient of the base color (0 to remove base color tainting) */
  118832. colorLevel: number;
  118833. private _refTexture;
  118834. private _ownRefractionTexture;
  118835. /**
  118836. * Gets or sets the refraction texture
  118837. * Please note that you are responsible for disposing the texture if you set it manually
  118838. */
  118839. refractionTexture: Texture;
  118840. /**
  118841. * Initializes the RefractionPostProcess
  118842. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118843. * @param name The name of the effect.
  118844. * @param refractionTextureUrl Url of the refraction texture to use
  118845. * @param color the base color of the refraction (used to taint the rendering)
  118846. * @param depth simulated refraction depth
  118847. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  118848. * @param camera The camera to apply the render pass to.
  118849. * @param options The required width/height ratio to downsize to before computing the render pass.
  118850. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118851. * @param engine The engine which the post process will be applied. (default: current engine)
  118852. * @param reusable If the post process can be reused on the same frame. (default: false)
  118853. */
  118854. constructor(name: string, refractionTextureUrl: string,
  118855. /** the base color of the refraction (used to taint the rendering) */
  118856. color: Color3,
  118857. /** simulated refraction depth */
  118858. depth: number,
  118859. /** the coefficient of the base color (0 to remove base color tainting) */
  118860. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118861. /**
  118862. * Disposes of the post process
  118863. * @param camera Camera to dispose post process on
  118864. */
  118865. dispose(camera: Camera): void;
  118866. }
  118867. }
  118868. declare module BABYLON {
  118869. /** @hidden */
  118870. export var sharpenPixelShader: {
  118871. name: string;
  118872. shader: string;
  118873. };
  118874. }
  118875. declare module BABYLON {
  118876. /**
  118877. * The SharpenPostProcess applies a sharpen kernel to every pixel
  118878. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118879. */
  118880. export class SharpenPostProcess extends PostProcess {
  118881. /**
  118882. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  118883. */
  118884. colorAmount: number;
  118885. /**
  118886. * How much sharpness should be applied (default: 0.3)
  118887. */
  118888. edgeAmount: number;
  118889. /**
  118890. * Creates a new instance ConvolutionPostProcess
  118891. * @param name The name of the effect.
  118892. * @param options The required width/height ratio to downsize to before computing the render pass.
  118893. * @param camera The camera to apply the render pass to.
  118894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118895. * @param engine The engine which the post process will be applied. (default: current engine)
  118896. * @param reusable If the post process can be reused on the same frame. (default: false)
  118897. * @param textureType Type of textures used when performing the post process. (default: 0)
  118898. * @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)
  118899. */
  118900. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118901. }
  118902. }
  118903. declare module BABYLON {
  118904. /**
  118905. * PostProcessRenderPipeline
  118906. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118907. */
  118908. export class PostProcessRenderPipeline {
  118909. private engine;
  118910. private _renderEffects;
  118911. private _renderEffectsForIsolatedPass;
  118912. /**
  118913. * List of inspectable custom properties (used by the Inspector)
  118914. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  118915. */
  118916. inspectableCustomProperties: IInspectable[];
  118917. /**
  118918. * @hidden
  118919. */
  118920. protected _cameras: Camera[];
  118921. /** @hidden */
  118922. _name: string;
  118923. /**
  118924. * Gets pipeline name
  118925. */
  118926. readonly name: string;
  118927. /**
  118928. * Initializes a PostProcessRenderPipeline
  118929. * @param engine engine to add the pipeline to
  118930. * @param name name of the pipeline
  118931. */
  118932. constructor(engine: Engine, name: string);
  118933. /**
  118934. * Gets the class name
  118935. * @returns "PostProcessRenderPipeline"
  118936. */
  118937. getClassName(): string;
  118938. /**
  118939. * If all the render effects in the pipeline are supported
  118940. */
  118941. readonly isSupported: boolean;
  118942. /**
  118943. * Adds an effect to the pipeline
  118944. * @param renderEffect the effect to add
  118945. */
  118946. addEffect(renderEffect: PostProcessRenderEffect): void;
  118947. /** @hidden */
  118948. _rebuild(): void;
  118949. /** @hidden */
  118950. _enableEffect(renderEffectName: string, cameras: Camera): void;
  118951. /** @hidden */
  118952. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  118953. /** @hidden */
  118954. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  118955. /** @hidden */
  118956. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  118957. /** @hidden */
  118958. _attachCameras(cameras: Camera, unique: boolean): void;
  118959. /** @hidden */
  118960. _attachCameras(cameras: Camera[], unique: boolean): void;
  118961. /** @hidden */
  118962. _detachCameras(cameras: Camera): void;
  118963. /** @hidden */
  118964. _detachCameras(cameras: Nullable<Camera[]>): void;
  118965. /** @hidden */
  118966. _update(): void;
  118967. /** @hidden */
  118968. _reset(): void;
  118969. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  118970. /**
  118971. * Disposes of the pipeline
  118972. */
  118973. dispose(): void;
  118974. }
  118975. }
  118976. declare module BABYLON {
  118977. /**
  118978. * PostProcessRenderPipelineManager class
  118979. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118980. */
  118981. export class PostProcessRenderPipelineManager {
  118982. private _renderPipelines;
  118983. /**
  118984. * Initializes a PostProcessRenderPipelineManager
  118985. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118986. */
  118987. constructor();
  118988. /**
  118989. * Gets the list of supported render pipelines
  118990. */
  118991. readonly supportedPipelines: PostProcessRenderPipeline[];
  118992. /**
  118993. * Adds a pipeline to the manager
  118994. * @param renderPipeline The pipeline to add
  118995. */
  118996. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  118997. /**
  118998. * Attaches a camera to the pipeline
  118999. * @param renderPipelineName The name of the pipeline to attach to
  119000. * @param cameras the camera to attach
  119001. * @param unique if the camera can be attached multiple times to the pipeline
  119002. */
  119003. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  119004. /**
  119005. * Detaches a camera from the pipeline
  119006. * @param renderPipelineName The name of the pipeline to detach from
  119007. * @param cameras the camera to detach
  119008. */
  119009. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  119010. /**
  119011. * Enables an effect by name on a pipeline
  119012. * @param renderPipelineName the name of the pipeline to enable the effect in
  119013. * @param renderEffectName the name of the effect to enable
  119014. * @param cameras the cameras that the effect should be enabled on
  119015. */
  119016. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  119017. /**
  119018. * Disables an effect by name on a pipeline
  119019. * @param renderPipelineName the name of the pipeline to disable the effect in
  119020. * @param renderEffectName the name of the effect to disable
  119021. * @param cameras the cameras that the effect should be disabled on
  119022. */
  119023. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  119024. /**
  119025. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  119026. */
  119027. update(): void;
  119028. /** @hidden */
  119029. _rebuild(): void;
  119030. /**
  119031. * Disposes of the manager and pipelines
  119032. */
  119033. dispose(): void;
  119034. }
  119035. }
  119036. declare module BABYLON {
  119037. interface Scene {
  119038. /** @hidden (Backing field) */
  119039. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  119040. /**
  119041. * Gets the postprocess render pipeline manager
  119042. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119043. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119044. */
  119045. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  119046. }
  119047. /**
  119048. * Defines the Render Pipeline scene component responsible to rendering pipelines
  119049. */
  119050. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  119051. /**
  119052. * The component name helpfull to identify the component in the list of scene components.
  119053. */
  119054. readonly name: string;
  119055. /**
  119056. * The scene the component belongs to.
  119057. */
  119058. scene: Scene;
  119059. /**
  119060. * Creates a new instance of the component for the given scene
  119061. * @param scene Defines the scene to register the component in
  119062. */
  119063. constructor(scene: Scene);
  119064. /**
  119065. * Registers the component in a given scene
  119066. */
  119067. register(): void;
  119068. /**
  119069. * Rebuilds the elements related to this component in case of
  119070. * context lost for instance.
  119071. */
  119072. rebuild(): void;
  119073. /**
  119074. * Disposes the component and the associated ressources
  119075. */
  119076. dispose(): void;
  119077. private _gatherRenderTargets;
  119078. }
  119079. }
  119080. declare module BABYLON {
  119081. /**
  119082. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  119083. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119084. */
  119085. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119086. private _scene;
  119087. private _camerasToBeAttached;
  119088. /**
  119089. * ID of the sharpen post process,
  119090. */
  119091. private readonly SharpenPostProcessId;
  119092. /**
  119093. * @ignore
  119094. * ID of the image processing post process;
  119095. */
  119096. readonly ImageProcessingPostProcessId: string;
  119097. /**
  119098. * @ignore
  119099. * ID of the Fast Approximate Anti-Aliasing post process;
  119100. */
  119101. readonly FxaaPostProcessId: string;
  119102. /**
  119103. * ID of the chromatic aberration post process,
  119104. */
  119105. private readonly ChromaticAberrationPostProcessId;
  119106. /**
  119107. * ID of the grain post process
  119108. */
  119109. private readonly GrainPostProcessId;
  119110. /**
  119111. * Sharpen post process which will apply a sharpen convolution to enhance edges
  119112. */
  119113. sharpen: SharpenPostProcess;
  119114. private _sharpenEffect;
  119115. private bloom;
  119116. /**
  119117. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  119118. */
  119119. depthOfField: DepthOfFieldEffect;
  119120. /**
  119121. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119122. */
  119123. fxaa: FxaaPostProcess;
  119124. /**
  119125. * Image post processing pass used to perform operations such as tone mapping or color grading.
  119126. */
  119127. imageProcessing: ImageProcessingPostProcess;
  119128. /**
  119129. * Chromatic aberration post process which will shift rgb colors in the image
  119130. */
  119131. chromaticAberration: ChromaticAberrationPostProcess;
  119132. private _chromaticAberrationEffect;
  119133. /**
  119134. * Grain post process which add noise to the image
  119135. */
  119136. grain: GrainPostProcess;
  119137. private _grainEffect;
  119138. /**
  119139. * Glow post process which adds a glow to emissive areas of the image
  119140. */
  119141. private _glowLayer;
  119142. /**
  119143. * Animations which can be used to tweak settings over a period of time
  119144. */
  119145. animations: Animation[];
  119146. private _imageProcessingConfigurationObserver;
  119147. private _sharpenEnabled;
  119148. private _bloomEnabled;
  119149. private _depthOfFieldEnabled;
  119150. private _depthOfFieldBlurLevel;
  119151. private _fxaaEnabled;
  119152. private _imageProcessingEnabled;
  119153. private _defaultPipelineTextureType;
  119154. private _bloomScale;
  119155. private _chromaticAberrationEnabled;
  119156. private _grainEnabled;
  119157. private _buildAllowed;
  119158. /**
  119159. * Gets active scene
  119160. */
  119161. readonly scene: Scene;
  119162. /**
  119163. * Enable or disable the sharpen process from the pipeline
  119164. */
  119165. sharpenEnabled: boolean;
  119166. private _resizeObserver;
  119167. private _hardwareScaleLevel;
  119168. private _bloomKernel;
  119169. /**
  119170. * Specifies the size of the bloom blur kernel, relative to the final output size
  119171. */
  119172. bloomKernel: number;
  119173. /**
  119174. * Specifies the weight of the bloom in the final rendering
  119175. */
  119176. private _bloomWeight;
  119177. /**
  119178. * Specifies the luma threshold for the area that will be blurred by the bloom
  119179. */
  119180. private _bloomThreshold;
  119181. private _hdr;
  119182. /**
  119183. * The strength of the bloom.
  119184. */
  119185. bloomWeight: number;
  119186. /**
  119187. * The strength of the bloom.
  119188. */
  119189. bloomThreshold: number;
  119190. /**
  119191. * The scale of the bloom, lower value will provide better performance.
  119192. */
  119193. bloomScale: number;
  119194. /**
  119195. * Enable or disable the bloom from the pipeline
  119196. */
  119197. bloomEnabled: boolean;
  119198. private _rebuildBloom;
  119199. /**
  119200. * If the depth of field is enabled.
  119201. */
  119202. depthOfFieldEnabled: boolean;
  119203. /**
  119204. * Blur level of the depth of field effect. (Higher blur will effect performance)
  119205. */
  119206. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  119207. /**
  119208. * If the anti aliasing is enabled.
  119209. */
  119210. fxaaEnabled: boolean;
  119211. private _samples;
  119212. /**
  119213. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119214. */
  119215. samples: number;
  119216. /**
  119217. * If image processing is enabled.
  119218. */
  119219. imageProcessingEnabled: boolean;
  119220. /**
  119221. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  119222. */
  119223. glowLayerEnabled: boolean;
  119224. /**
  119225. * Gets the glow layer (or null if not defined)
  119226. */
  119227. readonly glowLayer: Nullable<GlowLayer>;
  119228. /**
  119229. * Enable or disable the chromaticAberration process from the pipeline
  119230. */
  119231. chromaticAberrationEnabled: boolean;
  119232. /**
  119233. * Enable or disable the grain process from the pipeline
  119234. */
  119235. grainEnabled: boolean;
  119236. /**
  119237. * @constructor
  119238. * @param name - The rendering pipeline name (default: "")
  119239. * @param hdr - If high dynamic range textures should be used (default: true)
  119240. * @param scene - The scene linked to this pipeline (default: the last created scene)
  119241. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  119242. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  119243. */
  119244. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  119245. /**
  119246. * Get the class name
  119247. * @returns "DefaultRenderingPipeline"
  119248. */
  119249. getClassName(): string;
  119250. /**
  119251. * Force the compilation of the entire pipeline.
  119252. */
  119253. prepare(): void;
  119254. private _hasCleared;
  119255. private _prevPostProcess;
  119256. private _prevPrevPostProcess;
  119257. private _setAutoClearAndTextureSharing;
  119258. private _depthOfFieldSceneObserver;
  119259. private _buildPipeline;
  119260. private _disposePostProcesses;
  119261. /**
  119262. * Adds a camera to the pipeline
  119263. * @param camera the camera to be added
  119264. */
  119265. addCamera(camera: Camera): void;
  119266. /**
  119267. * Removes a camera from the pipeline
  119268. * @param camera the camera to remove
  119269. */
  119270. removeCamera(camera: Camera): void;
  119271. /**
  119272. * Dispose of the pipeline and stop all post processes
  119273. */
  119274. dispose(): void;
  119275. /**
  119276. * Serialize the rendering pipeline (Used when exporting)
  119277. * @returns the serialized object
  119278. */
  119279. serialize(): any;
  119280. /**
  119281. * Parse the serialized pipeline
  119282. * @param source Source pipeline.
  119283. * @param scene The scene to load the pipeline to.
  119284. * @param rootUrl The URL of the serialized pipeline.
  119285. * @returns An instantiated pipeline from the serialized object.
  119286. */
  119287. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  119288. }
  119289. }
  119290. declare module BABYLON {
  119291. /** @hidden */
  119292. export var lensHighlightsPixelShader: {
  119293. name: string;
  119294. shader: string;
  119295. };
  119296. }
  119297. declare module BABYLON {
  119298. /** @hidden */
  119299. export var depthOfFieldPixelShader: {
  119300. name: string;
  119301. shader: string;
  119302. };
  119303. }
  119304. declare module BABYLON {
  119305. /**
  119306. * BABYLON.JS Chromatic Aberration GLSL Shader
  119307. * Author: Olivier Guyot
  119308. * Separates very slightly R, G and B colors on the edges of the screen
  119309. * Inspired by Francois Tarlier & Martins Upitis
  119310. */
  119311. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  119312. /**
  119313. * @ignore
  119314. * The chromatic aberration PostProcess id in the pipeline
  119315. */
  119316. LensChromaticAberrationEffect: string;
  119317. /**
  119318. * @ignore
  119319. * The highlights enhancing PostProcess id in the pipeline
  119320. */
  119321. HighlightsEnhancingEffect: string;
  119322. /**
  119323. * @ignore
  119324. * The depth-of-field PostProcess id in the pipeline
  119325. */
  119326. LensDepthOfFieldEffect: string;
  119327. private _scene;
  119328. private _depthTexture;
  119329. private _grainTexture;
  119330. private _chromaticAberrationPostProcess;
  119331. private _highlightsPostProcess;
  119332. private _depthOfFieldPostProcess;
  119333. private _edgeBlur;
  119334. private _grainAmount;
  119335. private _chromaticAberration;
  119336. private _distortion;
  119337. private _highlightsGain;
  119338. private _highlightsThreshold;
  119339. private _dofDistance;
  119340. private _dofAperture;
  119341. private _dofDarken;
  119342. private _dofPentagon;
  119343. private _blurNoise;
  119344. /**
  119345. * @constructor
  119346. *
  119347. * Effect parameters are as follow:
  119348. * {
  119349. * chromatic_aberration: number; // from 0 to x (1 for realism)
  119350. * edge_blur: number; // from 0 to x (1 for realism)
  119351. * distortion: number; // from 0 to x (1 for realism)
  119352. * grain_amount: number; // from 0 to 1
  119353. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  119354. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  119355. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  119356. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  119357. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  119358. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  119359. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  119360. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  119361. * }
  119362. * Note: if an effect parameter is unset, effect is disabled
  119363. *
  119364. * @param name The rendering pipeline name
  119365. * @param parameters - An object containing all parameters (see above)
  119366. * @param scene The scene linked to this pipeline
  119367. * @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)
  119368. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119369. */
  119370. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  119371. /**
  119372. * Get the class name
  119373. * @returns "LensRenderingPipeline"
  119374. */
  119375. getClassName(): string;
  119376. /**
  119377. * Gets associated scene
  119378. */
  119379. readonly scene: Scene;
  119380. /**
  119381. * Gets or sets the edge blur
  119382. */
  119383. edgeBlur: number;
  119384. /**
  119385. * Gets or sets the grain amount
  119386. */
  119387. grainAmount: number;
  119388. /**
  119389. * Gets or sets the chromatic aberration amount
  119390. */
  119391. chromaticAberration: number;
  119392. /**
  119393. * Gets or sets the depth of field aperture
  119394. */
  119395. dofAperture: number;
  119396. /**
  119397. * Gets or sets the edge distortion
  119398. */
  119399. edgeDistortion: number;
  119400. /**
  119401. * Gets or sets the depth of field distortion
  119402. */
  119403. dofDistortion: number;
  119404. /**
  119405. * Gets or sets the darken out of focus amount
  119406. */
  119407. darkenOutOfFocus: number;
  119408. /**
  119409. * Gets or sets a boolean indicating if blur noise is enabled
  119410. */
  119411. blurNoise: boolean;
  119412. /**
  119413. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  119414. */
  119415. pentagonBokeh: boolean;
  119416. /**
  119417. * Gets or sets the highlight grain amount
  119418. */
  119419. highlightsGain: number;
  119420. /**
  119421. * Gets or sets the highlight threshold
  119422. */
  119423. highlightsThreshold: number;
  119424. /**
  119425. * Sets the amount of blur at the edges
  119426. * @param amount blur amount
  119427. */
  119428. setEdgeBlur(amount: number): void;
  119429. /**
  119430. * Sets edge blur to 0
  119431. */
  119432. disableEdgeBlur(): void;
  119433. /**
  119434. * Sets the amout of grain
  119435. * @param amount Amount of grain
  119436. */
  119437. setGrainAmount(amount: number): void;
  119438. /**
  119439. * Set grain amount to 0
  119440. */
  119441. disableGrain(): void;
  119442. /**
  119443. * Sets the chromatic aberration amount
  119444. * @param amount amount of chromatic aberration
  119445. */
  119446. setChromaticAberration(amount: number): void;
  119447. /**
  119448. * Sets chromatic aberration amount to 0
  119449. */
  119450. disableChromaticAberration(): void;
  119451. /**
  119452. * Sets the EdgeDistortion amount
  119453. * @param amount amount of EdgeDistortion
  119454. */
  119455. setEdgeDistortion(amount: number): void;
  119456. /**
  119457. * Sets edge distortion to 0
  119458. */
  119459. disableEdgeDistortion(): void;
  119460. /**
  119461. * Sets the FocusDistance amount
  119462. * @param amount amount of FocusDistance
  119463. */
  119464. setFocusDistance(amount: number): void;
  119465. /**
  119466. * Disables depth of field
  119467. */
  119468. disableDepthOfField(): void;
  119469. /**
  119470. * Sets the Aperture amount
  119471. * @param amount amount of Aperture
  119472. */
  119473. setAperture(amount: number): void;
  119474. /**
  119475. * Sets the DarkenOutOfFocus amount
  119476. * @param amount amount of DarkenOutOfFocus
  119477. */
  119478. setDarkenOutOfFocus(amount: number): void;
  119479. private _pentagonBokehIsEnabled;
  119480. /**
  119481. * Creates a pentagon bokeh effect
  119482. */
  119483. enablePentagonBokeh(): void;
  119484. /**
  119485. * Disables the pentagon bokeh effect
  119486. */
  119487. disablePentagonBokeh(): void;
  119488. /**
  119489. * Enables noise blur
  119490. */
  119491. enableNoiseBlur(): void;
  119492. /**
  119493. * Disables noise blur
  119494. */
  119495. disableNoiseBlur(): void;
  119496. /**
  119497. * Sets the HighlightsGain amount
  119498. * @param amount amount of HighlightsGain
  119499. */
  119500. setHighlightsGain(amount: number): void;
  119501. /**
  119502. * Sets the HighlightsThreshold amount
  119503. * @param amount amount of HighlightsThreshold
  119504. */
  119505. setHighlightsThreshold(amount: number): void;
  119506. /**
  119507. * Disables highlights
  119508. */
  119509. disableHighlights(): void;
  119510. /**
  119511. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  119512. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  119513. */
  119514. dispose(disableDepthRender?: boolean): void;
  119515. private _createChromaticAberrationPostProcess;
  119516. private _createHighlightsPostProcess;
  119517. private _createDepthOfFieldPostProcess;
  119518. private _createGrainTexture;
  119519. }
  119520. }
  119521. declare module BABYLON {
  119522. /** @hidden */
  119523. export var ssao2PixelShader: {
  119524. name: string;
  119525. shader: string;
  119526. };
  119527. }
  119528. declare module BABYLON {
  119529. /** @hidden */
  119530. export var ssaoCombinePixelShader: {
  119531. name: string;
  119532. shader: string;
  119533. };
  119534. }
  119535. declare module BABYLON {
  119536. /**
  119537. * Render pipeline to produce ssao effect
  119538. */
  119539. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  119540. /**
  119541. * @ignore
  119542. * The PassPostProcess id in the pipeline that contains the original scene color
  119543. */
  119544. SSAOOriginalSceneColorEffect: string;
  119545. /**
  119546. * @ignore
  119547. * The SSAO PostProcess id in the pipeline
  119548. */
  119549. SSAORenderEffect: string;
  119550. /**
  119551. * @ignore
  119552. * The horizontal blur PostProcess id in the pipeline
  119553. */
  119554. SSAOBlurHRenderEffect: string;
  119555. /**
  119556. * @ignore
  119557. * The vertical blur PostProcess id in the pipeline
  119558. */
  119559. SSAOBlurVRenderEffect: string;
  119560. /**
  119561. * @ignore
  119562. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119563. */
  119564. SSAOCombineRenderEffect: string;
  119565. /**
  119566. * The output strength of the SSAO post-process. Default value is 1.0.
  119567. */
  119568. totalStrength: number;
  119569. /**
  119570. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  119571. */
  119572. maxZ: number;
  119573. /**
  119574. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  119575. */
  119576. minZAspect: number;
  119577. private _samples;
  119578. /**
  119579. * Number of samples used for the SSAO calculations. Default value is 8
  119580. */
  119581. samples: number;
  119582. private _textureSamples;
  119583. /**
  119584. * Number of samples to use for antialiasing
  119585. */
  119586. textureSamples: number;
  119587. /**
  119588. * Ratio object used for SSAO ratio and blur ratio
  119589. */
  119590. private _ratio;
  119591. /**
  119592. * Dynamically generated sphere sampler.
  119593. */
  119594. private _sampleSphere;
  119595. /**
  119596. * Blur filter offsets
  119597. */
  119598. private _samplerOffsets;
  119599. private _expensiveBlur;
  119600. /**
  119601. * If bilateral blur should be used
  119602. */
  119603. expensiveBlur: boolean;
  119604. /**
  119605. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  119606. */
  119607. radius: number;
  119608. /**
  119609. * The base color of the SSAO post-process
  119610. * The final result is "base + ssao" between [0, 1]
  119611. */
  119612. base: number;
  119613. /**
  119614. * Support test.
  119615. */
  119616. static readonly IsSupported: boolean;
  119617. private _scene;
  119618. private _depthTexture;
  119619. private _normalTexture;
  119620. private _randomTexture;
  119621. private _originalColorPostProcess;
  119622. private _ssaoPostProcess;
  119623. private _blurHPostProcess;
  119624. private _blurVPostProcess;
  119625. private _ssaoCombinePostProcess;
  119626. private _firstUpdate;
  119627. /**
  119628. * Gets active scene
  119629. */
  119630. readonly scene: Scene;
  119631. /**
  119632. * @constructor
  119633. * @param name The rendering pipeline name
  119634. * @param scene The scene linked to this pipeline
  119635. * @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 }
  119636. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119637. */
  119638. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119639. /**
  119640. * Get the class name
  119641. * @returns "SSAO2RenderingPipeline"
  119642. */
  119643. getClassName(): string;
  119644. /**
  119645. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119646. */
  119647. dispose(disableGeometryBufferRenderer?: boolean): void;
  119648. private _createBlurPostProcess;
  119649. /** @hidden */
  119650. _rebuild(): void;
  119651. private _bits;
  119652. private _radicalInverse_VdC;
  119653. private _hammersley;
  119654. private _hemisphereSample_uniform;
  119655. private _generateHemisphere;
  119656. private _createSSAOPostProcess;
  119657. private _createSSAOCombinePostProcess;
  119658. private _createRandomTexture;
  119659. /**
  119660. * Serialize the rendering pipeline (Used when exporting)
  119661. * @returns the serialized object
  119662. */
  119663. serialize(): any;
  119664. /**
  119665. * Parse the serialized pipeline
  119666. * @param source Source pipeline.
  119667. * @param scene The scene to load the pipeline to.
  119668. * @param rootUrl The URL of the serialized pipeline.
  119669. * @returns An instantiated pipeline from the serialized object.
  119670. */
  119671. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  119672. }
  119673. }
  119674. declare module BABYLON {
  119675. /** @hidden */
  119676. export var ssaoPixelShader: {
  119677. name: string;
  119678. shader: string;
  119679. };
  119680. }
  119681. declare module BABYLON {
  119682. /**
  119683. * Render pipeline to produce ssao effect
  119684. */
  119685. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  119686. /**
  119687. * @ignore
  119688. * The PassPostProcess id in the pipeline that contains the original scene color
  119689. */
  119690. SSAOOriginalSceneColorEffect: string;
  119691. /**
  119692. * @ignore
  119693. * The SSAO PostProcess id in the pipeline
  119694. */
  119695. SSAORenderEffect: string;
  119696. /**
  119697. * @ignore
  119698. * The horizontal blur PostProcess id in the pipeline
  119699. */
  119700. SSAOBlurHRenderEffect: string;
  119701. /**
  119702. * @ignore
  119703. * The vertical blur PostProcess id in the pipeline
  119704. */
  119705. SSAOBlurVRenderEffect: string;
  119706. /**
  119707. * @ignore
  119708. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119709. */
  119710. SSAOCombineRenderEffect: string;
  119711. /**
  119712. * The output strength of the SSAO post-process. Default value is 1.0.
  119713. */
  119714. totalStrength: number;
  119715. /**
  119716. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  119717. */
  119718. radius: number;
  119719. /**
  119720. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  119721. * Must not be equal to fallOff and superior to fallOff.
  119722. * Default value is 0.0075
  119723. */
  119724. area: number;
  119725. /**
  119726. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  119727. * Must not be equal to area and inferior to area.
  119728. * Default value is 0.000001
  119729. */
  119730. fallOff: number;
  119731. /**
  119732. * The base color of the SSAO post-process
  119733. * The final result is "base + ssao" between [0, 1]
  119734. */
  119735. base: number;
  119736. private _scene;
  119737. private _depthTexture;
  119738. private _randomTexture;
  119739. private _originalColorPostProcess;
  119740. private _ssaoPostProcess;
  119741. private _blurHPostProcess;
  119742. private _blurVPostProcess;
  119743. private _ssaoCombinePostProcess;
  119744. private _firstUpdate;
  119745. /**
  119746. * Gets active scene
  119747. */
  119748. readonly scene: Scene;
  119749. /**
  119750. * @constructor
  119751. * @param name - The rendering pipeline name
  119752. * @param scene - The scene linked to this pipeline
  119753. * @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 }
  119754. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  119755. */
  119756. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119757. /**
  119758. * Get the class name
  119759. * @returns "SSAORenderingPipeline"
  119760. */
  119761. getClassName(): string;
  119762. /**
  119763. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119764. */
  119765. dispose(disableDepthRender?: boolean): void;
  119766. private _createBlurPostProcess;
  119767. /** @hidden */
  119768. _rebuild(): void;
  119769. private _createSSAOPostProcess;
  119770. private _createSSAOCombinePostProcess;
  119771. private _createRandomTexture;
  119772. }
  119773. }
  119774. declare module BABYLON {
  119775. /** @hidden */
  119776. export var standardPixelShader: {
  119777. name: string;
  119778. shader: string;
  119779. };
  119780. }
  119781. declare module BABYLON {
  119782. /**
  119783. * Standard rendering pipeline
  119784. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119785. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  119786. */
  119787. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119788. /**
  119789. * Public members
  119790. */
  119791. /**
  119792. * Post-process which contains the original scene color before the pipeline applies all the effects
  119793. */
  119794. originalPostProcess: Nullable<PostProcess>;
  119795. /**
  119796. * Post-process used to down scale an image x4
  119797. */
  119798. downSampleX4PostProcess: Nullable<PostProcess>;
  119799. /**
  119800. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  119801. */
  119802. brightPassPostProcess: Nullable<PostProcess>;
  119803. /**
  119804. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  119805. */
  119806. blurHPostProcesses: PostProcess[];
  119807. /**
  119808. * Post-process array storing all the vertical blur post-processes used by the pipeline
  119809. */
  119810. blurVPostProcesses: PostProcess[];
  119811. /**
  119812. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  119813. */
  119814. textureAdderPostProcess: Nullable<PostProcess>;
  119815. /**
  119816. * Post-process used to create volumetric lighting effect
  119817. */
  119818. volumetricLightPostProcess: Nullable<PostProcess>;
  119819. /**
  119820. * Post-process used to smooth the previous volumetric light post-process on the X axis
  119821. */
  119822. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  119823. /**
  119824. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  119825. */
  119826. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  119827. /**
  119828. * Post-process used to merge the volumetric light effect and the real scene color
  119829. */
  119830. volumetricLightMergePostProces: Nullable<PostProcess>;
  119831. /**
  119832. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  119833. */
  119834. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  119835. /**
  119836. * Base post-process used to calculate the average luminance of the final image for HDR
  119837. */
  119838. luminancePostProcess: Nullable<PostProcess>;
  119839. /**
  119840. * Post-processes used to create down sample post-processes in order to get
  119841. * the average luminance of the final image for HDR
  119842. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  119843. */
  119844. luminanceDownSamplePostProcesses: PostProcess[];
  119845. /**
  119846. * Post-process used to create a HDR effect (light adaptation)
  119847. */
  119848. hdrPostProcess: Nullable<PostProcess>;
  119849. /**
  119850. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  119851. */
  119852. textureAdderFinalPostProcess: Nullable<PostProcess>;
  119853. /**
  119854. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  119855. */
  119856. lensFlareFinalPostProcess: Nullable<PostProcess>;
  119857. /**
  119858. * Post-process used to merge the final HDR post-process and the real scene color
  119859. */
  119860. hdrFinalPostProcess: Nullable<PostProcess>;
  119861. /**
  119862. * Post-process used to create a lens flare effect
  119863. */
  119864. lensFlarePostProcess: Nullable<PostProcess>;
  119865. /**
  119866. * Post-process that merges the result of the lens flare post-process and the real scene color
  119867. */
  119868. lensFlareComposePostProcess: Nullable<PostProcess>;
  119869. /**
  119870. * Post-process used to create a motion blur effect
  119871. */
  119872. motionBlurPostProcess: Nullable<PostProcess>;
  119873. /**
  119874. * Post-process used to create a depth of field effect
  119875. */
  119876. depthOfFieldPostProcess: Nullable<PostProcess>;
  119877. /**
  119878. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119879. */
  119880. fxaaPostProcess: Nullable<FxaaPostProcess>;
  119881. /**
  119882. * Represents the brightness threshold in order to configure the illuminated surfaces
  119883. */
  119884. brightThreshold: number;
  119885. /**
  119886. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  119887. */
  119888. blurWidth: number;
  119889. /**
  119890. * Sets if the blur for highlighted surfaces must be only horizontal
  119891. */
  119892. horizontalBlur: boolean;
  119893. /**
  119894. * Gets the overall exposure used by the pipeline
  119895. */
  119896. /**
  119897. * Sets the overall exposure used by the pipeline
  119898. */
  119899. exposure: number;
  119900. /**
  119901. * Texture used typically to simulate "dirty" on camera lens
  119902. */
  119903. lensTexture: Nullable<Texture>;
  119904. /**
  119905. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  119906. */
  119907. volumetricLightCoefficient: number;
  119908. /**
  119909. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  119910. */
  119911. volumetricLightPower: number;
  119912. /**
  119913. * Used the set the blur intensity to smooth the volumetric lights
  119914. */
  119915. volumetricLightBlurScale: number;
  119916. /**
  119917. * Light (spot or directional) used to generate the volumetric lights rays
  119918. * The source light must have a shadow generate so the pipeline can get its
  119919. * depth map
  119920. */
  119921. sourceLight: Nullable<SpotLight | DirectionalLight>;
  119922. /**
  119923. * For eye adaptation, represents the minimum luminance the eye can see
  119924. */
  119925. hdrMinimumLuminance: number;
  119926. /**
  119927. * For eye adaptation, represents the decrease luminance speed
  119928. */
  119929. hdrDecreaseRate: number;
  119930. /**
  119931. * For eye adaptation, represents the increase luminance speed
  119932. */
  119933. hdrIncreaseRate: number;
  119934. /**
  119935. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119936. */
  119937. /**
  119938. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119939. */
  119940. hdrAutoExposure: boolean;
  119941. /**
  119942. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  119943. */
  119944. lensColorTexture: Nullable<Texture>;
  119945. /**
  119946. * The overall strengh for the lens flare effect
  119947. */
  119948. lensFlareStrength: number;
  119949. /**
  119950. * Dispersion coefficient for lens flare ghosts
  119951. */
  119952. lensFlareGhostDispersal: number;
  119953. /**
  119954. * Main lens flare halo width
  119955. */
  119956. lensFlareHaloWidth: number;
  119957. /**
  119958. * Based on the lens distortion effect, defines how much the lens flare result
  119959. * is distorted
  119960. */
  119961. lensFlareDistortionStrength: number;
  119962. /**
  119963. * Lens star texture must be used to simulate rays on the flares and is available
  119964. * in the documentation
  119965. */
  119966. lensStarTexture: Nullable<Texture>;
  119967. /**
  119968. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  119969. * flare effect by taking account of the dirt texture
  119970. */
  119971. lensFlareDirtTexture: Nullable<Texture>;
  119972. /**
  119973. * Represents the focal length for the depth of field effect
  119974. */
  119975. depthOfFieldDistance: number;
  119976. /**
  119977. * Represents the blur intensity for the blurred part of the depth of field effect
  119978. */
  119979. depthOfFieldBlurWidth: number;
  119980. /**
  119981. * Gets how much the image is blurred by the movement while using the motion blur post-process
  119982. */
  119983. /**
  119984. * Sets how much the image is blurred by the movement while using the motion blur post-process
  119985. */
  119986. motionStrength: number;
  119987. /**
  119988. * Gets wether or not the motion blur post-process is object based or screen based.
  119989. */
  119990. /**
  119991. * Sets wether or not the motion blur post-process should be object based or screen based
  119992. */
  119993. objectBasedMotionBlur: boolean;
  119994. /**
  119995. * List of animations for the pipeline (IAnimatable implementation)
  119996. */
  119997. animations: Animation[];
  119998. /**
  119999. * Private members
  120000. */
  120001. private _scene;
  120002. private _currentDepthOfFieldSource;
  120003. private _basePostProcess;
  120004. private _fixedExposure;
  120005. private _currentExposure;
  120006. private _hdrAutoExposure;
  120007. private _hdrCurrentLuminance;
  120008. private _motionStrength;
  120009. private _isObjectBasedMotionBlur;
  120010. private _floatTextureType;
  120011. private _ratio;
  120012. private _bloomEnabled;
  120013. private _depthOfFieldEnabled;
  120014. private _vlsEnabled;
  120015. private _lensFlareEnabled;
  120016. private _hdrEnabled;
  120017. private _motionBlurEnabled;
  120018. private _fxaaEnabled;
  120019. private _motionBlurSamples;
  120020. private _volumetricLightStepsCount;
  120021. private _samples;
  120022. /**
  120023. * @ignore
  120024. * Specifies if the bloom pipeline is enabled
  120025. */
  120026. BloomEnabled: boolean;
  120027. /**
  120028. * @ignore
  120029. * Specifies if the depth of field pipeline is enabed
  120030. */
  120031. DepthOfFieldEnabled: boolean;
  120032. /**
  120033. * @ignore
  120034. * Specifies if the lens flare pipeline is enabed
  120035. */
  120036. LensFlareEnabled: boolean;
  120037. /**
  120038. * @ignore
  120039. * Specifies if the HDR pipeline is enabled
  120040. */
  120041. HDREnabled: boolean;
  120042. /**
  120043. * @ignore
  120044. * Specifies if the volumetric lights scattering effect is enabled
  120045. */
  120046. VLSEnabled: boolean;
  120047. /**
  120048. * @ignore
  120049. * Specifies if the motion blur effect is enabled
  120050. */
  120051. MotionBlurEnabled: boolean;
  120052. /**
  120053. * Specifies if anti-aliasing is enabled
  120054. */
  120055. fxaaEnabled: boolean;
  120056. /**
  120057. * Specifies the number of steps used to calculate the volumetric lights
  120058. * Typically in interval [50, 200]
  120059. */
  120060. volumetricLightStepsCount: number;
  120061. /**
  120062. * Specifies the number of samples used for the motion blur effect
  120063. * Typically in interval [16, 64]
  120064. */
  120065. motionBlurSamples: number;
  120066. /**
  120067. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  120068. */
  120069. samples: number;
  120070. /**
  120071. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  120072. * @constructor
  120073. * @param name The rendering pipeline name
  120074. * @param scene The scene linked to this pipeline
  120075. * @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)
  120076. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  120077. * @param cameras The array of cameras that the rendering pipeline will be attached to
  120078. */
  120079. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  120080. private _buildPipeline;
  120081. private _createDownSampleX4PostProcess;
  120082. private _createBrightPassPostProcess;
  120083. private _createBlurPostProcesses;
  120084. private _createTextureAdderPostProcess;
  120085. private _createVolumetricLightPostProcess;
  120086. private _createLuminancePostProcesses;
  120087. private _createHdrPostProcess;
  120088. private _createLensFlarePostProcess;
  120089. private _createDepthOfFieldPostProcess;
  120090. private _createMotionBlurPostProcess;
  120091. private _getDepthTexture;
  120092. private _disposePostProcesses;
  120093. /**
  120094. * Dispose of the pipeline and stop all post processes
  120095. */
  120096. dispose(): void;
  120097. /**
  120098. * Serialize the rendering pipeline (Used when exporting)
  120099. * @returns the serialized object
  120100. */
  120101. serialize(): any;
  120102. /**
  120103. * Parse the serialized pipeline
  120104. * @param source Source pipeline.
  120105. * @param scene The scene to load the pipeline to.
  120106. * @param rootUrl The URL of the serialized pipeline.
  120107. * @returns An instantiated pipeline from the serialized object.
  120108. */
  120109. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  120110. /**
  120111. * Luminance steps
  120112. */
  120113. static LuminanceSteps: number;
  120114. }
  120115. }
  120116. declare module BABYLON {
  120117. /** @hidden */
  120118. export var tonemapPixelShader: {
  120119. name: string;
  120120. shader: string;
  120121. };
  120122. }
  120123. declare module BABYLON {
  120124. /** Defines operator used for tonemapping */
  120125. export enum TonemappingOperator {
  120126. /** Hable */
  120127. Hable = 0,
  120128. /** Reinhard */
  120129. Reinhard = 1,
  120130. /** HejiDawson */
  120131. HejiDawson = 2,
  120132. /** Photographic */
  120133. Photographic = 3
  120134. }
  120135. /**
  120136. * Defines a post process to apply tone mapping
  120137. */
  120138. export class TonemapPostProcess extends PostProcess {
  120139. private _operator;
  120140. /** Defines the required exposure adjustement */
  120141. exposureAdjustment: number;
  120142. /**
  120143. * Creates a new TonemapPostProcess
  120144. * @param name defines the name of the postprocess
  120145. * @param _operator defines the operator to use
  120146. * @param exposureAdjustment defines the required exposure adjustement
  120147. * @param camera defines the camera to use (can be null)
  120148. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  120149. * @param engine defines the hosting engine (can be ignore if camera is set)
  120150. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  120151. */
  120152. constructor(name: string, _operator: TonemappingOperator,
  120153. /** Defines the required exposure adjustement */
  120154. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  120155. }
  120156. }
  120157. declare module BABYLON {
  120158. /** @hidden */
  120159. export var depthVertexShader: {
  120160. name: string;
  120161. shader: string;
  120162. };
  120163. }
  120164. declare module BABYLON {
  120165. /** @hidden */
  120166. export var volumetricLightScatteringPixelShader: {
  120167. name: string;
  120168. shader: string;
  120169. };
  120170. }
  120171. declare module BABYLON {
  120172. /** @hidden */
  120173. export var volumetricLightScatteringPassPixelShader: {
  120174. name: string;
  120175. shader: string;
  120176. };
  120177. }
  120178. declare module BABYLON {
  120179. /**
  120180. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  120181. */
  120182. export class VolumetricLightScatteringPostProcess extends PostProcess {
  120183. private _volumetricLightScatteringPass;
  120184. private _volumetricLightScatteringRTT;
  120185. private _viewPort;
  120186. private _screenCoordinates;
  120187. private _cachedDefines;
  120188. /**
  120189. * If not undefined, the mesh position is computed from the attached node position
  120190. */
  120191. attachedNode: {
  120192. position: Vector3;
  120193. };
  120194. /**
  120195. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  120196. */
  120197. customMeshPosition: Vector3;
  120198. /**
  120199. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  120200. */
  120201. useCustomMeshPosition: boolean;
  120202. /**
  120203. * If the post-process should inverse the light scattering direction
  120204. */
  120205. invert: boolean;
  120206. /**
  120207. * The internal mesh used by the post-process
  120208. */
  120209. mesh: Mesh;
  120210. /**
  120211. * @hidden
  120212. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  120213. */
  120214. useDiffuseColor: boolean;
  120215. /**
  120216. * Array containing the excluded meshes not rendered in the internal pass
  120217. */
  120218. excludedMeshes: AbstractMesh[];
  120219. /**
  120220. * Controls the overall intensity of the post-process
  120221. */
  120222. exposure: number;
  120223. /**
  120224. * Dissipates each sample's contribution in range [0, 1]
  120225. */
  120226. decay: number;
  120227. /**
  120228. * Controls the overall intensity of each sample
  120229. */
  120230. weight: number;
  120231. /**
  120232. * Controls the density of each sample
  120233. */
  120234. density: number;
  120235. /**
  120236. * @constructor
  120237. * @param name The post-process name
  120238. * @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)
  120239. * @param camera The camera that the post-process will be attached to
  120240. * @param mesh The mesh used to create the light scattering
  120241. * @param samples The post-process quality, default 100
  120242. * @param samplingModeThe post-process filtering mode
  120243. * @param engine The babylon engine
  120244. * @param reusable If the post-process is reusable
  120245. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  120246. */
  120247. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  120248. /**
  120249. * Returns the string "VolumetricLightScatteringPostProcess"
  120250. * @returns "VolumetricLightScatteringPostProcess"
  120251. */
  120252. getClassName(): string;
  120253. private _isReady;
  120254. /**
  120255. * Sets the new light position for light scattering effect
  120256. * @param position The new custom light position
  120257. */
  120258. setCustomMeshPosition(position: Vector3): void;
  120259. /**
  120260. * Returns the light position for light scattering effect
  120261. * @return Vector3 The custom light position
  120262. */
  120263. getCustomMeshPosition(): Vector3;
  120264. /**
  120265. * Disposes the internal assets and detaches the post-process from the camera
  120266. */
  120267. dispose(camera: Camera): void;
  120268. /**
  120269. * Returns the render target texture used by the post-process
  120270. * @return the render target texture used by the post-process
  120271. */
  120272. getPass(): RenderTargetTexture;
  120273. private _meshExcluded;
  120274. private _createPass;
  120275. private _updateMeshScreenCoordinates;
  120276. /**
  120277. * Creates a default mesh for the Volumeric Light Scattering post-process
  120278. * @param name The mesh name
  120279. * @param scene The scene where to create the mesh
  120280. * @return the default mesh
  120281. */
  120282. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  120283. }
  120284. }
  120285. declare module BABYLON {
  120286. interface Scene {
  120287. /** @hidden (Backing field) */
  120288. _boundingBoxRenderer: BoundingBoxRenderer;
  120289. /** @hidden (Backing field) */
  120290. _forceShowBoundingBoxes: boolean;
  120291. /**
  120292. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  120293. */
  120294. forceShowBoundingBoxes: boolean;
  120295. /**
  120296. * Gets the bounding box renderer associated with the scene
  120297. * @returns a BoundingBoxRenderer
  120298. */
  120299. getBoundingBoxRenderer(): BoundingBoxRenderer;
  120300. }
  120301. interface AbstractMesh {
  120302. /** @hidden (Backing field) */
  120303. _showBoundingBox: boolean;
  120304. /**
  120305. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  120306. */
  120307. showBoundingBox: boolean;
  120308. }
  120309. /**
  120310. * Component responsible of rendering the bounding box of the meshes in a scene.
  120311. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  120312. */
  120313. export class BoundingBoxRenderer implements ISceneComponent {
  120314. /**
  120315. * The component name helpfull to identify the component in the list of scene components.
  120316. */
  120317. readonly name: string;
  120318. /**
  120319. * The scene the component belongs to.
  120320. */
  120321. scene: Scene;
  120322. /**
  120323. * Color of the bounding box lines placed in front of an object
  120324. */
  120325. frontColor: Color3;
  120326. /**
  120327. * Color of the bounding box lines placed behind an object
  120328. */
  120329. backColor: Color3;
  120330. /**
  120331. * Defines if the renderer should show the back lines or not
  120332. */
  120333. showBackLines: boolean;
  120334. /**
  120335. * @hidden
  120336. */
  120337. renderList: SmartArray<BoundingBox>;
  120338. private _colorShader;
  120339. private _vertexBuffers;
  120340. private _indexBuffer;
  120341. private _fillIndexBuffer;
  120342. private _fillIndexData;
  120343. /**
  120344. * Instantiates a new bounding box renderer in a scene.
  120345. * @param scene the scene the renderer renders in
  120346. */
  120347. constructor(scene: Scene);
  120348. /**
  120349. * Registers the component in a given scene
  120350. */
  120351. register(): void;
  120352. private _evaluateSubMesh;
  120353. private _activeMesh;
  120354. private _prepareRessources;
  120355. private _createIndexBuffer;
  120356. /**
  120357. * Rebuilds the elements related to this component in case of
  120358. * context lost for instance.
  120359. */
  120360. rebuild(): void;
  120361. /**
  120362. * @hidden
  120363. */
  120364. reset(): void;
  120365. /**
  120366. * Render the bounding boxes of a specific rendering group
  120367. * @param renderingGroupId defines the rendering group to render
  120368. */
  120369. render(renderingGroupId: number): void;
  120370. /**
  120371. * In case of occlusion queries, we can render the occlusion bounding box through this method
  120372. * @param mesh Define the mesh to render the occlusion bounding box for
  120373. */
  120374. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  120375. /**
  120376. * Dispose and release the resources attached to this renderer.
  120377. */
  120378. dispose(): void;
  120379. }
  120380. }
  120381. declare module BABYLON {
  120382. /** @hidden */
  120383. export var depthPixelShader: {
  120384. name: string;
  120385. shader: string;
  120386. };
  120387. }
  120388. declare module BABYLON {
  120389. /**
  120390. * This represents a depth renderer in Babylon.
  120391. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  120392. */
  120393. export class DepthRenderer {
  120394. private _scene;
  120395. private _depthMap;
  120396. private _effect;
  120397. private readonly _storeNonLinearDepth;
  120398. private readonly _clearColor;
  120399. /** Get if the depth renderer is using packed depth or not */
  120400. readonly isPacked: boolean;
  120401. private _cachedDefines;
  120402. private _camera;
  120403. /**
  120404. * Specifiess that the depth renderer will only be used within
  120405. * the camera it is created for.
  120406. * This can help forcing its rendering during the camera processing.
  120407. */
  120408. useOnlyInActiveCamera: boolean;
  120409. /** @hidden */
  120410. static _SceneComponentInitialization: (scene: Scene) => void;
  120411. /**
  120412. * Instantiates a depth renderer
  120413. * @param scene The scene the renderer belongs to
  120414. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  120415. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  120416. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  120417. */
  120418. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  120419. /**
  120420. * Creates the depth rendering effect and checks if the effect is ready.
  120421. * @param subMesh The submesh to be used to render the depth map of
  120422. * @param useInstances If multiple world instances should be used
  120423. * @returns if the depth renderer is ready to render the depth map
  120424. */
  120425. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120426. /**
  120427. * Gets the texture which the depth map will be written to.
  120428. * @returns The depth map texture
  120429. */
  120430. getDepthMap(): RenderTargetTexture;
  120431. /**
  120432. * Disposes of the depth renderer.
  120433. */
  120434. dispose(): void;
  120435. }
  120436. }
  120437. declare module BABYLON {
  120438. interface Scene {
  120439. /** @hidden (Backing field) */
  120440. _depthRenderer: {
  120441. [id: string]: DepthRenderer;
  120442. };
  120443. /**
  120444. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  120445. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  120446. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  120447. * @returns the created depth renderer
  120448. */
  120449. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  120450. /**
  120451. * Disables a depth renderer for a given camera
  120452. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  120453. */
  120454. disableDepthRenderer(camera?: Nullable<Camera>): void;
  120455. }
  120456. /**
  120457. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  120458. * in several rendering techniques.
  120459. */
  120460. export class DepthRendererSceneComponent implements ISceneComponent {
  120461. /**
  120462. * The component name helpfull to identify the component in the list of scene components.
  120463. */
  120464. readonly name: string;
  120465. /**
  120466. * The scene the component belongs to.
  120467. */
  120468. scene: Scene;
  120469. /**
  120470. * Creates a new instance of the component for the given scene
  120471. * @param scene Defines the scene to register the component in
  120472. */
  120473. constructor(scene: Scene);
  120474. /**
  120475. * Registers the component in a given scene
  120476. */
  120477. register(): void;
  120478. /**
  120479. * Rebuilds the elements related to this component in case of
  120480. * context lost for instance.
  120481. */
  120482. rebuild(): void;
  120483. /**
  120484. * Disposes the component and the associated ressources
  120485. */
  120486. dispose(): void;
  120487. private _gatherRenderTargets;
  120488. private _gatherActiveCameraRenderTargets;
  120489. }
  120490. }
  120491. declare module BABYLON {
  120492. /** @hidden */
  120493. export var outlinePixelShader: {
  120494. name: string;
  120495. shader: string;
  120496. };
  120497. }
  120498. declare module BABYLON {
  120499. /** @hidden */
  120500. export var outlineVertexShader: {
  120501. name: string;
  120502. shader: string;
  120503. };
  120504. }
  120505. declare module BABYLON {
  120506. interface Scene {
  120507. /** @hidden */
  120508. _outlineRenderer: OutlineRenderer;
  120509. /**
  120510. * Gets the outline renderer associated with the scene
  120511. * @returns a OutlineRenderer
  120512. */
  120513. getOutlineRenderer(): OutlineRenderer;
  120514. }
  120515. interface AbstractMesh {
  120516. /** @hidden (Backing field) */
  120517. _renderOutline: boolean;
  120518. /**
  120519. * Gets or sets a boolean indicating if the outline must be rendered as well
  120520. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  120521. */
  120522. renderOutline: boolean;
  120523. /** @hidden (Backing field) */
  120524. _renderOverlay: boolean;
  120525. /**
  120526. * Gets or sets a boolean indicating if the overlay must be rendered as well
  120527. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  120528. */
  120529. renderOverlay: boolean;
  120530. }
  120531. /**
  120532. * This class is responsible to draw bothe outline/overlay of meshes.
  120533. * It should not be used directly but through the available method on mesh.
  120534. */
  120535. export class OutlineRenderer implements ISceneComponent {
  120536. /**
  120537. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  120538. */
  120539. private static _StencilReference;
  120540. /**
  120541. * The name of the component. Each component must have a unique name.
  120542. */
  120543. name: string;
  120544. /**
  120545. * The scene the component belongs to.
  120546. */
  120547. scene: Scene;
  120548. /**
  120549. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  120550. */
  120551. zOffset: number;
  120552. private _engine;
  120553. private _effect;
  120554. private _cachedDefines;
  120555. private _savedDepthWrite;
  120556. /**
  120557. * Instantiates a new outline renderer. (There could be only one per scene).
  120558. * @param scene Defines the scene it belongs to
  120559. */
  120560. constructor(scene: Scene);
  120561. /**
  120562. * Register the component to one instance of a scene.
  120563. */
  120564. register(): void;
  120565. /**
  120566. * Rebuilds the elements related to this component in case of
  120567. * context lost for instance.
  120568. */
  120569. rebuild(): void;
  120570. /**
  120571. * Disposes the component and the associated ressources.
  120572. */
  120573. dispose(): void;
  120574. /**
  120575. * Renders the outline in the canvas.
  120576. * @param subMesh Defines the sumesh to render
  120577. * @param batch Defines the batch of meshes in case of instances
  120578. * @param useOverlay Defines if the rendering is for the overlay or the outline
  120579. */
  120580. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  120581. /**
  120582. * Returns whether or not the outline renderer is ready for a given submesh.
  120583. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  120584. * @param subMesh Defines the submesh to check readyness for
  120585. * @param useInstances Defines wheter wee are trying to render instances or not
  120586. * @returns true if ready otherwise false
  120587. */
  120588. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120589. private _beforeRenderingMesh;
  120590. private _afterRenderingMesh;
  120591. }
  120592. }
  120593. declare module BABYLON {
  120594. /**
  120595. * Defines the list of states available for a task inside a AssetsManager
  120596. */
  120597. export enum AssetTaskState {
  120598. /**
  120599. * Initialization
  120600. */
  120601. INIT = 0,
  120602. /**
  120603. * Running
  120604. */
  120605. RUNNING = 1,
  120606. /**
  120607. * Done
  120608. */
  120609. DONE = 2,
  120610. /**
  120611. * Error
  120612. */
  120613. ERROR = 3
  120614. }
  120615. /**
  120616. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  120617. */
  120618. export abstract class AbstractAssetTask {
  120619. /**
  120620. * Task name
  120621. */ name: string;
  120622. /**
  120623. * Callback called when the task is successful
  120624. */
  120625. onSuccess: (task: any) => void;
  120626. /**
  120627. * Callback called when the task is not successful
  120628. */
  120629. onError: (task: any, message?: string, exception?: any) => void;
  120630. /**
  120631. * Creates a new AssetsManager
  120632. * @param name defines the name of the task
  120633. */
  120634. constructor(
  120635. /**
  120636. * Task name
  120637. */ name: string);
  120638. private _isCompleted;
  120639. private _taskState;
  120640. private _errorObject;
  120641. /**
  120642. * Get if the task is completed
  120643. */
  120644. readonly isCompleted: boolean;
  120645. /**
  120646. * Gets the current state of the task
  120647. */
  120648. readonly taskState: AssetTaskState;
  120649. /**
  120650. * Gets the current error object (if task is in error)
  120651. */
  120652. readonly errorObject: {
  120653. message?: string;
  120654. exception?: any;
  120655. };
  120656. /**
  120657. * Internal only
  120658. * @hidden
  120659. */
  120660. _setErrorObject(message?: string, exception?: any): void;
  120661. /**
  120662. * Execute the current task
  120663. * @param scene defines the scene where you want your assets to be loaded
  120664. * @param onSuccess is a callback called when the task is successfully executed
  120665. * @param onError is a callback called if an error occurs
  120666. */
  120667. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120668. /**
  120669. * Execute the current task
  120670. * @param scene defines the scene where you want your assets to be loaded
  120671. * @param onSuccess is a callback called when the task is successfully executed
  120672. * @param onError is a callback called if an error occurs
  120673. */
  120674. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120675. /**
  120676. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  120677. * This can be used with failed tasks that have the reason for failure fixed.
  120678. */
  120679. reset(): void;
  120680. private onErrorCallback;
  120681. private onDoneCallback;
  120682. }
  120683. /**
  120684. * Define the interface used by progress events raised during assets loading
  120685. */
  120686. export interface IAssetsProgressEvent {
  120687. /**
  120688. * Defines the number of remaining tasks to process
  120689. */
  120690. remainingCount: number;
  120691. /**
  120692. * Defines the total number of tasks
  120693. */
  120694. totalCount: number;
  120695. /**
  120696. * Defines the task that was just processed
  120697. */
  120698. task: AbstractAssetTask;
  120699. }
  120700. /**
  120701. * Class used to share progress information about assets loading
  120702. */
  120703. export class AssetsProgressEvent implements IAssetsProgressEvent {
  120704. /**
  120705. * Defines the number of remaining tasks to process
  120706. */
  120707. remainingCount: number;
  120708. /**
  120709. * Defines the total number of tasks
  120710. */
  120711. totalCount: number;
  120712. /**
  120713. * Defines the task that was just processed
  120714. */
  120715. task: AbstractAssetTask;
  120716. /**
  120717. * Creates a AssetsProgressEvent
  120718. * @param remainingCount defines the number of remaining tasks to process
  120719. * @param totalCount defines the total number of tasks
  120720. * @param task defines the task that was just processed
  120721. */
  120722. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  120723. }
  120724. /**
  120725. * Define a task used by AssetsManager to load meshes
  120726. */
  120727. export class MeshAssetTask extends AbstractAssetTask {
  120728. /**
  120729. * Defines the name of the task
  120730. */
  120731. name: string;
  120732. /**
  120733. * Defines the list of mesh's names you want to load
  120734. */
  120735. meshesNames: any;
  120736. /**
  120737. * Defines the root url to use as a base to load your meshes and associated resources
  120738. */
  120739. rootUrl: string;
  120740. /**
  120741. * Defines the filename of the scene to load from
  120742. */
  120743. sceneFilename: string;
  120744. /**
  120745. * Gets the list of loaded meshes
  120746. */
  120747. loadedMeshes: Array<AbstractMesh>;
  120748. /**
  120749. * Gets the list of loaded particle systems
  120750. */
  120751. loadedParticleSystems: Array<IParticleSystem>;
  120752. /**
  120753. * Gets the list of loaded skeletons
  120754. */
  120755. loadedSkeletons: Array<Skeleton>;
  120756. /**
  120757. * Gets the list of loaded animation groups
  120758. */
  120759. loadedAnimationGroups: Array<AnimationGroup>;
  120760. /**
  120761. * Callback called when the task is successful
  120762. */
  120763. onSuccess: (task: MeshAssetTask) => void;
  120764. /**
  120765. * Callback called when the task is successful
  120766. */
  120767. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  120768. /**
  120769. * Creates a new MeshAssetTask
  120770. * @param name defines the name of the task
  120771. * @param meshesNames defines the list of mesh's names you want to load
  120772. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  120773. * @param sceneFilename defines the filename of the scene to load from
  120774. */
  120775. constructor(
  120776. /**
  120777. * Defines the name of the task
  120778. */
  120779. name: string,
  120780. /**
  120781. * Defines the list of mesh's names you want to load
  120782. */
  120783. meshesNames: any,
  120784. /**
  120785. * Defines the root url to use as a base to load your meshes and associated resources
  120786. */
  120787. rootUrl: string,
  120788. /**
  120789. * Defines the filename of the scene to load from
  120790. */
  120791. sceneFilename: string);
  120792. /**
  120793. * Execute the current task
  120794. * @param scene defines the scene where you want your assets to be loaded
  120795. * @param onSuccess is a callback called when the task is successfully executed
  120796. * @param onError is a callback called if an error occurs
  120797. */
  120798. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120799. }
  120800. /**
  120801. * Define a task used by AssetsManager to load text content
  120802. */
  120803. export class TextFileAssetTask extends AbstractAssetTask {
  120804. /**
  120805. * Defines the name of the task
  120806. */
  120807. name: string;
  120808. /**
  120809. * Defines the location of the file to load
  120810. */
  120811. url: string;
  120812. /**
  120813. * Gets the loaded text string
  120814. */
  120815. text: string;
  120816. /**
  120817. * Callback called when the task is successful
  120818. */
  120819. onSuccess: (task: TextFileAssetTask) => void;
  120820. /**
  120821. * Callback called when the task is successful
  120822. */
  120823. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  120824. /**
  120825. * Creates a new TextFileAssetTask object
  120826. * @param name defines the name of the task
  120827. * @param url defines the location of the file to load
  120828. */
  120829. constructor(
  120830. /**
  120831. * Defines the name of the task
  120832. */
  120833. name: string,
  120834. /**
  120835. * Defines the location of the file to load
  120836. */
  120837. url: string);
  120838. /**
  120839. * Execute the current task
  120840. * @param scene defines the scene where you want your assets to be loaded
  120841. * @param onSuccess is a callback called when the task is successfully executed
  120842. * @param onError is a callback called if an error occurs
  120843. */
  120844. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120845. }
  120846. /**
  120847. * Define a task used by AssetsManager to load binary data
  120848. */
  120849. export class BinaryFileAssetTask extends AbstractAssetTask {
  120850. /**
  120851. * Defines the name of the task
  120852. */
  120853. name: string;
  120854. /**
  120855. * Defines the location of the file to load
  120856. */
  120857. url: string;
  120858. /**
  120859. * Gets the lodaded data (as an array buffer)
  120860. */
  120861. data: ArrayBuffer;
  120862. /**
  120863. * Callback called when the task is successful
  120864. */
  120865. onSuccess: (task: BinaryFileAssetTask) => void;
  120866. /**
  120867. * Callback called when the task is successful
  120868. */
  120869. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  120870. /**
  120871. * Creates a new BinaryFileAssetTask object
  120872. * @param name defines the name of the new task
  120873. * @param url defines the location of the file to load
  120874. */
  120875. constructor(
  120876. /**
  120877. * Defines the name of the task
  120878. */
  120879. name: string,
  120880. /**
  120881. * Defines the location of the file to load
  120882. */
  120883. url: string);
  120884. /**
  120885. * Execute the current task
  120886. * @param scene defines the scene where you want your assets to be loaded
  120887. * @param onSuccess is a callback called when the task is successfully executed
  120888. * @param onError is a callback called if an error occurs
  120889. */
  120890. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120891. }
  120892. /**
  120893. * Define a task used by AssetsManager to load images
  120894. */
  120895. export class ImageAssetTask extends AbstractAssetTask {
  120896. /**
  120897. * Defines the name of the task
  120898. */
  120899. name: string;
  120900. /**
  120901. * Defines the location of the image to load
  120902. */
  120903. url: string;
  120904. /**
  120905. * Gets the loaded images
  120906. */
  120907. image: HTMLImageElement;
  120908. /**
  120909. * Callback called when the task is successful
  120910. */
  120911. onSuccess: (task: ImageAssetTask) => void;
  120912. /**
  120913. * Callback called when the task is successful
  120914. */
  120915. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  120916. /**
  120917. * Creates a new ImageAssetTask
  120918. * @param name defines the name of the task
  120919. * @param url defines the location of the image to load
  120920. */
  120921. constructor(
  120922. /**
  120923. * Defines the name of the task
  120924. */
  120925. name: string,
  120926. /**
  120927. * Defines the location of the image to load
  120928. */
  120929. url: string);
  120930. /**
  120931. * Execute the current task
  120932. * @param scene defines the scene where you want your assets to be loaded
  120933. * @param onSuccess is a callback called when the task is successfully executed
  120934. * @param onError is a callback called if an error occurs
  120935. */
  120936. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120937. }
  120938. /**
  120939. * Defines the interface used by texture loading tasks
  120940. */
  120941. export interface ITextureAssetTask<TEX extends BaseTexture> {
  120942. /**
  120943. * Gets the loaded texture
  120944. */
  120945. texture: TEX;
  120946. }
  120947. /**
  120948. * Define a task used by AssetsManager to load 2D textures
  120949. */
  120950. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  120951. /**
  120952. * Defines the name of the task
  120953. */
  120954. name: string;
  120955. /**
  120956. * Defines the location of the file to load
  120957. */
  120958. url: string;
  120959. /**
  120960. * Defines if mipmap should not be generated (default is false)
  120961. */
  120962. noMipmap?: boolean | undefined;
  120963. /**
  120964. * Defines if texture must be inverted on Y axis (default is false)
  120965. */
  120966. invertY?: boolean | undefined;
  120967. /**
  120968. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120969. */
  120970. samplingMode: number;
  120971. /**
  120972. * Gets the loaded texture
  120973. */
  120974. texture: Texture;
  120975. /**
  120976. * Callback called when the task is successful
  120977. */
  120978. onSuccess: (task: TextureAssetTask) => void;
  120979. /**
  120980. * Callback called when the task is successful
  120981. */
  120982. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  120983. /**
  120984. * Creates a new TextureAssetTask object
  120985. * @param name defines the name of the task
  120986. * @param url defines the location of the file to load
  120987. * @param noMipmap defines if mipmap should not be generated (default is false)
  120988. * @param invertY defines if texture must be inverted on Y axis (default is false)
  120989. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120990. */
  120991. constructor(
  120992. /**
  120993. * Defines the name of the task
  120994. */
  120995. name: string,
  120996. /**
  120997. * Defines the location of the file to load
  120998. */
  120999. url: string,
  121000. /**
  121001. * Defines if mipmap should not be generated (default is false)
  121002. */
  121003. noMipmap?: boolean | undefined,
  121004. /**
  121005. * Defines if texture must be inverted on Y axis (default is false)
  121006. */
  121007. invertY?: boolean | undefined,
  121008. /**
  121009. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121010. */
  121011. samplingMode?: number);
  121012. /**
  121013. * Execute the current task
  121014. * @param scene defines the scene where you want your assets to be loaded
  121015. * @param onSuccess is a callback called when the task is successfully executed
  121016. * @param onError is a callback called if an error occurs
  121017. */
  121018. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121019. }
  121020. /**
  121021. * Define a task used by AssetsManager to load cube textures
  121022. */
  121023. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  121024. /**
  121025. * Defines the name of the task
  121026. */
  121027. name: string;
  121028. /**
  121029. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121030. */
  121031. url: string;
  121032. /**
  121033. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121034. */
  121035. extensions?: string[] | undefined;
  121036. /**
  121037. * Defines if mipmaps should not be generated (default is false)
  121038. */
  121039. noMipmap?: boolean | undefined;
  121040. /**
  121041. * Defines the explicit list of files (undefined by default)
  121042. */
  121043. files?: string[] | undefined;
  121044. /**
  121045. * Gets the loaded texture
  121046. */
  121047. texture: CubeTexture;
  121048. /**
  121049. * Callback called when the task is successful
  121050. */
  121051. onSuccess: (task: CubeTextureAssetTask) => void;
  121052. /**
  121053. * Callback called when the task is successful
  121054. */
  121055. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  121056. /**
  121057. * Creates a new CubeTextureAssetTask
  121058. * @param name defines the name of the task
  121059. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121060. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121061. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121062. * @param files defines the explicit list of files (undefined by default)
  121063. */
  121064. constructor(
  121065. /**
  121066. * Defines the name of the task
  121067. */
  121068. name: string,
  121069. /**
  121070. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121071. */
  121072. url: string,
  121073. /**
  121074. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121075. */
  121076. extensions?: string[] | undefined,
  121077. /**
  121078. * Defines if mipmaps should not be generated (default is false)
  121079. */
  121080. noMipmap?: boolean | undefined,
  121081. /**
  121082. * Defines the explicit list of files (undefined by default)
  121083. */
  121084. files?: string[] | undefined);
  121085. /**
  121086. * Execute the current task
  121087. * @param scene defines the scene where you want your assets to be loaded
  121088. * @param onSuccess is a callback called when the task is successfully executed
  121089. * @param onError is a callback called if an error occurs
  121090. */
  121091. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121092. }
  121093. /**
  121094. * Define a task used by AssetsManager to load HDR cube textures
  121095. */
  121096. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  121097. /**
  121098. * Defines the name of the task
  121099. */
  121100. name: string;
  121101. /**
  121102. * Defines the location of the file to load
  121103. */
  121104. url: string;
  121105. /**
  121106. * Defines the desired size (the more it increases the longer the generation will be)
  121107. */
  121108. size: number;
  121109. /**
  121110. * Defines if mipmaps should not be generated (default is false)
  121111. */
  121112. noMipmap: boolean;
  121113. /**
  121114. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121115. */
  121116. generateHarmonics: boolean;
  121117. /**
  121118. * 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)
  121119. */
  121120. gammaSpace: boolean;
  121121. /**
  121122. * Internal Use Only
  121123. */
  121124. reserved: boolean;
  121125. /**
  121126. * Gets the loaded texture
  121127. */
  121128. texture: HDRCubeTexture;
  121129. /**
  121130. * Callback called when the task is successful
  121131. */
  121132. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  121133. /**
  121134. * Callback called when the task is successful
  121135. */
  121136. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  121137. /**
  121138. * Creates a new HDRCubeTextureAssetTask object
  121139. * @param name defines the name of the task
  121140. * @param url defines the location of the file to load
  121141. * @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.
  121142. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121143. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121144. * @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)
  121145. * @param reserved Internal use only
  121146. */
  121147. constructor(
  121148. /**
  121149. * Defines the name of the task
  121150. */
  121151. name: string,
  121152. /**
  121153. * Defines the location of the file to load
  121154. */
  121155. url: string,
  121156. /**
  121157. * Defines the desired size (the more it increases the longer the generation will be)
  121158. */
  121159. size: number,
  121160. /**
  121161. * Defines if mipmaps should not be generated (default is false)
  121162. */
  121163. noMipmap?: boolean,
  121164. /**
  121165. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121166. */
  121167. generateHarmonics?: boolean,
  121168. /**
  121169. * 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)
  121170. */
  121171. gammaSpace?: boolean,
  121172. /**
  121173. * Internal Use Only
  121174. */
  121175. reserved?: boolean);
  121176. /**
  121177. * Execute the current task
  121178. * @param scene defines the scene where you want your assets to be loaded
  121179. * @param onSuccess is a callback called when the task is successfully executed
  121180. * @param onError is a callback called if an error occurs
  121181. */
  121182. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121183. }
  121184. /**
  121185. * Define a task used by AssetsManager to load Equirectangular cube textures
  121186. */
  121187. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  121188. /**
  121189. * Defines the name of the task
  121190. */
  121191. name: string;
  121192. /**
  121193. * Defines the location of the file to load
  121194. */
  121195. url: string;
  121196. /**
  121197. * Defines the desired size (the more it increases the longer the generation will be)
  121198. */
  121199. size: number;
  121200. /**
  121201. * Defines if mipmaps should not be generated (default is false)
  121202. */
  121203. noMipmap: boolean;
  121204. /**
  121205. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121206. * but the standard material would require them in Gamma space) (default is true)
  121207. */
  121208. gammaSpace: boolean;
  121209. /**
  121210. * Gets the loaded texture
  121211. */
  121212. texture: EquiRectangularCubeTexture;
  121213. /**
  121214. * Callback called when the task is successful
  121215. */
  121216. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  121217. /**
  121218. * Callback called when the task is successful
  121219. */
  121220. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  121221. /**
  121222. * Creates a new EquiRectangularCubeTextureAssetTask object
  121223. * @param name defines the name of the task
  121224. * @param url defines the location of the file to load
  121225. * @param size defines the desired size (the more it increases the longer the generation will be)
  121226. * If the size is omitted this implies you are using a preprocessed cubemap.
  121227. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121228. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  121229. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  121230. * (default is true)
  121231. */
  121232. constructor(
  121233. /**
  121234. * Defines the name of the task
  121235. */
  121236. name: string,
  121237. /**
  121238. * Defines the location of the file to load
  121239. */
  121240. url: string,
  121241. /**
  121242. * Defines the desired size (the more it increases the longer the generation will be)
  121243. */
  121244. size: number,
  121245. /**
  121246. * Defines if mipmaps should not be generated (default is false)
  121247. */
  121248. noMipmap?: boolean,
  121249. /**
  121250. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121251. * but the standard material would require them in Gamma space) (default is true)
  121252. */
  121253. gammaSpace?: boolean);
  121254. /**
  121255. * Execute the current task
  121256. * @param scene defines the scene where you want your assets to be loaded
  121257. * @param onSuccess is a callback called when the task is successfully executed
  121258. * @param onError is a callback called if an error occurs
  121259. */
  121260. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121261. }
  121262. /**
  121263. * This class can be used to easily import assets into a scene
  121264. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  121265. */
  121266. export class AssetsManager {
  121267. private _scene;
  121268. private _isLoading;
  121269. protected _tasks: AbstractAssetTask[];
  121270. protected _waitingTasksCount: number;
  121271. protected _totalTasksCount: number;
  121272. /**
  121273. * Callback called when all tasks are processed
  121274. */
  121275. onFinish: (tasks: AbstractAssetTask[]) => void;
  121276. /**
  121277. * Callback called when a task is successful
  121278. */
  121279. onTaskSuccess: (task: AbstractAssetTask) => void;
  121280. /**
  121281. * Callback called when a task had an error
  121282. */
  121283. onTaskError: (task: AbstractAssetTask) => void;
  121284. /**
  121285. * Callback called when a task is done (whatever the result is)
  121286. */
  121287. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  121288. /**
  121289. * Observable called when all tasks are processed
  121290. */
  121291. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  121292. /**
  121293. * Observable called when a task had an error
  121294. */
  121295. onTaskErrorObservable: Observable<AbstractAssetTask>;
  121296. /**
  121297. * Observable called when all tasks were executed
  121298. */
  121299. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  121300. /**
  121301. * Observable called when a task is done (whatever the result is)
  121302. */
  121303. onProgressObservable: Observable<IAssetsProgressEvent>;
  121304. /**
  121305. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  121306. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121307. */
  121308. useDefaultLoadingScreen: boolean;
  121309. /**
  121310. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  121311. * when all assets have been downloaded.
  121312. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  121313. */
  121314. autoHideLoadingUI: boolean;
  121315. /**
  121316. * Creates a new AssetsManager
  121317. * @param scene defines the scene to work on
  121318. */
  121319. constructor(scene: Scene);
  121320. /**
  121321. * Add a MeshAssetTask to the list of active tasks
  121322. * @param taskName defines the name of the new task
  121323. * @param meshesNames defines the name of meshes to load
  121324. * @param rootUrl defines the root url to use to locate files
  121325. * @param sceneFilename defines the filename of the scene file
  121326. * @returns a new MeshAssetTask object
  121327. */
  121328. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  121329. /**
  121330. * Add a TextFileAssetTask to the list of active tasks
  121331. * @param taskName defines the name of the new task
  121332. * @param url defines the url of the file to load
  121333. * @returns a new TextFileAssetTask object
  121334. */
  121335. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  121336. /**
  121337. * Add a BinaryFileAssetTask to the list of active tasks
  121338. * @param taskName defines the name of the new task
  121339. * @param url defines the url of the file to load
  121340. * @returns a new BinaryFileAssetTask object
  121341. */
  121342. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  121343. /**
  121344. * Add a ImageAssetTask to the list of active tasks
  121345. * @param taskName defines the name of the new task
  121346. * @param url defines the url of the file to load
  121347. * @returns a new ImageAssetTask object
  121348. */
  121349. addImageTask(taskName: string, url: string): ImageAssetTask;
  121350. /**
  121351. * Add a TextureAssetTask to the list of active tasks
  121352. * @param taskName defines the name of the new task
  121353. * @param url defines the url of the file to load
  121354. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121355. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  121356. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121357. * @returns a new TextureAssetTask object
  121358. */
  121359. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  121360. /**
  121361. * Add a CubeTextureAssetTask to the list of active tasks
  121362. * @param taskName defines the name of the new task
  121363. * @param url defines the url of the file to load
  121364. * @param extensions defines the extension to use to load the cube map (can be null)
  121365. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121366. * @param files defines the list of files to load (can be null)
  121367. * @returns a new CubeTextureAssetTask object
  121368. */
  121369. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  121370. /**
  121371. *
  121372. * Add a HDRCubeTextureAssetTask to the list of active tasks
  121373. * @param taskName defines the name of the new task
  121374. * @param url defines the url of the file to load
  121375. * @param size defines the size you want for the cubemap (can be null)
  121376. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121377. * @param generateHarmonics defines if you want to automatically generate (true by default)
  121378. * @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)
  121379. * @param reserved Internal use only
  121380. * @returns a new HDRCubeTextureAssetTask object
  121381. */
  121382. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  121383. /**
  121384. *
  121385. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  121386. * @param taskName defines the name of the new task
  121387. * @param url defines the url of the file to load
  121388. * @param size defines the size you want for the cubemap (can be null)
  121389. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121390. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  121391. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  121392. * @returns a new EquiRectangularCubeTextureAssetTask object
  121393. */
  121394. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  121395. /**
  121396. * Remove a task from the assets manager.
  121397. * @param task the task to remove
  121398. */
  121399. removeTask(task: AbstractAssetTask): void;
  121400. private _decreaseWaitingTasksCount;
  121401. private _runTask;
  121402. /**
  121403. * Reset the AssetsManager and remove all tasks
  121404. * @return the current instance of the AssetsManager
  121405. */
  121406. reset(): AssetsManager;
  121407. /**
  121408. * Start the loading process
  121409. * @return the current instance of the AssetsManager
  121410. */
  121411. load(): AssetsManager;
  121412. /**
  121413. * Start the loading process as an async operation
  121414. * @return a promise returning the list of failed tasks
  121415. */
  121416. loadAsync(): Promise<void>;
  121417. }
  121418. }
  121419. declare module BABYLON {
  121420. /**
  121421. * Wrapper class for promise with external resolve and reject.
  121422. */
  121423. export class Deferred<T> {
  121424. /**
  121425. * The promise associated with this deferred object.
  121426. */
  121427. readonly promise: Promise<T>;
  121428. private _resolve;
  121429. private _reject;
  121430. /**
  121431. * The resolve method of the promise associated with this deferred object.
  121432. */
  121433. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  121434. /**
  121435. * The reject method of the promise associated with this deferred object.
  121436. */
  121437. readonly reject: (reason?: any) => void;
  121438. /**
  121439. * Constructor for this deferred object.
  121440. */
  121441. constructor();
  121442. }
  121443. }
  121444. declare module BABYLON {
  121445. /**
  121446. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  121447. */
  121448. export class MeshExploder {
  121449. private _centerMesh;
  121450. private _meshes;
  121451. private _meshesOrigins;
  121452. private _toCenterVectors;
  121453. private _scaledDirection;
  121454. private _newPosition;
  121455. private _centerPosition;
  121456. /**
  121457. * Explodes meshes from a center mesh.
  121458. * @param meshes The meshes to explode.
  121459. * @param centerMesh The mesh to be center of explosion.
  121460. */
  121461. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  121462. private _setCenterMesh;
  121463. /**
  121464. * Get class name
  121465. * @returns "MeshExploder"
  121466. */
  121467. getClassName(): string;
  121468. /**
  121469. * "Exploded meshes"
  121470. * @returns Array of meshes with the centerMesh at index 0.
  121471. */
  121472. getMeshes(): Array<Mesh>;
  121473. /**
  121474. * Explodes meshes giving a specific direction
  121475. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  121476. */
  121477. explode(direction?: number): void;
  121478. }
  121479. }
  121480. declare module BABYLON {
  121481. /**
  121482. * Class used to help managing file picking and drag'n'drop
  121483. */
  121484. export class FilesInput {
  121485. /**
  121486. * List of files ready to be loaded
  121487. */
  121488. static readonly FilesToLoad: {
  121489. [key: string]: File;
  121490. };
  121491. /**
  121492. * Callback called when a file is processed
  121493. */
  121494. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  121495. private _engine;
  121496. private _currentScene;
  121497. private _sceneLoadedCallback;
  121498. private _progressCallback;
  121499. private _additionalRenderLoopLogicCallback;
  121500. private _textureLoadingCallback;
  121501. private _startingProcessingFilesCallback;
  121502. private _onReloadCallback;
  121503. private _errorCallback;
  121504. private _elementToMonitor;
  121505. private _sceneFileToLoad;
  121506. private _filesToLoad;
  121507. /**
  121508. * Creates a new FilesInput
  121509. * @param engine defines the rendering engine
  121510. * @param scene defines the hosting scene
  121511. * @param sceneLoadedCallback callback called when scene is loaded
  121512. * @param progressCallback callback called to track progress
  121513. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  121514. * @param textureLoadingCallback callback called when a texture is loading
  121515. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  121516. * @param onReloadCallback callback called when a reload is requested
  121517. * @param errorCallback callback call if an error occurs
  121518. */
  121519. 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);
  121520. private _dragEnterHandler;
  121521. private _dragOverHandler;
  121522. private _dropHandler;
  121523. /**
  121524. * Calls this function to listen to drag'n'drop events on a specific DOM element
  121525. * @param elementToMonitor defines the DOM element to track
  121526. */
  121527. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  121528. /**
  121529. * Release all associated resources
  121530. */
  121531. dispose(): void;
  121532. private renderFunction;
  121533. private drag;
  121534. private drop;
  121535. private _traverseFolder;
  121536. private _processFiles;
  121537. /**
  121538. * Load files from a drop event
  121539. * @param event defines the drop event to use as source
  121540. */
  121541. loadFiles(event: any): void;
  121542. private _processReload;
  121543. /**
  121544. * Reload the current scene from the loaded files
  121545. */
  121546. reload(): void;
  121547. }
  121548. }
  121549. declare module BABYLON {
  121550. /**
  121551. * Defines the root class used to create scene optimization to use with SceneOptimizer
  121552. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121553. */
  121554. export class SceneOptimization {
  121555. /**
  121556. * Defines the priority of this optimization (0 by default which means first in the list)
  121557. */
  121558. priority: number;
  121559. /**
  121560. * Gets a string describing the action executed by the current optimization
  121561. * @returns description string
  121562. */
  121563. getDescription(): string;
  121564. /**
  121565. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121566. * @param scene defines the current scene where to apply this optimization
  121567. * @param optimizer defines the current optimizer
  121568. * @returns true if everything that can be done was applied
  121569. */
  121570. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121571. /**
  121572. * Creates the SceneOptimization object
  121573. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121574. * @param desc defines the description associated with the optimization
  121575. */
  121576. constructor(
  121577. /**
  121578. * Defines the priority of this optimization (0 by default which means first in the list)
  121579. */
  121580. priority?: number);
  121581. }
  121582. /**
  121583. * Defines an optimization used to reduce the size of render target textures
  121584. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121585. */
  121586. export class TextureOptimization extends SceneOptimization {
  121587. /**
  121588. * Defines the priority of this optimization (0 by default which means first in the list)
  121589. */
  121590. priority: number;
  121591. /**
  121592. * 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
  121593. */
  121594. maximumSize: number;
  121595. /**
  121596. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121597. */
  121598. step: number;
  121599. /**
  121600. * Gets a string describing the action executed by the current optimization
  121601. * @returns description string
  121602. */
  121603. getDescription(): string;
  121604. /**
  121605. * Creates the TextureOptimization object
  121606. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121607. * @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
  121608. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121609. */
  121610. constructor(
  121611. /**
  121612. * Defines the priority of this optimization (0 by default which means first in the list)
  121613. */
  121614. priority?: number,
  121615. /**
  121616. * 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
  121617. */
  121618. maximumSize?: number,
  121619. /**
  121620. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121621. */
  121622. step?: number);
  121623. /**
  121624. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121625. * @param scene defines the current scene where to apply this optimization
  121626. * @param optimizer defines the current optimizer
  121627. * @returns true if everything that can be done was applied
  121628. */
  121629. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121630. }
  121631. /**
  121632. * Defines an optimization used to increase or decrease the rendering resolution
  121633. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121634. */
  121635. export class HardwareScalingOptimization extends SceneOptimization {
  121636. /**
  121637. * Defines the priority of this optimization (0 by default which means first in the list)
  121638. */
  121639. priority: number;
  121640. /**
  121641. * Defines the maximum scale to use (2 by default)
  121642. */
  121643. maximumScale: number;
  121644. /**
  121645. * Defines the step to use between two passes (0.5 by default)
  121646. */
  121647. step: number;
  121648. private _currentScale;
  121649. private _directionOffset;
  121650. /**
  121651. * Gets a string describing the action executed by the current optimization
  121652. * @return description string
  121653. */
  121654. getDescription(): string;
  121655. /**
  121656. * Creates the HardwareScalingOptimization object
  121657. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121658. * @param maximumScale defines the maximum scale to use (2 by default)
  121659. * @param step defines the step to use between two passes (0.5 by default)
  121660. */
  121661. constructor(
  121662. /**
  121663. * Defines the priority of this optimization (0 by default which means first in the list)
  121664. */
  121665. priority?: number,
  121666. /**
  121667. * Defines the maximum scale to use (2 by default)
  121668. */
  121669. maximumScale?: number,
  121670. /**
  121671. * Defines the step to use between two passes (0.5 by default)
  121672. */
  121673. step?: number);
  121674. /**
  121675. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121676. * @param scene defines the current scene where to apply this optimization
  121677. * @param optimizer defines the current optimizer
  121678. * @returns true if everything that can be done was applied
  121679. */
  121680. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121681. }
  121682. /**
  121683. * Defines an optimization used to remove shadows
  121684. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121685. */
  121686. export class ShadowsOptimization extends SceneOptimization {
  121687. /**
  121688. * Gets a string describing the action executed by the current optimization
  121689. * @return description string
  121690. */
  121691. getDescription(): string;
  121692. /**
  121693. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121694. * @param scene defines the current scene where to apply this optimization
  121695. * @param optimizer defines the current optimizer
  121696. * @returns true if everything that can be done was applied
  121697. */
  121698. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121699. }
  121700. /**
  121701. * Defines an optimization used to turn post-processes off
  121702. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121703. */
  121704. export class PostProcessesOptimization extends SceneOptimization {
  121705. /**
  121706. * Gets a string describing the action executed by the current optimization
  121707. * @return description string
  121708. */
  121709. getDescription(): string;
  121710. /**
  121711. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121712. * @param scene defines the current scene where to apply this optimization
  121713. * @param optimizer defines the current optimizer
  121714. * @returns true if everything that can be done was applied
  121715. */
  121716. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121717. }
  121718. /**
  121719. * Defines an optimization used to turn lens flares off
  121720. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121721. */
  121722. export class LensFlaresOptimization extends SceneOptimization {
  121723. /**
  121724. * Gets a string describing the action executed by the current optimization
  121725. * @return description string
  121726. */
  121727. getDescription(): string;
  121728. /**
  121729. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121730. * @param scene defines the current scene where to apply this optimization
  121731. * @param optimizer defines the current optimizer
  121732. * @returns true if everything that can be done was applied
  121733. */
  121734. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121735. }
  121736. /**
  121737. * Defines an optimization based on user defined callback.
  121738. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121739. */
  121740. export class CustomOptimization extends SceneOptimization {
  121741. /**
  121742. * Callback called to apply the custom optimization.
  121743. */
  121744. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  121745. /**
  121746. * Callback called to get custom description
  121747. */
  121748. onGetDescription: () => string;
  121749. /**
  121750. * Gets a string describing the action executed by the current optimization
  121751. * @returns description string
  121752. */
  121753. getDescription(): string;
  121754. /**
  121755. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121756. * @param scene defines the current scene where to apply this optimization
  121757. * @param optimizer defines the current optimizer
  121758. * @returns true if everything that can be done was applied
  121759. */
  121760. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121761. }
  121762. /**
  121763. * Defines an optimization used to turn particles off
  121764. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121765. */
  121766. export class ParticlesOptimization extends SceneOptimization {
  121767. /**
  121768. * Gets a string describing the action executed by the current optimization
  121769. * @return description string
  121770. */
  121771. getDescription(): string;
  121772. /**
  121773. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121774. * @param scene defines the current scene where to apply this optimization
  121775. * @param optimizer defines the current optimizer
  121776. * @returns true if everything that can be done was applied
  121777. */
  121778. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121779. }
  121780. /**
  121781. * Defines an optimization used to turn render targets off
  121782. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121783. */
  121784. export class RenderTargetsOptimization extends SceneOptimization {
  121785. /**
  121786. * Gets a string describing the action executed by the current optimization
  121787. * @return description string
  121788. */
  121789. getDescription(): string;
  121790. /**
  121791. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121792. * @param scene defines the current scene where to apply this optimization
  121793. * @param optimizer defines the current optimizer
  121794. * @returns true if everything that can be done was applied
  121795. */
  121796. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121797. }
  121798. /**
  121799. * Defines an optimization used to merge meshes with compatible materials
  121800. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121801. */
  121802. export class MergeMeshesOptimization extends SceneOptimization {
  121803. private static _UpdateSelectionTree;
  121804. /**
  121805. * Gets or sets a boolean which defines if optimization octree has to be updated
  121806. */
  121807. /**
  121808. * Gets or sets a boolean which defines if optimization octree has to be updated
  121809. */
  121810. static UpdateSelectionTree: boolean;
  121811. /**
  121812. * Gets a string describing the action executed by the current optimization
  121813. * @return description string
  121814. */
  121815. getDescription(): string;
  121816. private _canBeMerged;
  121817. /**
  121818. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121819. * @param scene defines the current scene where to apply this optimization
  121820. * @param optimizer defines the current optimizer
  121821. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  121822. * @returns true if everything that can be done was applied
  121823. */
  121824. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  121825. }
  121826. /**
  121827. * Defines a list of options used by SceneOptimizer
  121828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121829. */
  121830. export class SceneOptimizerOptions {
  121831. /**
  121832. * Defines the target frame rate to reach (60 by default)
  121833. */
  121834. targetFrameRate: number;
  121835. /**
  121836. * Defines the interval between two checkes (2000ms by default)
  121837. */
  121838. trackerDuration: number;
  121839. /**
  121840. * Gets the list of optimizations to apply
  121841. */
  121842. optimizations: SceneOptimization[];
  121843. /**
  121844. * Creates a new list of options used by SceneOptimizer
  121845. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  121846. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  121847. */
  121848. constructor(
  121849. /**
  121850. * Defines the target frame rate to reach (60 by default)
  121851. */
  121852. targetFrameRate?: number,
  121853. /**
  121854. * Defines the interval between two checkes (2000ms by default)
  121855. */
  121856. trackerDuration?: number);
  121857. /**
  121858. * Add a new optimization
  121859. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  121860. * @returns the current SceneOptimizerOptions
  121861. */
  121862. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  121863. /**
  121864. * Add a new custom optimization
  121865. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  121866. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  121867. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121868. * @returns the current SceneOptimizerOptions
  121869. */
  121870. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  121871. /**
  121872. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  121873. * @param targetFrameRate defines the target frame rate (60 by default)
  121874. * @returns a SceneOptimizerOptions object
  121875. */
  121876. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121877. /**
  121878. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  121879. * @param targetFrameRate defines the target frame rate (60 by default)
  121880. * @returns a SceneOptimizerOptions object
  121881. */
  121882. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121883. /**
  121884. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  121885. * @param targetFrameRate defines the target frame rate (60 by default)
  121886. * @returns a SceneOptimizerOptions object
  121887. */
  121888. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121889. }
  121890. /**
  121891. * Class used to run optimizations in order to reach a target frame rate
  121892. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121893. */
  121894. export class SceneOptimizer implements IDisposable {
  121895. private _isRunning;
  121896. private _options;
  121897. private _scene;
  121898. private _currentPriorityLevel;
  121899. private _targetFrameRate;
  121900. private _trackerDuration;
  121901. private _currentFrameRate;
  121902. private _sceneDisposeObserver;
  121903. private _improvementMode;
  121904. /**
  121905. * Defines an observable called when the optimizer reaches the target frame rate
  121906. */
  121907. onSuccessObservable: Observable<SceneOptimizer>;
  121908. /**
  121909. * Defines an observable called when the optimizer enables an optimization
  121910. */
  121911. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  121912. /**
  121913. * Defines an observable called when the optimizer is not able to reach the target frame rate
  121914. */
  121915. onFailureObservable: Observable<SceneOptimizer>;
  121916. /**
  121917. * Gets a boolean indicating if the optimizer is in improvement mode
  121918. */
  121919. readonly isInImprovementMode: boolean;
  121920. /**
  121921. * Gets the current priority level (0 at start)
  121922. */
  121923. readonly currentPriorityLevel: number;
  121924. /**
  121925. * Gets the current frame rate checked by the SceneOptimizer
  121926. */
  121927. readonly currentFrameRate: number;
  121928. /**
  121929. * Gets or sets the current target frame rate (60 by default)
  121930. */
  121931. /**
  121932. * Gets or sets the current target frame rate (60 by default)
  121933. */
  121934. targetFrameRate: number;
  121935. /**
  121936. * Gets or sets the current interval between two checks (every 2000ms by default)
  121937. */
  121938. /**
  121939. * Gets or sets the current interval between two checks (every 2000ms by default)
  121940. */
  121941. trackerDuration: number;
  121942. /**
  121943. * Gets the list of active optimizations
  121944. */
  121945. readonly optimizations: SceneOptimization[];
  121946. /**
  121947. * Creates a new SceneOptimizer
  121948. * @param scene defines the scene to work on
  121949. * @param options defines the options to use with the SceneOptimizer
  121950. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  121951. * @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)
  121952. */
  121953. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  121954. /**
  121955. * Stops the current optimizer
  121956. */
  121957. stop(): void;
  121958. /**
  121959. * Reset the optimizer to initial step (current priority level = 0)
  121960. */
  121961. reset(): void;
  121962. /**
  121963. * Start the optimizer. By default it will try to reach a specific framerate
  121964. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  121965. */
  121966. start(): void;
  121967. private _checkCurrentState;
  121968. /**
  121969. * Release all resources
  121970. */
  121971. dispose(): void;
  121972. /**
  121973. * Helper function to create a SceneOptimizer with one single line of code
  121974. * @param scene defines the scene to work on
  121975. * @param options defines the options to use with the SceneOptimizer
  121976. * @param onSuccess defines a callback to call on success
  121977. * @param onFailure defines a callback to call on failure
  121978. * @returns the new SceneOptimizer object
  121979. */
  121980. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  121981. }
  121982. }
  121983. declare module BABYLON {
  121984. /**
  121985. * Class used to serialize a scene into a string
  121986. */
  121987. export class SceneSerializer {
  121988. /**
  121989. * Clear cache used by a previous serialization
  121990. */
  121991. static ClearCache(): void;
  121992. /**
  121993. * Serialize a scene into a JSON compatible object
  121994. * @param scene defines the scene to serialize
  121995. * @returns a JSON compatible object
  121996. */
  121997. static Serialize(scene: Scene): any;
  121998. /**
  121999. * Serialize a mesh into a JSON compatible object
  122000. * @param toSerialize defines the mesh to serialize
  122001. * @param withParents defines if parents must be serialized as well
  122002. * @param withChildren defines if children must be serialized as well
  122003. * @returns a JSON compatible object
  122004. */
  122005. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  122006. }
  122007. }
  122008. declare module BABYLON {
  122009. /**
  122010. * Class used to host texture specific utilities
  122011. */
  122012. export class TextureTools {
  122013. /**
  122014. * Uses the GPU to create a copy texture rescaled at a given size
  122015. * @param texture Texture to copy from
  122016. * @param width defines the desired width
  122017. * @param height defines the desired height
  122018. * @param useBilinearMode defines if bilinear mode has to be used
  122019. * @return the generated texture
  122020. */
  122021. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  122022. }
  122023. }
  122024. declare module BABYLON {
  122025. /**
  122026. * This represents the different options available for the video capture.
  122027. */
  122028. export interface VideoRecorderOptions {
  122029. /** Defines the mime type of the video. */
  122030. mimeType: string;
  122031. /** Defines the FPS the video should be recorded at. */
  122032. fps: number;
  122033. /** Defines the chunk size for the recording data. */
  122034. recordChunckSize: number;
  122035. /** The audio tracks to attach to the recording. */
  122036. audioTracks?: MediaStreamTrack[];
  122037. }
  122038. /**
  122039. * This can help with recording videos from BabylonJS.
  122040. * This is based on the available WebRTC functionalities of the browser.
  122041. *
  122042. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  122043. */
  122044. export class VideoRecorder {
  122045. private static readonly _defaultOptions;
  122046. /**
  122047. * Returns whether or not the VideoRecorder is available in your browser.
  122048. * @param engine Defines the Babylon Engine.
  122049. * @returns true if supported otherwise false.
  122050. */
  122051. static IsSupported(engine: Engine): boolean;
  122052. private readonly _options;
  122053. private _canvas;
  122054. private _mediaRecorder;
  122055. private _recordedChunks;
  122056. private _fileName;
  122057. private _resolve;
  122058. private _reject;
  122059. /**
  122060. * True when a recording is already in progress.
  122061. */
  122062. readonly isRecording: boolean;
  122063. /**
  122064. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  122065. * @param engine Defines the BabylonJS Engine you wish to record.
  122066. * @param options Defines options that can be used to customize the capture.
  122067. */
  122068. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  122069. /**
  122070. * Stops the current recording before the default capture timeout passed in the startRecording function.
  122071. */
  122072. stopRecording(): void;
  122073. /**
  122074. * Starts recording the canvas for a max duration specified in parameters.
  122075. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  122076. * If null no automatic download will start and you can rely on the promise to get the data back.
  122077. * @param maxDuration Defines the maximum recording time in seconds.
  122078. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  122079. * @return A promise callback at the end of the recording with the video data in Blob.
  122080. */
  122081. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  122082. /**
  122083. * Releases internal resources used during the recording.
  122084. */
  122085. dispose(): void;
  122086. private _handleDataAvailable;
  122087. private _handleError;
  122088. private _handleStop;
  122089. }
  122090. }
  122091. declare module BABYLON {
  122092. /**
  122093. * Class containing a set of static utilities functions for screenshots
  122094. */
  122095. export class ScreenshotTools {
  122096. /**
  122097. * Captures a screenshot of the current rendering
  122098. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122099. * @param engine defines the rendering engine
  122100. * @param camera defines the source camera
  122101. * @param size This parameter can be set to a single number or to an object with the
  122102. * following (optional) properties: precision, width, height. If a single number is passed,
  122103. * it will be used for both width and height. If an object is passed, the screenshot size
  122104. * will be derived from the parameters. The precision property is a multiplier allowing
  122105. * rendering at a higher or lower resolution
  122106. * @param successCallback defines the callback receives a single parameter which contains the
  122107. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122108. * src parameter of an <img> to display it
  122109. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122110. * Check your browser for supported MIME types
  122111. */
  122112. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  122113. /**
  122114. * Generates an image screenshot from the specified camera.
  122115. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122116. * @param engine The engine to use for rendering
  122117. * @param camera The camera to use for rendering
  122118. * @param size This parameter can be set to a single number or to an object with the
  122119. * following (optional) properties: precision, width, height. If a single number is passed,
  122120. * it will be used for both width and height. If an object is passed, the screenshot size
  122121. * will be derived from the parameters. The precision property is a multiplier allowing
  122122. * rendering at a higher or lower resolution
  122123. * @param successCallback The callback receives a single parameter which contains the
  122124. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122125. * src parameter of an <img> to display it
  122126. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122127. * Check your browser for supported MIME types
  122128. * @param samples Texture samples (default: 1)
  122129. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122130. * @param fileName A name for for the downloaded file.
  122131. */
  122132. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122133. }
  122134. }
  122135. declare module BABYLON {
  122136. /**
  122137. * A cursor which tracks a point on a path
  122138. */
  122139. export class PathCursor {
  122140. private path;
  122141. /**
  122142. * Stores path cursor callbacks for when an onchange event is triggered
  122143. */
  122144. private _onchange;
  122145. /**
  122146. * The value of the path cursor
  122147. */
  122148. value: number;
  122149. /**
  122150. * The animation array of the path cursor
  122151. */
  122152. animations: Animation[];
  122153. /**
  122154. * Initializes the path cursor
  122155. * @param path The path to track
  122156. */
  122157. constructor(path: Path2);
  122158. /**
  122159. * Gets the cursor point on the path
  122160. * @returns A point on the path cursor at the cursor location
  122161. */
  122162. getPoint(): Vector3;
  122163. /**
  122164. * Moves the cursor ahead by the step amount
  122165. * @param step The amount to move the cursor forward
  122166. * @returns This path cursor
  122167. */
  122168. moveAhead(step?: number): PathCursor;
  122169. /**
  122170. * Moves the cursor behind by the step amount
  122171. * @param step The amount to move the cursor back
  122172. * @returns This path cursor
  122173. */
  122174. moveBack(step?: number): PathCursor;
  122175. /**
  122176. * Moves the cursor by the step amount
  122177. * If the step amount is greater than one, an exception is thrown
  122178. * @param step The amount to move the cursor
  122179. * @returns This path cursor
  122180. */
  122181. move(step: number): PathCursor;
  122182. /**
  122183. * Ensures that the value is limited between zero and one
  122184. * @returns This path cursor
  122185. */
  122186. private ensureLimits;
  122187. /**
  122188. * Runs onchange callbacks on change (used by the animation engine)
  122189. * @returns This path cursor
  122190. */
  122191. private raiseOnChange;
  122192. /**
  122193. * Executes a function on change
  122194. * @param f A path cursor onchange callback
  122195. * @returns This path cursor
  122196. */
  122197. onchange(f: (cursor: PathCursor) => void): PathCursor;
  122198. }
  122199. }
  122200. declare module BABYLON {
  122201. /** @hidden */
  122202. export var blurPixelShader: {
  122203. name: string;
  122204. shader: string;
  122205. };
  122206. }
  122207. declare module BABYLON {
  122208. /** @hidden */
  122209. export var pointCloudVertexDeclaration: {
  122210. name: string;
  122211. shader: string;
  122212. };
  122213. }
  122214. // Mixins
  122215. interface Window {
  122216. mozIndexedDB: IDBFactory;
  122217. webkitIndexedDB: IDBFactory;
  122218. msIndexedDB: IDBFactory;
  122219. webkitURL: typeof URL;
  122220. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  122221. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  122222. WebGLRenderingContext: WebGLRenderingContext;
  122223. MSGesture: MSGesture;
  122224. CANNON: any;
  122225. AudioContext: AudioContext;
  122226. webkitAudioContext: AudioContext;
  122227. PointerEvent: any;
  122228. Math: Math;
  122229. Uint8Array: Uint8ArrayConstructor;
  122230. Float32Array: Float32ArrayConstructor;
  122231. mozURL: typeof URL;
  122232. msURL: typeof URL;
  122233. VRFrameData: any; // WebVR, from specs 1.1
  122234. DracoDecoderModule: any;
  122235. setImmediate(handler: (...args: any[]) => void): number;
  122236. }
  122237. interface HTMLCanvasElement {
  122238. requestPointerLock(): void;
  122239. msRequestPointerLock?(): void;
  122240. mozRequestPointerLock?(): void;
  122241. webkitRequestPointerLock?(): void;
  122242. /** Track wether a record is in progress */
  122243. isRecording: boolean;
  122244. /** Capture Stream method defined by some browsers */
  122245. captureStream(fps?: number): MediaStream;
  122246. }
  122247. interface CanvasRenderingContext2D {
  122248. msImageSmoothingEnabled: boolean;
  122249. }
  122250. interface MouseEvent {
  122251. mozMovementX: number;
  122252. mozMovementY: number;
  122253. webkitMovementX: number;
  122254. webkitMovementY: number;
  122255. msMovementX: number;
  122256. msMovementY: number;
  122257. }
  122258. interface Navigator {
  122259. mozGetVRDevices: (any: any) => any;
  122260. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122261. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122262. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122263. webkitGetGamepads(): Gamepad[];
  122264. msGetGamepads(): Gamepad[];
  122265. webkitGamepads(): Gamepad[];
  122266. }
  122267. interface HTMLVideoElement {
  122268. mozSrcObject: any;
  122269. }
  122270. interface Math {
  122271. fround(x: number): number;
  122272. imul(a: number, b: number): number;
  122273. }
  122274. interface WebGLRenderingContext {
  122275. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  122276. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  122277. vertexAttribDivisor(index: number, divisor: number): void;
  122278. createVertexArray(): any;
  122279. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  122280. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  122281. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  122282. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  122283. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  122284. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  122285. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  122286. // Queries
  122287. createQuery(): WebGLQuery;
  122288. deleteQuery(query: WebGLQuery): void;
  122289. beginQuery(target: number, query: WebGLQuery): void;
  122290. endQuery(target: number): void;
  122291. getQueryParameter(query: WebGLQuery, pname: number): any;
  122292. getQuery(target: number, pname: number): any;
  122293. MAX_SAMPLES: number;
  122294. RGBA8: number;
  122295. READ_FRAMEBUFFER: number;
  122296. DRAW_FRAMEBUFFER: number;
  122297. UNIFORM_BUFFER: number;
  122298. HALF_FLOAT_OES: number;
  122299. RGBA16F: number;
  122300. RGBA32F: number;
  122301. R32F: number;
  122302. RG32F: number;
  122303. RGB32F: number;
  122304. R16F: number;
  122305. RG16F: number;
  122306. RGB16F: number;
  122307. RED: number;
  122308. RG: number;
  122309. R8: number;
  122310. RG8: number;
  122311. UNSIGNED_INT_24_8: number;
  122312. DEPTH24_STENCIL8: number;
  122313. /* Multiple Render Targets */
  122314. drawBuffers(buffers: number[]): void;
  122315. readBuffer(src: number): void;
  122316. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  122317. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  122318. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  122319. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  122320. // Occlusion Query
  122321. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  122322. ANY_SAMPLES_PASSED: number;
  122323. QUERY_RESULT_AVAILABLE: number;
  122324. QUERY_RESULT: number;
  122325. }
  122326. interface WebGLProgram {
  122327. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  122328. }
  122329. interface EXT_disjoint_timer_query {
  122330. QUERY_COUNTER_BITS_EXT: number;
  122331. TIME_ELAPSED_EXT: number;
  122332. TIMESTAMP_EXT: number;
  122333. GPU_DISJOINT_EXT: number;
  122334. QUERY_RESULT_EXT: number;
  122335. QUERY_RESULT_AVAILABLE_EXT: number;
  122336. queryCounterEXT(query: WebGLQuery, target: number): void;
  122337. createQueryEXT(): WebGLQuery;
  122338. beginQueryEXT(target: number, query: WebGLQuery): void;
  122339. endQueryEXT(target: number): void;
  122340. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  122341. deleteQueryEXT(query: WebGLQuery): void;
  122342. }
  122343. interface WebGLUniformLocation {
  122344. _currentState: any;
  122345. }
  122346. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  122347. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  122348. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  122349. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122350. interface WebGLRenderingContext {
  122351. readonly RASTERIZER_DISCARD: number;
  122352. readonly DEPTH_COMPONENT24: number;
  122353. readonly TEXTURE_3D: number;
  122354. readonly TEXTURE_2D_ARRAY: number;
  122355. readonly TEXTURE_COMPARE_FUNC: number;
  122356. readonly TEXTURE_COMPARE_MODE: number;
  122357. readonly COMPARE_REF_TO_TEXTURE: number;
  122358. readonly TEXTURE_WRAP_R: number;
  122359. readonly HALF_FLOAT: number;
  122360. readonly RGB8: number;
  122361. readonly RED_INTEGER: number;
  122362. readonly RG_INTEGER: number;
  122363. readonly RGB_INTEGER: number;
  122364. readonly RGBA_INTEGER: number;
  122365. readonly R8_SNORM: number;
  122366. readonly RG8_SNORM: number;
  122367. readonly RGB8_SNORM: number;
  122368. readonly RGBA8_SNORM: number;
  122369. readonly R8I: number;
  122370. readonly RG8I: number;
  122371. readonly RGB8I: number;
  122372. readonly RGBA8I: number;
  122373. readonly R8UI: number;
  122374. readonly RG8UI: number;
  122375. readonly RGB8UI: number;
  122376. readonly RGBA8UI: number;
  122377. readonly R16I: number;
  122378. readonly RG16I: number;
  122379. readonly RGB16I: number;
  122380. readonly RGBA16I: number;
  122381. readonly R16UI: number;
  122382. readonly RG16UI: number;
  122383. readonly RGB16UI: number;
  122384. readonly RGBA16UI: number;
  122385. readonly R32I: number;
  122386. readonly RG32I: number;
  122387. readonly RGB32I: number;
  122388. readonly RGBA32I: number;
  122389. readonly R32UI: number;
  122390. readonly RG32UI: number;
  122391. readonly RGB32UI: number;
  122392. readonly RGBA32UI: number;
  122393. readonly RGB10_A2UI: number;
  122394. readonly R11F_G11F_B10F: number;
  122395. readonly RGB9_E5: number;
  122396. readonly RGB10_A2: number;
  122397. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  122398. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  122399. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  122400. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  122401. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  122402. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  122403. 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;
  122404. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  122405. readonly TRANSFORM_FEEDBACK: number;
  122406. readonly INTERLEAVED_ATTRIBS: number;
  122407. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  122408. createTransformFeedback(): WebGLTransformFeedback;
  122409. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  122410. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  122411. beginTransformFeedback(primitiveMode: number): void;
  122412. endTransformFeedback(): void;
  122413. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  122414. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122415. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122416. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122417. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  122418. }
  122419. interface ImageBitmap {
  122420. readonly width: number;
  122421. readonly height: number;
  122422. close(): void;
  122423. }
  122424. interface WebGLQuery extends WebGLObject {
  122425. }
  122426. declare var WebGLQuery: {
  122427. prototype: WebGLQuery;
  122428. new(): WebGLQuery;
  122429. };
  122430. interface WebGLSampler extends WebGLObject {
  122431. }
  122432. declare var WebGLSampler: {
  122433. prototype: WebGLSampler;
  122434. new(): WebGLSampler;
  122435. };
  122436. interface WebGLSync extends WebGLObject {
  122437. }
  122438. declare var WebGLSync: {
  122439. prototype: WebGLSync;
  122440. new(): WebGLSync;
  122441. };
  122442. interface WebGLTransformFeedback extends WebGLObject {
  122443. }
  122444. declare var WebGLTransformFeedback: {
  122445. prototype: WebGLTransformFeedback;
  122446. new(): WebGLTransformFeedback;
  122447. };
  122448. interface WebGLVertexArrayObject extends WebGLObject {
  122449. }
  122450. declare var WebGLVertexArrayObject: {
  122451. prototype: WebGLVertexArrayObject;
  122452. new(): WebGLVertexArrayObject;
  122453. };
  122454. // Type definitions for WebVR API
  122455. // Project: https://w3c.github.io/webvr/
  122456. // Definitions by: six a <https://github.com/lostfictions>
  122457. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122458. interface VRDisplay extends EventTarget {
  122459. /**
  122460. * Dictionary of capabilities describing the VRDisplay.
  122461. */
  122462. readonly capabilities: VRDisplayCapabilities;
  122463. /**
  122464. * z-depth defining the far plane of the eye view frustum
  122465. * enables mapping of values in the render target depth
  122466. * attachment to scene coordinates. Initially set to 10000.0.
  122467. */
  122468. depthFar: number;
  122469. /**
  122470. * z-depth defining the near plane of the eye view frustum
  122471. * enables mapping of values in the render target depth
  122472. * attachment to scene coordinates. Initially set to 0.01.
  122473. */
  122474. depthNear: number;
  122475. /**
  122476. * An identifier for this distinct VRDisplay. Used as an
  122477. * association point in the Gamepad API.
  122478. */
  122479. readonly displayId: number;
  122480. /**
  122481. * A display name, a user-readable name identifying it.
  122482. */
  122483. readonly displayName: string;
  122484. readonly isConnected: boolean;
  122485. readonly isPresenting: boolean;
  122486. /**
  122487. * If this VRDisplay supports room-scale experiences, the optional
  122488. * stage attribute contains details on the room-scale parameters.
  122489. */
  122490. readonly stageParameters: VRStageParameters | null;
  122491. /**
  122492. * Passing the value returned by `requestAnimationFrame` to
  122493. * `cancelAnimationFrame` will unregister the callback.
  122494. * @param handle Define the hanle of the request to cancel
  122495. */
  122496. cancelAnimationFrame(handle: number): void;
  122497. /**
  122498. * Stops presenting to the VRDisplay.
  122499. * @returns a promise to know when it stopped
  122500. */
  122501. exitPresent(): Promise<void>;
  122502. /**
  122503. * Return the current VREyeParameters for the given eye.
  122504. * @param whichEye Define the eye we want the parameter for
  122505. * @returns the eye parameters
  122506. */
  122507. getEyeParameters(whichEye: string): VREyeParameters;
  122508. /**
  122509. * Populates the passed VRFrameData with the information required to render
  122510. * the current frame.
  122511. * @param frameData Define the data structure to populate
  122512. * @returns true if ok otherwise false
  122513. */
  122514. getFrameData(frameData: VRFrameData): boolean;
  122515. /**
  122516. * Get the layers currently being presented.
  122517. * @returns the list of VR layers
  122518. */
  122519. getLayers(): VRLayer[];
  122520. /**
  122521. * Return a VRPose containing the future predicted pose of the VRDisplay
  122522. * when the current frame will be presented. The value returned will not
  122523. * change until JavaScript has returned control to the browser.
  122524. *
  122525. * The VRPose will contain the position, orientation, velocity,
  122526. * and acceleration of each of these properties.
  122527. * @returns the pose object
  122528. */
  122529. getPose(): VRPose;
  122530. /**
  122531. * Return the current instantaneous pose of the VRDisplay, with no
  122532. * prediction applied.
  122533. * @returns the current instantaneous pose
  122534. */
  122535. getImmediatePose(): VRPose;
  122536. /**
  122537. * The callback passed to `requestAnimationFrame` will be called
  122538. * any time a new frame should be rendered. When the VRDisplay is
  122539. * presenting the callback will be called at the native refresh
  122540. * rate of the HMD. When not presenting this function acts
  122541. * identically to how window.requestAnimationFrame acts. Content should
  122542. * make no assumptions of frame rate or vsync behavior as the HMD runs
  122543. * asynchronously from other displays and at differing refresh rates.
  122544. * @param callback Define the eaction to run next frame
  122545. * @returns the request handle it
  122546. */
  122547. requestAnimationFrame(callback: FrameRequestCallback): number;
  122548. /**
  122549. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  122550. * Repeat calls while already presenting will update the VRLayers being displayed.
  122551. * @param layers Define the list of layer to present
  122552. * @returns a promise to know when the request has been fulfilled
  122553. */
  122554. requestPresent(layers: VRLayer[]): Promise<void>;
  122555. /**
  122556. * Reset the pose for this display, treating its current position and
  122557. * orientation as the "origin/zero" values. VRPose.position,
  122558. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  122559. * updated when calling resetPose(). This should be called in only
  122560. * sitting-space experiences.
  122561. */
  122562. resetPose(): void;
  122563. /**
  122564. * The VRLayer provided to the VRDisplay will be captured and presented
  122565. * in the HMD. Calling this function has the same effect on the source
  122566. * canvas as any other operation that uses its source image, and canvases
  122567. * created without preserveDrawingBuffer set to true will be cleared.
  122568. * @param pose Define the pose to submit
  122569. */
  122570. submitFrame(pose?: VRPose): void;
  122571. }
  122572. declare var VRDisplay: {
  122573. prototype: VRDisplay;
  122574. new(): VRDisplay;
  122575. };
  122576. interface VRLayer {
  122577. leftBounds?: number[] | Float32Array | null;
  122578. rightBounds?: number[] | Float32Array | null;
  122579. source?: HTMLCanvasElement | null;
  122580. }
  122581. interface VRDisplayCapabilities {
  122582. readonly canPresent: boolean;
  122583. readonly hasExternalDisplay: boolean;
  122584. readonly hasOrientation: boolean;
  122585. readonly hasPosition: boolean;
  122586. readonly maxLayers: number;
  122587. }
  122588. interface VREyeParameters {
  122589. /** @deprecated */
  122590. readonly fieldOfView: VRFieldOfView;
  122591. readonly offset: Float32Array;
  122592. readonly renderHeight: number;
  122593. readonly renderWidth: number;
  122594. }
  122595. interface VRFieldOfView {
  122596. readonly downDegrees: number;
  122597. readonly leftDegrees: number;
  122598. readonly rightDegrees: number;
  122599. readonly upDegrees: number;
  122600. }
  122601. interface VRFrameData {
  122602. readonly leftProjectionMatrix: Float32Array;
  122603. readonly leftViewMatrix: Float32Array;
  122604. readonly pose: VRPose;
  122605. readonly rightProjectionMatrix: Float32Array;
  122606. readonly rightViewMatrix: Float32Array;
  122607. readonly timestamp: number;
  122608. }
  122609. interface VRPose {
  122610. readonly angularAcceleration: Float32Array | null;
  122611. readonly angularVelocity: Float32Array | null;
  122612. readonly linearAcceleration: Float32Array | null;
  122613. readonly linearVelocity: Float32Array | null;
  122614. readonly orientation: Float32Array | null;
  122615. readonly position: Float32Array | null;
  122616. readonly timestamp: number;
  122617. }
  122618. interface VRStageParameters {
  122619. sittingToStandingTransform?: Float32Array;
  122620. sizeX?: number;
  122621. sizeY?: number;
  122622. }
  122623. interface Navigator {
  122624. getVRDisplays(): Promise<VRDisplay[]>;
  122625. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  122626. }
  122627. interface Window {
  122628. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  122629. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  122630. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  122631. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122632. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122633. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  122634. }
  122635. interface Gamepad {
  122636. readonly displayId: number;
  122637. }
  122638. type XRSessionMode =
  122639. | "inline"
  122640. | "immersive-vr"
  122641. | "immersive-ar";
  122642. type XRReferenceSpaceType =
  122643. | "viewer"
  122644. | "local"
  122645. | "local-floor"
  122646. | "bounded-floor"
  122647. | "unbounded";
  122648. type XREnvironmentBlendMode =
  122649. | "opaque"
  122650. | "additive"
  122651. | "alpha-blend";
  122652. type XRVisibilityState =
  122653. | "visible"
  122654. | "visible-blurred"
  122655. | "hidden";
  122656. type XRHandedness =
  122657. | "none"
  122658. | "left"
  122659. | "right";
  122660. type XRTargetRayMode =
  122661. | "gaze"
  122662. | "tracked-pointer"
  122663. | "screen";
  122664. type XREye =
  122665. | "none"
  122666. | "left"
  122667. | "right";
  122668. interface XRSpace extends EventTarget {
  122669. }
  122670. interface XRRenderState {
  122671. depthNear: number ;
  122672. depthFar: number ;
  122673. inlineVerticalFieldOfView: number | undefined;
  122674. baseLayer: XRWebGLLayer | undefined;
  122675. }
  122676. interface XRInputSource {
  122677. handedness: XRHandedness;
  122678. targetRayMode: XRTargetRayMode;
  122679. targetRaySpace: XRSpace;
  122680. gripSpace: XRSpace | undefined;
  122681. gamepad: Gamepad | undefined;
  122682. profiles: Array<string>;
  122683. }
  122684. interface XRSession {
  122685. addEventListener: Function;
  122686. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  122687. updateRenderState(XRRenderStateInit: any): Promise<void>;
  122688. requestAnimationFrame: Function;
  122689. end(): Promise<void>;
  122690. renderState: XRRenderState;
  122691. inputSources: Array<XRInputSource>;
  122692. }
  122693. interface XRReferenceSpace extends XRSpace {
  122694. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  122695. onreset: any;
  122696. }
  122697. interface XRFrame {
  122698. session: XRSession;
  122699. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  122700. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  122701. }
  122702. interface XRViewerPose extends XRPose {
  122703. views: Array<XRView>;
  122704. }
  122705. interface XRPose {
  122706. transform: XRRigidTransform;
  122707. emulatedPosition: boolean;
  122708. }
  122709. declare var XRWebGLLayer: {
  122710. prototype: XRWebGLLayer;
  122711. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  122712. };
  122713. interface XRWebGLLayer {
  122714. framebuffer: WebGLFramebuffer;
  122715. framebufferWidth: number;
  122716. framebufferHeight: number;
  122717. getViewport: Function;
  122718. }
  122719. interface XRRigidTransform {
  122720. position: DOMPointReadOnly;
  122721. orientation: DOMPointReadOnly;
  122722. matrix: Float32Array;
  122723. inverse: XRRigidTransform;
  122724. }
  122725. interface XRView {
  122726. eye: XREye;
  122727. projectionMatrix: Float32Array;
  122728. transform: XRRigidTransform;
  122729. }
  122730. interface XRInputSourceChangeEvent {
  122731. session: XRSession;
  122732. removed: Array<XRInputSource>;
  122733. added: Array<XRInputSource>;
  122734. }